{-# 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.AutoScalingPlans.Types.ApplicationSource
-- 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.AutoScalingPlans.Types.ApplicationSource where

import Amazonka.AutoScalingPlans.Types.TagFilter
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents an application source.
--
-- /See:/ 'newApplicationSource' smart constructor.
data ApplicationSource = ApplicationSource'
  { -- | A set of tags (up to 50).
    ApplicationSource -> Maybe [TagFilter]
tagFilters :: Prelude.Maybe [TagFilter],
    -- | The Amazon Resource Name (ARN) of a AWS CloudFormation stack.
    ApplicationSource -> Maybe Text
cloudFormationStackARN :: Prelude.Maybe Prelude.Text
  }
  deriving (ApplicationSource -> ApplicationSource -> Bool
(ApplicationSource -> ApplicationSource -> Bool)
-> (ApplicationSource -> ApplicationSource -> Bool)
-> Eq ApplicationSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationSource -> ApplicationSource -> Bool
$c/= :: ApplicationSource -> ApplicationSource -> Bool
== :: ApplicationSource -> ApplicationSource -> Bool
$c== :: ApplicationSource -> ApplicationSource -> Bool
Prelude.Eq, ReadPrec [ApplicationSource]
ReadPrec ApplicationSource
Int -> ReadS ApplicationSource
ReadS [ApplicationSource]
(Int -> ReadS ApplicationSource)
-> ReadS [ApplicationSource]
-> ReadPrec ApplicationSource
-> ReadPrec [ApplicationSource]
-> Read ApplicationSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApplicationSource]
$creadListPrec :: ReadPrec [ApplicationSource]
readPrec :: ReadPrec ApplicationSource
$creadPrec :: ReadPrec ApplicationSource
readList :: ReadS [ApplicationSource]
$creadList :: ReadS [ApplicationSource]
readsPrec :: Int -> ReadS ApplicationSource
$creadsPrec :: Int -> ReadS ApplicationSource
Prelude.Read, Int -> ApplicationSource -> ShowS
[ApplicationSource] -> ShowS
ApplicationSource -> String
(Int -> ApplicationSource -> ShowS)
-> (ApplicationSource -> String)
-> ([ApplicationSource] -> ShowS)
-> Show ApplicationSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationSource] -> ShowS
$cshowList :: [ApplicationSource] -> ShowS
show :: ApplicationSource -> String
$cshow :: ApplicationSource -> String
showsPrec :: Int -> ApplicationSource -> ShowS
$cshowsPrec :: Int -> ApplicationSource -> ShowS
Prelude.Show, (forall x. ApplicationSource -> Rep ApplicationSource x)
-> (forall x. Rep ApplicationSource x -> ApplicationSource)
-> Generic ApplicationSource
forall x. Rep ApplicationSource x -> ApplicationSource
forall x. ApplicationSource -> Rep ApplicationSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ApplicationSource x -> ApplicationSource
$cfrom :: forall x. ApplicationSource -> Rep ApplicationSource x
Prelude.Generic)

-- |
-- Create a value of 'ApplicationSource' 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:
--
-- 'tagFilters', 'applicationSource_tagFilters' - A set of tags (up to 50).
--
-- 'cloudFormationStackARN', 'applicationSource_cloudFormationStackARN' - The Amazon Resource Name (ARN) of a AWS CloudFormation stack.
newApplicationSource ::
  ApplicationSource
newApplicationSource :: ApplicationSource
newApplicationSource =
  ApplicationSource' :: Maybe [TagFilter] -> Maybe Text -> ApplicationSource
ApplicationSource'
    { $sel:tagFilters:ApplicationSource' :: Maybe [TagFilter]
tagFilters = Maybe [TagFilter]
forall a. Maybe a
Prelude.Nothing,
      $sel:cloudFormationStackARN:ApplicationSource' :: Maybe Text
cloudFormationStackARN = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A set of tags (up to 50).
applicationSource_tagFilters :: Lens.Lens' ApplicationSource (Prelude.Maybe [TagFilter])
applicationSource_tagFilters :: (Maybe [TagFilter] -> f (Maybe [TagFilter]))
-> ApplicationSource -> f ApplicationSource
applicationSource_tagFilters = (ApplicationSource -> Maybe [TagFilter])
-> (ApplicationSource -> Maybe [TagFilter] -> ApplicationSource)
-> Lens
     ApplicationSource
     ApplicationSource
     (Maybe [TagFilter])
     (Maybe [TagFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationSource' {Maybe [TagFilter]
tagFilters :: Maybe [TagFilter]
$sel:tagFilters:ApplicationSource' :: ApplicationSource -> Maybe [TagFilter]
tagFilters} -> Maybe [TagFilter]
tagFilters) (\s :: ApplicationSource
s@ApplicationSource' {} Maybe [TagFilter]
a -> ApplicationSource
s {$sel:tagFilters:ApplicationSource' :: Maybe [TagFilter]
tagFilters = Maybe [TagFilter]
a} :: ApplicationSource) ((Maybe [TagFilter] -> f (Maybe [TagFilter]))
 -> ApplicationSource -> f ApplicationSource)
-> ((Maybe [TagFilter] -> f (Maybe [TagFilter]))
    -> Maybe [TagFilter] -> f (Maybe [TagFilter]))
-> (Maybe [TagFilter] -> f (Maybe [TagFilter]))
-> ApplicationSource
-> f ApplicationSource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [TagFilter] [TagFilter] [TagFilter] [TagFilter]
-> Iso
     (Maybe [TagFilter])
     (Maybe [TagFilter])
     (Maybe [TagFilter])
     (Maybe [TagFilter])
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 [TagFilter] [TagFilter] [TagFilter] [TagFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) of a AWS CloudFormation stack.
applicationSource_cloudFormationStackARN :: Lens.Lens' ApplicationSource (Prelude.Maybe Prelude.Text)
applicationSource_cloudFormationStackARN :: (Maybe Text -> f (Maybe Text))
-> ApplicationSource -> f ApplicationSource
applicationSource_cloudFormationStackARN = (ApplicationSource -> Maybe Text)
-> (ApplicationSource -> Maybe Text -> ApplicationSource)
-> Lens
     ApplicationSource ApplicationSource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationSource' {Maybe Text
cloudFormationStackARN :: Maybe Text
$sel:cloudFormationStackARN:ApplicationSource' :: ApplicationSource -> Maybe Text
cloudFormationStackARN} -> Maybe Text
cloudFormationStackARN) (\s :: ApplicationSource
s@ApplicationSource' {} Maybe Text
a -> ApplicationSource
s {$sel:cloudFormationStackARN:ApplicationSource' :: Maybe Text
cloudFormationStackARN = Maybe Text
a} :: ApplicationSource)

instance Core.FromJSON ApplicationSource where
  parseJSON :: Value -> Parser ApplicationSource
parseJSON =
    String
-> (Object -> Parser ApplicationSource)
-> Value
-> Parser ApplicationSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ApplicationSource"
      ( \Object
x ->
          Maybe [TagFilter] -> Maybe Text -> ApplicationSource
ApplicationSource'
            (Maybe [TagFilter] -> Maybe Text -> ApplicationSource)
-> Parser (Maybe [TagFilter])
-> Parser (Maybe Text -> ApplicationSource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [TagFilter]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TagFilters" Parser (Maybe (Maybe [TagFilter]))
-> Maybe [TagFilter] -> Parser (Maybe [TagFilter])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [TagFilter]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> ApplicationSource)
-> Parser (Maybe Text) -> Parser ApplicationSource
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
"CloudFormationStackARN")
      )

instance Prelude.Hashable ApplicationSource

instance Prelude.NFData ApplicationSource

instance Core.ToJSON ApplicationSource where
  toJSON :: ApplicationSource -> Value
toJSON ApplicationSource' {Maybe [TagFilter]
Maybe Text
cloudFormationStackARN :: Maybe Text
tagFilters :: Maybe [TagFilter]
$sel:cloudFormationStackARN:ApplicationSource' :: ApplicationSource -> Maybe Text
$sel:tagFilters:ApplicationSource' :: ApplicationSource -> Maybe [TagFilter]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TagFilters" Text -> [TagFilter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([TagFilter] -> Pair) -> Maybe [TagFilter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [TagFilter]
tagFilters,
            (Text
"CloudFormationStackARN" 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
cloudFormationStackARN
          ]
      )