{-# 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.AppConfig.Types.Action
-- 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.AppConfig.Types.Action where

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

-- | An action defines the tasks the extension performs during the AppConfig
-- workflow. Each action includes an action point such as
-- @ON_CREATE_HOSTED_CONFIGURATION@, @PRE_DEPLOYMENT@, or @ON_DEPLOYMENT@.
-- Each action also includes a name, a URI to an Lambda function, and an
-- Amazon Resource Name (ARN) for an Identity and Access Management assume
-- role. You specify the name, URI, and ARN for each /action point/ defined
-- in the extension. You can specify the following actions for an
-- extension:
--
-- -   @PRE_CREATE_HOSTED_CONFIGURATION_VERSION@
--
-- -   @PRE_START_DEPLOYMENT@
--
-- -   @ON_DEPLOYMENT_START@
--
-- -   @ON_DEPLOYMENT_STEP@
--
-- -   @ON_DEPLOYMENT_BAKING@
--
-- -   @ON_DEPLOYMENT_COMPLETE@
--
-- -   @ON_DEPLOYMENT_ROLLED_BACK@
--
-- /See:/ 'newAction' smart constructor.
data Action = Action'
  { -- | Information about the action.
    Action -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The action name.
    Action -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | An Amazon Resource Name (ARN) for an Identity and Access Management
    -- assume role.
    Action -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | The extension URI associated to the action point in the extension
    -- definition. The URI can be an Amazon Resource Name (ARN) for one of the
    -- following: an Lambda function, an Amazon Simple Queue Service queue, an
    -- Amazon Simple Notification Service topic, or the Amazon EventBridge
    -- default event bus.
    Action -> Maybe Text
uri :: Prelude.Maybe Prelude.Text
  }
  deriving (Action -> Action -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Action -> Action -> Bool
$c/= :: Action -> Action -> Bool
== :: Action -> Action -> Bool
$c== :: Action -> Action -> Bool
Prelude.Eq, ReadPrec [Action]
ReadPrec Action
Int -> ReadS Action
ReadS [Action]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Action]
$creadListPrec :: ReadPrec [Action]
readPrec :: ReadPrec Action
$creadPrec :: ReadPrec Action
readList :: ReadS [Action]
$creadList :: ReadS [Action]
readsPrec :: Int -> ReadS Action
$creadsPrec :: Int -> ReadS Action
Prelude.Read, Int -> Action -> ShowS
[Action] -> ShowS
Action -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Action] -> ShowS
$cshowList :: [Action] -> ShowS
show :: Action -> String
$cshow :: Action -> String
showsPrec :: Int -> Action -> ShowS
$cshowsPrec :: Int -> Action -> ShowS
Prelude.Show, forall x. Rep Action x -> Action
forall x. Action -> Rep Action x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Action x -> Action
$cfrom :: forall x. Action -> Rep Action x
Prelude.Generic)

-- |
-- Create a value of 'Action' 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:
--
-- 'description', 'action_description' - Information about the action.
--
-- 'name', 'action_name' - The action name.
--
-- 'roleArn', 'action_roleArn' - An Amazon Resource Name (ARN) for an Identity and Access Management
-- assume role.
--
-- 'uri', 'action_uri' - The extension URI associated to the action point in the extension
-- definition. The URI can be an Amazon Resource Name (ARN) for one of the
-- following: an Lambda function, an Amazon Simple Queue Service queue, an
-- Amazon Simple Notification Service topic, or the Amazon EventBridge
-- default event bus.
newAction ::
  Action
newAction :: Action
newAction =
  Action'
    { $sel:description:Action' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Action' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:Action' :: Maybe Text
roleArn = forall a. Maybe a
Prelude.Nothing,
      $sel:uri:Action' :: Maybe Text
uri = forall a. Maybe a
Prelude.Nothing
    }

-- | Information about the action.
action_description :: Lens.Lens' Action (Prelude.Maybe Prelude.Text)
action_description :: Lens' Action (Maybe Text)
action_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe Text
description :: Maybe Text
$sel:description:Action' :: Action -> Maybe Text
description} -> Maybe Text
description) (\s :: Action
s@Action' {} Maybe Text
a -> Action
s {$sel:description:Action' :: Maybe Text
description = Maybe Text
a} :: Action)

-- | The action name.
action_name :: Lens.Lens' Action (Prelude.Maybe Prelude.Text)
action_name :: Lens' Action (Maybe Text)
action_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe Text
name :: Maybe Text
$sel:name:Action' :: Action -> Maybe Text
name} -> Maybe Text
name) (\s :: Action
s@Action' {} Maybe Text
a -> Action
s {$sel:name:Action' :: Maybe Text
name = Maybe Text
a} :: Action)

-- | An Amazon Resource Name (ARN) for an Identity and Access Management
-- assume role.
action_roleArn :: Lens.Lens' Action (Prelude.Maybe Prelude.Text)
action_roleArn :: Lens' Action (Maybe Text)
action_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:Action' :: Action -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: Action
s@Action' {} Maybe Text
a -> Action
s {$sel:roleArn:Action' :: Maybe Text
roleArn = Maybe Text
a} :: Action)

-- | The extension URI associated to the action point in the extension
-- definition. The URI can be an Amazon Resource Name (ARN) for one of the
-- following: an Lambda function, an Amazon Simple Queue Service queue, an
-- Amazon Simple Notification Service topic, or the Amazon EventBridge
-- default event bus.
action_uri :: Lens.Lens' Action (Prelude.Maybe Prelude.Text)
action_uri :: Lens' Action (Maybe Text)
action_uri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe Text
uri :: Maybe Text
$sel:uri:Action' :: Action -> Maybe Text
uri} -> Maybe Text
uri) (\s :: Action
s@Action' {} Maybe Text
a -> Action
s {$sel:uri:Action' :: Maybe Text
uri = Maybe Text
a} :: Action)

instance Data.FromJSON Action where
  parseJSON :: Value -> Parser Action
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Action"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Action
Action'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Description")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RoleArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Uri")
      )

instance Prelude.Hashable Action where
  hashWithSalt :: Int -> Action -> Int
hashWithSalt Int
_salt Action' {Maybe Text
uri :: Maybe Text
roleArn :: Maybe Text
name :: Maybe Text
description :: Maybe Text
$sel:uri:Action' :: Action -> Maybe Text
$sel:roleArn:Action' :: Action -> Maybe Text
$sel:name:Action' :: Action -> Maybe Text
$sel:description:Action' :: Action -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
roleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
uri

instance Prelude.NFData Action where
  rnf :: Action -> ()
rnf Action' {Maybe Text
uri :: Maybe Text
roleArn :: Maybe Text
name :: Maybe Text
description :: Maybe Text
$sel:uri:Action' :: Action -> Maybe Text
$sel:roleArn:Action' :: Action -> Maybe Text
$sel:name:Action' :: Action -> Maybe Text
$sel:description:Action' :: Action -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
uri

instance Data.ToJSON Action where
  toJSON :: Action -> Value
toJSON Action' {Maybe Text
uri :: Maybe Text
roleArn :: Maybe Text
name :: Maybe Text
description :: Maybe Text
$sel:uri:Action' :: Action -> Maybe Text
$sel:roleArn:Action' :: Action -> Maybe Text
$sel:name:Action' :: Action -> Maybe Text
$sel:description:Action' :: Action -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Description" 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 Text
description,
            (Key
"Name" 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 Text
name,
            (Key
"RoleArn" 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 Text
roleArn,
            (Key
"Uri" 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 Text
uri
          ]
      )