{-# 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.LinkAttributeAction
-- 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.LinkAttributeAction 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 a typed link attribute value. Updates are only
-- supported for attributes which don’t contribute to link identity.
--
-- /See:/ 'newLinkAttributeAction' smart constructor.
data LinkAttributeAction = LinkAttributeAction'
  { -- | A type that can be either @UPDATE_OR_CREATE@ or @DELETE@.
    LinkAttributeAction -> Maybe UpdateActionType
attributeActionType :: Prelude.Maybe UpdateActionType,
    -- | The value that you want to update to.
    LinkAttributeAction -> Maybe TypedAttributeValue
attributeUpdateValue :: Prelude.Maybe TypedAttributeValue
  }
  deriving (LinkAttributeAction -> LinkAttributeAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LinkAttributeAction -> LinkAttributeAction -> Bool
$c/= :: LinkAttributeAction -> LinkAttributeAction -> Bool
== :: LinkAttributeAction -> LinkAttributeAction -> Bool
$c== :: LinkAttributeAction -> LinkAttributeAction -> Bool
Prelude.Eq, ReadPrec [LinkAttributeAction]
ReadPrec LinkAttributeAction
Int -> ReadS LinkAttributeAction
ReadS [LinkAttributeAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LinkAttributeAction]
$creadListPrec :: ReadPrec [LinkAttributeAction]
readPrec :: ReadPrec LinkAttributeAction
$creadPrec :: ReadPrec LinkAttributeAction
readList :: ReadS [LinkAttributeAction]
$creadList :: ReadS [LinkAttributeAction]
readsPrec :: Int -> ReadS LinkAttributeAction
$creadsPrec :: Int -> ReadS LinkAttributeAction
Prelude.Read, Int -> LinkAttributeAction -> ShowS
[LinkAttributeAction] -> ShowS
LinkAttributeAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LinkAttributeAction] -> ShowS
$cshowList :: [LinkAttributeAction] -> ShowS
show :: LinkAttributeAction -> String
$cshow :: LinkAttributeAction -> String
showsPrec :: Int -> LinkAttributeAction -> ShowS
$cshowsPrec :: Int -> LinkAttributeAction -> ShowS
Prelude.Show, forall x. Rep LinkAttributeAction x -> LinkAttributeAction
forall x. LinkAttributeAction -> Rep LinkAttributeAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LinkAttributeAction x -> LinkAttributeAction
$cfrom :: forall x. LinkAttributeAction -> Rep LinkAttributeAction x
Prelude.Generic)

-- |
-- Create a value of 'LinkAttributeAction' 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:
--
-- 'attributeActionType', 'linkAttributeAction_attributeActionType' - A type that can be either @UPDATE_OR_CREATE@ or @DELETE@.
--
-- 'attributeUpdateValue', 'linkAttributeAction_attributeUpdateValue' - The value that you want to update to.
newLinkAttributeAction ::
  LinkAttributeAction
newLinkAttributeAction :: LinkAttributeAction
newLinkAttributeAction =
  LinkAttributeAction'
    { $sel:attributeActionType:LinkAttributeAction' :: Maybe UpdateActionType
attributeActionType =
        forall a. Maybe a
Prelude.Nothing,
      $sel:attributeUpdateValue:LinkAttributeAction' :: Maybe TypedAttributeValue
attributeUpdateValue = forall a. Maybe a
Prelude.Nothing
    }

-- | A type that can be either @UPDATE_OR_CREATE@ or @DELETE@.
linkAttributeAction_attributeActionType :: Lens.Lens' LinkAttributeAction (Prelude.Maybe UpdateActionType)
linkAttributeAction_attributeActionType :: Lens' LinkAttributeAction (Maybe UpdateActionType)
linkAttributeAction_attributeActionType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LinkAttributeAction' {Maybe UpdateActionType
attributeActionType :: Maybe UpdateActionType
$sel:attributeActionType:LinkAttributeAction' :: LinkAttributeAction -> Maybe UpdateActionType
attributeActionType} -> Maybe UpdateActionType
attributeActionType) (\s :: LinkAttributeAction
s@LinkAttributeAction' {} Maybe UpdateActionType
a -> LinkAttributeAction
s {$sel:attributeActionType:LinkAttributeAction' :: Maybe UpdateActionType
attributeActionType = Maybe UpdateActionType
a} :: LinkAttributeAction)

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

instance Prelude.Hashable LinkAttributeAction where
  hashWithSalt :: Int -> LinkAttributeAction -> Int
hashWithSalt Int
_salt LinkAttributeAction' {Maybe TypedAttributeValue
Maybe UpdateActionType
attributeUpdateValue :: Maybe TypedAttributeValue
attributeActionType :: Maybe UpdateActionType
$sel:attributeUpdateValue:LinkAttributeAction' :: LinkAttributeAction -> Maybe TypedAttributeValue
$sel:attributeActionType:LinkAttributeAction' :: LinkAttributeAction -> Maybe UpdateActionType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UpdateActionType
attributeActionType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TypedAttributeValue
attributeUpdateValue

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

instance Data.ToJSON LinkAttributeAction where
  toJSON :: LinkAttributeAction -> Value
toJSON LinkAttributeAction' {Maybe TypedAttributeValue
Maybe UpdateActionType
attributeUpdateValue :: Maybe TypedAttributeValue
attributeActionType :: Maybe UpdateActionType
$sel:attributeUpdateValue:LinkAttributeAction' :: LinkAttributeAction -> Maybe TypedAttributeValue
$sel:attributeActionType:LinkAttributeAction' :: LinkAttributeAction -> Maybe UpdateActionType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AttributeActionType" 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
attributeActionType,
            (Key
"AttributeUpdateValue" 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
attributeUpdateValue
          ]
      )