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

import Amazonka.CodePipeline.Types.JobWorkerExecutorConfiguration
import Amazonka.CodePipeline.Types.LambdaExecutorConfiguration
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The action engine, or executor, related to the supported integration
-- model used to create and update the action type. The available executor
-- types are @Lambda@ and @JobWorker@.
--
-- /See:/ 'newExecutorConfiguration' smart constructor.
data ExecutorConfiguration = ExecutorConfiguration'
  { -- | Details about the @Lambda@ executor of the action type.
    ExecutorConfiguration -> Maybe LambdaExecutorConfiguration
lambdaExecutorConfiguration :: Prelude.Maybe LambdaExecutorConfiguration,
    -- | Details about the @JobWorker@ executor of the action type.
    ExecutorConfiguration -> Maybe JobWorkerExecutorConfiguration
jobWorkerExecutorConfiguration :: Prelude.Maybe JobWorkerExecutorConfiguration
  }
  deriving (ExecutorConfiguration -> ExecutorConfiguration -> Bool
(ExecutorConfiguration -> ExecutorConfiguration -> Bool)
-> (ExecutorConfiguration -> ExecutorConfiguration -> Bool)
-> Eq ExecutorConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecutorConfiguration -> ExecutorConfiguration -> Bool
$c/= :: ExecutorConfiguration -> ExecutorConfiguration -> Bool
== :: ExecutorConfiguration -> ExecutorConfiguration -> Bool
$c== :: ExecutorConfiguration -> ExecutorConfiguration -> Bool
Prelude.Eq, ReadPrec [ExecutorConfiguration]
ReadPrec ExecutorConfiguration
Int -> ReadS ExecutorConfiguration
ReadS [ExecutorConfiguration]
(Int -> ReadS ExecutorConfiguration)
-> ReadS [ExecutorConfiguration]
-> ReadPrec ExecutorConfiguration
-> ReadPrec [ExecutorConfiguration]
-> Read ExecutorConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecutorConfiguration]
$creadListPrec :: ReadPrec [ExecutorConfiguration]
readPrec :: ReadPrec ExecutorConfiguration
$creadPrec :: ReadPrec ExecutorConfiguration
readList :: ReadS [ExecutorConfiguration]
$creadList :: ReadS [ExecutorConfiguration]
readsPrec :: Int -> ReadS ExecutorConfiguration
$creadsPrec :: Int -> ReadS ExecutorConfiguration
Prelude.Read, Int -> ExecutorConfiguration -> ShowS
[ExecutorConfiguration] -> ShowS
ExecutorConfiguration -> String
(Int -> ExecutorConfiguration -> ShowS)
-> (ExecutorConfiguration -> String)
-> ([ExecutorConfiguration] -> ShowS)
-> Show ExecutorConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecutorConfiguration] -> ShowS
$cshowList :: [ExecutorConfiguration] -> ShowS
show :: ExecutorConfiguration -> String
$cshow :: ExecutorConfiguration -> String
showsPrec :: Int -> ExecutorConfiguration -> ShowS
$cshowsPrec :: Int -> ExecutorConfiguration -> ShowS
Prelude.Show, (forall x. ExecutorConfiguration -> Rep ExecutorConfiguration x)
-> (forall x. Rep ExecutorConfiguration x -> ExecutorConfiguration)
-> Generic ExecutorConfiguration
forall x. Rep ExecutorConfiguration x -> ExecutorConfiguration
forall x. ExecutorConfiguration -> Rep ExecutorConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecutorConfiguration x -> ExecutorConfiguration
$cfrom :: forall x. ExecutorConfiguration -> Rep ExecutorConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ExecutorConfiguration' 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:
--
-- 'lambdaExecutorConfiguration', 'executorConfiguration_lambdaExecutorConfiguration' - Details about the @Lambda@ executor of the action type.
--
-- 'jobWorkerExecutorConfiguration', 'executorConfiguration_jobWorkerExecutorConfiguration' - Details about the @JobWorker@ executor of the action type.
newExecutorConfiguration ::
  ExecutorConfiguration
newExecutorConfiguration :: ExecutorConfiguration
newExecutorConfiguration =
  ExecutorConfiguration' :: Maybe LambdaExecutorConfiguration
-> Maybe JobWorkerExecutorConfiguration -> ExecutorConfiguration
ExecutorConfiguration'
    { $sel:lambdaExecutorConfiguration:ExecutorConfiguration' :: Maybe LambdaExecutorConfiguration
lambdaExecutorConfiguration =
        Maybe LambdaExecutorConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:jobWorkerExecutorConfiguration:ExecutorConfiguration' :: Maybe JobWorkerExecutorConfiguration
jobWorkerExecutorConfiguration = Maybe JobWorkerExecutorConfiguration
forall a. Maybe a
Prelude.Nothing
    }

-- | Details about the @Lambda@ executor of the action type.
executorConfiguration_lambdaExecutorConfiguration :: Lens.Lens' ExecutorConfiguration (Prelude.Maybe LambdaExecutorConfiguration)
executorConfiguration_lambdaExecutorConfiguration :: (Maybe LambdaExecutorConfiguration
 -> f (Maybe LambdaExecutorConfiguration))
-> ExecutorConfiguration -> f ExecutorConfiguration
executorConfiguration_lambdaExecutorConfiguration = (ExecutorConfiguration -> Maybe LambdaExecutorConfiguration)
-> (ExecutorConfiguration
    -> Maybe LambdaExecutorConfiguration -> ExecutorConfiguration)
-> Lens
     ExecutorConfiguration
     ExecutorConfiguration
     (Maybe LambdaExecutorConfiguration)
     (Maybe LambdaExecutorConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutorConfiguration' {Maybe LambdaExecutorConfiguration
lambdaExecutorConfiguration :: Maybe LambdaExecutorConfiguration
$sel:lambdaExecutorConfiguration:ExecutorConfiguration' :: ExecutorConfiguration -> Maybe LambdaExecutorConfiguration
lambdaExecutorConfiguration} -> Maybe LambdaExecutorConfiguration
lambdaExecutorConfiguration) (\s :: ExecutorConfiguration
s@ExecutorConfiguration' {} Maybe LambdaExecutorConfiguration
a -> ExecutorConfiguration
s {$sel:lambdaExecutorConfiguration:ExecutorConfiguration' :: Maybe LambdaExecutorConfiguration
lambdaExecutorConfiguration = Maybe LambdaExecutorConfiguration
a} :: ExecutorConfiguration)

-- | Details about the @JobWorker@ executor of the action type.
executorConfiguration_jobWorkerExecutorConfiguration :: Lens.Lens' ExecutorConfiguration (Prelude.Maybe JobWorkerExecutorConfiguration)
executorConfiguration_jobWorkerExecutorConfiguration :: (Maybe JobWorkerExecutorConfiguration
 -> f (Maybe JobWorkerExecutorConfiguration))
-> ExecutorConfiguration -> f ExecutorConfiguration
executorConfiguration_jobWorkerExecutorConfiguration = (ExecutorConfiguration -> Maybe JobWorkerExecutorConfiguration)
-> (ExecutorConfiguration
    -> Maybe JobWorkerExecutorConfiguration -> ExecutorConfiguration)
-> Lens
     ExecutorConfiguration
     ExecutorConfiguration
     (Maybe JobWorkerExecutorConfiguration)
     (Maybe JobWorkerExecutorConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutorConfiguration' {Maybe JobWorkerExecutorConfiguration
jobWorkerExecutorConfiguration :: Maybe JobWorkerExecutorConfiguration
$sel:jobWorkerExecutorConfiguration:ExecutorConfiguration' :: ExecutorConfiguration -> Maybe JobWorkerExecutorConfiguration
jobWorkerExecutorConfiguration} -> Maybe JobWorkerExecutorConfiguration
jobWorkerExecutorConfiguration) (\s :: ExecutorConfiguration
s@ExecutorConfiguration' {} Maybe JobWorkerExecutorConfiguration
a -> ExecutorConfiguration
s {$sel:jobWorkerExecutorConfiguration:ExecutorConfiguration' :: Maybe JobWorkerExecutorConfiguration
jobWorkerExecutorConfiguration = Maybe JobWorkerExecutorConfiguration
a} :: ExecutorConfiguration)

instance Core.FromJSON ExecutorConfiguration where
  parseJSON :: Value -> Parser ExecutorConfiguration
parseJSON =
    String
-> (Object -> Parser ExecutorConfiguration)
-> Value
-> Parser ExecutorConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExecutorConfiguration"
      ( \Object
x ->
          Maybe LambdaExecutorConfiguration
-> Maybe JobWorkerExecutorConfiguration -> ExecutorConfiguration
ExecutorConfiguration'
            (Maybe LambdaExecutorConfiguration
 -> Maybe JobWorkerExecutorConfiguration -> ExecutorConfiguration)
-> Parser (Maybe LambdaExecutorConfiguration)
-> Parser
     (Maybe JobWorkerExecutorConfiguration -> ExecutorConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe LambdaExecutorConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lambdaExecutorConfiguration")
            Parser
  (Maybe JobWorkerExecutorConfiguration -> ExecutorConfiguration)
-> Parser (Maybe JobWorkerExecutorConfiguration)
-> Parser ExecutorConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe JobWorkerExecutorConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"jobWorkerExecutorConfiguration")
      )

instance Prelude.Hashable ExecutorConfiguration

instance Prelude.NFData ExecutorConfiguration

instance Core.ToJSON ExecutorConfiguration where
  toJSON :: ExecutorConfiguration -> Value
toJSON ExecutorConfiguration' {Maybe JobWorkerExecutorConfiguration
Maybe LambdaExecutorConfiguration
jobWorkerExecutorConfiguration :: Maybe JobWorkerExecutorConfiguration
lambdaExecutorConfiguration :: Maybe LambdaExecutorConfiguration
$sel:jobWorkerExecutorConfiguration:ExecutorConfiguration' :: ExecutorConfiguration -> Maybe JobWorkerExecutorConfiguration
$sel:lambdaExecutorConfiguration:ExecutorConfiguration' :: ExecutorConfiguration -> Maybe LambdaExecutorConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"lambdaExecutorConfiguration" Text -> LambdaExecutorConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (LambdaExecutorConfiguration -> Pair)
-> Maybe LambdaExecutorConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LambdaExecutorConfiguration
lambdaExecutorConfiguration,
            (Text
"jobWorkerExecutorConfiguration" Text -> JobWorkerExecutorConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (JobWorkerExecutorConfiguration -> Pair)
-> Maybe JobWorkerExecutorConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe JobWorkerExecutorConfiguration
jobWorkerExecutorConfiguration
          ]
      )