{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ElasticBeanstalk.Types.ApplicationResourceLifecycleConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ElasticBeanstalk.Types.ApplicationVersionLifecycleConfig
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'
  { -- | 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,
    -- | Defines lifecycle settings for application versions.
    ApplicationResourceLifecycleConfig
-> Maybe ApplicationVersionLifecycleConfig
versionLifecycleConfig :: Prelude.Maybe ApplicationVersionLifecycleConfig
  }
  deriving (ApplicationResourceLifecycleConfig
-> ApplicationResourceLifecycleConfig -> Bool
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]
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
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.
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:
--
-- '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.
--
-- 'versionLifecycleConfig', 'applicationResourceLifecycleConfig_versionLifecycleConfig' - Defines lifecycle settings for application versions.
newApplicationResourceLifecycleConfig ::
  ApplicationResourceLifecycleConfig
newApplicationResourceLifecycleConfig :: ApplicationResourceLifecycleConfig
newApplicationResourceLifecycleConfig =
  ApplicationResourceLifecycleConfig'
    { $sel:serviceRole:ApplicationResourceLifecycleConfig' :: Maybe Text
serviceRole =
        forall a. Maybe a
Prelude.Nothing,
      $sel:versionLifecycleConfig:ApplicationResourceLifecycleConfig' :: Maybe ApplicationVersionLifecycleConfig
versionLifecycleConfig =
        forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' ApplicationResourceLifecycleConfig (Maybe Text)
applicationResourceLifecycleConfig_serviceRole = 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)

-- | Defines lifecycle settings for application versions.
applicationResourceLifecycleConfig_versionLifecycleConfig :: Lens.Lens' ApplicationResourceLifecycleConfig (Prelude.Maybe ApplicationVersionLifecycleConfig)
applicationResourceLifecycleConfig_versionLifecycleConfig :: Lens'
  ApplicationResourceLifecycleConfig
  (Maybe ApplicationVersionLifecycleConfig)
applicationResourceLifecycleConfig_versionLifecycleConfig = 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)

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

instance
  Prelude.Hashable
    ApplicationResourceLifecycleConfig
  where
  hashWithSalt :: Int -> ApplicationResourceLifecycleConfig -> Int
hashWithSalt
    Int
_salt
    ApplicationResourceLifecycleConfig' {Maybe Text
Maybe ApplicationVersionLifecycleConfig
versionLifecycleConfig :: Maybe ApplicationVersionLifecycleConfig
serviceRole :: Maybe Text
$sel:versionLifecycleConfig:ApplicationResourceLifecycleConfig' :: ApplicationResourceLifecycleConfig
-> Maybe ApplicationVersionLifecycleConfig
$sel:serviceRole:ApplicationResourceLifecycleConfig' :: ApplicationResourceLifecycleConfig -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
serviceRole
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ApplicationVersionLifecycleConfig
versionLifecycleConfig

instance
  Prelude.NFData
    ApplicationResourceLifecycleConfig
  where
  rnf :: ApplicationResourceLifecycleConfig -> ()
rnf ApplicationResourceLifecycleConfig' {Maybe Text
Maybe ApplicationVersionLifecycleConfig
versionLifecycleConfig :: Maybe ApplicationVersionLifecycleConfig
serviceRole :: Maybe Text
$sel:versionLifecycleConfig:ApplicationResourceLifecycleConfig' :: ApplicationResourceLifecycleConfig
-> Maybe ApplicationVersionLifecycleConfig
$sel:serviceRole:ApplicationResourceLifecycleConfig' :: ApplicationResourceLifecycleConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
serviceRole
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ApplicationVersionLifecycleConfig
versionLifecycleConfig

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