{-# 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.KinesisAnalytics.ListApplications
-- 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)
--
-- This documentation is for version 1 of the Amazon Kinesis Data Analytics
-- API, which only supports SQL applications. Version 2 of the API supports
-- SQL and Java applications. For more information about version 2, see
-- </kinesisanalytics/latest/apiv2/Welcome.html Amazon Kinesis Data Analytics API V2 Documentation>.
--
-- Returns a list of Amazon Kinesis Analytics applications in your account.
-- For each application, the response includes the application name, Amazon
-- Resource Name (ARN), and status. If the response returns the
-- @HasMoreApplications@ value as true, you can send another request by
-- adding the @ExclusiveStartApplicationName@ in the request body, and set
-- the value of this to the last application name from the previous
-- response.
--
-- If you want detailed information about a specific application, use
-- <https://docs.aws.amazon.com/kinesisanalytics/latest/dev/API_DescribeApplication.html DescribeApplication>.
--
-- This operation requires permissions to perform the
-- @kinesisanalytics:ListApplications@ action.
module Amazonka.KinesisAnalytics.ListApplications
  ( -- * Creating a Request
    ListApplications (..),
    newListApplications,

    -- * Request Lenses
    listApplications_limit,
    listApplications_exclusiveStartApplicationName,

    -- * Destructuring the Response
    ListApplicationsResponse (..),
    newListApplicationsResponse,

    -- * Response Lenses
    listApplicationsResponse_httpStatus,
    listApplicationsResponse_applicationSummaries,
    listApplicationsResponse_hasMoreApplications,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.KinesisAnalytics.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

-- |
--
-- /See:/ 'newListApplications' smart constructor.
data ListApplications = ListApplications'
  { -- | Maximum number of applications to list.
    ListApplications -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | Name of the application to start the list with. When using pagination to
    -- retrieve the list, you don\'t need to specify this parameter in the
    -- first request. However, in subsequent requests, you add the last
    -- application name from the previous response to get the next page of
    -- applications.
    ListApplications -> Maybe Text
exclusiveStartApplicationName :: Prelude.Maybe Prelude.Text
  }
  deriving (ListApplications -> ListApplications -> Bool
(ListApplications -> ListApplications -> Bool)
-> (ListApplications -> ListApplications -> Bool)
-> Eq ListApplications
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListApplications -> ListApplications -> Bool
$c/= :: ListApplications -> ListApplications -> Bool
== :: ListApplications -> ListApplications -> Bool
$c== :: ListApplications -> ListApplications -> Bool
Prelude.Eq, ReadPrec [ListApplications]
ReadPrec ListApplications
Int -> ReadS ListApplications
ReadS [ListApplications]
(Int -> ReadS ListApplications)
-> ReadS [ListApplications]
-> ReadPrec ListApplications
-> ReadPrec [ListApplications]
-> Read ListApplications
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListApplications]
$creadListPrec :: ReadPrec [ListApplications]
readPrec :: ReadPrec ListApplications
$creadPrec :: ReadPrec ListApplications
readList :: ReadS [ListApplications]
$creadList :: ReadS [ListApplications]
readsPrec :: Int -> ReadS ListApplications
$creadsPrec :: Int -> ReadS ListApplications
Prelude.Read, Int -> ListApplications -> ShowS
[ListApplications] -> ShowS
ListApplications -> String
(Int -> ListApplications -> ShowS)
-> (ListApplications -> String)
-> ([ListApplications] -> ShowS)
-> Show ListApplications
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListApplications] -> ShowS
$cshowList :: [ListApplications] -> ShowS
show :: ListApplications -> String
$cshow :: ListApplications -> String
showsPrec :: Int -> ListApplications -> ShowS
$cshowsPrec :: Int -> ListApplications -> ShowS
Prelude.Show, (forall x. ListApplications -> Rep ListApplications x)
-> (forall x. Rep ListApplications x -> ListApplications)
-> Generic ListApplications
forall x. Rep ListApplications x -> ListApplications
forall x. ListApplications -> Rep ListApplications x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListApplications x -> ListApplications
$cfrom :: forall x. ListApplications -> Rep ListApplications x
Prelude.Generic)

-- |
-- Create a value of 'ListApplications' 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:
--
-- 'limit', 'listApplications_limit' - Maximum number of applications to list.
--
-- 'exclusiveStartApplicationName', 'listApplications_exclusiveStartApplicationName' - Name of the application to start the list with. When using pagination to
-- retrieve the list, you don\'t need to specify this parameter in the
-- first request. However, in subsequent requests, you add the last
-- application name from the previous response to get the next page of
-- applications.
newListApplications ::
  ListApplications
newListApplications :: ListApplications
newListApplications =
  ListApplications' :: Maybe Natural -> Maybe Text -> ListApplications
ListApplications'
    { $sel:limit:ListApplications' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:exclusiveStartApplicationName:ListApplications' :: Maybe Text
exclusiveStartApplicationName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Maximum number of applications to list.
listApplications_limit :: Lens.Lens' ListApplications (Prelude.Maybe Prelude.Natural)
listApplications_limit :: (Maybe Natural -> f (Maybe Natural))
-> ListApplications -> f ListApplications
listApplications_limit = (ListApplications -> Maybe Natural)
-> (ListApplications -> Maybe Natural -> ListApplications)
-> Lens
     ListApplications ListApplications (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListApplications' {Maybe Natural
limit :: Maybe Natural
$sel:limit:ListApplications' :: ListApplications -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: ListApplications
s@ListApplications' {} Maybe Natural
a -> ListApplications
s {$sel:limit:ListApplications' :: Maybe Natural
limit = Maybe Natural
a} :: ListApplications)

-- | Name of the application to start the list with. When using pagination to
-- retrieve the list, you don\'t need to specify this parameter in the
-- first request. However, in subsequent requests, you add the last
-- application name from the previous response to get the next page of
-- applications.
listApplications_exclusiveStartApplicationName :: Lens.Lens' ListApplications (Prelude.Maybe Prelude.Text)
listApplications_exclusiveStartApplicationName :: (Maybe Text -> f (Maybe Text))
-> ListApplications -> f ListApplications
listApplications_exclusiveStartApplicationName = (ListApplications -> Maybe Text)
-> (ListApplications -> Maybe Text -> ListApplications)
-> Lens ListApplications ListApplications (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListApplications' {Maybe Text
exclusiveStartApplicationName :: Maybe Text
$sel:exclusiveStartApplicationName:ListApplications' :: ListApplications -> Maybe Text
exclusiveStartApplicationName} -> Maybe Text
exclusiveStartApplicationName) (\s :: ListApplications
s@ListApplications' {} Maybe Text
a -> ListApplications
s {$sel:exclusiveStartApplicationName:ListApplications' :: Maybe Text
exclusiveStartApplicationName = Maybe Text
a} :: ListApplications)

instance Core.AWSRequest ListApplications where
  type
    AWSResponse ListApplications =
      ListApplicationsResponse
  request :: ListApplications -> Request ListApplications
request = Service -> ListApplications -> Request ListApplications
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListApplications
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListApplications)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListApplications))
-> Logger
-> Service
-> Proxy ListApplications
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListApplications)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> [ApplicationSummary] -> Bool -> ListApplicationsResponse
ListApplicationsResponse'
            (Int -> [ApplicationSummary] -> Bool -> ListApplicationsResponse)
-> Either String Int
-> Either
     String ([ApplicationSummary] -> Bool -> ListApplicationsResponse)
forall (f :: * -> *) a b. Functor 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))
            Either
  String ([ApplicationSummary] -> Bool -> ListApplicationsResponse)
-> Either String [ApplicationSummary]
-> Either String (Bool -> ListApplicationsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe [ApplicationSummary])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ApplicationSummaries"
                            Either String (Maybe [ApplicationSummary])
-> [ApplicationSummary] -> Either String [ApplicationSummary]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [ApplicationSummary]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Bool -> ListApplicationsResponse)
-> Either String Bool -> Either String ListApplicationsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Bool
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"HasMoreApplications")
      )

instance Prelude.Hashable ListApplications

instance Prelude.NFData ListApplications

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

instance Core.ToJSON ListApplications where
  toJSON :: ListApplications -> Value
toJSON ListApplications' {Maybe Natural
Maybe Text
exclusiveStartApplicationName :: Maybe Text
limit :: Maybe Natural
$sel:exclusiveStartApplicationName:ListApplications' :: ListApplications -> Maybe Text
$sel:limit:ListApplications' :: ListApplications -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Limit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
limit,
            (Text
"ExclusiveStartApplicationName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
exclusiveStartApplicationName
          ]
      )

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

instance Core.ToQuery ListApplications where
  toQuery :: ListApplications -> QueryString
toQuery = QueryString -> ListApplications -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- |
--
-- /See:/ 'newListApplicationsResponse' smart constructor.
data ListApplicationsResponse = ListApplicationsResponse'
  { -- | The response's http status code.
    ListApplicationsResponse -> Int
httpStatus :: Prelude.Int,
    -- | List of @ApplicationSummary@ objects.
    ListApplicationsResponse -> [ApplicationSummary]
applicationSummaries :: [ApplicationSummary],
    -- | Returns true if there are more applications to retrieve.
    ListApplicationsResponse -> Bool
hasMoreApplications :: Prelude.Bool
  }
  deriving (ListApplicationsResponse -> ListApplicationsResponse -> Bool
(ListApplicationsResponse -> ListApplicationsResponse -> Bool)
-> (ListApplicationsResponse -> ListApplicationsResponse -> Bool)
-> Eq ListApplicationsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListApplicationsResponse -> ListApplicationsResponse -> Bool
$c/= :: ListApplicationsResponse -> ListApplicationsResponse -> Bool
== :: ListApplicationsResponse -> ListApplicationsResponse -> Bool
$c== :: ListApplicationsResponse -> ListApplicationsResponse -> Bool
Prelude.Eq, ReadPrec [ListApplicationsResponse]
ReadPrec ListApplicationsResponse
Int -> ReadS ListApplicationsResponse
ReadS [ListApplicationsResponse]
(Int -> ReadS ListApplicationsResponse)
-> ReadS [ListApplicationsResponse]
-> ReadPrec ListApplicationsResponse
-> ReadPrec [ListApplicationsResponse]
-> Read ListApplicationsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListApplicationsResponse]
$creadListPrec :: ReadPrec [ListApplicationsResponse]
readPrec :: ReadPrec ListApplicationsResponse
$creadPrec :: ReadPrec ListApplicationsResponse
readList :: ReadS [ListApplicationsResponse]
$creadList :: ReadS [ListApplicationsResponse]
readsPrec :: Int -> ReadS ListApplicationsResponse
$creadsPrec :: Int -> ReadS ListApplicationsResponse
Prelude.Read, Int -> ListApplicationsResponse -> ShowS
[ListApplicationsResponse] -> ShowS
ListApplicationsResponse -> String
(Int -> ListApplicationsResponse -> ShowS)
-> (ListApplicationsResponse -> String)
-> ([ListApplicationsResponse] -> ShowS)
-> Show ListApplicationsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListApplicationsResponse] -> ShowS
$cshowList :: [ListApplicationsResponse] -> ShowS
show :: ListApplicationsResponse -> String
$cshow :: ListApplicationsResponse -> String
showsPrec :: Int -> ListApplicationsResponse -> ShowS
$cshowsPrec :: Int -> ListApplicationsResponse -> ShowS
Prelude.Show, (forall x.
 ListApplicationsResponse -> Rep ListApplicationsResponse x)
-> (forall x.
    Rep ListApplicationsResponse x -> ListApplicationsResponse)
-> Generic ListApplicationsResponse
forall x.
Rep ListApplicationsResponse x -> ListApplicationsResponse
forall x.
ListApplicationsResponse -> Rep ListApplicationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListApplicationsResponse x -> ListApplicationsResponse
$cfrom :: forall x.
ListApplicationsResponse -> Rep ListApplicationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListApplicationsResponse' 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:
--
-- 'httpStatus', 'listApplicationsResponse_httpStatus' - The response's http status code.
--
-- 'applicationSummaries', 'listApplicationsResponse_applicationSummaries' - List of @ApplicationSummary@ objects.
--
-- 'hasMoreApplications', 'listApplicationsResponse_hasMoreApplications' - Returns true if there are more applications to retrieve.
newListApplicationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'hasMoreApplications'
  Prelude.Bool ->
  ListApplicationsResponse
newListApplicationsResponse :: Int -> Bool -> ListApplicationsResponse
newListApplicationsResponse
  Int
pHttpStatus_
  Bool
pHasMoreApplications_ =
    ListApplicationsResponse' :: Int -> [ApplicationSummary] -> Bool -> ListApplicationsResponse
ListApplicationsResponse'
      { $sel:httpStatus:ListApplicationsResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:applicationSummaries:ListApplicationsResponse' :: [ApplicationSummary]
applicationSummaries = [ApplicationSummary]
forall a. Monoid a => a
Prelude.mempty,
        $sel:hasMoreApplications:ListApplicationsResponse' :: Bool
hasMoreApplications = Bool
pHasMoreApplications_
      }

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

-- | List of @ApplicationSummary@ objects.
listApplicationsResponse_applicationSummaries :: Lens.Lens' ListApplicationsResponse [ApplicationSummary]
listApplicationsResponse_applicationSummaries :: ([ApplicationSummary] -> f [ApplicationSummary])
-> ListApplicationsResponse -> f ListApplicationsResponse
listApplicationsResponse_applicationSummaries = (ListApplicationsResponse -> [ApplicationSummary])
-> (ListApplicationsResponse
    -> [ApplicationSummary] -> ListApplicationsResponse)
-> Lens
     ListApplicationsResponse
     ListApplicationsResponse
     [ApplicationSummary]
     [ApplicationSummary]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListApplicationsResponse' {[ApplicationSummary]
applicationSummaries :: [ApplicationSummary]
$sel:applicationSummaries:ListApplicationsResponse' :: ListApplicationsResponse -> [ApplicationSummary]
applicationSummaries} -> [ApplicationSummary]
applicationSummaries) (\s :: ListApplicationsResponse
s@ListApplicationsResponse' {} [ApplicationSummary]
a -> ListApplicationsResponse
s {$sel:applicationSummaries:ListApplicationsResponse' :: [ApplicationSummary]
applicationSummaries = [ApplicationSummary]
a} :: ListApplicationsResponse) (([ApplicationSummary] -> f [ApplicationSummary])
 -> ListApplicationsResponse -> f ListApplicationsResponse)
-> (([ApplicationSummary] -> f [ApplicationSummary])
    -> [ApplicationSummary] -> f [ApplicationSummary])
-> ([ApplicationSummary] -> f [ApplicationSummary])
-> ListApplicationsResponse
-> f ListApplicationsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ApplicationSummary] -> f [ApplicationSummary])
-> [ApplicationSummary] -> f [ApplicationSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Returns true if there are more applications to retrieve.
listApplicationsResponse_hasMoreApplications :: Lens.Lens' ListApplicationsResponse Prelude.Bool
listApplicationsResponse_hasMoreApplications :: (Bool -> f Bool)
-> ListApplicationsResponse -> f ListApplicationsResponse
listApplicationsResponse_hasMoreApplications = (ListApplicationsResponse -> Bool)
-> (ListApplicationsResponse -> Bool -> ListApplicationsResponse)
-> Lens ListApplicationsResponse ListApplicationsResponse Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListApplicationsResponse' {Bool
hasMoreApplications :: Bool
$sel:hasMoreApplications:ListApplicationsResponse' :: ListApplicationsResponse -> Bool
hasMoreApplications} -> Bool
hasMoreApplications) (\s :: ListApplicationsResponse
s@ListApplicationsResponse' {} Bool
a -> ListApplicationsResponse
s {$sel:hasMoreApplications:ListApplicationsResponse' :: Bool
hasMoreApplications = Bool
a} :: ListApplicationsResponse)

instance Prelude.NFData ListApplicationsResponse