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

import Amazonka.CloudDirectory.Types.FacetAttribute
import Amazonka.CloudDirectory.Types.UpdateActionType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A structure that contains information used to update an attribute.
--
-- /See:/ 'newFacetAttributeUpdate' smart constructor.
data FacetAttributeUpdate = FacetAttributeUpdate'
  { -- | The attribute to update.
    FacetAttributeUpdate -> Maybe FacetAttribute
attribute :: Prelude.Maybe FacetAttribute,
    -- | The action to perform when updating the attribute.
    FacetAttributeUpdate -> Maybe UpdateActionType
action :: Prelude.Maybe UpdateActionType
  }
  deriving (FacetAttributeUpdate -> FacetAttributeUpdate -> Bool
(FacetAttributeUpdate -> FacetAttributeUpdate -> Bool)
-> (FacetAttributeUpdate -> FacetAttributeUpdate -> Bool)
-> Eq FacetAttributeUpdate
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]
(Int -> ReadS FacetAttributeUpdate)
-> ReadS [FacetAttributeUpdate]
-> ReadPrec FacetAttributeUpdate
-> ReadPrec [FacetAttributeUpdate]
-> Read 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
(Int -> FacetAttributeUpdate -> ShowS)
-> (FacetAttributeUpdate -> String)
-> ([FacetAttributeUpdate] -> ShowS)
-> Show FacetAttributeUpdate
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. FacetAttributeUpdate -> Rep FacetAttributeUpdate x)
-> (forall x. Rep FacetAttributeUpdate x -> FacetAttributeUpdate)
-> Generic FacetAttributeUpdate
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:
--
-- 'attribute', 'facetAttributeUpdate_attribute' - The attribute to update.
--
-- 'action', 'facetAttributeUpdate_action' - The action to perform when updating the attribute.
newFacetAttributeUpdate ::
  FacetAttributeUpdate
newFacetAttributeUpdate :: FacetAttributeUpdate
newFacetAttributeUpdate =
  FacetAttributeUpdate' :: Maybe FacetAttribute
-> Maybe UpdateActionType -> FacetAttributeUpdate
FacetAttributeUpdate'
    { $sel:attribute:FacetAttributeUpdate' :: Maybe FacetAttribute
attribute = Maybe FacetAttribute
forall a. Maybe a
Prelude.Nothing,
      $sel:action:FacetAttributeUpdate' :: Maybe UpdateActionType
action = Maybe UpdateActionType
forall a. Maybe a
Prelude.Nothing
    }

-- | The attribute to update.
facetAttributeUpdate_attribute :: Lens.Lens' FacetAttributeUpdate (Prelude.Maybe FacetAttribute)
facetAttributeUpdate_attribute :: (Maybe FacetAttribute -> f (Maybe FacetAttribute))
-> FacetAttributeUpdate -> f FacetAttributeUpdate
facetAttributeUpdate_attribute = (FacetAttributeUpdate -> Maybe FacetAttribute)
-> (FacetAttributeUpdate
    -> Maybe FacetAttribute -> FacetAttributeUpdate)
-> Lens
     FacetAttributeUpdate
     FacetAttributeUpdate
     (Maybe FacetAttribute)
     (Maybe FacetAttribute)
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)

-- | The action to perform when updating the attribute.
facetAttributeUpdate_action :: Lens.Lens' FacetAttributeUpdate (Prelude.Maybe UpdateActionType)
facetAttributeUpdate_action :: (Maybe UpdateActionType -> f (Maybe UpdateActionType))
-> FacetAttributeUpdate -> f FacetAttributeUpdate
facetAttributeUpdate_action = (FacetAttributeUpdate -> Maybe UpdateActionType)
-> (FacetAttributeUpdate
    -> Maybe UpdateActionType -> FacetAttributeUpdate)
-> Lens
     FacetAttributeUpdate
     FacetAttributeUpdate
     (Maybe UpdateActionType)
     (Maybe UpdateActionType)
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)

instance Prelude.Hashable FacetAttributeUpdate

instance Prelude.NFData FacetAttributeUpdate

instance Core.ToJSON FacetAttributeUpdate where
  toJSON :: FacetAttributeUpdate -> Value
toJSON FacetAttributeUpdate' {Maybe FacetAttribute
Maybe UpdateActionType
action :: Maybe UpdateActionType
attribute :: Maybe FacetAttribute
$sel:action:FacetAttributeUpdate' :: FacetAttributeUpdate -> Maybe UpdateActionType
$sel:attribute:FacetAttributeUpdate' :: FacetAttributeUpdate -> Maybe FacetAttribute
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Attribute" Text -> FacetAttribute -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (FacetAttribute -> Pair) -> Maybe FacetAttribute -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FacetAttribute
attribute,
            (Text
"Action" 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
action
          ]
      )