{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 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 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
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]
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
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. 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'
    { $sel:applicationNames:DescribeApplications' :: Maybe [Text]
applicationNames =
        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 :: Lens' DescribeApplications (Maybe [Text])
describeApplications_applicationNames = 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) 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 DescribeApplications where
  type
    AWSResponse DescribeApplications =
      DescribeApplicationsResponse
  request :: (Service -> Service)
-> DescribeApplications -> Request DescribeApplications
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 DescribeApplications
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeApplications)))
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
"DescribeApplicationsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [ApplicationDescription]
-> Int -> DescribeApplicationsResponse
DescribeApplicationsResponse'
            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
"Applications"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

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

instance Prelude.NFData DescribeApplications where
  rnf :: DescribeApplications -> ()
rnf DescribeApplications' {Maybe [Text]
applicationNames :: Maybe [Text]
$sel:applicationNames:DescribeApplications' :: DescribeApplications -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
applicationNames

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

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

instance Data.ToQuery DescribeApplications where
  toQuery :: DescribeApplications -> QueryString
toQuery DescribeApplications' {Maybe [Text]
applicationNames :: Maybe [Text]
$sel:applicationNames:DescribeApplications' :: DescribeApplications -> Maybe [Text]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DescribeApplications" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"ApplicationNames"
          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]
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
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]
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
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.
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'
    { $sel:applications:DescribeApplicationsResponse' :: Maybe [ApplicationDescription]
applications =
        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 :: Lens' DescribeApplicationsResponse (Maybe [ApplicationDescription])
describeApplicationsResponse_applications = 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) 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

-- | The response's http status code.
describeApplicationsResponse_httpStatus :: Lens.Lens' DescribeApplicationsResponse Prelude.Int
describeApplicationsResponse_httpStatus :: Lens' DescribeApplicationsResponse Int
describeApplicationsResponse_httpStatus = 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 where
  rnf :: DescribeApplicationsResponse -> ()
rnf DescribeApplicationsResponse' {Int
Maybe [ApplicationDescription]
httpStatus :: Int
applications :: Maybe [ApplicationDescription]
$sel:httpStatus:DescribeApplicationsResponse' :: DescribeApplicationsResponse -> Int
$sel:applications:DescribeApplicationsResponse' :: DescribeApplicationsResponse -> Maybe [ApplicationDescription]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ApplicationDescription]
applications
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus