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

import Amazonka.CloudDirectory.Types.TypedAttributeValue
import Amazonka.CloudDirectory.Types.UpdateActionType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ObjectAttributeAction -> ObjectAttributeAction -> Bool)
-> (ObjectAttributeAction -> ObjectAttributeAction -> Bool)
-> Eq ObjectAttributeAction
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]
(Int -> ReadS ObjectAttributeAction)
-> ReadS [ObjectAttributeAction]
-> ReadPrec ObjectAttributeAction
-> ReadPrec [ObjectAttributeAction]
-> Read 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
(Int -> ObjectAttributeAction -> ShowS)
-> (ObjectAttributeAction -> String)
-> ([ObjectAttributeAction] -> ShowS)
-> Show ObjectAttributeAction
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. ObjectAttributeAction -> Rep ObjectAttributeAction x)
-> (forall x. Rep ObjectAttributeAction x -> ObjectAttributeAction)
-> Generic ObjectAttributeAction
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' :: Maybe UpdateActionType
-> Maybe TypedAttributeValue -> ObjectAttributeAction
ObjectAttributeAction'
    { $sel:objectAttributeActionType:ObjectAttributeAction' :: Maybe UpdateActionType
objectAttributeActionType =
        Maybe UpdateActionType
forall a. Maybe a
Prelude.Nothing,
      $sel:objectAttributeUpdateValue:ObjectAttributeAction' :: Maybe TypedAttributeValue
objectAttributeUpdateValue = Maybe TypedAttributeValue
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 :: (Maybe UpdateActionType -> f (Maybe UpdateActionType))
-> ObjectAttributeAction -> f ObjectAttributeAction
objectAttributeAction_objectAttributeActionType = (ObjectAttributeAction -> Maybe UpdateActionType)
-> (ObjectAttributeAction
    -> Maybe UpdateActionType -> ObjectAttributeAction)
-> Lens
     ObjectAttributeAction
     ObjectAttributeAction
     (Maybe UpdateActionType)
     (Maybe UpdateActionType)
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 :: (Maybe TypedAttributeValue -> f (Maybe TypedAttributeValue))
-> ObjectAttributeAction -> f ObjectAttributeAction
objectAttributeAction_objectAttributeUpdateValue = (ObjectAttributeAction -> Maybe TypedAttributeValue)
-> (ObjectAttributeAction
    -> Maybe TypedAttributeValue -> ObjectAttributeAction)
-> Lens
     ObjectAttributeAction
     ObjectAttributeAction
     (Maybe TypedAttributeValue)
     (Maybe TypedAttributeValue)
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

instance Prelude.NFData ObjectAttributeAction

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ObjectAttributeActionType" Text -> UpdateActionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (UpdateActionType -> Pair) -> Maybe UpdateActionType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UpdateActionType
objectAttributeActionType,
            (Text
"ObjectAttributeUpdateValue" Text -> TypedAttributeValue -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (TypedAttributeValue -> Pair)
-> Maybe TypedAttributeValue -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TypedAttributeValue
objectAttributeUpdateValue
          ]
      )