{-# 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.AppStream.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)
--
-- Retrieves a list that describes one or more applications.
module Amazonka.AppStream.DescribeApplications
  ( -- * Creating a Request
    DescribeApplications (..),
    newDescribeApplications,

    -- * Request Lenses
    describeApplications_arns,
    describeApplications_maxResults,
    describeApplications_nextToken,

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

    -- * Response Lenses
    describeApplicationsResponse_applications,
    describeApplicationsResponse_nextToken,
    describeApplicationsResponse_httpStatus,
  )
where

import Amazonka.AppStream.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeApplications' smart constructor.
data DescribeApplications = DescribeApplications'
  { -- | The ARNs for the applications.
    DescribeApplications -> Maybe [Text]
arns :: Prelude.Maybe [Prelude.Text],
    -- | The maximum size of each page of results.
    DescribeApplications -> Maybe Int
maxResults :: Prelude.Maybe Prelude.Int,
    -- | The pagination token used to retrieve the next page of results for this
    -- operation.
    DescribeApplications -> Maybe Text
nextToken :: 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:
--
-- 'arns', 'describeApplications_arns' - The ARNs for the applications.
--
-- 'maxResults', 'describeApplications_maxResults' - The maximum size of each page of results.
--
-- 'nextToken', 'describeApplications_nextToken' - The pagination token used to retrieve the next page of results for this
-- operation.
newDescribeApplications ::
  DescribeApplications
newDescribeApplications :: DescribeApplications
newDescribeApplications =
  DescribeApplications'
    { $sel:arns:DescribeApplications' :: Maybe [Text]
arns = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:DescribeApplications' :: Maybe Int
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeApplications' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The ARNs for the applications.
describeApplications_arns :: Lens.Lens' DescribeApplications (Prelude.Maybe [Prelude.Text])
describeApplications_arns :: Lens' DescribeApplications (Maybe [Text])
describeApplications_arns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeApplications' {Maybe [Text]
arns :: Maybe [Text]
$sel:arns:DescribeApplications' :: DescribeApplications -> Maybe [Text]
arns} -> Maybe [Text]
arns) (\s :: DescribeApplications
s@DescribeApplications' {} Maybe [Text]
a -> DescribeApplications
s {$sel:arns:DescribeApplications' :: Maybe [Text]
arns = 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

-- | The maximum size of each page of results.
describeApplications_maxResults :: Lens.Lens' DescribeApplications (Prelude.Maybe Prelude.Int)
describeApplications_maxResults :: Lens' DescribeApplications (Maybe Int)
describeApplications_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeApplications' {Maybe Int
maxResults :: Maybe Int
$sel:maxResults:DescribeApplications' :: DescribeApplications -> Maybe Int
maxResults} -> Maybe Int
maxResults) (\s :: DescribeApplications
s@DescribeApplications' {} Maybe Int
a -> DescribeApplications
s {$sel:maxResults:DescribeApplications' :: Maybe Int
maxResults = Maybe Int
a} :: DescribeApplications)

-- | The pagination token used to retrieve the next page of results for this
-- operation.
describeApplications_nextToken :: Lens.Lens' DescribeApplications (Prelude.Maybe Prelude.Text)
describeApplications_nextToken :: Lens' DescribeApplications (Maybe Text)
describeApplications_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeApplications' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeApplications' :: DescribeApplications -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeApplications
s@DescribeApplications' {} Maybe Text
a -> DescribeApplications
s {$sel:nextToken:DescribeApplications' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeApplications)

instance Core.AWSRequest DescribeApplications where
  type
    AWSResponse DescribeApplications =
      DescribeApplicationsResponse
  request :: (Service -> Service)
-> DescribeApplications -> Request DescribeApplications
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (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 =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Application]
-> Maybe Text -> Int -> DescribeApplicationsResponse
DescribeApplicationsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Applications" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NextToken")
            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 Int
Maybe [Text]
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Int
arns :: Maybe [Text]
$sel:nextToken:DescribeApplications' :: DescribeApplications -> Maybe Text
$sel:maxResults:DescribeApplications' :: DescribeApplications -> Maybe Int
$sel:arns:DescribeApplications' :: DescribeApplications -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
arns
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData DescribeApplications where
  rnf :: DescribeApplications -> ()
rnf DescribeApplications' {Maybe Int
Maybe [Text]
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Int
arns :: Maybe [Text]
$sel:nextToken:DescribeApplications' :: DescribeApplications -> Maybe Text
$sel:maxResults:DescribeApplications' :: DescribeApplications -> Maybe Int
$sel:arns:DescribeApplications' :: DescribeApplications -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
arns
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

instance Data.ToHeaders DescribeApplications where
  toHeaders :: DescribeApplications -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"PhotonAdminProxyService.DescribeApplications" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DescribeApplications where
  toJSON :: DescribeApplications -> Value
toJSON DescribeApplications' {Maybe Int
Maybe [Text]
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Int
arns :: Maybe [Text]
$sel:nextToken:DescribeApplications' :: DescribeApplications -> Maybe Text
$sel:maxResults:DescribeApplications' :: DescribeApplications -> Maybe Int
$sel:arns:DescribeApplications' :: DescribeApplications -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Arns" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
arns,
            (Key
"MaxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maxResults,
            (Key
"NextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken
          ]
      )

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 = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newDescribeApplicationsResponse' smart constructor.
data DescribeApplicationsResponse = DescribeApplicationsResponse'
  { -- | The applications in the list.
    DescribeApplicationsResponse -> Maybe [Application]
applications :: Prelude.Maybe [Application],
    -- | The pagination token used to retrieve the next page of results for this
    -- operation.
    DescribeApplicationsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | 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' - The applications in the list.
--
-- 'nextToken', 'describeApplicationsResponse_nextToken' - The pagination token used to retrieve the next page of results for this
-- operation.
--
-- '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 [Application]
applications =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:DescribeApplicationsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeApplicationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The applications in the list.
describeApplicationsResponse_applications :: Lens.Lens' DescribeApplicationsResponse (Prelude.Maybe [Application])
describeApplicationsResponse_applications :: Lens' DescribeApplicationsResponse (Maybe [Application])
describeApplicationsResponse_applications = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeApplicationsResponse' {Maybe [Application]
applications :: Maybe [Application]
$sel:applications:DescribeApplicationsResponse' :: DescribeApplicationsResponse -> Maybe [Application]
applications} -> Maybe [Application]
applications) (\s :: DescribeApplicationsResponse
s@DescribeApplicationsResponse' {} Maybe [Application]
a -> DescribeApplicationsResponse
s {$sel:applications:DescribeApplicationsResponse' :: Maybe [Application]
applications = Maybe [Application]
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 pagination token used to retrieve the next page of results for this
-- operation.
describeApplicationsResponse_nextToken :: Lens.Lens' DescribeApplicationsResponse (Prelude.Maybe Prelude.Text)
describeApplicationsResponse_nextToken :: Lens' DescribeApplicationsResponse (Maybe Text)
describeApplicationsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeApplicationsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:DescribeApplicationsResponse' :: DescribeApplicationsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: DescribeApplicationsResponse
s@DescribeApplicationsResponse' {} Maybe Text
a -> DescribeApplicationsResponse
s {$sel:nextToken:DescribeApplicationsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: DescribeApplicationsResponse)

-- | 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 [Application]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
applications :: Maybe [Application]
$sel:httpStatus:DescribeApplicationsResponse' :: DescribeApplicationsResponse -> Int
$sel:nextToken:DescribeApplicationsResponse' :: DescribeApplicationsResponse -> Maybe Text
$sel:applications:DescribeApplicationsResponse' :: DescribeApplicationsResponse -> Maybe [Application]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Application]
applications
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus