{-# 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-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.LinkAttributeAction 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 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
(LinkAttributeAction -> LinkAttributeAction -> Bool)
-> (LinkAttributeAction -> LinkAttributeAction -> Bool)
-> Eq LinkAttributeAction
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]
(Int -> ReadS LinkAttributeAction)
-> ReadS [LinkAttributeAction]
-> ReadPrec LinkAttributeAction
-> ReadPrec [LinkAttributeAction]
-> Read 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
(Int -> LinkAttributeAction -> ShowS)
-> (LinkAttributeAction -> String)
-> ([LinkAttributeAction] -> ShowS)
-> Show LinkAttributeAction
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. LinkAttributeAction -> Rep LinkAttributeAction x)
-> (forall x. Rep LinkAttributeAction x -> LinkAttributeAction)
-> Generic LinkAttributeAction
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' :: Maybe UpdateActionType
-> Maybe TypedAttributeValue -> LinkAttributeAction
LinkAttributeAction'
    { $sel:attributeActionType:LinkAttributeAction' :: Maybe UpdateActionType
attributeActionType =
        Maybe UpdateActionType
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeUpdateValue:LinkAttributeAction' :: Maybe TypedAttributeValue
attributeUpdateValue = Maybe TypedAttributeValue
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 :: (Maybe UpdateActionType -> f (Maybe UpdateActionType))
-> LinkAttributeAction -> f LinkAttributeAction
linkAttributeAction_attributeActionType = (LinkAttributeAction -> Maybe UpdateActionType)
-> (LinkAttributeAction
    -> Maybe UpdateActionType -> LinkAttributeAction)
-> Lens
     LinkAttributeAction
     LinkAttributeAction
     (Maybe UpdateActionType)
     (Maybe UpdateActionType)
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 :: (Maybe TypedAttributeValue -> f (Maybe TypedAttributeValue))
-> LinkAttributeAction -> f LinkAttributeAction
linkAttributeAction_attributeUpdateValue = (LinkAttributeAction -> Maybe TypedAttributeValue)
-> (LinkAttributeAction
    -> Maybe TypedAttributeValue -> LinkAttributeAction)
-> Lens
     LinkAttributeAction
     LinkAttributeAction
     (Maybe TypedAttributeValue)
     (Maybe TypedAttributeValue)
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

instance Prelude.NFData LinkAttributeAction

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AttributeActionType" 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
attributeActionType,
            (Text
"AttributeUpdateValue" 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
attributeUpdateValue
          ]
      )