{-# 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.ElasticBeanstalk.Types.ApplicationResourceLifecycleConfig
-- 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.ElasticBeanstalk.Types.ApplicationResourceLifecycleConfig where

import qualified Amazonka.Core as Core
import Amazonka.ElasticBeanstalk.Types.ApplicationVersionLifecycleConfig
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The resource lifecycle configuration for an application. Defines
-- lifecycle settings for resources that belong to the application, and the
-- service role that AWS Elastic Beanstalk assumes in order to apply
-- lifecycle settings. The version lifecycle configuration defines
-- lifecycle settings for application versions.
--
-- /See:/ 'newApplicationResourceLifecycleConfig' smart constructor.
data ApplicationResourceLifecycleConfig = ApplicationResourceLifecycleConfig'
  { -- | Defines lifecycle settings for application versions.
    ApplicationResourceLifecycleConfig
-> Maybe ApplicationVersionLifecycleConfig
versionLifecycleConfig :: Prelude.Maybe ApplicationVersionLifecycleConfig,
    -- | The ARN of an IAM service role that Elastic Beanstalk has permission to
    -- assume.
    --
    -- The @ServiceRole@ property is required the first time that you provide a
    -- @VersionLifecycleConfig@ for the application in one of the supporting
    -- calls (@CreateApplication@ or @UpdateApplicationResourceLifecycle@).
    -- After you provide it once, in either one of the calls, Elastic Beanstalk
    -- persists the Service Role with the application, and you don\'t need to
    -- specify it again in subsequent @UpdateApplicationResourceLifecycle@
    -- calls. You can, however, specify it in subsequent calls to change the
    -- Service Role to another value.
    ApplicationResourceLifecycleConfig -> Maybe Text
serviceRole :: Prelude.Maybe Prelude.Text
  }
  deriving (ApplicationResourceLifecycleConfig
-> ApplicationResourceLifecycleConfig -> Bool
(ApplicationResourceLifecycleConfig
 -> ApplicationResourceLifecycleConfig -> Bool)
-> (ApplicationResourceLifecycleConfig
    -> ApplicationResourceLifecycleConfig -> Bool)
-> Eq ApplicationResourceLifecycleConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationResourceLifecycleConfig
-> ApplicationResourceLifecycleConfig -> Bool
$c/= :: ApplicationResourceLifecycleConfig
-> ApplicationResourceLifecycleConfig -> Bool
== :: ApplicationResourceLifecycleConfig
-> ApplicationResourceLifecycleConfig -> Bool
$c== :: ApplicationResourceLifecycleConfig
-> ApplicationResourceLifecycleConfig -> Bool
Prelude.Eq, ReadPrec [ApplicationResourceLifecycleConfig]
ReadPrec ApplicationResourceLifecycleConfig
Int -> ReadS ApplicationResourceLifecycleConfig
ReadS [ApplicationResourceLifecycleConfig]
(Int -> ReadS ApplicationResourceLifecycleConfig)
-> ReadS [ApplicationResourceLifecycleConfig]
-> ReadPrec ApplicationResourceLifecycleConfig
-> ReadPrec [ApplicationResourceLifecycleConfig]
-> Read ApplicationResourceLifecycleConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApplicationResourceLifecycleConfig]
$creadListPrec :: ReadPrec [ApplicationResourceLifecycleConfig]
readPrec :: ReadPrec ApplicationResourceLifecycleConfig
$creadPrec :: ReadPrec ApplicationResourceLifecycleConfig
readList :: ReadS [ApplicationResourceLifecycleConfig]
$creadList :: ReadS [ApplicationResourceLifecycleConfig]
readsPrec :: Int -> ReadS ApplicationResourceLifecycleConfig
$creadsPrec :: Int -> ReadS ApplicationResourceLifecycleConfig
Prelude.Read, Int -> ApplicationResourceLifecycleConfig -> ShowS
[ApplicationResourceLifecycleConfig] -> ShowS
ApplicationResourceLifecycleConfig -> String
(Int -> ApplicationResourceLifecycleConfig -> ShowS)
-> (ApplicationResourceLifecycleConfig -> String)
-> ([ApplicationResourceLifecycleConfig] -> ShowS)
-> Show ApplicationResourceLifecycleConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationResourceLifecycleConfig] -> ShowS
$cshowList :: [ApplicationResourceLifecycleConfig] -> ShowS
show :: ApplicationResourceLifecycleConfig -> String
$cshow :: ApplicationResourceLifecycleConfig -> String
showsPrec :: Int -> ApplicationResourceLifecycleConfig -> ShowS
$cshowsPrec :: Int -> ApplicationResourceLifecycleConfig -> ShowS
Prelude.Show, (forall x.
 ApplicationResourceLifecycleConfig
 -> Rep ApplicationResourceLifecycleConfig x)
-> (forall x.
    Rep ApplicationResourceLifecycleConfig x
    -> ApplicationResourceLifecycleConfig)
-> Generic ApplicationResourceLifecycleConfig
forall x.
Rep ApplicationResourceLifecycleConfig x
-> ApplicationResourceLifecycleConfig
forall x.
ApplicationResourceLifecycleConfig
-> Rep ApplicationResourceLifecycleConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ApplicationResourceLifecycleConfig x
-> ApplicationResourceLifecycleConfig
$cfrom :: forall x.
ApplicationResourceLifecycleConfig
-> Rep ApplicationResourceLifecycleConfig x
Prelude.Generic)

-- |
-- Create a value of 'ApplicationResourceLifecycleConfig' 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:
--
-- 'versionLifecycleConfig', 'applicationResourceLifecycleConfig_versionLifecycleConfig' - Defines lifecycle settings for application versions.
--
-- 'serviceRole', 'applicationResourceLifecycleConfig_serviceRole' - The ARN of an IAM service role that Elastic Beanstalk has permission to
-- assume.
--
-- The @ServiceRole@ property is required the first time that you provide a
-- @VersionLifecycleConfig@ for the application in one of the supporting
-- calls (@CreateApplication@ or @UpdateApplicationResourceLifecycle@).
-- After you provide it once, in either one of the calls, Elastic Beanstalk
-- persists the Service Role with the application, and you don\'t need to
-- specify it again in subsequent @UpdateApplicationResourceLifecycle@
-- calls. You can, however, specify it in subsequent calls to change the
-- Service Role to another value.
newApplicationResourceLifecycleConfig ::
  ApplicationResourceLifecycleConfig
newApplicationResourceLifecycleConfig :: ApplicationResourceLifecycleConfig
newApplicationResourceLifecycleConfig =
  ApplicationResourceLifecycleConfig' :: Maybe ApplicationVersionLifecycleConfig
-> Maybe Text -> ApplicationResourceLifecycleConfig
ApplicationResourceLifecycleConfig'
    { $sel:versionLifecycleConfig:ApplicationResourceLifecycleConfig' :: Maybe ApplicationVersionLifecycleConfig
versionLifecycleConfig =
        Maybe ApplicationVersionLifecycleConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:serviceRole:ApplicationResourceLifecycleConfig' :: Maybe Text
serviceRole = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Defines lifecycle settings for application versions.
applicationResourceLifecycleConfig_versionLifecycleConfig :: Lens.Lens' ApplicationResourceLifecycleConfig (Prelude.Maybe ApplicationVersionLifecycleConfig)
applicationResourceLifecycleConfig_versionLifecycleConfig :: (Maybe ApplicationVersionLifecycleConfig
 -> f (Maybe ApplicationVersionLifecycleConfig))
-> ApplicationResourceLifecycleConfig
-> f ApplicationResourceLifecycleConfig
applicationResourceLifecycleConfig_versionLifecycleConfig = (ApplicationResourceLifecycleConfig
 -> Maybe ApplicationVersionLifecycleConfig)
-> (ApplicationResourceLifecycleConfig
    -> Maybe ApplicationVersionLifecycleConfig
    -> ApplicationResourceLifecycleConfig)
-> Lens
     ApplicationResourceLifecycleConfig
     ApplicationResourceLifecycleConfig
     (Maybe ApplicationVersionLifecycleConfig)
     (Maybe ApplicationVersionLifecycleConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationResourceLifecycleConfig' {Maybe ApplicationVersionLifecycleConfig
versionLifecycleConfig :: Maybe ApplicationVersionLifecycleConfig
$sel:versionLifecycleConfig:ApplicationResourceLifecycleConfig' :: ApplicationResourceLifecycleConfig
-> Maybe ApplicationVersionLifecycleConfig
versionLifecycleConfig} -> Maybe ApplicationVersionLifecycleConfig
versionLifecycleConfig) (\s :: ApplicationResourceLifecycleConfig
s@ApplicationResourceLifecycleConfig' {} Maybe ApplicationVersionLifecycleConfig
a -> ApplicationResourceLifecycleConfig
s {$sel:versionLifecycleConfig:ApplicationResourceLifecycleConfig' :: Maybe ApplicationVersionLifecycleConfig
versionLifecycleConfig = Maybe ApplicationVersionLifecycleConfig
a} :: ApplicationResourceLifecycleConfig)

-- | The ARN of an IAM service role that Elastic Beanstalk has permission to
-- assume.
--
-- The @ServiceRole@ property is required the first time that you provide a
-- @VersionLifecycleConfig@ for the application in one of the supporting
-- calls (@CreateApplication@ or @UpdateApplicationResourceLifecycle@).
-- After you provide it once, in either one of the calls, Elastic Beanstalk
-- persists the Service Role with the application, and you don\'t need to
-- specify it again in subsequent @UpdateApplicationResourceLifecycle@
-- calls. You can, however, specify it in subsequent calls to change the
-- Service Role to another value.
applicationResourceLifecycleConfig_serviceRole :: Lens.Lens' ApplicationResourceLifecycleConfig (Prelude.Maybe Prelude.Text)
applicationResourceLifecycleConfig_serviceRole :: (Maybe Text -> f (Maybe Text))
-> ApplicationResourceLifecycleConfig
-> f ApplicationResourceLifecycleConfig
applicationResourceLifecycleConfig_serviceRole = (ApplicationResourceLifecycleConfig -> Maybe Text)
-> (ApplicationResourceLifecycleConfig
    -> Maybe Text -> ApplicationResourceLifecycleConfig)
-> Lens
     ApplicationResourceLifecycleConfig
     ApplicationResourceLifecycleConfig
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ApplicationResourceLifecycleConfig' {Maybe Text
serviceRole :: Maybe Text
$sel:serviceRole:ApplicationResourceLifecycleConfig' :: ApplicationResourceLifecycleConfig -> Maybe Text
serviceRole} -> Maybe Text
serviceRole) (\s :: ApplicationResourceLifecycleConfig
s@ApplicationResourceLifecycleConfig' {} Maybe Text
a -> ApplicationResourceLifecycleConfig
s {$sel:serviceRole:ApplicationResourceLifecycleConfig' :: Maybe Text
serviceRole = Maybe Text
a} :: ApplicationResourceLifecycleConfig)

instance
  Core.FromXML
    ApplicationResourceLifecycleConfig
  where
  parseXML :: [Node] -> Either String ApplicationResourceLifecycleConfig
parseXML [Node]
x =
    Maybe ApplicationVersionLifecycleConfig
-> Maybe Text -> ApplicationResourceLifecycleConfig
ApplicationResourceLifecycleConfig'
      (Maybe ApplicationVersionLifecycleConfig
 -> Maybe Text -> ApplicationResourceLifecycleConfig)
-> Either String (Maybe ApplicationVersionLifecycleConfig)
-> Either String (Maybe Text -> ApplicationResourceLifecycleConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node]
-> Text -> Either String (Maybe ApplicationVersionLifecycleConfig)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"VersionLifecycleConfig")
      Either String (Maybe Text -> ApplicationResourceLifecycleConfig)
-> Either String (Maybe Text)
-> Either String ApplicationResourceLifecycleConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ServiceRole")

instance
  Prelude.Hashable
    ApplicationResourceLifecycleConfig

instance
  Prelude.NFData
    ApplicationResourceLifecycleConfig

instance
  Core.ToQuery
    ApplicationResourceLifecycleConfig
  where
  toQuery :: ApplicationResourceLifecycleConfig -> QueryString
toQuery ApplicationResourceLifecycleConfig' {Maybe Text
Maybe ApplicationVersionLifecycleConfig
serviceRole :: Maybe Text
versionLifecycleConfig :: Maybe ApplicationVersionLifecycleConfig
$sel:serviceRole:ApplicationResourceLifecycleConfig' :: ApplicationResourceLifecycleConfig -> Maybe Text
$sel:versionLifecycleConfig:ApplicationResourceLifecycleConfig' :: ApplicationResourceLifecycleConfig
-> Maybe ApplicationVersionLifecycleConfig
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"VersionLifecycleConfig"
          ByteString
-> Maybe ApplicationVersionLifecycleConfig -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe ApplicationVersionLifecycleConfig
versionLifecycleConfig,
        ByteString
"ServiceRole" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
serviceRole
      ]