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

import Amazonka.CloudDirectory.Types.AttributeKey
import Amazonka.CloudDirectory.Types.ObjectAttributeAction
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:/ '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
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]
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
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. 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'
    { $sel:objectAttributeAction:ObjectAttributeUpdate' :: Maybe ObjectAttributeAction
objectAttributeAction =
        forall a. Maybe a
Prelude.Nothing,
      $sel:objectAttributeKey:ObjectAttributeUpdate' :: Maybe AttributeKey
objectAttributeKey = 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 :: Lens' ObjectAttributeUpdate (Maybe ObjectAttributeAction)
objectAttributeUpdate_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 :: Lens' ObjectAttributeUpdate (Maybe AttributeKey)
objectAttributeUpdate_objectAttributeKey = 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 where
  hashWithSalt :: Int -> ObjectAttributeUpdate -> Int
hashWithSalt Int
_salt ObjectAttributeUpdate' {Maybe AttributeKey
Maybe ObjectAttributeAction
objectAttributeKey :: Maybe AttributeKey
objectAttributeAction :: Maybe ObjectAttributeAction
$sel:objectAttributeKey:ObjectAttributeUpdate' :: ObjectAttributeUpdate -> Maybe AttributeKey
$sel:objectAttributeAction:ObjectAttributeUpdate' :: ObjectAttributeUpdate -> Maybe ObjectAttributeAction
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ObjectAttributeAction
objectAttributeAction
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AttributeKey
objectAttributeKey

instance Prelude.NFData ObjectAttributeUpdate where
  rnf :: ObjectAttributeUpdate -> ()
rnf ObjectAttributeUpdate' {Maybe AttributeKey
Maybe ObjectAttributeAction
objectAttributeKey :: Maybe AttributeKey
objectAttributeAction :: Maybe ObjectAttributeAction
$sel:objectAttributeKey:ObjectAttributeUpdate' :: ObjectAttributeUpdate -> Maybe AttributeKey
$sel:objectAttributeAction:ObjectAttributeUpdate' :: ObjectAttributeUpdate -> Maybe ObjectAttributeAction
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ObjectAttributeAction
objectAttributeAction
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AttributeKey
objectAttributeKey

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ObjectAttributeAction" 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 ObjectAttributeAction
objectAttributeAction,
            (Key
"ObjectAttributeKey" 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
objectAttributeKey
          ]
      )