{-# 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.DescribeApplications
-- 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)
--
-- Returns the descriptions of existing applications.
module Amazonka.ElasticBeanstalk.DescribeApplications
  ( -- * Creating a Request
    DescribeApplications (..),
    newDescribeApplications,

    -- * Request Lenses
    describeApplications_applicationNames,

    -- * Destructuring the Response
    DescribeApplicationsResponse (..),
    newDescribeApplicationsResponse,

    -- * Response Lenses
    describeApplicationsResponse_applications,
    describeApplicationsResponse_httpStatus,
  )
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 describe one or more applications.
--
-- /See:/ 'newDescribeApplications' smart constructor.
data DescribeApplications = DescribeApplications'
  { -- | If specified, AWS Elastic Beanstalk restricts the returned descriptions
    -- to only include those with the specified names.
    DescribeApplications -> Maybe [Text]
applicationNames :: Prelude.Maybe [Prelude.Text]
  }
  deriving (DescribeApplications -> DescribeApplications -> Bool
(DescribeApplications -> DescribeApplications -> Bool)
-> (DescribeApplications -> DescribeApplications -> Bool)
-> Eq DescribeApplications
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeApplications -> DescribeApplications -> Bool
$c/= :: DescribeApplications -> DescribeApplications -> Bool
== :: DescribeApplications -> DescribeApplications -> Bool
$c== :: DescribeApplications -> DescribeApplications -> Bool
Prelude.Eq, ReadPrec [DescribeApplications]
ReadPrec DescribeApplications
Int -> ReadS DescribeApplications
ReadS [DescribeApplications]
(Int -> ReadS DescribeApplications)
-> ReadS [DescribeApplications]
-> ReadPrec DescribeApplications
-> ReadPrec [DescribeApplications]
-> Read DescribeApplications
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeApplications]
$creadListPrec :: ReadPrec [DescribeApplications]
readPrec :: ReadPrec DescribeApplications
$creadPrec :: ReadPrec DescribeApplications
readList :: ReadS [DescribeApplications]
$creadList :: ReadS [DescribeApplications]
readsPrec :: Int -> ReadS DescribeApplications
$creadsPrec :: Int -> ReadS DescribeApplications
Prelude.Read, Int -> DescribeApplications -> ShowS
[DescribeApplications] -> ShowS
DescribeApplications -> String
(Int -> DescribeApplications -> ShowS)
-> (DescribeApplications -> String)
-> ([DescribeApplications] -> ShowS)
-> Show DescribeApplications
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeApplications] -> ShowS
$cshowList :: [DescribeApplications] -> ShowS
show :: DescribeApplications -> String
$cshow :: DescribeApplications -> String
showsPrec :: Int -> DescribeApplications -> ShowS
$cshowsPrec :: Int -> DescribeApplications -> ShowS
Prelude.Show, (forall x. DescribeApplications -> Rep DescribeApplications x)
-> (forall x. Rep DescribeApplications x -> DescribeApplications)
-> Generic DescribeApplications
forall x. Rep DescribeApplications x -> DescribeApplications
forall x. DescribeApplications -> Rep DescribeApplications x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeApplications x -> DescribeApplications
$cfrom :: forall x. DescribeApplications -> Rep DescribeApplications x
Prelude.Generic)

-- |
-- Create a value of 'DescribeApplications' 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:
--
-- 'applicationNames', 'describeApplications_applicationNames' - If specified, AWS Elastic Beanstalk restricts the returned descriptions
-- to only include those with the specified names.
newDescribeApplications ::
  DescribeApplications
newDescribeApplications :: DescribeApplications
newDescribeApplications =
  DescribeApplications' :: Maybe [Text] -> DescribeApplications
DescribeApplications'
    { $sel:applicationNames:DescribeApplications' :: Maybe [Text]
applicationNames =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | If specified, AWS Elastic Beanstalk restricts the returned descriptions
-- to only include those with the specified names.
describeApplications_applicationNames :: Lens.Lens' DescribeApplications (Prelude.Maybe [Prelude.Text])
describeApplications_applicationNames :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeApplications -> f DescribeApplications
describeApplications_applicationNames = (DescribeApplications -> Maybe [Text])
-> (DescribeApplications -> Maybe [Text] -> DescribeApplications)
-> Lens
     DescribeApplications
     DescribeApplications
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeApplications' {Maybe [Text]
applicationNames :: Maybe [Text]
$sel:applicationNames:DescribeApplications' :: DescribeApplications -> Maybe [Text]
applicationNames} -> Maybe [Text]
applicationNames) (\s :: DescribeApplications
s@DescribeApplications' {} Maybe [Text]
a -> DescribeApplications
s {$sel:applicationNames:DescribeApplications' :: Maybe [Text]
applicationNames = Maybe [Text]
a} :: DescribeApplications) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeApplications -> f DescribeApplications)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeApplications
-> f DescribeApplications
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

instance Core.AWSRequest DescribeApplications where
  type
    AWSResponse DescribeApplications =
      DescribeApplicationsResponse
  request :: DescribeApplications -> Request DescribeApplications
request = Service -> DescribeApplications -> Request DescribeApplications
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeApplications
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeApplications)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DescribeApplications))
-> Logger
-> Service
-> Proxy DescribeApplications
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeApplications)))
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
"DescribeApplicationsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [ApplicationDescription]
-> Int -> DescribeApplicationsResponse
DescribeApplicationsResponse'
            (Maybe [ApplicationDescription]
 -> Int -> DescribeApplicationsResponse)
-> Either String (Maybe [ApplicationDescription])
-> Either String (Int -> DescribeApplicationsResponse)
forall (f :: * -> *) a b. Functor 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
"Applications" 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 [ApplicationDescription]))
-> Either String (Maybe [ApplicationDescription])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [ApplicationDescription])
-> [Node] -> Either String (Maybe [ApplicationDescription])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [ApplicationDescription]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either String (Int -> DescribeApplicationsResponse)
-> Either String Int -> Either String DescribeApplicationsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeApplications

instance Prelude.NFData DescribeApplications

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

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

instance Core.ToQuery DescribeApplications where
  toQuery :: DescribeApplications -> QueryString
toQuery DescribeApplications' {Maybe [Text]
applicationNames :: Maybe [Text]
$sel:applicationNames:DescribeApplications' :: DescribeApplications -> 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
"DescribeApplications" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"ApplicationNames"
          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]
applicationNames
            )
      ]

-- | Result message containing a list of application descriptions.
--
-- /See:/ 'newDescribeApplicationsResponse' smart constructor.
data DescribeApplicationsResponse = DescribeApplicationsResponse'
  { -- | This parameter contains a list of ApplicationDescription.
    DescribeApplicationsResponse -> Maybe [ApplicationDescription]
applications :: Prelude.Maybe [ApplicationDescription],
    -- | The response's http status code.
    DescribeApplicationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeApplicationsResponse
-> DescribeApplicationsResponse -> Bool
(DescribeApplicationsResponse
 -> DescribeApplicationsResponse -> Bool)
-> (DescribeApplicationsResponse
    -> DescribeApplicationsResponse -> Bool)
-> Eq DescribeApplicationsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeApplicationsResponse
-> DescribeApplicationsResponse -> Bool
$c/= :: DescribeApplicationsResponse
-> DescribeApplicationsResponse -> Bool
== :: DescribeApplicationsResponse
-> DescribeApplicationsResponse -> Bool
$c== :: DescribeApplicationsResponse
-> DescribeApplicationsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeApplicationsResponse]
ReadPrec DescribeApplicationsResponse
Int -> ReadS DescribeApplicationsResponse
ReadS [DescribeApplicationsResponse]
(Int -> ReadS DescribeApplicationsResponse)
-> ReadS [DescribeApplicationsResponse]
-> ReadPrec DescribeApplicationsResponse
-> ReadPrec [DescribeApplicationsResponse]
-> Read DescribeApplicationsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeApplicationsResponse]
$creadListPrec :: ReadPrec [DescribeApplicationsResponse]
readPrec :: ReadPrec DescribeApplicationsResponse
$creadPrec :: ReadPrec DescribeApplicationsResponse
readList :: ReadS [DescribeApplicationsResponse]
$creadList :: ReadS [DescribeApplicationsResponse]
readsPrec :: Int -> ReadS DescribeApplicationsResponse
$creadsPrec :: Int -> ReadS DescribeApplicationsResponse
Prelude.Read, Int -> DescribeApplicationsResponse -> ShowS
[DescribeApplicationsResponse] -> ShowS
DescribeApplicationsResponse -> String
(Int -> DescribeApplicationsResponse -> ShowS)
-> (DescribeApplicationsResponse -> String)
-> ([DescribeApplicationsResponse] -> ShowS)
-> Show DescribeApplicationsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeApplicationsResponse] -> ShowS
$cshowList :: [DescribeApplicationsResponse] -> ShowS
show :: DescribeApplicationsResponse -> String
$cshow :: DescribeApplicationsResponse -> String
showsPrec :: Int -> DescribeApplicationsResponse -> ShowS
$cshowsPrec :: Int -> DescribeApplicationsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeApplicationsResponse -> Rep DescribeApplicationsResponse x)
-> (forall x.
    Rep DescribeApplicationsResponse x -> DescribeApplicationsResponse)
-> Generic DescribeApplicationsResponse
forall x.
Rep DescribeApplicationsResponse x -> DescribeApplicationsResponse
forall x.
DescribeApplicationsResponse -> Rep DescribeApplicationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeApplicationsResponse x -> DescribeApplicationsResponse
$cfrom :: forall x.
DescribeApplicationsResponse -> Rep DescribeApplicationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeApplicationsResponse' 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:
--
-- 'applications', 'describeApplicationsResponse_applications' - This parameter contains a list of ApplicationDescription.
--
-- 'httpStatus', 'describeApplicationsResponse_httpStatus' - The response's http status code.
newDescribeApplicationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeApplicationsResponse
newDescribeApplicationsResponse :: Int -> DescribeApplicationsResponse
newDescribeApplicationsResponse Int
pHttpStatus_ =
  DescribeApplicationsResponse' :: Maybe [ApplicationDescription]
-> Int -> DescribeApplicationsResponse
DescribeApplicationsResponse'
    { $sel:applications:DescribeApplicationsResponse' :: Maybe [ApplicationDescription]
applications =
        Maybe [ApplicationDescription]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeApplicationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | This parameter contains a list of ApplicationDescription.
describeApplicationsResponse_applications :: Lens.Lens' DescribeApplicationsResponse (Prelude.Maybe [ApplicationDescription])
describeApplicationsResponse_applications :: (Maybe [ApplicationDescription]
 -> f (Maybe [ApplicationDescription]))
-> DescribeApplicationsResponse -> f DescribeApplicationsResponse
describeApplicationsResponse_applications = (DescribeApplicationsResponse -> Maybe [ApplicationDescription])
-> (DescribeApplicationsResponse
    -> Maybe [ApplicationDescription] -> DescribeApplicationsResponse)
-> Lens
     DescribeApplicationsResponse
     DescribeApplicationsResponse
     (Maybe [ApplicationDescription])
     (Maybe [ApplicationDescription])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeApplicationsResponse' {Maybe [ApplicationDescription]
applications :: Maybe [ApplicationDescription]
$sel:applications:DescribeApplicationsResponse' :: DescribeApplicationsResponse -> Maybe [ApplicationDescription]
applications} -> Maybe [ApplicationDescription]
applications) (\s :: DescribeApplicationsResponse
s@DescribeApplicationsResponse' {} Maybe [ApplicationDescription]
a -> DescribeApplicationsResponse
s {$sel:applications:DescribeApplicationsResponse' :: Maybe [ApplicationDescription]
applications = Maybe [ApplicationDescription]
a} :: DescribeApplicationsResponse) ((Maybe [ApplicationDescription]
  -> f (Maybe [ApplicationDescription]))
 -> DescribeApplicationsResponse -> f DescribeApplicationsResponse)
-> ((Maybe [ApplicationDescription]
     -> f (Maybe [ApplicationDescription]))
    -> Maybe [ApplicationDescription]
    -> f (Maybe [ApplicationDescription]))
-> (Maybe [ApplicationDescription]
    -> f (Maybe [ApplicationDescription]))
-> DescribeApplicationsResponse
-> f DescribeApplicationsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ApplicationDescription]
  [ApplicationDescription]
  [ApplicationDescription]
  [ApplicationDescription]
-> Iso
     (Maybe [ApplicationDescription])
     (Maybe [ApplicationDescription])
     (Maybe [ApplicationDescription])
     (Maybe [ApplicationDescription])
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
  [ApplicationDescription]
  [ApplicationDescription]
  [ApplicationDescription]
  [ApplicationDescription]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
describeApplicationsResponse_httpStatus :: Lens.Lens' DescribeApplicationsResponse Prelude.Int
describeApplicationsResponse_httpStatus :: (Int -> f Int)
-> DescribeApplicationsResponse -> f DescribeApplicationsResponse
describeApplicationsResponse_httpStatus = (DescribeApplicationsResponse -> Int)
-> (DescribeApplicationsResponse
    -> Int -> DescribeApplicationsResponse)
-> Lens
     DescribeApplicationsResponse DescribeApplicationsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeApplicationsResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeApplicationsResponse' :: DescribeApplicationsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeApplicationsResponse
s@DescribeApplicationsResponse' {} Int
a -> DescribeApplicationsResponse
s {$sel:httpStatus:DescribeApplicationsResponse' :: Int
httpStatus = Int
a} :: DescribeApplicationsResponse)

instance Prelude.NFData DescribeApplicationsResponse