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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Details about the polling configuration for the @JobWorker@ action
-- engine, or executor.
--
-- /See:/ 'newJobWorkerExecutorConfiguration' smart constructor.
data JobWorkerExecutorConfiguration = JobWorkerExecutorConfiguration'
  { -- | The accounts in which the job worker is configured and might poll for
    -- jobs as part of the action execution.
    JobWorkerExecutorConfiguration -> Maybe (NonEmpty Text)
pollingAccounts :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The service Principals in which the job worker is configured and might
    -- poll for jobs as part of the action execution.
    JobWorkerExecutorConfiguration -> Maybe (NonEmpty Text)
pollingServicePrincipals :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text)
  }
  deriving (JobWorkerExecutorConfiguration
-> JobWorkerExecutorConfiguration -> Bool
(JobWorkerExecutorConfiguration
 -> JobWorkerExecutorConfiguration -> Bool)
-> (JobWorkerExecutorConfiguration
    -> JobWorkerExecutorConfiguration -> Bool)
-> Eq JobWorkerExecutorConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JobWorkerExecutorConfiguration
-> JobWorkerExecutorConfiguration -> Bool
$c/= :: JobWorkerExecutorConfiguration
-> JobWorkerExecutorConfiguration -> Bool
== :: JobWorkerExecutorConfiguration
-> JobWorkerExecutorConfiguration -> Bool
$c== :: JobWorkerExecutorConfiguration
-> JobWorkerExecutorConfiguration -> Bool
Prelude.Eq, ReadPrec [JobWorkerExecutorConfiguration]
ReadPrec JobWorkerExecutorConfiguration
Int -> ReadS JobWorkerExecutorConfiguration
ReadS [JobWorkerExecutorConfiguration]
(Int -> ReadS JobWorkerExecutorConfiguration)
-> ReadS [JobWorkerExecutorConfiguration]
-> ReadPrec JobWorkerExecutorConfiguration
-> ReadPrec [JobWorkerExecutorConfiguration]
-> Read JobWorkerExecutorConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JobWorkerExecutorConfiguration]
$creadListPrec :: ReadPrec [JobWorkerExecutorConfiguration]
readPrec :: ReadPrec JobWorkerExecutorConfiguration
$creadPrec :: ReadPrec JobWorkerExecutorConfiguration
readList :: ReadS [JobWorkerExecutorConfiguration]
$creadList :: ReadS [JobWorkerExecutorConfiguration]
readsPrec :: Int -> ReadS JobWorkerExecutorConfiguration
$creadsPrec :: Int -> ReadS JobWorkerExecutorConfiguration
Prelude.Read, Int -> JobWorkerExecutorConfiguration -> ShowS
[JobWorkerExecutorConfiguration] -> ShowS
JobWorkerExecutorConfiguration -> String
(Int -> JobWorkerExecutorConfiguration -> ShowS)
-> (JobWorkerExecutorConfiguration -> String)
-> ([JobWorkerExecutorConfiguration] -> ShowS)
-> Show JobWorkerExecutorConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JobWorkerExecutorConfiguration] -> ShowS
$cshowList :: [JobWorkerExecutorConfiguration] -> ShowS
show :: JobWorkerExecutorConfiguration -> String
$cshow :: JobWorkerExecutorConfiguration -> String
showsPrec :: Int -> JobWorkerExecutorConfiguration -> ShowS
$cshowsPrec :: Int -> JobWorkerExecutorConfiguration -> ShowS
Prelude.Show, (forall x.
 JobWorkerExecutorConfiguration
 -> Rep JobWorkerExecutorConfiguration x)
-> (forall x.
    Rep JobWorkerExecutorConfiguration x
    -> JobWorkerExecutorConfiguration)
-> Generic JobWorkerExecutorConfiguration
forall x.
Rep JobWorkerExecutorConfiguration x
-> JobWorkerExecutorConfiguration
forall x.
JobWorkerExecutorConfiguration
-> Rep JobWorkerExecutorConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep JobWorkerExecutorConfiguration x
-> JobWorkerExecutorConfiguration
$cfrom :: forall x.
JobWorkerExecutorConfiguration
-> Rep JobWorkerExecutorConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'JobWorkerExecutorConfiguration' 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:
--
-- 'pollingAccounts', 'jobWorkerExecutorConfiguration_pollingAccounts' - The accounts in which the job worker is configured and might poll for
-- jobs as part of the action execution.
--
-- 'pollingServicePrincipals', 'jobWorkerExecutorConfiguration_pollingServicePrincipals' - The service Principals in which the job worker is configured and might
-- poll for jobs as part of the action execution.
newJobWorkerExecutorConfiguration ::
  JobWorkerExecutorConfiguration
newJobWorkerExecutorConfiguration :: JobWorkerExecutorConfiguration
newJobWorkerExecutorConfiguration =
  JobWorkerExecutorConfiguration' :: Maybe (NonEmpty Text)
-> Maybe (NonEmpty Text) -> JobWorkerExecutorConfiguration
JobWorkerExecutorConfiguration'
    { $sel:pollingAccounts:JobWorkerExecutorConfiguration' :: Maybe (NonEmpty Text)
pollingAccounts =
        Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:pollingServicePrincipals:JobWorkerExecutorConfiguration' :: Maybe (NonEmpty Text)
pollingServicePrincipals = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | The accounts in which the job worker is configured and might poll for
-- jobs as part of the action execution.
jobWorkerExecutorConfiguration_pollingAccounts :: Lens.Lens' JobWorkerExecutorConfiguration (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
jobWorkerExecutorConfiguration_pollingAccounts :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> JobWorkerExecutorConfiguration
-> f JobWorkerExecutorConfiguration
jobWorkerExecutorConfiguration_pollingAccounts = (JobWorkerExecutorConfiguration -> Maybe (NonEmpty Text))
-> (JobWorkerExecutorConfiguration
    -> Maybe (NonEmpty Text) -> JobWorkerExecutorConfiguration)
-> Lens
     JobWorkerExecutorConfiguration
     JobWorkerExecutorConfiguration
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobWorkerExecutorConfiguration' {Maybe (NonEmpty Text)
pollingAccounts :: Maybe (NonEmpty Text)
$sel:pollingAccounts:JobWorkerExecutorConfiguration' :: JobWorkerExecutorConfiguration -> Maybe (NonEmpty Text)
pollingAccounts} -> Maybe (NonEmpty Text)
pollingAccounts) (\s :: JobWorkerExecutorConfiguration
s@JobWorkerExecutorConfiguration' {} Maybe (NonEmpty Text)
a -> JobWorkerExecutorConfiguration
s {$sel:pollingAccounts:JobWorkerExecutorConfiguration' :: Maybe (NonEmpty Text)
pollingAccounts = Maybe (NonEmpty Text)
a} :: JobWorkerExecutorConfiguration) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> JobWorkerExecutorConfiguration
 -> f JobWorkerExecutorConfiguration)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> JobWorkerExecutorConfiguration
-> f JobWorkerExecutorConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The service Principals in which the job worker is configured and might
-- poll for jobs as part of the action execution.
jobWorkerExecutorConfiguration_pollingServicePrincipals :: Lens.Lens' JobWorkerExecutorConfiguration (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
jobWorkerExecutorConfiguration_pollingServicePrincipals :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> JobWorkerExecutorConfiguration
-> f JobWorkerExecutorConfiguration
jobWorkerExecutorConfiguration_pollingServicePrincipals = (JobWorkerExecutorConfiguration -> Maybe (NonEmpty Text))
-> (JobWorkerExecutorConfiguration
    -> Maybe (NonEmpty Text) -> JobWorkerExecutorConfiguration)
-> Lens
     JobWorkerExecutorConfiguration
     JobWorkerExecutorConfiguration
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobWorkerExecutorConfiguration' {Maybe (NonEmpty Text)
pollingServicePrincipals :: Maybe (NonEmpty Text)
$sel:pollingServicePrincipals:JobWorkerExecutorConfiguration' :: JobWorkerExecutorConfiguration -> Maybe (NonEmpty Text)
pollingServicePrincipals} -> Maybe (NonEmpty Text)
pollingServicePrincipals) (\s :: JobWorkerExecutorConfiguration
s@JobWorkerExecutorConfiguration' {} Maybe (NonEmpty Text)
a -> JobWorkerExecutorConfiguration
s {$sel:pollingServicePrincipals:JobWorkerExecutorConfiguration' :: Maybe (NonEmpty Text)
pollingServicePrincipals = Maybe (NonEmpty Text)
a} :: JobWorkerExecutorConfiguration) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> JobWorkerExecutorConfiguration
 -> f JobWorkerExecutorConfiguration)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> JobWorkerExecutorConfiguration
-> f JobWorkerExecutorConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.Hashable
    JobWorkerExecutorConfiguration

instance
  Prelude.NFData
    JobWorkerExecutorConfiguration

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