{-# 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.CodePipeline.Types.ExecutionTrigger
-- 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.CodePipeline.Types.ExecutionTrigger where

import Amazonka.CodePipeline.Types.TriggerType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The interaction or event that started a pipeline execution.
--
-- /See:/ 'newExecutionTrigger' smart constructor.
data ExecutionTrigger = ExecutionTrigger'
  { -- | The type of change-detection method, command, or user interaction that
    -- started a pipeline execution.
    ExecutionTrigger -> Maybe TriggerType
triggerType :: Prelude.Maybe TriggerType,
    -- | Detail related to the event that started a pipeline execution, such as
    -- the webhook ARN of the webhook that triggered the pipeline execution or
    -- the user ARN for a user-initiated @start-pipeline-execution@ CLI
    -- command.
    ExecutionTrigger -> Maybe Text
triggerDetail :: Prelude.Maybe Prelude.Text
  }
  deriving (ExecutionTrigger -> ExecutionTrigger -> Bool
(ExecutionTrigger -> ExecutionTrigger -> Bool)
-> (ExecutionTrigger -> ExecutionTrigger -> Bool)
-> Eq ExecutionTrigger
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecutionTrigger -> ExecutionTrigger -> Bool
$c/= :: ExecutionTrigger -> ExecutionTrigger -> Bool
== :: ExecutionTrigger -> ExecutionTrigger -> Bool
$c== :: ExecutionTrigger -> ExecutionTrigger -> Bool
Prelude.Eq, ReadPrec [ExecutionTrigger]
ReadPrec ExecutionTrigger
Int -> ReadS ExecutionTrigger
ReadS [ExecutionTrigger]
(Int -> ReadS ExecutionTrigger)
-> ReadS [ExecutionTrigger]
-> ReadPrec ExecutionTrigger
-> ReadPrec [ExecutionTrigger]
-> Read ExecutionTrigger
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecutionTrigger]
$creadListPrec :: ReadPrec [ExecutionTrigger]
readPrec :: ReadPrec ExecutionTrigger
$creadPrec :: ReadPrec ExecutionTrigger
readList :: ReadS [ExecutionTrigger]
$creadList :: ReadS [ExecutionTrigger]
readsPrec :: Int -> ReadS ExecutionTrigger
$creadsPrec :: Int -> ReadS ExecutionTrigger
Prelude.Read, Int -> ExecutionTrigger -> ShowS
[ExecutionTrigger] -> ShowS
ExecutionTrigger -> String
(Int -> ExecutionTrigger -> ShowS)
-> (ExecutionTrigger -> String)
-> ([ExecutionTrigger] -> ShowS)
-> Show ExecutionTrigger
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecutionTrigger] -> ShowS
$cshowList :: [ExecutionTrigger] -> ShowS
show :: ExecutionTrigger -> String
$cshow :: ExecutionTrigger -> String
showsPrec :: Int -> ExecutionTrigger -> ShowS
$cshowsPrec :: Int -> ExecutionTrigger -> ShowS
Prelude.Show, (forall x. ExecutionTrigger -> Rep ExecutionTrigger x)
-> (forall x. Rep ExecutionTrigger x -> ExecutionTrigger)
-> Generic ExecutionTrigger
forall x. Rep ExecutionTrigger x -> ExecutionTrigger
forall x. ExecutionTrigger -> Rep ExecutionTrigger x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecutionTrigger x -> ExecutionTrigger
$cfrom :: forall x. ExecutionTrigger -> Rep ExecutionTrigger x
Prelude.Generic)

-- |
-- Create a value of 'ExecutionTrigger' 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:
--
-- 'triggerType', 'executionTrigger_triggerType' - The type of change-detection method, command, or user interaction that
-- started a pipeline execution.
--
-- 'triggerDetail', 'executionTrigger_triggerDetail' - Detail related to the event that started a pipeline execution, such as
-- the webhook ARN of the webhook that triggered the pipeline execution or
-- the user ARN for a user-initiated @start-pipeline-execution@ CLI
-- command.
newExecutionTrigger ::
  ExecutionTrigger
newExecutionTrigger :: ExecutionTrigger
newExecutionTrigger =
  ExecutionTrigger' :: Maybe TriggerType -> Maybe Text -> ExecutionTrigger
ExecutionTrigger'
    { $sel:triggerType:ExecutionTrigger' :: Maybe TriggerType
triggerType = Maybe TriggerType
forall a. Maybe a
Prelude.Nothing,
      $sel:triggerDetail:ExecutionTrigger' :: Maybe Text
triggerDetail = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of change-detection method, command, or user interaction that
-- started a pipeline execution.
executionTrigger_triggerType :: Lens.Lens' ExecutionTrigger (Prelude.Maybe TriggerType)
executionTrigger_triggerType :: (Maybe TriggerType -> f (Maybe TriggerType))
-> ExecutionTrigger -> f ExecutionTrigger
executionTrigger_triggerType = (ExecutionTrigger -> Maybe TriggerType)
-> (ExecutionTrigger -> Maybe TriggerType -> ExecutionTrigger)
-> Lens
     ExecutionTrigger
     ExecutionTrigger
     (Maybe TriggerType)
     (Maybe TriggerType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionTrigger' {Maybe TriggerType
triggerType :: Maybe TriggerType
$sel:triggerType:ExecutionTrigger' :: ExecutionTrigger -> Maybe TriggerType
triggerType} -> Maybe TriggerType
triggerType) (\s :: ExecutionTrigger
s@ExecutionTrigger' {} Maybe TriggerType
a -> ExecutionTrigger
s {$sel:triggerType:ExecutionTrigger' :: Maybe TriggerType
triggerType = Maybe TriggerType
a} :: ExecutionTrigger)

-- | Detail related to the event that started a pipeline execution, such as
-- the webhook ARN of the webhook that triggered the pipeline execution or
-- the user ARN for a user-initiated @start-pipeline-execution@ CLI
-- command.
executionTrigger_triggerDetail :: Lens.Lens' ExecutionTrigger (Prelude.Maybe Prelude.Text)
executionTrigger_triggerDetail :: (Maybe Text -> f (Maybe Text))
-> ExecutionTrigger -> f ExecutionTrigger
executionTrigger_triggerDetail = (ExecutionTrigger -> Maybe Text)
-> (ExecutionTrigger -> Maybe Text -> ExecutionTrigger)
-> Lens ExecutionTrigger ExecutionTrigger (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionTrigger' {Maybe Text
triggerDetail :: Maybe Text
$sel:triggerDetail:ExecutionTrigger' :: ExecutionTrigger -> Maybe Text
triggerDetail} -> Maybe Text
triggerDetail) (\s :: ExecutionTrigger
s@ExecutionTrigger' {} Maybe Text
a -> ExecutionTrigger
s {$sel:triggerDetail:ExecutionTrigger' :: Maybe Text
triggerDetail = Maybe Text
a} :: ExecutionTrigger)

instance Core.FromJSON ExecutionTrigger where
  parseJSON :: Value -> Parser ExecutionTrigger
parseJSON =
    String
-> (Object -> Parser ExecutionTrigger)
-> Value
-> Parser ExecutionTrigger
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExecutionTrigger"
      ( \Object
x ->
          Maybe TriggerType -> Maybe Text -> ExecutionTrigger
ExecutionTrigger'
            (Maybe TriggerType -> Maybe Text -> ExecutionTrigger)
-> Parser (Maybe TriggerType)
-> Parser (Maybe Text -> ExecutionTrigger)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TriggerType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"triggerType")
            Parser (Maybe Text -> ExecutionTrigger)
-> Parser (Maybe Text) -> Parser ExecutionTrigger
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"triggerDetail")
      )

instance Prelude.Hashable ExecutionTrigger

instance Prelude.NFData ExecutionTrigger