{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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_maxResults,
    listAppInstances_nextToken,

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

-- | The maximum number of @AppInstance@s that you want to return.
listAppInstances_maxResults :: Lens.Lens' ListAppInstances (Prelude.Maybe Prelude.Natural)
listAppInstances_maxResults :: Lens' ListAppInstances (Maybe Natural)
listAppInstances_maxResults = 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)

-- | 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 :: Lens' ListAppInstances (Maybe Text)
listAppInstances_nextToken = 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) 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 a. Iso' (Sensitive a) a
Data._Sensitive

instance Core.AWSRequest ListAppInstances where
  type
    AWSResponse ListAppInstances =
      ListAppInstancesResponse
  request :: (Service -> Service)
-> ListAppInstances -> Request ListAppInstances
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListAppInstances
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListAppInstances)))
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 [AppInstanceSummary]
-> Maybe (Sensitive Text) -> Int -> ListAppInstancesResponse
ListAppInstancesResponse'
            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
"AppInstances" 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 ListAppInstances where
  hashWithSalt :: Int -> ListAppInstances -> Int
hashWithSalt Int
_salt ListAppInstances' {Maybe Natural
Maybe (Sensitive Text)
nextToken :: Maybe (Sensitive Text)
maxResults :: Maybe Natural
$sel:nextToken:ListAppInstances' :: ListAppInstances -> Maybe (Sensitive Text)
$sel:maxResults:ListAppInstances' :: ListAppInstances -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
nextToken

instance Prelude.NFData ListAppInstances where
  rnf :: ListAppInstances -> ()
rnf ListAppInstances' {Maybe Natural
Maybe (Sensitive Text)
nextToken :: Maybe (Sensitive Text)
maxResults :: Maybe Natural
$sel:nextToken:ListAppInstances' :: ListAppInstances -> Maybe (Sensitive Text)
$sel:maxResults:ListAppInstances' :: ListAppInstances -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
nextToken

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

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

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

-- | /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 (Data.Sensitive Prelude.Text),
    -- | The response's http status code.
    ListAppInstancesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAppInstancesResponse -> ListAppInstancesResponse -> Bool
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
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.
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'
    { $sel:appInstances:ListAppInstancesResponse' :: Maybe [AppInstanceSummary]
appInstances =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAppInstancesResponse' :: Maybe (Sensitive Text)
nextToken = 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 :: Lens' ListAppInstancesResponse (Maybe [AppInstanceSummary])
listAppInstancesResponse_appInstances = 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) 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 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 :: Lens' ListAppInstancesResponse (Maybe Text)
listAppInstancesResponse_nextToken = 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) 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 a. Iso' (Sensitive a) a
Data._Sensitive

-- | The response's http status code.
listAppInstancesResponse_httpStatus :: Lens.Lens' ListAppInstancesResponse Prelude.Int
listAppInstancesResponse_httpStatus :: Lens' ListAppInstancesResponse Int
listAppInstancesResponse_httpStatus = 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 where
  rnf :: ListAppInstancesResponse -> ()
rnf ListAppInstancesResponse' {Int
Maybe [AppInstanceSummary]
Maybe (Sensitive Text)
httpStatus :: Int
nextToken :: Maybe (Sensitive Text)
appInstances :: Maybe [AppInstanceSummary]
$sel:httpStatus:ListAppInstancesResponse' :: ListAppInstancesResponse -> Int
$sel:nextToken:ListAppInstancesResponse' :: ListAppInstancesResponse -> Maybe (Sensitive Text)
$sel:appInstances:ListAppInstancesResponse' :: ListAppInstancesResponse -> Maybe [AppInstanceSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AppInstanceSummary]
appInstances
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus