{-# 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.IdentityStore.Types.AttributeOperation
-- 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.IdentityStore.Types.AttributeOperation where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IdentityStore.Types.AttributeValue
import qualified Amazonka.Prelude as Prelude

-- | An operation that applies to the requested group. This operation might
-- add, replace, or remove an attribute.
--
-- /See:/ 'newAttributeOperation' smart constructor.
data AttributeOperation = AttributeOperation'
  { -- | The value of the attribute. This is a @Document@ type. This type is not
    -- supported by Java V1, Go V1, and older versions of the AWS CLI.
    AttributeOperation -> Maybe AttributeValue
attributeValue :: Prelude.Maybe AttributeValue,
    -- | A string representation of the path to a given attribute or
    -- sub-attribute. Supports JMESPath.
    AttributeOperation -> Text
attributePath :: Prelude.Text
  }
  deriving (AttributeOperation -> AttributeOperation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttributeOperation -> AttributeOperation -> Bool
$c/= :: AttributeOperation -> AttributeOperation -> Bool
== :: AttributeOperation -> AttributeOperation -> Bool
$c== :: AttributeOperation -> AttributeOperation -> Bool
Prelude.Eq, ReadPrec [AttributeOperation]
ReadPrec AttributeOperation
Int -> ReadS AttributeOperation
ReadS [AttributeOperation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttributeOperation]
$creadListPrec :: ReadPrec [AttributeOperation]
readPrec :: ReadPrec AttributeOperation
$creadPrec :: ReadPrec AttributeOperation
readList :: ReadS [AttributeOperation]
$creadList :: ReadS [AttributeOperation]
readsPrec :: Int -> ReadS AttributeOperation
$creadsPrec :: Int -> ReadS AttributeOperation
Prelude.Read, Int -> AttributeOperation -> ShowS
[AttributeOperation] -> ShowS
AttributeOperation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttributeOperation] -> ShowS
$cshowList :: [AttributeOperation] -> ShowS
show :: AttributeOperation -> String
$cshow :: AttributeOperation -> String
showsPrec :: Int -> AttributeOperation -> ShowS
$cshowsPrec :: Int -> AttributeOperation -> ShowS
Prelude.Show, forall x. Rep AttributeOperation x -> AttributeOperation
forall x. AttributeOperation -> Rep AttributeOperation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttributeOperation x -> AttributeOperation
$cfrom :: forall x. AttributeOperation -> Rep AttributeOperation x
Prelude.Generic)

-- |
-- Create a value of 'AttributeOperation' 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:
--
-- 'attributeValue', 'attributeOperation_attributeValue' - The value of the attribute. This is a @Document@ type. This type is not
-- supported by Java V1, Go V1, and older versions of the AWS CLI.
--
-- 'attributePath', 'attributeOperation_attributePath' - A string representation of the path to a given attribute or
-- sub-attribute. Supports JMESPath.
newAttributeOperation ::
  -- | 'attributePath'
  Prelude.Text ->
  AttributeOperation
newAttributeOperation :: Text -> AttributeOperation
newAttributeOperation Text
pAttributePath_ =
  AttributeOperation'
    { $sel:attributeValue:AttributeOperation' :: Maybe AttributeValue
attributeValue =
        forall a. Maybe a
Prelude.Nothing,
      $sel:attributePath:AttributeOperation' :: Text
attributePath = Text
pAttributePath_
    }

-- | The value of the attribute. This is a @Document@ type. This type is not
-- supported by Java V1, Go V1, and older versions of the AWS CLI.
attributeOperation_attributeValue :: Lens.Lens' AttributeOperation (Prelude.Maybe AttributeValue)
attributeOperation_attributeValue :: Lens' AttributeOperation (Maybe AttributeValue)
attributeOperation_attributeValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeOperation' {Maybe AttributeValue
attributeValue :: Maybe AttributeValue
$sel:attributeValue:AttributeOperation' :: AttributeOperation -> Maybe AttributeValue
attributeValue} -> Maybe AttributeValue
attributeValue) (\s :: AttributeOperation
s@AttributeOperation' {} Maybe AttributeValue
a -> AttributeOperation
s {$sel:attributeValue:AttributeOperation' :: Maybe AttributeValue
attributeValue = Maybe AttributeValue
a} :: AttributeOperation)

-- | A string representation of the path to a given attribute or
-- sub-attribute. Supports JMESPath.
attributeOperation_attributePath :: Lens.Lens' AttributeOperation Prelude.Text
attributeOperation_attributePath :: Lens' AttributeOperation Text
attributeOperation_attributePath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeOperation' {Text
attributePath :: Text
$sel:attributePath:AttributeOperation' :: AttributeOperation -> Text
attributePath} -> Text
attributePath) (\s :: AttributeOperation
s@AttributeOperation' {} Text
a -> AttributeOperation
s {$sel:attributePath:AttributeOperation' :: Text
attributePath = Text
a} :: AttributeOperation)

instance Prelude.Hashable AttributeOperation where
  hashWithSalt :: Int -> AttributeOperation -> Int
hashWithSalt Int
_salt AttributeOperation' {Maybe AttributeValue
Text
attributePath :: Text
attributeValue :: Maybe AttributeValue
$sel:attributePath:AttributeOperation' :: AttributeOperation -> Text
$sel:attributeValue:AttributeOperation' :: AttributeOperation -> Maybe AttributeValue
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AttributeValue
attributeValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
attributePath

instance Prelude.NFData AttributeOperation where
  rnf :: AttributeOperation -> ()
rnf AttributeOperation' {Maybe AttributeValue
Text
attributePath :: Text
attributeValue :: Maybe AttributeValue
$sel:attributePath:AttributeOperation' :: AttributeOperation -> Text
$sel:attributeValue:AttributeOperation' :: AttributeOperation -> Maybe AttributeValue
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AttributeValue
attributeValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
attributePath

instance Data.ToJSON AttributeOperation where
  toJSON :: AttributeOperation -> Value
toJSON AttributeOperation' {Maybe AttributeValue
Text
attributePath :: Text
attributeValue :: Maybe AttributeValue
$sel:attributePath:AttributeOperation' :: AttributeOperation -> Text
$sel:attributeValue:AttributeOperation' :: AttributeOperation -> Maybe AttributeValue
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AttributeValue" 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 AttributeValue
attributeValue,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"AttributePath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
attributePath)
          ]
      )