{-# 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.EnvironmentDescriptionsMessage
-- 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.EnvironmentDescriptionsMessage where

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

-- | Result message containing a list of environment descriptions.
--
-- /See:/ 'newEnvironmentDescriptionsMessage' smart constructor.
data EnvironmentDescriptionsMessage = EnvironmentDescriptionsMessage'
  { -- | In a paginated request, the token that you can pass in a subsequent
    -- request to get the next response page.
    EnvironmentDescriptionsMessage -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Returns an EnvironmentDescription list.
    EnvironmentDescriptionsMessage -> Maybe [EnvironmentDescription]
environments :: Prelude.Maybe [EnvironmentDescription]
  }
  deriving (EnvironmentDescriptionsMessage
-> EnvironmentDescriptionsMessage -> Bool
(EnvironmentDescriptionsMessage
 -> EnvironmentDescriptionsMessage -> Bool)
-> (EnvironmentDescriptionsMessage
    -> EnvironmentDescriptionsMessage -> Bool)
-> Eq EnvironmentDescriptionsMessage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnvironmentDescriptionsMessage
-> EnvironmentDescriptionsMessage -> Bool
$c/= :: EnvironmentDescriptionsMessage
-> EnvironmentDescriptionsMessage -> Bool
== :: EnvironmentDescriptionsMessage
-> EnvironmentDescriptionsMessage -> Bool
$c== :: EnvironmentDescriptionsMessage
-> EnvironmentDescriptionsMessage -> Bool
Prelude.Eq, ReadPrec [EnvironmentDescriptionsMessage]
ReadPrec EnvironmentDescriptionsMessage
Int -> ReadS EnvironmentDescriptionsMessage
ReadS [EnvironmentDescriptionsMessage]
(Int -> ReadS EnvironmentDescriptionsMessage)
-> ReadS [EnvironmentDescriptionsMessage]
-> ReadPrec EnvironmentDescriptionsMessage
-> ReadPrec [EnvironmentDescriptionsMessage]
-> Read EnvironmentDescriptionsMessage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnvironmentDescriptionsMessage]
$creadListPrec :: ReadPrec [EnvironmentDescriptionsMessage]
readPrec :: ReadPrec EnvironmentDescriptionsMessage
$creadPrec :: ReadPrec EnvironmentDescriptionsMessage
readList :: ReadS [EnvironmentDescriptionsMessage]
$creadList :: ReadS [EnvironmentDescriptionsMessage]
readsPrec :: Int -> ReadS EnvironmentDescriptionsMessage
$creadsPrec :: Int -> ReadS EnvironmentDescriptionsMessage
Prelude.Read, Int -> EnvironmentDescriptionsMessage -> ShowS
[EnvironmentDescriptionsMessage] -> ShowS
EnvironmentDescriptionsMessage -> String
(Int -> EnvironmentDescriptionsMessage -> ShowS)
-> (EnvironmentDescriptionsMessage -> String)
-> ([EnvironmentDescriptionsMessage] -> ShowS)
-> Show EnvironmentDescriptionsMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnvironmentDescriptionsMessage] -> ShowS
$cshowList :: [EnvironmentDescriptionsMessage] -> ShowS
show :: EnvironmentDescriptionsMessage -> String
$cshow :: EnvironmentDescriptionsMessage -> String
showsPrec :: Int -> EnvironmentDescriptionsMessage -> ShowS
$cshowsPrec :: Int -> EnvironmentDescriptionsMessage -> ShowS
Prelude.Show, (forall x.
 EnvironmentDescriptionsMessage
 -> Rep EnvironmentDescriptionsMessage x)
-> (forall x.
    Rep EnvironmentDescriptionsMessage x
    -> EnvironmentDescriptionsMessage)
-> Generic EnvironmentDescriptionsMessage
forall x.
Rep EnvironmentDescriptionsMessage x
-> EnvironmentDescriptionsMessage
forall x.
EnvironmentDescriptionsMessage
-> Rep EnvironmentDescriptionsMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EnvironmentDescriptionsMessage x
-> EnvironmentDescriptionsMessage
$cfrom :: forall x.
EnvironmentDescriptionsMessage
-> Rep EnvironmentDescriptionsMessage x
Prelude.Generic)

-- |
-- Create a value of 'EnvironmentDescriptionsMessage' 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:
--
-- 'nextToken', 'environmentDescriptionsMessage_nextToken' - In a paginated request, the token that you can pass in a subsequent
-- request to get the next response page.
--
-- 'environments', 'environmentDescriptionsMessage_environments' - Returns an EnvironmentDescription list.
newEnvironmentDescriptionsMessage ::
  EnvironmentDescriptionsMessage
newEnvironmentDescriptionsMessage :: EnvironmentDescriptionsMessage
newEnvironmentDescriptionsMessage =
  EnvironmentDescriptionsMessage' :: Maybe Text
-> Maybe [EnvironmentDescription] -> EnvironmentDescriptionsMessage
EnvironmentDescriptionsMessage'
    { $sel:nextToken:EnvironmentDescriptionsMessage' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:environments:EnvironmentDescriptionsMessage' :: Maybe [EnvironmentDescription]
environments = Maybe [EnvironmentDescription]
forall a. Maybe a
Prelude.Nothing
    }

-- | In a paginated request, the token that you can pass in a subsequent
-- request to get the next response page.
environmentDescriptionsMessage_nextToken :: Lens.Lens' EnvironmentDescriptionsMessage (Prelude.Maybe Prelude.Text)
environmentDescriptionsMessage_nextToken :: (Maybe Text -> f (Maybe Text))
-> EnvironmentDescriptionsMessage
-> f EnvironmentDescriptionsMessage
environmentDescriptionsMessage_nextToken = (EnvironmentDescriptionsMessage -> Maybe Text)
-> (EnvironmentDescriptionsMessage
    -> Maybe Text -> EnvironmentDescriptionsMessage)
-> Lens
     EnvironmentDescriptionsMessage
     EnvironmentDescriptionsMessage
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentDescriptionsMessage' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:EnvironmentDescriptionsMessage' :: EnvironmentDescriptionsMessage -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: EnvironmentDescriptionsMessage
s@EnvironmentDescriptionsMessage' {} Maybe Text
a -> EnvironmentDescriptionsMessage
s {$sel:nextToken:EnvironmentDescriptionsMessage' :: Maybe Text
nextToken = Maybe Text
a} :: EnvironmentDescriptionsMessage)

-- | Returns an EnvironmentDescription list.
environmentDescriptionsMessage_environments :: Lens.Lens' EnvironmentDescriptionsMessage (Prelude.Maybe [EnvironmentDescription])
environmentDescriptionsMessage_environments :: (Maybe [EnvironmentDescription]
 -> f (Maybe [EnvironmentDescription]))
-> EnvironmentDescriptionsMessage
-> f EnvironmentDescriptionsMessage
environmentDescriptionsMessage_environments = (EnvironmentDescriptionsMessage -> Maybe [EnvironmentDescription])
-> (EnvironmentDescriptionsMessage
    -> Maybe [EnvironmentDescription]
    -> EnvironmentDescriptionsMessage)
-> Lens
     EnvironmentDescriptionsMessage
     EnvironmentDescriptionsMessage
     (Maybe [EnvironmentDescription])
     (Maybe [EnvironmentDescription])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnvironmentDescriptionsMessage' {Maybe [EnvironmentDescription]
environments :: Maybe [EnvironmentDescription]
$sel:environments:EnvironmentDescriptionsMessage' :: EnvironmentDescriptionsMessage -> Maybe [EnvironmentDescription]
environments} -> Maybe [EnvironmentDescription]
environments) (\s :: EnvironmentDescriptionsMessage
s@EnvironmentDescriptionsMessage' {} Maybe [EnvironmentDescription]
a -> EnvironmentDescriptionsMessage
s {$sel:environments:EnvironmentDescriptionsMessage' :: Maybe [EnvironmentDescription]
environments = Maybe [EnvironmentDescription]
a} :: EnvironmentDescriptionsMessage) ((Maybe [EnvironmentDescription]
  -> f (Maybe [EnvironmentDescription]))
 -> EnvironmentDescriptionsMessage
 -> f EnvironmentDescriptionsMessage)
-> ((Maybe [EnvironmentDescription]
     -> f (Maybe [EnvironmentDescription]))
    -> Maybe [EnvironmentDescription]
    -> f (Maybe [EnvironmentDescription]))
-> (Maybe [EnvironmentDescription]
    -> f (Maybe [EnvironmentDescription]))
-> EnvironmentDescriptionsMessage
-> f EnvironmentDescriptionsMessage
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [EnvironmentDescription]
  [EnvironmentDescription]
  [EnvironmentDescription]
  [EnvironmentDescription]
-> Iso
     (Maybe [EnvironmentDescription])
     (Maybe [EnvironmentDescription])
     (Maybe [EnvironmentDescription])
     (Maybe [EnvironmentDescription])
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
  [EnvironmentDescription]
  [EnvironmentDescription]
  [EnvironmentDescription]
  [EnvironmentDescription]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML EnvironmentDescriptionsMessage where
  parseXML :: [Node] -> Either String EnvironmentDescriptionsMessage
parseXML [Node]
x =
    Maybe Text
-> Maybe [EnvironmentDescription] -> EnvironmentDescriptionsMessage
EnvironmentDescriptionsMessage'
      (Maybe Text
 -> Maybe [EnvironmentDescription]
 -> EnvironmentDescriptionsMessage)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [EnvironmentDescription] -> EnvironmentDescriptionsMessage)
forall (f :: * -> *) a b. Functor 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
"NextToken")
      Either
  String
  (Maybe [EnvironmentDescription] -> EnvironmentDescriptionsMessage)
-> Either String (Maybe [EnvironmentDescription])
-> Either String EnvironmentDescriptionsMessage
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Environments" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [EnvironmentDescription]))
-> Either String (Maybe [EnvironmentDescription])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [EnvironmentDescription])
-> [Node] -> Either String (Maybe [EnvironmentDescription])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [EnvironmentDescription]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )

instance
  Prelude.Hashable
    EnvironmentDescriptionsMessage

instance
  Prelude.NFData
    EnvironmentDescriptionsMessage