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

import Amazonka.CloudDirectory.Types.TypedAttributeValue
import Amazonka.CloudDirectory.Types.UpdateActionType
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

-- | The action to take on the object attribute.
--
-- /See:/ 'newObjectAttributeAction' smart constructor.
data ObjectAttributeAction = ObjectAttributeAction'
  { -- | A type that can be either @Update@ or @Delete@.
    ObjectAttributeAction -> Maybe UpdateActionType
objectAttributeActionType :: Prelude.Maybe UpdateActionType,
    -- | The value that you want to update to.
    ObjectAttributeAction -> Maybe TypedAttributeValue
objectAttributeUpdateValue :: Prelude.Maybe TypedAttributeValue
  }
  deriving (ObjectAttributeAction -> ObjectAttributeAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ObjectAttributeAction -> ObjectAttributeAction -> Bool
$c/= :: ObjectAttributeAction -> ObjectAttributeAction -> Bool
== :: ObjectAttributeAction -> ObjectAttributeAction -> Bool
$c== :: ObjectAttributeAction -> ObjectAttributeAction -> Bool
Prelude.Eq, ReadPrec [ObjectAttributeAction]
ReadPrec ObjectAttributeAction
Int -> ReadS ObjectAttributeAction
ReadS [ObjectAttributeAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ObjectAttributeAction]
$creadListPrec :: ReadPrec [ObjectAttributeAction]
readPrec :: ReadPrec ObjectAttributeAction
$creadPrec :: ReadPrec ObjectAttributeAction
readList :: ReadS [ObjectAttributeAction]
$creadList :: ReadS [ObjectAttributeAction]
readsPrec :: Int -> ReadS ObjectAttributeAction
$creadsPrec :: Int -> ReadS ObjectAttributeAction
Prelude.Read, Int -> ObjectAttributeAction -> ShowS
[ObjectAttributeAction] -> ShowS
ObjectAttributeAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ObjectAttributeAction] -> ShowS
$cshowList :: [ObjectAttributeAction] -> ShowS
show :: ObjectAttributeAction -> String
$cshow :: ObjectAttributeAction -> String
showsPrec :: Int -> ObjectAttributeAction -> ShowS
$cshowsPrec :: Int -> ObjectAttributeAction -> ShowS
Prelude.Show, forall x. Rep ObjectAttributeAction x -> ObjectAttributeAction
forall x. ObjectAttributeAction -> Rep ObjectAttributeAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ObjectAttributeAction x -> ObjectAttributeAction
$cfrom :: forall x. ObjectAttributeAction -> Rep ObjectAttributeAction x
Prelude.Generic)

-- |
-- Create a value of 'ObjectAttributeAction' 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:
--
-- 'objectAttributeActionType', 'objectAttributeAction_objectAttributeActionType' - A type that can be either @Update@ or @Delete@.
--
-- 'objectAttributeUpdateValue', 'objectAttributeAction_objectAttributeUpdateValue' - The value that you want to update to.
newObjectAttributeAction ::
  ObjectAttributeAction
newObjectAttributeAction :: ObjectAttributeAction
newObjectAttributeAction =
  ObjectAttributeAction'
    { $sel:objectAttributeActionType:ObjectAttributeAction' :: Maybe UpdateActionType
objectAttributeActionType =
        forall a. Maybe a
Prelude.Nothing,
      $sel:objectAttributeUpdateValue:ObjectAttributeAction' :: Maybe TypedAttributeValue
objectAttributeUpdateValue = forall a. Maybe a
Prelude.Nothing
    }

-- | A type that can be either @Update@ or @Delete@.
objectAttributeAction_objectAttributeActionType :: Lens.Lens' ObjectAttributeAction (Prelude.Maybe UpdateActionType)
objectAttributeAction_objectAttributeActionType :: Lens' ObjectAttributeAction (Maybe UpdateActionType)
objectAttributeAction_objectAttributeActionType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectAttributeAction' {Maybe UpdateActionType
objectAttributeActionType :: Maybe UpdateActionType
$sel:objectAttributeActionType:ObjectAttributeAction' :: ObjectAttributeAction -> Maybe UpdateActionType
objectAttributeActionType} -> Maybe UpdateActionType
objectAttributeActionType) (\s :: ObjectAttributeAction
s@ObjectAttributeAction' {} Maybe UpdateActionType
a -> ObjectAttributeAction
s {$sel:objectAttributeActionType:ObjectAttributeAction' :: Maybe UpdateActionType
objectAttributeActionType = Maybe UpdateActionType
a} :: ObjectAttributeAction)

-- | The value that you want to update to.
objectAttributeAction_objectAttributeUpdateValue :: Lens.Lens' ObjectAttributeAction (Prelude.Maybe TypedAttributeValue)
objectAttributeAction_objectAttributeUpdateValue :: Lens' ObjectAttributeAction (Maybe TypedAttributeValue)
objectAttributeAction_objectAttributeUpdateValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectAttributeAction' {Maybe TypedAttributeValue
objectAttributeUpdateValue :: Maybe TypedAttributeValue
$sel:objectAttributeUpdateValue:ObjectAttributeAction' :: ObjectAttributeAction -> Maybe TypedAttributeValue
objectAttributeUpdateValue} -> Maybe TypedAttributeValue
objectAttributeUpdateValue) (\s :: ObjectAttributeAction
s@ObjectAttributeAction' {} Maybe TypedAttributeValue
a -> ObjectAttributeAction
s {$sel:objectAttributeUpdateValue:ObjectAttributeAction' :: Maybe TypedAttributeValue
objectAttributeUpdateValue = Maybe TypedAttributeValue
a} :: ObjectAttributeAction)

instance Prelude.Hashable ObjectAttributeAction where
  hashWithSalt :: Int -> ObjectAttributeAction -> Int
hashWithSalt Int
_salt ObjectAttributeAction' {Maybe TypedAttributeValue
Maybe UpdateActionType
objectAttributeUpdateValue :: Maybe TypedAttributeValue
objectAttributeActionType :: Maybe UpdateActionType
$sel:objectAttributeUpdateValue:ObjectAttributeAction' :: ObjectAttributeAction -> Maybe TypedAttributeValue
$sel:objectAttributeActionType:ObjectAttributeAction' :: ObjectAttributeAction -> Maybe UpdateActionType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UpdateActionType
objectAttributeActionType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TypedAttributeValue
objectAttributeUpdateValue

instance Prelude.NFData ObjectAttributeAction where
  rnf :: ObjectAttributeAction -> ()
rnf ObjectAttributeAction' {Maybe TypedAttributeValue
Maybe UpdateActionType
objectAttributeUpdateValue :: Maybe TypedAttributeValue
objectAttributeActionType :: Maybe UpdateActionType
$sel:objectAttributeUpdateValue:ObjectAttributeAction' :: ObjectAttributeAction -> Maybe TypedAttributeValue
$sel:objectAttributeActionType:ObjectAttributeAction' :: ObjectAttributeAction -> Maybe UpdateActionType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe UpdateActionType
objectAttributeActionType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TypedAttributeValue
objectAttributeUpdateValue

instance Data.ToJSON ObjectAttributeAction where
  toJSON :: ObjectAttributeAction -> Value
toJSON ObjectAttributeAction' {Maybe TypedAttributeValue
Maybe UpdateActionType
objectAttributeUpdateValue :: Maybe TypedAttributeValue
objectAttributeActionType :: Maybe UpdateActionType
$sel:objectAttributeUpdateValue:ObjectAttributeAction' :: ObjectAttributeAction -> Maybe TypedAttributeValue
$sel:objectAttributeActionType:ObjectAttributeAction' :: ObjectAttributeAction -> Maybe UpdateActionType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ObjectAttributeActionType" 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 UpdateActionType
objectAttributeActionType,
            (Key
"ObjectAttributeUpdateValue" 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 TypedAttributeValue
objectAttributeUpdateValue
          ]
      )