{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.ComposeEnvironments
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Create or update a group of environments that each run a separate
-- component of a single application. Takes a list of version labels that
-- specify application source bundles for each of the environments to
-- create or update. The name of each environment and other required
-- information must be included in the source bundles in an environment
-- manifest named @env.yaml@. See
-- <https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-mgmt-compose.html Compose Environments>
-- for details.
module Amazonka.ElasticBeanstalk.ComposeEnvironments
  ( -- * Creating a Request
    ComposeEnvironments (..),
    newComposeEnvironments,

    -- * Request Lenses
    composeEnvironments_applicationName,
    composeEnvironments_groupName,
    composeEnvironments_versionLabels,

    -- * Destructuring the Response
    EnvironmentDescriptionsMessage (..),
    newEnvironmentDescriptionsMessage,

    -- * Response Lenses
    environmentDescriptionsMessage_environments,
    environmentDescriptionsMessage_nextToken,
  )
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
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Request to create or update a group of environments.
--
-- /See:/ 'newComposeEnvironments' smart constructor.
data ComposeEnvironments = ComposeEnvironments'
  { -- | The name of the application to which the specified source bundles
    -- belong.
    ComposeEnvironments -> Maybe Text
applicationName :: Prelude.Maybe Prelude.Text,
    -- | The name of the group to which the target environments belong. Specify a
    -- group name only if the environment name defined in each target
    -- environment\'s manifest ends with a + (plus) character. See
    -- <https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-cfg-manifest.html Environment Manifest (env.yaml)>
    -- for details.
    ComposeEnvironments -> Maybe Text
groupName :: Prelude.Maybe Prelude.Text,
    -- | A list of version labels, specifying one or more application source
    -- bundles that belong to the target application. Each source bundle must
    -- include an environment manifest that specifies the name of the
    -- environment and the name of the solution stack to use, and optionally
    -- can specify environment links to create.
    ComposeEnvironments -> Maybe [Text]
versionLabels :: Prelude.Maybe [Prelude.Text]
  }
  deriving (ComposeEnvironments -> ComposeEnvironments -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComposeEnvironments -> ComposeEnvironments -> Bool
$c/= :: ComposeEnvironments -> ComposeEnvironments -> Bool
== :: ComposeEnvironments -> ComposeEnvironments -> Bool
$c== :: ComposeEnvironments -> ComposeEnvironments -> Bool
Prelude.Eq, ReadPrec [ComposeEnvironments]
ReadPrec ComposeEnvironments
Int -> ReadS ComposeEnvironments
ReadS [ComposeEnvironments]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComposeEnvironments]
$creadListPrec :: ReadPrec [ComposeEnvironments]
readPrec :: ReadPrec ComposeEnvironments
$creadPrec :: ReadPrec ComposeEnvironments
readList :: ReadS [ComposeEnvironments]
$creadList :: ReadS [ComposeEnvironments]
readsPrec :: Int -> ReadS ComposeEnvironments
$creadsPrec :: Int -> ReadS ComposeEnvironments
Prelude.Read, Int -> ComposeEnvironments -> ShowS
[ComposeEnvironments] -> ShowS
ComposeEnvironments -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComposeEnvironments] -> ShowS
$cshowList :: [ComposeEnvironments] -> ShowS
show :: ComposeEnvironments -> String
$cshow :: ComposeEnvironments -> String
showsPrec :: Int -> ComposeEnvironments -> ShowS
$cshowsPrec :: Int -> ComposeEnvironments -> ShowS
Prelude.Show, forall x. Rep ComposeEnvironments x -> ComposeEnvironments
forall x. ComposeEnvironments -> Rep ComposeEnvironments x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ComposeEnvironments x -> ComposeEnvironments
$cfrom :: forall x. ComposeEnvironments -> Rep ComposeEnvironments x
Prelude.Generic)

-- |
-- Create a value of 'ComposeEnvironments' 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:
--
-- 'applicationName', 'composeEnvironments_applicationName' - The name of the application to which the specified source bundles
-- belong.
--
-- 'groupName', 'composeEnvironments_groupName' - The name of the group to which the target environments belong. Specify a
-- group name only if the environment name defined in each target
-- environment\'s manifest ends with a + (plus) character. See
-- <https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-cfg-manifest.html Environment Manifest (env.yaml)>
-- for details.
--
-- 'versionLabels', 'composeEnvironments_versionLabels' - A list of version labels, specifying one or more application source
-- bundles that belong to the target application. Each source bundle must
-- include an environment manifest that specifies the name of the
-- environment and the name of the solution stack to use, and optionally
-- can specify environment links to create.
newComposeEnvironments ::
  ComposeEnvironments
newComposeEnvironments :: ComposeEnvironments
newComposeEnvironments =
  ComposeEnvironments'
    { $sel:applicationName:ComposeEnvironments' :: Maybe Text
applicationName =
        forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:ComposeEnvironments' :: Maybe Text
groupName = forall a. Maybe a
Prelude.Nothing,
      $sel:versionLabels:ComposeEnvironments' :: Maybe [Text]
versionLabels = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the application to which the specified source bundles
-- belong.
composeEnvironments_applicationName :: Lens.Lens' ComposeEnvironments (Prelude.Maybe Prelude.Text)
composeEnvironments_applicationName :: Lens' ComposeEnvironments (Maybe Text)
composeEnvironments_applicationName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComposeEnvironments' {Maybe Text
applicationName :: Maybe Text
$sel:applicationName:ComposeEnvironments' :: ComposeEnvironments -> Maybe Text
applicationName} -> Maybe Text
applicationName) (\s :: ComposeEnvironments
s@ComposeEnvironments' {} Maybe Text
a -> ComposeEnvironments
s {$sel:applicationName:ComposeEnvironments' :: Maybe Text
applicationName = Maybe Text
a} :: ComposeEnvironments)

-- | The name of the group to which the target environments belong. Specify a
-- group name only if the environment name defined in each target
-- environment\'s manifest ends with a + (plus) character. See
-- <https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-cfg-manifest.html Environment Manifest (env.yaml)>
-- for details.
composeEnvironments_groupName :: Lens.Lens' ComposeEnvironments (Prelude.Maybe Prelude.Text)
composeEnvironments_groupName :: Lens' ComposeEnvironments (Maybe Text)
composeEnvironments_groupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComposeEnvironments' {Maybe Text
groupName :: Maybe Text
$sel:groupName:ComposeEnvironments' :: ComposeEnvironments -> Maybe Text
groupName} -> Maybe Text
groupName) (\s :: ComposeEnvironments
s@ComposeEnvironments' {} Maybe Text
a -> ComposeEnvironments
s {$sel:groupName:ComposeEnvironments' :: Maybe Text
groupName = Maybe Text
a} :: ComposeEnvironments)

-- | A list of version labels, specifying one or more application source
-- bundles that belong to the target application. Each source bundle must
-- include an environment manifest that specifies the name of the
-- environment and the name of the solution stack to use, and optionally
-- can specify environment links to create.
composeEnvironments_versionLabels :: Lens.Lens' ComposeEnvironments (Prelude.Maybe [Prelude.Text])
composeEnvironments_versionLabels :: Lens' ComposeEnvironments (Maybe [Text])
composeEnvironments_versionLabels = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComposeEnvironments' {Maybe [Text]
versionLabels :: Maybe [Text]
$sel:versionLabels:ComposeEnvironments' :: ComposeEnvironments -> Maybe [Text]
versionLabels} -> Maybe [Text]
versionLabels) (\s :: ComposeEnvironments
s@ComposeEnvironments' {} Maybe [Text]
a -> ComposeEnvironments
s {$sel:versionLabels:ComposeEnvironments' :: Maybe [Text]
versionLabels = Maybe [Text]
a} :: ComposeEnvironments) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest ComposeEnvironments where
  type
    AWSResponse ComposeEnvironments =
      EnvironmentDescriptionsMessage
  request :: (Service -> Service)
-> ComposeEnvironments -> Request ComposeEnvironments
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ComposeEnvironments
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ComposeEnvironments)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ComposeEnvironmentsResult"
      (\Int
s ResponseHeaders
h [Node]
x -> forall a. FromXML a => [Node] -> Either String a
Data.parseXML [Node]
x)

instance Prelude.Hashable ComposeEnvironments where
  hashWithSalt :: Int -> ComposeEnvironments -> Int
hashWithSalt Int
_salt ComposeEnvironments' {Maybe [Text]
Maybe Text
versionLabels :: Maybe [Text]
groupName :: Maybe Text
applicationName :: Maybe Text
$sel:versionLabels:ComposeEnvironments' :: ComposeEnvironments -> Maybe [Text]
$sel:groupName:ComposeEnvironments' :: ComposeEnvironments -> Maybe Text
$sel:applicationName:ComposeEnvironments' :: ComposeEnvironments -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
applicationName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
groupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
versionLabels

instance Prelude.NFData ComposeEnvironments where
  rnf :: ComposeEnvironments -> ()
rnf ComposeEnvironments' {Maybe [Text]
Maybe Text
versionLabels :: Maybe [Text]
groupName :: Maybe Text
applicationName :: Maybe Text
$sel:versionLabels:ComposeEnvironments' :: ComposeEnvironments -> Maybe [Text]
$sel:groupName:ComposeEnvironments' :: ComposeEnvironments -> Maybe Text
$sel:applicationName:ComposeEnvironments' :: ComposeEnvironments -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
applicationName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
groupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
versionLabels

instance Data.ToHeaders ComposeEnvironments where
  toHeaders :: ComposeEnvironments -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath ComposeEnvironments where
  toPath :: ComposeEnvironments -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery ComposeEnvironments where
  toQuery :: ComposeEnvironments -> QueryString
toQuery ComposeEnvironments' {Maybe [Text]
Maybe Text
versionLabels :: Maybe [Text]
groupName :: Maybe Text
applicationName :: Maybe Text
$sel:versionLabels:ComposeEnvironments' :: ComposeEnvironments -> Maybe [Text]
$sel:groupName:ComposeEnvironments' :: ComposeEnvironments -> Maybe Text
$sel:applicationName:ComposeEnvironments' :: ComposeEnvironments -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"ComposeEnvironments" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"ApplicationName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
applicationName,
        ByteString
"GroupName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
groupName,
        ByteString
"VersionLabels"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member"
                forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
versionLabels
            )
      ]