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

import Amazonka.CloudDirectory.Types.AttributeKey
import Amazonka.CloudDirectory.Types.ObjectAttributeAction
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:/ 'newObjectAttributeUpdate' smart constructor.
data ObjectAttributeUpdate = ObjectAttributeUpdate'
  { -- | The action to perform as part of the attribute update.
    ObjectAttributeUpdate -> Maybe ObjectAttributeAction
objectAttributeAction :: Prelude.Maybe ObjectAttributeAction,
    -- | The key of the attribute being updated.
    ObjectAttributeUpdate -> Maybe AttributeKey
objectAttributeKey :: Prelude.Maybe AttributeKey
  }
  deriving (ObjectAttributeUpdate -> ObjectAttributeUpdate -> Bool
(ObjectAttributeUpdate -> ObjectAttributeUpdate -> Bool)
-> (ObjectAttributeUpdate -> ObjectAttributeUpdate -> Bool)
-> Eq ObjectAttributeUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ObjectAttributeUpdate -> ObjectAttributeUpdate -> Bool
$c/= :: ObjectAttributeUpdate -> ObjectAttributeUpdate -> Bool
== :: ObjectAttributeUpdate -> ObjectAttributeUpdate -> Bool
$c== :: ObjectAttributeUpdate -> ObjectAttributeUpdate -> Bool
Prelude.Eq, ReadPrec [ObjectAttributeUpdate]
ReadPrec ObjectAttributeUpdate
Int -> ReadS ObjectAttributeUpdate
ReadS [ObjectAttributeUpdate]
(Int -> ReadS ObjectAttributeUpdate)
-> ReadS [ObjectAttributeUpdate]
-> ReadPrec ObjectAttributeUpdate
-> ReadPrec [ObjectAttributeUpdate]
-> Read ObjectAttributeUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ObjectAttributeUpdate]
$creadListPrec :: ReadPrec [ObjectAttributeUpdate]
readPrec :: ReadPrec ObjectAttributeUpdate
$creadPrec :: ReadPrec ObjectAttributeUpdate
readList :: ReadS [ObjectAttributeUpdate]
$creadList :: ReadS [ObjectAttributeUpdate]
readsPrec :: Int -> ReadS ObjectAttributeUpdate
$creadsPrec :: Int -> ReadS ObjectAttributeUpdate
Prelude.Read, Int -> ObjectAttributeUpdate -> ShowS
[ObjectAttributeUpdate] -> ShowS
ObjectAttributeUpdate -> String
(Int -> ObjectAttributeUpdate -> ShowS)
-> (ObjectAttributeUpdate -> String)
-> ([ObjectAttributeUpdate] -> ShowS)
-> Show ObjectAttributeUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ObjectAttributeUpdate] -> ShowS
$cshowList :: [ObjectAttributeUpdate] -> ShowS
show :: ObjectAttributeUpdate -> String
$cshow :: ObjectAttributeUpdate -> String
showsPrec :: Int -> ObjectAttributeUpdate -> ShowS
$cshowsPrec :: Int -> ObjectAttributeUpdate -> ShowS
Prelude.Show, (forall x. ObjectAttributeUpdate -> Rep ObjectAttributeUpdate x)
-> (forall x. Rep ObjectAttributeUpdate x -> ObjectAttributeUpdate)
-> Generic ObjectAttributeUpdate
forall x. Rep ObjectAttributeUpdate x -> ObjectAttributeUpdate
forall x. ObjectAttributeUpdate -> Rep ObjectAttributeUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ObjectAttributeUpdate x -> ObjectAttributeUpdate
$cfrom :: forall x. ObjectAttributeUpdate -> Rep ObjectAttributeUpdate x
Prelude.Generic)

-- |
-- Create a value of 'ObjectAttributeUpdate' 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:
--
-- 'objectAttributeAction', 'objectAttributeUpdate_objectAttributeAction' - The action to perform as part of the attribute update.
--
-- 'objectAttributeKey', 'objectAttributeUpdate_objectAttributeKey' - The key of the attribute being updated.
newObjectAttributeUpdate ::
  ObjectAttributeUpdate
newObjectAttributeUpdate :: ObjectAttributeUpdate
newObjectAttributeUpdate =
  ObjectAttributeUpdate' :: Maybe ObjectAttributeAction
-> Maybe AttributeKey -> ObjectAttributeUpdate
ObjectAttributeUpdate'
    { $sel:objectAttributeAction:ObjectAttributeUpdate' :: Maybe ObjectAttributeAction
objectAttributeAction =
        Maybe ObjectAttributeAction
forall a. Maybe a
Prelude.Nothing,
      $sel:objectAttributeKey:ObjectAttributeUpdate' :: Maybe AttributeKey
objectAttributeKey = Maybe AttributeKey
forall a. Maybe a
Prelude.Nothing
    }

-- | The action to perform as part of the attribute update.
objectAttributeUpdate_objectAttributeAction :: Lens.Lens' ObjectAttributeUpdate (Prelude.Maybe ObjectAttributeAction)
objectAttributeUpdate_objectAttributeAction :: (Maybe ObjectAttributeAction -> f (Maybe ObjectAttributeAction))
-> ObjectAttributeUpdate -> f ObjectAttributeUpdate
objectAttributeUpdate_objectAttributeAction = (ObjectAttributeUpdate -> Maybe ObjectAttributeAction)
-> (ObjectAttributeUpdate
    -> Maybe ObjectAttributeAction -> ObjectAttributeUpdate)
-> Lens
     ObjectAttributeUpdate
     ObjectAttributeUpdate
     (Maybe ObjectAttributeAction)
     (Maybe ObjectAttributeAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectAttributeUpdate' {Maybe ObjectAttributeAction
objectAttributeAction :: Maybe ObjectAttributeAction
$sel:objectAttributeAction:ObjectAttributeUpdate' :: ObjectAttributeUpdate -> Maybe ObjectAttributeAction
objectAttributeAction} -> Maybe ObjectAttributeAction
objectAttributeAction) (\s :: ObjectAttributeUpdate
s@ObjectAttributeUpdate' {} Maybe ObjectAttributeAction
a -> ObjectAttributeUpdate
s {$sel:objectAttributeAction:ObjectAttributeUpdate' :: Maybe ObjectAttributeAction
objectAttributeAction = Maybe ObjectAttributeAction
a} :: ObjectAttributeUpdate)

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

instance Prelude.Hashable ObjectAttributeUpdate

instance Prelude.NFData ObjectAttributeUpdate

instance Core.ToJSON ObjectAttributeUpdate where
  toJSON :: ObjectAttributeUpdate -> Value
toJSON ObjectAttributeUpdate' {Maybe AttributeKey
Maybe ObjectAttributeAction
objectAttributeKey :: Maybe AttributeKey
objectAttributeAction :: Maybe ObjectAttributeAction
$sel:objectAttributeKey:ObjectAttributeUpdate' :: ObjectAttributeUpdate -> Maybe AttributeKey
$sel:objectAttributeAction:ObjectAttributeUpdate' :: ObjectAttributeUpdate -> Maybe ObjectAttributeAction
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ObjectAttributeAction" Text -> ObjectAttributeAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ObjectAttributeAction -> Pair)
-> Maybe ObjectAttributeAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ObjectAttributeAction
objectAttributeAction,
            (Text
"ObjectAttributeKey" 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
objectAttributeKey
          ]
      )