{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:jobTimeout:ActionTypeExecutor' :: Maybe Natural
jobTimeout = forall a. Maybe a
Prelude.Nothing,
      $sel:policyStatementsTemplate:ActionTypeExecutor' :: Maybe Text
policyStatementsTemplate = 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 :: Lens' ActionTypeExecutor (Maybe Natural)
actionTypeExecutor_jobTimeout = 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 :: Lens' ActionTypeExecutor (Maybe Text)
actionTypeExecutor_policyStatementsTemplate = 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 :: Lens' ActionTypeExecutor ExecutorConfiguration
actionTypeExecutor_configuration = 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 :: Lens' ActionTypeExecutor ExecutorType
actionTypeExecutor_type = 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 Data.FromJSON ActionTypeExecutor where
  parseJSON :: Value -> Parser ActionTypeExecutor
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ActionTypeExecutor"
      ( \Object
x ->
          Maybe Natural
-> Maybe Text
-> ExecutorConfiguration
-> ExecutorType
-> ActionTypeExecutor
ActionTypeExecutor'
            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
"jobTimeout")
            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
"policyStatementsTemplate")
            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
"configuration")
            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
"type")
      )

instance Prelude.Hashable ActionTypeExecutor where
  hashWithSalt :: Int -> ActionTypeExecutor -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
jobTimeout
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
policyStatementsTemplate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ExecutorConfiguration
configuration
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ExecutorType
type'

instance Prelude.NFData ActionTypeExecutor where
  rnf :: ActionTypeExecutor -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
jobTimeout
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
policyStatementsTemplate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ExecutorConfiguration
configuration
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ExecutorType
type'

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"jobTimeout" 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 Natural
jobTimeout,
            (Key
"policyStatementsTemplate" 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
policyStatementsTemplate,
            forall a. a -> Maybe a
Prelude.Just (Key
"configuration" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ExecutorConfiguration
configuration),
            forall a. a -> Maybe a
Prelude.Just (Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ExecutorType
type')
          ]
      )