{-# 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.CloudHSM.ListLunaClients
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- This is documentation for __AWS CloudHSM Classic__. For more
-- information, see
-- <http://aws.amazon.com/cloudhsm/faqs-classic/ AWS CloudHSM Classic FAQs>,
-- the
-- <https://docs.aws.amazon.com/cloudhsm/classic/userguide/ AWS CloudHSM Classic User Guide>,
-- and the
-- <https://docs.aws.amazon.com/cloudhsm/classic/APIReference/ AWS CloudHSM Classic API Reference>.
--
-- __For information about the current version of AWS CloudHSM__, see
-- <http://aws.amazon.com/cloudhsm/ AWS CloudHSM>, the
-- <https://docs.aws.amazon.com/cloudhsm/latest/userguide/ AWS CloudHSM User Guide>,
-- and the
-- <https://docs.aws.amazon.com/cloudhsm/latest/APIReference/ AWS CloudHSM API Reference>.
--
-- Lists all of the clients.
--
-- This operation supports pagination with the use of the @NextToken@
-- member. If more results are available, the @NextToken@ member of the
-- response contains a token that you pass in the next call to
-- @ListLunaClients@ to retrieve the next set of items.
--
-- This operation returns paginated results.
module Amazonka.CloudHSM.ListLunaClients
  ( -- * Creating a Request
    ListLunaClients (..),
    newListLunaClients,

    -- * Request Lenses
    listLunaClients_nextToken,

    -- * Destructuring the Response
    ListLunaClientsResponse (..),
    newListLunaClientsResponse,

    -- * Response Lenses
    listLunaClientsResponse_nextToken,
    listLunaClientsResponse_httpStatus,
    listLunaClientsResponse_clientList,
  )
where

import Amazonka.CloudHSM.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:/ 'newListLunaClients' smart constructor.
data ListLunaClients = ListLunaClients'
  { -- | The @NextToken@ value from a previous call to @ListLunaClients@. Pass
    -- null if this is the first call.
    ListLunaClients -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListLunaClients -> ListLunaClients -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListLunaClients -> ListLunaClients -> Bool
$c/= :: ListLunaClients -> ListLunaClients -> Bool
== :: ListLunaClients -> ListLunaClients -> Bool
$c== :: ListLunaClients -> ListLunaClients -> Bool
Prelude.Eq, ReadPrec [ListLunaClients]
ReadPrec ListLunaClients
Int -> ReadS ListLunaClients
ReadS [ListLunaClients]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListLunaClients]
$creadListPrec :: ReadPrec [ListLunaClients]
readPrec :: ReadPrec ListLunaClients
$creadPrec :: ReadPrec ListLunaClients
readList :: ReadS [ListLunaClients]
$creadList :: ReadS [ListLunaClients]
readsPrec :: Int -> ReadS ListLunaClients
$creadsPrec :: Int -> ReadS ListLunaClients
Prelude.Read, Int -> ListLunaClients -> ShowS
[ListLunaClients] -> ShowS
ListLunaClients -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListLunaClients] -> ShowS
$cshowList :: [ListLunaClients] -> ShowS
show :: ListLunaClients -> String
$cshow :: ListLunaClients -> String
showsPrec :: Int -> ListLunaClients -> ShowS
$cshowsPrec :: Int -> ListLunaClients -> ShowS
Prelude.Show, forall x. Rep ListLunaClients x -> ListLunaClients
forall x. ListLunaClients -> Rep ListLunaClients x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListLunaClients x -> ListLunaClients
$cfrom :: forall x. ListLunaClients -> Rep ListLunaClients x
Prelude.Generic)

-- |
-- Create a value of 'ListLunaClients' 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', 'listLunaClients_nextToken' - The @NextToken@ value from a previous call to @ListLunaClients@. Pass
-- null if this is the first call.
newListLunaClients ::
  ListLunaClients
newListLunaClients :: ListLunaClients
newListLunaClients =
  ListLunaClients' {$sel:nextToken:ListLunaClients' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing}

-- | The @NextToken@ value from a previous call to @ListLunaClients@. Pass
-- null if this is the first call.
listLunaClients_nextToken :: Lens.Lens' ListLunaClients (Prelude.Maybe Prelude.Text)
listLunaClients_nextToken :: Lens' ListLunaClients (Maybe Text)
listLunaClients_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListLunaClients' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListLunaClients' :: ListLunaClients -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListLunaClients
s@ListLunaClients' {} Maybe Text
a -> ListLunaClients
s {$sel:nextToken:ListLunaClients' :: Maybe Text
nextToken = Maybe Text
a} :: ListLunaClients)

instance Core.AWSPager ListLunaClients where
  page :: ListLunaClients
-> AWSResponse ListLunaClients -> Maybe ListLunaClients
page ListLunaClients
rq AWSResponse ListLunaClients
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListLunaClients
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListLunaClientsResponse (Maybe Text)
listLunaClientsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        (AWSResponse ListLunaClients
rs forall s a. s -> Getting a s a -> a
Lens.^. Lens' ListLunaClientsResponse [Text]
listLunaClientsResponse_clientList) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListLunaClients
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListLunaClients (Maybe Text)
listLunaClients_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListLunaClients
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListLunaClientsResponse (Maybe Text)
listLunaClientsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListLunaClients where
  type
    AWSResponse ListLunaClients =
      ListLunaClientsResponse
  request :: (Service -> Service) -> ListLunaClients -> Request ListLunaClients
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 ListLunaClients
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListLunaClients)))
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 Text -> Int -> [Text] -> ListLunaClientsResponse
ListLunaClientsResponse'
            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
"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))
            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
"ClientList" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListLunaClients where
  hashWithSalt :: Int -> ListLunaClients -> Int
hashWithSalt Int
_salt ListLunaClients' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListLunaClients' :: ListLunaClients -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListLunaClients where
  rnf :: ListLunaClients -> ()
rnf ListLunaClients' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListLunaClients' :: ListLunaClients -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

instance Data.ToHeaders ListLunaClients where
  toHeaders :: ListLunaClients -> 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
"CloudHsmFrontendService.ListLunaClients" ::
                          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 ListLunaClients where
  toJSON :: ListLunaClients -> Value
toJSON ListLunaClients' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListLunaClients' :: ListLunaClients -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(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 ListLunaClients where
  toPath :: ListLunaClients -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newListLunaClientsResponse' smart constructor.
data ListLunaClientsResponse = ListLunaClientsResponse'
  { -- | If not null, more results are available. Pass this to @ListLunaClients@
    -- to retrieve the next set of items.
    ListLunaClientsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListLunaClientsResponse -> Int
httpStatus :: Prelude.Int,
    -- | The list of clients.
    ListLunaClientsResponse -> [Text]
clientList :: [Prelude.Text]
  }
  deriving (ListLunaClientsResponse -> ListLunaClientsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListLunaClientsResponse -> ListLunaClientsResponse -> Bool
$c/= :: ListLunaClientsResponse -> ListLunaClientsResponse -> Bool
== :: ListLunaClientsResponse -> ListLunaClientsResponse -> Bool
$c== :: ListLunaClientsResponse -> ListLunaClientsResponse -> Bool
Prelude.Eq, ReadPrec [ListLunaClientsResponse]
ReadPrec ListLunaClientsResponse
Int -> ReadS ListLunaClientsResponse
ReadS [ListLunaClientsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListLunaClientsResponse]
$creadListPrec :: ReadPrec [ListLunaClientsResponse]
readPrec :: ReadPrec ListLunaClientsResponse
$creadPrec :: ReadPrec ListLunaClientsResponse
readList :: ReadS [ListLunaClientsResponse]
$creadList :: ReadS [ListLunaClientsResponse]
readsPrec :: Int -> ReadS ListLunaClientsResponse
$creadsPrec :: Int -> ReadS ListLunaClientsResponse
Prelude.Read, Int -> ListLunaClientsResponse -> ShowS
[ListLunaClientsResponse] -> ShowS
ListLunaClientsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListLunaClientsResponse] -> ShowS
$cshowList :: [ListLunaClientsResponse] -> ShowS
show :: ListLunaClientsResponse -> String
$cshow :: ListLunaClientsResponse -> String
showsPrec :: Int -> ListLunaClientsResponse -> ShowS
$cshowsPrec :: Int -> ListLunaClientsResponse -> ShowS
Prelude.Show, forall x. Rep ListLunaClientsResponse x -> ListLunaClientsResponse
forall x. ListLunaClientsResponse -> Rep ListLunaClientsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListLunaClientsResponse x -> ListLunaClientsResponse
$cfrom :: forall x. ListLunaClientsResponse -> Rep ListLunaClientsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListLunaClientsResponse' 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', 'listLunaClientsResponse_nextToken' - If not null, more results are available. Pass this to @ListLunaClients@
-- to retrieve the next set of items.
--
-- 'httpStatus', 'listLunaClientsResponse_httpStatus' - The response's http status code.
--
-- 'clientList', 'listLunaClientsResponse_clientList' - The list of clients.
newListLunaClientsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListLunaClientsResponse
newListLunaClientsResponse :: Int -> ListLunaClientsResponse
newListLunaClientsResponse Int
pHttpStatus_ =
  ListLunaClientsResponse'
    { $sel:nextToken:ListLunaClientsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListLunaClientsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:clientList:ListLunaClientsResponse' :: [Text]
clientList = forall a. Monoid a => a
Prelude.mempty
    }

-- | If not null, more results are available. Pass this to @ListLunaClients@
-- to retrieve the next set of items.
listLunaClientsResponse_nextToken :: Lens.Lens' ListLunaClientsResponse (Prelude.Maybe Prelude.Text)
listLunaClientsResponse_nextToken :: Lens' ListLunaClientsResponse (Maybe Text)
listLunaClientsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListLunaClientsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListLunaClientsResponse' :: ListLunaClientsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListLunaClientsResponse
s@ListLunaClientsResponse' {} Maybe Text
a -> ListLunaClientsResponse
s {$sel:nextToken:ListLunaClientsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListLunaClientsResponse)

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

-- | The list of clients.
listLunaClientsResponse_clientList :: Lens.Lens' ListLunaClientsResponse [Prelude.Text]
listLunaClientsResponse_clientList :: Lens' ListLunaClientsResponse [Text]
listLunaClientsResponse_clientList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListLunaClientsResponse' {[Text]
clientList :: [Text]
$sel:clientList:ListLunaClientsResponse' :: ListLunaClientsResponse -> [Text]
clientList} -> [Text]
clientList) (\s :: ListLunaClientsResponse
s@ListLunaClientsResponse' {} [Text]
a -> ListLunaClientsResponse
s {$sel:clientList:ListLunaClientsResponse' :: [Text]
clientList = [Text]
a} :: ListLunaClientsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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