{-# 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-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)
--
-- 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_versionLabels,
    composeEnvironments_applicationName,
    composeEnvironments_groupName,

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

    -- * Response Lenses
    environmentDescriptionsMessage_nextToken,
    environmentDescriptionsMessage_environments,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ElasticBeanstalk.Types
import qualified Amazonka.Lens as Lens
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'
  { -- | 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],
    -- | 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
  }
  deriving (ComposeEnvironments -> ComposeEnvironments -> Bool
(ComposeEnvironments -> ComposeEnvironments -> Bool)
-> (ComposeEnvironments -> ComposeEnvironments -> Bool)
-> Eq ComposeEnvironments
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]
(Int -> ReadS ComposeEnvironments)
-> ReadS [ComposeEnvironments]
-> ReadPrec ComposeEnvironments
-> ReadPrec [ComposeEnvironments]
-> Read 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
(Int -> ComposeEnvironments -> ShowS)
-> (ComposeEnvironments -> String)
-> ([ComposeEnvironments] -> ShowS)
-> Show ComposeEnvironments
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. ComposeEnvironments -> Rep ComposeEnvironments x)
-> (forall x. Rep ComposeEnvironments x -> ComposeEnvironments)
-> Generic ComposeEnvironments
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:
--
-- '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.
--
-- '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.
newComposeEnvironments ::
  ComposeEnvironments
newComposeEnvironments :: ComposeEnvironments
newComposeEnvironments =
  ComposeEnvironments' :: Maybe [Text] -> Maybe Text -> Maybe Text -> ComposeEnvironments
ComposeEnvironments'
    { $sel:versionLabels:ComposeEnvironments' :: Maybe [Text]
versionLabels =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:applicationName:ComposeEnvironments' :: Maybe Text
applicationName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:ComposeEnvironments' :: Maybe Text
groupName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe [Text] -> f (Maybe [Text]))
-> ComposeEnvironments -> f ComposeEnvironments
composeEnvironments_versionLabels = (ComposeEnvironments -> Maybe [Text])
-> (ComposeEnvironments -> Maybe [Text] -> ComposeEnvironments)
-> Lens
     ComposeEnvironments
     ComposeEnvironments
     (Maybe [Text])
     (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> ComposeEnvironments -> f ComposeEnvironments)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ComposeEnvironments
-> f ComposeEnvironments
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

-- | The name of the application to which the specified source bundles
-- belong.
composeEnvironments_applicationName :: Lens.Lens' ComposeEnvironments (Prelude.Maybe Prelude.Text)
composeEnvironments_applicationName :: (Maybe Text -> f (Maybe Text))
-> ComposeEnvironments -> f ComposeEnvironments
composeEnvironments_applicationName = (ComposeEnvironments -> Maybe Text)
-> (ComposeEnvironments -> Maybe Text -> ComposeEnvironments)
-> Lens
     ComposeEnvironments ComposeEnvironments (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> ComposeEnvironments -> f ComposeEnvironments
composeEnvironments_groupName = (ComposeEnvironments -> Maybe Text)
-> (ComposeEnvironments -> Maybe Text -> ComposeEnvironments)
-> Lens
     ComposeEnvironments ComposeEnvironments (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable ComposeEnvironments

instance Prelude.NFData ComposeEnvironments

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

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

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