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

import Amazonka.CodePipeline.Types.ExecutorConfiguration
import Amazonka.CodePipeline.Types.ExecutorType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The action engine, or executor, for an action type created for a
-- provider, where the action is to be used by customers of the provider.
-- The action engine is associated with the model used to create and update
-- the action, such as the Lambda integration model.
--
-- /See:/ 'newActionTypeExecutor' smart constructor.
data ActionTypeExecutor = ActionTypeExecutor'
  { -- | The timeout in seconds for the job. An action execution can have
    -- multiple jobs. This is the timeout for a single job, not the entire
    -- action execution.
    ActionTypeExecutor -> Maybe Natural
jobTimeout :: Prelude.Maybe Prelude.Natural,
    -- | The policy statement that specifies the permissions in the CodePipeline
    -- customer’s account that are needed to successfully run an action.
    --
    -- To grant permission to another account, specify the account ID as the
    -- Principal, a domain-style identifier defined by the service, for example
    -- @codepipeline.amazonaws.com@.
    --
    -- The size of the passed JSON policy document cannot exceed 2048
    -- characters.
    ActionTypeExecutor -> Maybe Text
policyStatementsTemplate :: Prelude.Maybe Prelude.Text,
    -- | The action configuration properties for the action type. These
    -- properties are specified in the action definition when the action type
    -- is created.
    ActionTypeExecutor -> ExecutorConfiguration
configuration :: ExecutorConfiguration,
    -- | The integration model used to create and update the action type,
    -- @Lambda@ or @JobWorker@.
    ActionTypeExecutor -> ExecutorType
type' :: ExecutorType
  }
  deriving (ActionTypeExecutor -> ActionTypeExecutor -> Bool
(ActionTypeExecutor -> ActionTypeExecutor -> Bool)
-> (ActionTypeExecutor -> ActionTypeExecutor -> Bool)
-> Eq ActionTypeExecutor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActionTypeExecutor -> ActionTypeExecutor -> Bool
$c/= :: ActionTypeExecutor -> ActionTypeExecutor -> Bool
== :: ActionTypeExecutor -> ActionTypeExecutor -> Bool
$c== :: ActionTypeExecutor -> ActionTypeExecutor -> Bool
Prelude.Eq, ReadPrec [ActionTypeExecutor]
ReadPrec ActionTypeExecutor
Int -> ReadS ActionTypeExecutor
ReadS [ActionTypeExecutor]
(Int -> ReadS ActionTypeExecutor)
-> ReadS [ActionTypeExecutor]
-> ReadPrec ActionTypeExecutor
-> ReadPrec [ActionTypeExecutor]
-> Read ActionTypeExecutor
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActionTypeExecutor]
$creadListPrec :: ReadPrec [ActionTypeExecutor]
readPrec :: ReadPrec ActionTypeExecutor
$creadPrec :: ReadPrec ActionTypeExecutor
readList :: ReadS [ActionTypeExecutor]
$creadList :: ReadS [ActionTypeExecutor]
readsPrec :: Int -> ReadS ActionTypeExecutor
$creadsPrec :: Int -> ReadS ActionTypeExecutor
Prelude.Read, Int -> ActionTypeExecutor -> ShowS
[ActionTypeExecutor] -> ShowS
ActionTypeExecutor -> String
(Int -> ActionTypeExecutor -> ShowS)
-> (ActionTypeExecutor -> String)
-> ([ActionTypeExecutor] -> ShowS)
-> Show ActionTypeExecutor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActionTypeExecutor] -> ShowS
$cshowList :: [ActionTypeExecutor] -> ShowS
show :: ActionTypeExecutor -> String
$cshow :: ActionTypeExecutor -> String
showsPrec :: Int -> ActionTypeExecutor -> ShowS
$cshowsPrec :: Int -> ActionTypeExecutor -> ShowS
Prelude.Show, (forall x. ActionTypeExecutor -> Rep ActionTypeExecutor x)
-> (forall x. Rep ActionTypeExecutor x -> ActionTypeExecutor)
-> Generic ActionTypeExecutor
forall x. Rep ActionTypeExecutor x -> ActionTypeExecutor
forall x. ActionTypeExecutor -> Rep ActionTypeExecutor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActionTypeExecutor x -> ActionTypeExecutor
$cfrom :: forall x. ActionTypeExecutor -> Rep ActionTypeExecutor x
Prelude.Generic)

-- |
-- Create a value of 'ActionTypeExecutor' 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:
--
-- 'jobTimeout', 'actionTypeExecutor_jobTimeout' - The timeout in seconds for the job. An action execution can have
-- multiple jobs. This is the timeout for a single job, not the entire
-- action execution.
--
-- 'policyStatementsTemplate', 'actionTypeExecutor_policyStatementsTemplate' - The policy statement that specifies the permissions in the CodePipeline
-- customer’s account that are needed to successfully run an action.
--
-- To grant permission to another account, specify the account ID as the
-- Principal, a domain-style identifier defined by the service, for example
-- @codepipeline.amazonaws.com@.
--
-- The size of the passed JSON policy document cannot exceed 2048
-- characters.
--
-- 'configuration', 'actionTypeExecutor_configuration' - The action configuration properties for the action type. These
-- properties are specified in the action definition when the action type
-- is created.
--
-- 'type'', 'actionTypeExecutor_type' - The integration model used to create and update the action type,
-- @Lambda@ or @JobWorker@.
newActionTypeExecutor ::
  -- | 'configuration'
  ExecutorConfiguration ->
  -- | 'type''
  ExecutorType ->
  ActionTypeExecutor
newActionTypeExecutor :: ExecutorConfiguration -> ExecutorType -> ActionTypeExecutor
newActionTypeExecutor ExecutorConfiguration
pConfiguration_ ExecutorType
pType_ =
  ActionTypeExecutor' :: Maybe Natural
-> Maybe Text
-> ExecutorConfiguration
-> ExecutorType
-> ActionTypeExecutor
ActionTypeExecutor'
    { $sel:jobTimeout:ActionTypeExecutor' :: Maybe Natural
jobTimeout = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:policyStatementsTemplate:ActionTypeExecutor' :: Maybe Text
policyStatementsTemplate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:configuration:ActionTypeExecutor' :: ExecutorConfiguration
configuration = ExecutorConfiguration
pConfiguration_,
      $sel:type':ActionTypeExecutor' :: ExecutorType
type' = ExecutorType
pType_
    }

-- | The timeout in seconds for the job. An action execution can have
-- multiple jobs. This is the timeout for a single job, not the entire
-- action execution.
actionTypeExecutor_jobTimeout :: Lens.Lens' ActionTypeExecutor (Prelude.Maybe Prelude.Natural)
actionTypeExecutor_jobTimeout :: (Maybe Natural -> f (Maybe Natural))
-> ActionTypeExecutor -> f ActionTypeExecutor
actionTypeExecutor_jobTimeout = (ActionTypeExecutor -> Maybe Natural)
-> (ActionTypeExecutor -> Maybe Natural -> ActionTypeExecutor)
-> Lens
     ActionTypeExecutor
     ActionTypeExecutor
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionTypeExecutor' {Maybe Natural
jobTimeout :: Maybe Natural
$sel:jobTimeout:ActionTypeExecutor' :: ActionTypeExecutor -> Maybe Natural
jobTimeout} -> Maybe Natural
jobTimeout) (\s :: ActionTypeExecutor
s@ActionTypeExecutor' {} Maybe Natural
a -> ActionTypeExecutor
s {$sel:jobTimeout:ActionTypeExecutor' :: Maybe Natural
jobTimeout = Maybe Natural
a} :: ActionTypeExecutor)

-- | The policy statement that specifies the permissions in the CodePipeline
-- customer’s account that are needed to successfully run an action.
--
-- To grant permission to another account, specify the account ID as the
-- Principal, a domain-style identifier defined by the service, for example
-- @codepipeline.amazonaws.com@.
--
-- The size of the passed JSON policy document cannot exceed 2048
-- characters.
actionTypeExecutor_policyStatementsTemplate :: Lens.Lens' ActionTypeExecutor (Prelude.Maybe Prelude.Text)
actionTypeExecutor_policyStatementsTemplate :: (Maybe Text -> f (Maybe Text))
-> ActionTypeExecutor -> f ActionTypeExecutor
actionTypeExecutor_policyStatementsTemplate = (ActionTypeExecutor -> Maybe Text)
-> (ActionTypeExecutor -> Maybe Text -> ActionTypeExecutor)
-> Lens
     ActionTypeExecutor ActionTypeExecutor (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionTypeExecutor' {Maybe Text
policyStatementsTemplate :: Maybe Text
$sel:policyStatementsTemplate:ActionTypeExecutor' :: ActionTypeExecutor -> Maybe Text
policyStatementsTemplate} -> Maybe Text
policyStatementsTemplate) (\s :: ActionTypeExecutor
s@ActionTypeExecutor' {} Maybe Text
a -> ActionTypeExecutor
s {$sel:policyStatementsTemplate:ActionTypeExecutor' :: Maybe Text
policyStatementsTemplate = Maybe Text
a} :: ActionTypeExecutor)

-- | The action configuration properties for the action type. These
-- properties are specified in the action definition when the action type
-- is created.
actionTypeExecutor_configuration :: Lens.Lens' ActionTypeExecutor ExecutorConfiguration
actionTypeExecutor_configuration :: (ExecutorConfiguration -> f ExecutorConfiguration)
-> ActionTypeExecutor -> f ActionTypeExecutor
actionTypeExecutor_configuration = (ActionTypeExecutor -> ExecutorConfiguration)
-> (ActionTypeExecutor
    -> ExecutorConfiguration -> ActionTypeExecutor)
-> Lens
     ActionTypeExecutor
     ActionTypeExecutor
     ExecutorConfiguration
     ExecutorConfiguration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionTypeExecutor' {ExecutorConfiguration
configuration :: ExecutorConfiguration
$sel:configuration:ActionTypeExecutor' :: ActionTypeExecutor -> ExecutorConfiguration
configuration} -> ExecutorConfiguration
configuration) (\s :: ActionTypeExecutor
s@ActionTypeExecutor' {} ExecutorConfiguration
a -> ActionTypeExecutor
s {$sel:configuration:ActionTypeExecutor' :: ExecutorConfiguration
configuration = ExecutorConfiguration
a} :: ActionTypeExecutor)

-- | The integration model used to create and update the action type,
-- @Lambda@ or @JobWorker@.
actionTypeExecutor_type :: Lens.Lens' ActionTypeExecutor ExecutorType
actionTypeExecutor_type :: (ExecutorType -> f ExecutorType)
-> ActionTypeExecutor -> f ActionTypeExecutor
actionTypeExecutor_type = (ActionTypeExecutor -> ExecutorType)
-> (ActionTypeExecutor -> ExecutorType -> ActionTypeExecutor)
-> Lens
     ActionTypeExecutor ActionTypeExecutor ExecutorType ExecutorType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionTypeExecutor' {ExecutorType
type' :: ExecutorType
$sel:type':ActionTypeExecutor' :: ActionTypeExecutor -> ExecutorType
type'} -> ExecutorType
type') (\s :: ActionTypeExecutor
s@ActionTypeExecutor' {} ExecutorType
a -> ActionTypeExecutor
s {$sel:type':ActionTypeExecutor' :: ExecutorType
type' = ExecutorType
a} :: ActionTypeExecutor)

instance Core.FromJSON ActionTypeExecutor where
  parseJSON :: Value -> Parser ActionTypeExecutor
parseJSON =
    String
-> (Object -> Parser ActionTypeExecutor)
-> Value
-> Parser ActionTypeExecutor
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ActionTypeExecutor"
      ( \Object
x ->
          Maybe Natural
-> Maybe Text
-> ExecutorConfiguration
-> ExecutorType
-> ActionTypeExecutor
ActionTypeExecutor'
            (Maybe Natural
 -> Maybe Text
 -> ExecutorConfiguration
 -> ExecutorType
 -> ActionTypeExecutor)
-> Parser (Maybe Natural)
-> Parser
     (Maybe Text
      -> ExecutorConfiguration -> ExecutorType -> ActionTypeExecutor)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"jobTimeout")
            Parser
  (Maybe Text
   -> ExecutorConfiguration -> ExecutorType -> ActionTypeExecutor)
-> Parser (Maybe Text)
-> Parser
     (ExecutorConfiguration -> ExecutorType -> ActionTypeExecutor)
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
"policyStatementsTemplate")
            Parser
  (ExecutorConfiguration -> ExecutorType -> ActionTypeExecutor)
-> Parser ExecutorConfiguration
-> Parser (ExecutorType -> ActionTypeExecutor)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ExecutorConfiguration
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"configuration")
            Parser (ExecutorType -> ActionTypeExecutor)
-> Parser ExecutorType -> Parser ActionTypeExecutor
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ExecutorType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"type")
      )

instance Prelude.Hashable ActionTypeExecutor

instance Prelude.NFData ActionTypeExecutor

instance Core.ToJSON ActionTypeExecutor where
  toJSON :: ActionTypeExecutor -> Value
toJSON ActionTypeExecutor' {Maybe Natural
Maybe Text
ExecutorType
ExecutorConfiguration
type' :: ExecutorType
configuration :: ExecutorConfiguration
policyStatementsTemplate :: Maybe Text
jobTimeout :: Maybe Natural
$sel:type':ActionTypeExecutor' :: ActionTypeExecutor -> ExecutorType
$sel:configuration:ActionTypeExecutor' :: ActionTypeExecutor -> ExecutorConfiguration
$sel:policyStatementsTemplate:ActionTypeExecutor' :: ActionTypeExecutor -> Maybe Text
$sel:jobTimeout:ActionTypeExecutor' :: ActionTypeExecutor -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"jobTimeout" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
jobTimeout,
            (Text
"policyStatementsTemplate" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
policyStatementsTemplate,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"configuration" Text -> ExecutorConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ExecutorConfiguration
configuration),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> ExecutorType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ExecutorType
type')
          ]
      )