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

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

-- | A structure that contains information used to update an attribute.
--
-- /See:/ 'newFacetAttributeUpdate' smart constructor.
data FacetAttributeUpdate = FacetAttributeUpdate'
  { -- | The action to perform when updating the attribute.
    FacetAttributeUpdate -> Maybe UpdateActionType
action :: Prelude.Maybe UpdateActionType,
    -- | The attribute to update.
    FacetAttributeUpdate -> Maybe FacetAttribute
attribute :: Prelude.Maybe FacetAttribute
  }
  deriving (FacetAttributeUpdate -> FacetAttributeUpdate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FacetAttributeUpdate -> FacetAttributeUpdate -> Bool
$c/= :: FacetAttributeUpdate -> FacetAttributeUpdate -> Bool
== :: FacetAttributeUpdate -> FacetAttributeUpdate -> Bool
$c== :: FacetAttributeUpdate -> FacetAttributeUpdate -> Bool
Prelude.Eq, ReadPrec [FacetAttributeUpdate]
ReadPrec FacetAttributeUpdate
Int -> ReadS FacetAttributeUpdate
ReadS [FacetAttributeUpdate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FacetAttributeUpdate]
$creadListPrec :: ReadPrec [FacetAttributeUpdate]
readPrec :: ReadPrec FacetAttributeUpdate
$creadPrec :: ReadPrec FacetAttributeUpdate
readList :: ReadS [FacetAttributeUpdate]
$creadList :: ReadS [FacetAttributeUpdate]
readsPrec :: Int -> ReadS FacetAttributeUpdate
$creadsPrec :: Int -> ReadS FacetAttributeUpdate
Prelude.Read, Int -> FacetAttributeUpdate -> ShowS
[FacetAttributeUpdate] -> ShowS
FacetAttributeUpdate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FacetAttributeUpdate] -> ShowS
$cshowList :: [FacetAttributeUpdate] -> ShowS
show :: FacetAttributeUpdate -> String
$cshow :: FacetAttributeUpdate -> String
showsPrec :: Int -> FacetAttributeUpdate -> ShowS
$cshowsPrec :: Int -> FacetAttributeUpdate -> ShowS
Prelude.Show, forall x. Rep FacetAttributeUpdate x -> FacetAttributeUpdate
forall x. FacetAttributeUpdate -> Rep FacetAttributeUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FacetAttributeUpdate x -> FacetAttributeUpdate
$cfrom :: forall x. FacetAttributeUpdate -> Rep FacetAttributeUpdate x
Prelude.Generic)

-- |
-- Create a value of 'FacetAttributeUpdate' 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:
--
-- 'action', 'facetAttributeUpdate_action' - The action to perform when updating the attribute.
--
-- 'attribute', 'facetAttributeUpdate_attribute' - The attribute to update.
newFacetAttributeUpdate ::
  FacetAttributeUpdate
newFacetAttributeUpdate :: FacetAttributeUpdate
newFacetAttributeUpdate =
  FacetAttributeUpdate'
    { $sel:action:FacetAttributeUpdate' :: Maybe UpdateActionType
action = forall a. Maybe a
Prelude.Nothing,
      $sel:attribute:FacetAttributeUpdate' :: Maybe FacetAttribute
attribute = forall a. Maybe a
Prelude.Nothing
    }

-- | The action to perform when updating the attribute.
facetAttributeUpdate_action :: Lens.Lens' FacetAttributeUpdate (Prelude.Maybe UpdateActionType)
facetAttributeUpdate_action :: Lens' FacetAttributeUpdate (Maybe UpdateActionType)
facetAttributeUpdate_action = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FacetAttributeUpdate' {Maybe UpdateActionType
action :: Maybe UpdateActionType
$sel:action:FacetAttributeUpdate' :: FacetAttributeUpdate -> Maybe UpdateActionType
action} -> Maybe UpdateActionType
action) (\s :: FacetAttributeUpdate
s@FacetAttributeUpdate' {} Maybe UpdateActionType
a -> FacetAttributeUpdate
s {$sel:action:FacetAttributeUpdate' :: Maybe UpdateActionType
action = Maybe UpdateActionType
a} :: FacetAttributeUpdate)

-- | The attribute to update.
facetAttributeUpdate_attribute :: Lens.Lens' FacetAttributeUpdate (Prelude.Maybe FacetAttribute)
facetAttributeUpdate_attribute :: Lens' FacetAttributeUpdate (Maybe FacetAttribute)
facetAttributeUpdate_attribute = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FacetAttributeUpdate' {Maybe FacetAttribute
attribute :: Maybe FacetAttribute
$sel:attribute:FacetAttributeUpdate' :: FacetAttributeUpdate -> Maybe FacetAttribute
attribute} -> Maybe FacetAttribute
attribute) (\s :: FacetAttributeUpdate
s@FacetAttributeUpdate' {} Maybe FacetAttribute
a -> FacetAttributeUpdate
s {$sel:attribute:FacetAttributeUpdate' :: Maybe FacetAttribute
attribute = Maybe FacetAttribute
a} :: FacetAttributeUpdate)

instance Prelude.Hashable FacetAttributeUpdate where
  hashWithSalt :: Int -> FacetAttributeUpdate -> Int
hashWithSalt Int
_salt FacetAttributeUpdate' {Maybe FacetAttribute
Maybe UpdateActionType
attribute :: Maybe FacetAttribute
action :: Maybe UpdateActionType
$sel:attribute:FacetAttributeUpdate' :: FacetAttributeUpdate -> Maybe FacetAttribute
$sel:action:FacetAttributeUpdate' :: FacetAttributeUpdate -> Maybe UpdateActionType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UpdateActionType
action
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FacetAttribute
attribute

instance Prelude.NFData FacetAttributeUpdate where
  rnf :: FacetAttributeUpdate -> ()
rnf FacetAttributeUpdate' {Maybe FacetAttribute
Maybe UpdateActionType
attribute :: Maybe FacetAttribute
action :: Maybe UpdateActionType
$sel:attribute:FacetAttributeUpdate' :: FacetAttributeUpdate -> Maybe FacetAttribute
$sel:action:FacetAttributeUpdate' :: FacetAttributeUpdate -> Maybe UpdateActionType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe UpdateActionType
action
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FacetAttribute
attribute

instance Data.ToJSON FacetAttributeUpdate where
  toJSON :: FacetAttributeUpdate -> Value
toJSON FacetAttributeUpdate' {Maybe FacetAttribute
Maybe UpdateActionType
attribute :: Maybe FacetAttribute
action :: Maybe UpdateActionType
$sel:attribute:FacetAttributeUpdate' :: FacetAttributeUpdate -> Maybe FacetAttribute
$sel:action:FacetAttributeUpdate' :: FacetAttributeUpdate -> Maybe UpdateActionType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Action" 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
action,
            (Key
"Attribute" 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 FacetAttribute
attribute
          ]
      )