{-# 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.AmplifyUiBuilder.Types.MutationActionSetStateParameter
-- 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.AmplifyUiBuilder.Types.MutationActionSetStateParameter where

import Amazonka.AmplifyUiBuilder.Types.ComponentProperty
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

-- | Represents the state configuration when an action modifies a property of
-- another element within the same component.
--
-- /See:/ 'newMutationActionSetStateParameter' smart constructor.
data MutationActionSetStateParameter = MutationActionSetStateParameter'
  { -- | The name of the component that is being modified.
    MutationActionSetStateParameter -> Text
componentName :: Prelude.Text,
    -- | The name of the component property to apply the state configuration to.
    MutationActionSetStateParameter -> Text
property :: Prelude.Text,
    -- | The state configuration to assign to the property.
    MutationActionSetStateParameter -> ComponentProperty
set :: ComponentProperty
  }
  deriving (MutationActionSetStateParameter
-> MutationActionSetStateParameter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MutationActionSetStateParameter
-> MutationActionSetStateParameter -> Bool
$c/= :: MutationActionSetStateParameter
-> MutationActionSetStateParameter -> Bool
== :: MutationActionSetStateParameter
-> MutationActionSetStateParameter -> Bool
$c== :: MutationActionSetStateParameter
-> MutationActionSetStateParameter -> Bool
Prelude.Eq, ReadPrec [MutationActionSetStateParameter]
ReadPrec MutationActionSetStateParameter
Int -> ReadS MutationActionSetStateParameter
ReadS [MutationActionSetStateParameter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MutationActionSetStateParameter]
$creadListPrec :: ReadPrec [MutationActionSetStateParameter]
readPrec :: ReadPrec MutationActionSetStateParameter
$creadPrec :: ReadPrec MutationActionSetStateParameter
readList :: ReadS [MutationActionSetStateParameter]
$creadList :: ReadS [MutationActionSetStateParameter]
readsPrec :: Int -> ReadS MutationActionSetStateParameter
$creadsPrec :: Int -> ReadS MutationActionSetStateParameter
Prelude.Read, Int -> MutationActionSetStateParameter -> ShowS
[MutationActionSetStateParameter] -> ShowS
MutationActionSetStateParameter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MutationActionSetStateParameter] -> ShowS
$cshowList :: [MutationActionSetStateParameter] -> ShowS
show :: MutationActionSetStateParameter -> String
$cshow :: MutationActionSetStateParameter -> String
showsPrec :: Int -> MutationActionSetStateParameter -> ShowS
$cshowsPrec :: Int -> MutationActionSetStateParameter -> ShowS
Prelude.Show, forall x.
Rep MutationActionSetStateParameter x
-> MutationActionSetStateParameter
forall x.
MutationActionSetStateParameter
-> Rep MutationActionSetStateParameter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep MutationActionSetStateParameter x
-> MutationActionSetStateParameter
$cfrom :: forall x.
MutationActionSetStateParameter
-> Rep MutationActionSetStateParameter x
Prelude.Generic)

-- |
-- Create a value of 'MutationActionSetStateParameter' 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:
--
-- 'componentName', 'mutationActionSetStateParameter_componentName' - The name of the component that is being modified.
--
-- 'property', 'mutationActionSetStateParameter_property' - The name of the component property to apply the state configuration to.
--
-- 'set', 'mutationActionSetStateParameter_set' - The state configuration to assign to the property.
newMutationActionSetStateParameter ::
  -- | 'componentName'
  Prelude.Text ->
  -- | 'property'
  Prelude.Text ->
  -- | 'set'
  ComponentProperty ->
  MutationActionSetStateParameter
newMutationActionSetStateParameter :: Text
-> Text -> ComponentProperty -> MutationActionSetStateParameter
newMutationActionSetStateParameter
  Text
pComponentName_
  Text
pProperty_
  ComponentProperty
pSet_ =
    MutationActionSetStateParameter'
      { $sel:componentName:MutationActionSetStateParameter' :: Text
componentName =
          Text
pComponentName_,
        $sel:property:MutationActionSetStateParameter' :: Text
property = Text
pProperty_,
        $sel:set:MutationActionSetStateParameter' :: ComponentProperty
set = ComponentProperty
pSet_
      }

-- | The name of the component that is being modified.
mutationActionSetStateParameter_componentName :: Lens.Lens' MutationActionSetStateParameter Prelude.Text
mutationActionSetStateParameter_componentName :: Lens' MutationActionSetStateParameter Text
mutationActionSetStateParameter_componentName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MutationActionSetStateParameter' {Text
componentName :: Text
$sel:componentName:MutationActionSetStateParameter' :: MutationActionSetStateParameter -> Text
componentName} -> Text
componentName) (\s :: MutationActionSetStateParameter
s@MutationActionSetStateParameter' {} Text
a -> MutationActionSetStateParameter
s {$sel:componentName:MutationActionSetStateParameter' :: Text
componentName = Text
a} :: MutationActionSetStateParameter)

-- | The name of the component property to apply the state configuration to.
mutationActionSetStateParameter_property :: Lens.Lens' MutationActionSetStateParameter Prelude.Text
mutationActionSetStateParameter_property :: Lens' MutationActionSetStateParameter Text
mutationActionSetStateParameter_property = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MutationActionSetStateParameter' {Text
property :: Text
$sel:property:MutationActionSetStateParameter' :: MutationActionSetStateParameter -> Text
property} -> Text
property) (\s :: MutationActionSetStateParameter
s@MutationActionSetStateParameter' {} Text
a -> MutationActionSetStateParameter
s {$sel:property:MutationActionSetStateParameter' :: Text
property = Text
a} :: MutationActionSetStateParameter)

-- | The state configuration to assign to the property.
mutationActionSetStateParameter_set :: Lens.Lens' MutationActionSetStateParameter ComponentProperty
mutationActionSetStateParameter_set :: Lens' MutationActionSetStateParameter ComponentProperty
mutationActionSetStateParameter_set = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MutationActionSetStateParameter' {ComponentProperty
set :: ComponentProperty
$sel:set:MutationActionSetStateParameter' :: MutationActionSetStateParameter -> ComponentProperty
set} -> ComponentProperty
set) (\s :: MutationActionSetStateParameter
s@MutationActionSetStateParameter' {} ComponentProperty
a -> MutationActionSetStateParameter
s {$sel:set:MutationActionSetStateParameter' :: ComponentProperty
set = ComponentProperty
a} :: MutationActionSetStateParameter)

instance
  Data.FromJSON
    MutationActionSetStateParameter
  where
  parseJSON :: Value -> Parser MutationActionSetStateParameter
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MutationActionSetStateParameter"
      ( \Object
x ->
          Text
-> Text -> ComponentProperty -> MutationActionSetStateParameter
MutationActionSetStateParameter'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"componentName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"property")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"set")
      )

instance
  Prelude.Hashable
    MutationActionSetStateParameter
  where
  hashWithSalt :: Int -> MutationActionSetStateParameter -> Int
hashWithSalt
    Int
_salt
    MutationActionSetStateParameter' {Text
ComponentProperty
set :: ComponentProperty
property :: Text
componentName :: Text
$sel:set:MutationActionSetStateParameter' :: MutationActionSetStateParameter -> ComponentProperty
$sel:property:MutationActionSetStateParameter' :: MutationActionSetStateParameter -> Text
$sel:componentName:MutationActionSetStateParameter' :: MutationActionSetStateParameter -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
componentName
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
property
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ComponentProperty
set

instance
  Prelude.NFData
    MutationActionSetStateParameter
  where
  rnf :: MutationActionSetStateParameter -> ()
rnf MutationActionSetStateParameter' {Text
ComponentProperty
set :: ComponentProperty
property :: Text
componentName :: Text
$sel:set:MutationActionSetStateParameter' :: MutationActionSetStateParameter -> ComponentProperty
$sel:property:MutationActionSetStateParameter' :: MutationActionSetStateParameter -> Text
$sel:componentName:MutationActionSetStateParameter' :: MutationActionSetStateParameter -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
componentName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
property
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ComponentProperty
set

instance Data.ToJSON MutationActionSetStateParameter where
  toJSON :: MutationActionSetStateParameter -> Value
toJSON MutationActionSetStateParameter' {Text
ComponentProperty
set :: ComponentProperty
property :: Text
componentName :: Text
$sel:set:MutationActionSetStateParameter' :: MutationActionSetStateParameter -> ComponentProperty
$sel:property:MutationActionSetStateParameter' :: MutationActionSetStateParameter -> Text
$sel:componentName:MutationActionSetStateParameter' :: MutationActionSetStateParameter -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"componentName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
componentName),
            forall a. a -> Maybe a
Prelude.Just (Key
"property" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
property),
            forall a. a -> Maybe a
Prelude.Just (Key
"set" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ComponentProperty
set)
          ]
      )