{-# 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.AppSync.Types.PipelineConfig
-- 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.AppSync.Types.PipelineConfig where

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

-- | The pipeline configuration for a resolver of kind @PIPELINE@.
--
-- /See:/ 'newPipelineConfig' smart constructor.
data PipelineConfig = PipelineConfig'
  { -- | A list of @Function@ objects.
    PipelineConfig -> Maybe [Text]
functions :: Prelude.Maybe [Prelude.Text]
  }
  deriving (PipelineConfig -> PipelineConfig -> Bool
(PipelineConfig -> PipelineConfig -> Bool)
-> (PipelineConfig -> PipelineConfig -> Bool) -> Eq PipelineConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PipelineConfig -> PipelineConfig -> Bool
$c/= :: PipelineConfig -> PipelineConfig -> Bool
== :: PipelineConfig -> PipelineConfig -> Bool
$c== :: PipelineConfig -> PipelineConfig -> Bool
Prelude.Eq, ReadPrec [PipelineConfig]
ReadPrec PipelineConfig
Int -> ReadS PipelineConfig
ReadS [PipelineConfig]
(Int -> ReadS PipelineConfig)
-> ReadS [PipelineConfig]
-> ReadPrec PipelineConfig
-> ReadPrec [PipelineConfig]
-> Read PipelineConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PipelineConfig]
$creadListPrec :: ReadPrec [PipelineConfig]
readPrec :: ReadPrec PipelineConfig
$creadPrec :: ReadPrec PipelineConfig
readList :: ReadS [PipelineConfig]
$creadList :: ReadS [PipelineConfig]
readsPrec :: Int -> ReadS PipelineConfig
$creadsPrec :: Int -> ReadS PipelineConfig
Prelude.Read, Int -> PipelineConfig -> ShowS
[PipelineConfig] -> ShowS
PipelineConfig -> String
(Int -> PipelineConfig -> ShowS)
-> (PipelineConfig -> String)
-> ([PipelineConfig] -> ShowS)
-> Show PipelineConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PipelineConfig] -> ShowS
$cshowList :: [PipelineConfig] -> ShowS
show :: PipelineConfig -> String
$cshow :: PipelineConfig -> String
showsPrec :: Int -> PipelineConfig -> ShowS
$cshowsPrec :: Int -> PipelineConfig -> ShowS
Prelude.Show, (forall x. PipelineConfig -> Rep PipelineConfig x)
-> (forall x. Rep PipelineConfig x -> PipelineConfig)
-> Generic PipelineConfig
forall x. Rep PipelineConfig x -> PipelineConfig
forall x. PipelineConfig -> Rep PipelineConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PipelineConfig x -> PipelineConfig
$cfrom :: forall x. PipelineConfig -> Rep PipelineConfig x
Prelude.Generic)

-- |
-- Create a value of 'PipelineConfig' 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:
--
-- 'functions', 'pipelineConfig_functions' - A list of @Function@ objects.
newPipelineConfig ::
  PipelineConfig
newPipelineConfig :: PipelineConfig
newPipelineConfig =
  PipelineConfig' :: Maybe [Text] -> PipelineConfig
PipelineConfig' {$sel:functions:PipelineConfig' :: Maybe [Text]
functions = Maybe [Text]
forall a. Maybe a
Prelude.Nothing}

-- | A list of @Function@ objects.
pipelineConfig_functions :: Lens.Lens' PipelineConfig (Prelude.Maybe [Prelude.Text])
pipelineConfig_functions :: (Maybe [Text] -> f (Maybe [Text]))
-> PipelineConfig -> f PipelineConfig
pipelineConfig_functions = (PipelineConfig -> Maybe [Text])
-> (PipelineConfig -> Maybe [Text] -> PipelineConfig)
-> Lens PipelineConfig PipelineConfig (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PipelineConfig' {Maybe [Text]
functions :: Maybe [Text]
$sel:functions:PipelineConfig' :: PipelineConfig -> Maybe [Text]
functions} -> Maybe [Text]
functions) (\s :: PipelineConfig
s@PipelineConfig' {} Maybe [Text]
a -> PipelineConfig
s {$sel:functions:PipelineConfig' :: Maybe [Text]
functions = Maybe [Text]
a} :: PipelineConfig) ((Maybe [Text] -> f (Maybe [Text]))
 -> PipelineConfig -> f PipelineConfig)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PipelineConfig
-> f PipelineConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON PipelineConfig where
  parseJSON :: Value -> Parser PipelineConfig
parseJSON =
    String
-> (Object -> Parser PipelineConfig)
-> Value
-> Parser PipelineConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PipelineConfig"
      ( \Object
x ->
          Maybe [Text] -> PipelineConfig
PipelineConfig'
            (Maybe [Text] -> PipelineConfig)
-> Parser (Maybe [Text]) -> Parser PipelineConfig
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"functions" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable PipelineConfig

instance Prelude.NFData PipelineConfig

instance Core.ToJSON PipelineConfig where
  toJSON :: PipelineConfig -> Value
toJSON PipelineConfig' {Maybe [Text]
functions :: Maybe [Text]
$sel:functions:PipelineConfig' :: PipelineConfig -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"functions" 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]
functions]
      )