{-# 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.Chime.ListAppInstances
-- 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)
--
-- Lists all Amazon Chime @AppInstance@s created under a single AWS
-- account.
module Amazonka.Chime.ListAppInstances
  ( -- * Creating a Request
    ListAppInstances (..),
    newListAppInstances,

    -- * Request Lenses
    listAppInstances_nextToken,
    listAppInstances_maxResults,

    -- * Destructuring the Response
    ListAppInstancesResponse (..),
    newListAppInstancesResponse,

    -- * Response Lenses
    listAppInstancesResponse_appInstances,
    listAppInstancesResponse_nextToken,
    listAppInstancesResponse_httpStatus,
  )
where

import Amazonka.Chime.Types
import qualified Amazonka.Core as Core
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:/ 'newListAppInstances' smart constructor.
data ListAppInstances = ListAppInstances'
  { -- | The token passed by previous API requests until you reach the maximum
    -- number of @AppInstance@s.
    ListAppInstances -> Maybe (Sensitive Text)
nextToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The maximum number of @AppInstance@s that you want to return.
    ListAppInstances -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListAppInstances -> ListAppInstances -> Bool
(ListAppInstances -> ListAppInstances -> Bool)
-> (ListAppInstances -> ListAppInstances -> Bool)
-> Eq ListAppInstances
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAppInstances -> ListAppInstances -> Bool
$c/= :: ListAppInstances -> ListAppInstances -> Bool
== :: ListAppInstances -> ListAppInstances -> Bool
$c== :: ListAppInstances -> ListAppInstances -> Bool
Prelude.Eq, Int -> ListAppInstances -> ShowS
[ListAppInstances] -> ShowS
ListAppInstances -> String
(Int -> ListAppInstances -> ShowS)
-> (ListAppInstances -> String)
-> ([ListAppInstances] -> ShowS)
-> Show ListAppInstances
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAppInstances] -> ShowS
$cshowList :: [ListAppInstances] -> ShowS
show :: ListAppInstances -> String
$cshow :: ListAppInstances -> String
showsPrec :: Int -> ListAppInstances -> ShowS
$cshowsPrec :: Int -> ListAppInstances -> ShowS
Prelude.Show, (forall x. ListAppInstances -> Rep ListAppInstances x)
-> (forall x. Rep ListAppInstances x -> ListAppInstances)
-> Generic ListAppInstances
forall x. Rep ListAppInstances x -> ListAppInstances
forall x. ListAppInstances -> Rep ListAppInstances x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAppInstances x -> ListAppInstances
$cfrom :: forall x. ListAppInstances -> Rep ListAppInstances x
Prelude.Generic)

-- |
-- Create a value of 'ListAppInstances' 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', 'listAppInstances_nextToken' - The token passed by previous API requests until you reach the maximum
-- number of @AppInstance@s.
--
-- 'maxResults', 'listAppInstances_maxResults' - The maximum number of @AppInstance@s that you want to return.
newListAppInstances ::
  ListAppInstances
newListAppInstances :: ListAppInstances
newListAppInstances =
  ListAppInstances' :: Maybe (Sensitive Text) -> Maybe Natural -> ListAppInstances
ListAppInstances'
    { $sel:nextToken:ListAppInstances' :: Maybe (Sensitive Text)
nextToken = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListAppInstances' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The token passed by previous API requests until you reach the maximum
-- number of @AppInstance@s.
listAppInstances_nextToken :: Lens.Lens' ListAppInstances (Prelude.Maybe Prelude.Text)
listAppInstances_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAppInstances -> f ListAppInstances
listAppInstances_nextToken = (ListAppInstances -> Maybe (Sensitive Text))
-> (ListAppInstances -> Maybe (Sensitive Text) -> ListAppInstances)
-> Lens
     ListAppInstances
     ListAppInstances
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAppInstances' {Maybe (Sensitive Text)
nextToken :: Maybe (Sensitive Text)
$sel:nextToken:ListAppInstances' :: ListAppInstances -> Maybe (Sensitive Text)
nextToken} -> Maybe (Sensitive Text)
nextToken) (\s :: ListAppInstances
s@ListAppInstances' {} Maybe (Sensitive Text)
a -> ListAppInstances
s {$sel:nextToken:ListAppInstances' :: Maybe (Sensitive Text)
nextToken = Maybe (Sensitive Text)
a} :: ListAppInstances) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> ListAppInstances -> f ListAppInstances)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> ListAppInstances
-> f ListAppInstances
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The maximum number of @AppInstance@s that you want to return.
listAppInstances_maxResults :: Lens.Lens' ListAppInstances (Prelude.Maybe Prelude.Natural)
listAppInstances_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListAppInstances -> f ListAppInstances
listAppInstances_maxResults = (ListAppInstances -> Maybe Natural)
-> (ListAppInstances -> Maybe Natural -> ListAppInstances)
-> Lens
     ListAppInstances ListAppInstances (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAppInstances' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListAppInstances' :: ListAppInstances -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListAppInstances
s@ListAppInstances' {} Maybe Natural
a -> ListAppInstances
s {$sel:maxResults:ListAppInstances' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListAppInstances)

instance Core.AWSRequest ListAppInstances where
  type
    AWSResponse ListAppInstances =
      ListAppInstancesResponse
  request :: ListAppInstances -> Request ListAppInstances
request = Service -> ListAppInstances -> Request ListAppInstances
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListAppInstances
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListAppInstances)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListAppInstances))
-> Logger
-> Service
-> Proxy ListAppInstances
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListAppInstances)))
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 ->
          Maybe [AppInstanceSummary]
-> Maybe (Sensitive Text) -> Int -> ListAppInstancesResponse
ListAppInstancesResponse'
            (Maybe [AppInstanceSummary]
 -> Maybe (Sensitive Text) -> Int -> ListAppInstancesResponse)
-> Either String (Maybe [AppInstanceSummary])
-> Either
     String (Maybe (Sensitive Text) -> Int -> ListAppInstancesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Either String (Maybe (Maybe [AppInstanceSummary]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AppInstances" Either String (Maybe (Maybe [AppInstanceSummary]))
-> Maybe [AppInstanceSummary]
-> Either String (Maybe [AppInstanceSummary])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [AppInstanceSummary]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String (Maybe (Sensitive Text) -> Int -> ListAppInstancesResponse)
-> Either String (Maybe (Sensitive Text))
-> Either String (Int -> ListAppInstancesResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Int -> ListAppInstancesResponse)
-> Either String Int -> Either String ListAppInstancesResponse
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 ListAppInstances

instance Prelude.NFData ListAppInstances

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

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

instance Core.ToQuery ListAppInstances where
  toQuery :: ListAppInstances -> QueryString
toQuery ListAppInstances' {Maybe Natural
Maybe (Sensitive Text)
maxResults :: Maybe Natural
nextToken :: Maybe (Sensitive Text)
$sel:maxResults:ListAppInstances' :: ListAppInstances -> Maybe Natural
$sel:nextToken:ListAppInstances' :: ListAppInstances -> Maybe (Sensitive Text)
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"next-token" ByteString -> Maybe (Sensitive Text) -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe (Sensitive Text)
nextToken,
        ByteString
"max-results" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults
      ]

-- | /See:/ 'newListAppInstancesResponse' smart constructor.
data ListAppInstancesResponse = ListAppInstancesResponse'
  { -- | The information for each @AppInstance@.
    ListAppInstancesResponse -> Maybe [AppInstanceSummary]
appInstances :: Prelude.Maybe [AppInstanceSummary],
    -- | The token passed by previous API requests until the maximum number of
    -- @AppInstance@s is reached.
    ListAppInstancesResponse -> Maybe (Sensitive Text)
nextToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The response's http status code.
    ListAppInstancesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAppInstancesResponse -> ListAppInstancesResponse -> Bool
(ListAppInstancesResponse -> ListAppInstancesResponse -> Bool)
-> (ListAppInstancesResponse -> ListAppInstancesResponse -> Bool)
-> Eq ListAppInstancesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAppInstancesResponse -> ListAppInstancesResponse -> Bool
$c/= :: ListAppInstancesResponse -> ListAppInstancesResponse -> Bool
== :: ListAppInstancesResponse -> ListAppInstancesResponse -> Bool
$c== :: ListAppInstancesResponse -> ListAppInstancesResponse -> Bool
Prelude.Eq, Int -> ListAppInstancesResponse -> ShowS
[ListAppInstancesResponse] -> ShowS
ListAppInstancesResponse -> String
(Int -> ListAppInstancesResponse -> ShowS)
-> (ListAppInstancesResponse -> String)
-> ([ListAppInstancesResponse] -> ShowS)
-> Show ListAppInstancesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAppInstancesResponse] -> ShowS
$cshowList :: [ListAppInstancesResponse] -> ShowS
show :: ListAppInstancesResponse -> String
$cshow :: ListAppInstancesResponse -> String
showsPrec :: Int -> ListAppInstancesResponse -> ShowS
$cshowsPrec :: Int -> ListAppInstancesResponse -> ShowS
Prelude.Show, (forall x.
 ListAppInstancesResponse -> Rep ListAppInstancesResponse x)
-> (forall x.
    Rep ListAppInstancesResponse x -> ListAppInstancesResponse)
-> Generic ListAppInstancesResponse
forall x.
Rep ListAppInstancesResponse x -> ListAppInstancesResponse
forall x.
ListAppInstancesResponse -> Rep ListAppInstancesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListAppInstancesResponse x -> ListAppInstancesResponse
$cfrom :: forall x.
ListAppInstancesResponse -> Rep ListAppInstancesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAppInstancesResponse' 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:
--
-- 'appInstances', 'listAppInstancesResponse_appInstances' - The information for each @AppInstance@.
--
-- 'nextToken', 'listAppInstancesResponse_nextToken' - The token passed by previous API requests until the maximum number of
-- @AppInstance@s is reached.
--
-- 'httpStatus', 'listAppInstancesResponse_httpStatus' - The response's http status code.
newListAppInstancesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAppInstancesResponse
newListAppInstancesResponse :: Int -> ListAppInstancesResponse
newListAppInstancesResponse Int
pHttpStatus_ =
  ListAppInstancesResponse' :: Maybe [AppInstanceSummary]
-> Maybe (Sensitive Text) -> Int -> ListAppInstancesResponse
ListAppInstancesResponse'
    { $sel:appInstances:ListAppInstancesResponse' :: Maybe [AppInstanceSummary]
appInstances =
        Maybe [AppInstanceSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAppInstancesResponse' :: Maybe (Sensitive Text)
nextToken = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAppInstancesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The information for each @AppInstance@.
listAppInstancesResponse_appInstances :: Lens.Lens' ListAppInstancesResponse (Prelude.Maybe [AppInstanceSummary])
listAppInstancesResponse_appInstances :: (Maybe [AppInstanceSummary] -> f (Maybe [AppInstanceSummary]))
-> ListAppInstancesResponse -> f ListAppInstancesResponse
listAppInstancesResponse_appInstances = (ListAppInstancesResponse -> Maybe [AppInstanceSummary])
-> (ListAppInstancesResponse
    -> Maybe [AppInstanceSummary] -> ListAppInstancesResponse)
-> Lens
     ListAppInstancesResponse
     ListAppInstancesResponse
     (Maybe [AppInstanceSummary])
     (Maybe [AppInstanceSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAppInstancesResponse' {Maybe [AppInstanceSummary]
appInstances :: Maybe [AppInstanceSummary]
$sel:appInstances:ListAppInstancesResponse' :: ListAppInstancesResponse -> Maybe [AppInstanceSummary]
appInstances} -> Maybe [AppInstanceSummary]
appInstances) (\s :: ListAppInstancesResponse
s@ListAppInstancesResponse' {} Maybe [AppInstanceSummary]
a -> ListAppInstancesResponse
s {$sel:appInstances:ListAppInstancesResponse' :: Maybe [AppInstanceSummary]
appInstances = Maybe [AppInstanceSummary]
a} :: ListAppInstancesResponse) ((Maybe [AppInstanceSummary] -> f (Maybe [AppInstanceSummary]))
 -> ListAppInstancesResponse -> f ListAppInstancesResponse)
-> ((Maybe [AppInstanceSummary] -> f (Maybe [AppInstanceSummary]))
    -> Maybe [AppInstanceSummary] -> f (Maybe [AppInstanceSummary]))
-> (Maybe [AppInstanceSummary] -> f (Maybe [AppInstanceSummary]))
-> ListAppInstancesResponse
-> f ListAppInstancesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AppInstanceSummary]
  [AppInstanceSummary]
  [AppInstanceSummary]
  [AppInstanceSummary]
-> Iso
     (Maybe [AppInstanceSummary])
     (Maybe [AppInstanceSummary])
     (Maybe [AppInstanceSummary])
     (Maybe [AppInstanceSummary])
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
  [AppInstanceSummary]
  [AppInstanceSummary]
  [AppInstanceSummary]
  [AppInstanceSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token passed by previous API requests until the maximum number of
-- @AppInstance@s is reached.
listAppInstancesResponse_nextToken :: Lens.Lens' ListAppInstancesResponse (Prelude.Maybe Prelude.Text)
listAppInstancesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListAppInstancesResponse -> f ListAppInstancesResponse
listAppInstancesResponse_nextToken = (ListAppInstancesResponse -> Maybe (Sensitive Text))
-> (ListAppInstancesResponse
    -> Maybe (Sensitive Text) -> ListAppInstancesResponse)
-> Lens
     ListAppInstancesResponse
     ListAppInstancesResponse
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAppInstancesResponse' {Maybe (Sensitive Text)
nextToken :: Maybe (Sensitive Text)
$sel:nextToken:ListAppInstancesResponse' :: ListAppInstancesResponse -> Maybe (Sensitive Text)
nextToken} -> Maybe (Sensitive Text)
nextToken) (\s :: ListAppInstancesResponse
s@ListAppInstancesResponse' {} Maybe (Sensitive Text)
a -> ListAppInstancesResponse
s {$sel:nextToken:ListAppInstancesResponse' :: Maybe (Sensitive Text)
nextToken = Maybe (Sensitive Text)
a} :: ListAppInstancesResponse) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> ListAppInstancesResponse -> f ListAppInstancesResponse)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> ListAppInstancesResponse
-> f ListAppInstancesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

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

instance Prelude.NFData ListAppInstancesResponse