{-# 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.RolesAnywhere.ListCrls
-- 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 Crls in the authenticated account and Amazon Web Services
-- Region.
--
-- __Required permissions:__ @rolesanywhere:ListCrls@.
--
-- This operation returns paginated results.
module Amazonka.RolesAnywhere.ListCrls
  ( -- * Creating a Request
    ListCrls (..),
    newListCrls,

    -- * Request Lenses
    listCrls_nextToken,
    listCrls_pageSize,

    -- * Destructuring the Response
    ListCrlsResponse (..),
    newListCrlsResponse,

    -- * Response Lenses
    listCrlsResponse_crls,
    listCrlsResponse_nextToken,
    listCrlsResponse_httpStatus,
  )
where

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
import Amazonka.RolesAnywhere.Types

-- | /See:/ 'newListCrls' smart constructor.
data ListCrls = ListCrls'
  { -- | A token that indicates where the output should continue from, if a
    -- previous operation did not show all results. To get the next results,
    -- call the operation again with this value.
    ListCrls -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The number of resources in the paginated list.
    ListCrls -> Maybe Int
pageSize :: Prelude.Maybe Prelude.Int
  }
  deriving (ListCrls -> ListCrls -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCrls -> ListCrls -> Bool
$c/= :: ListCrls -> ListCrls -> Bool
== :: ListCrls -> ListCrls -> Bool
$c== :: ListCrls -> ListCrls -> Bool
Prelude.Eq, ReadPrec [ListCrls]
ReadPrec ListCrls
Int -> ReadS ListCrls
ReadS [ListCrls]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCrls]
$creadListPrec :: ReadPrec [ListCrls]
readPrec :: ReadPrec ListCrls
$creadPrec :: ReadPrec ListCrls
readList :: ReadS [ListCrls]
$creadList :: ReadS [ListCrls]
readsPrec :: Int -> ReadS ListCrls
$creadsPrec :: Int -> ReadS ListCrls
Prelude.Read, Int -> ListCrls -> ShowS
[ListCrls] -> ShowS
ListCrls -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCrls] -> ShowS
$cshowList :: [ListCrls] -> ShowS
show :: ListCrls -> String
$cshow :: ListCrls -> String
showsPrec :: Int -> ListCrls -> ShowS
$cshowsPrec :: Int -> ListCrls -> ShowS
Prelude.Show, forall x. Rep ListCrls x -> ListCrls
forall x. ListCrls -> Rep ListCrls x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListCrls x -> ListCrls
$cfrom :: forall x. ListCrls -> Rep ListCrls x
Prelude.Generic)

-- |
-- Create a value of 'ListCrls' 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', 'listCrls_nextToken' - A token that indicates where the output should continue from, if a
-- previous operation did not show all results. To get the next results,
-- call the operation again with this value.
--
-- 'pageSize', 'listCrls_pageSize' - The number of resources in the paginated list.
newListCrls ::
  ListCrls
newListCrls :: ListCrls
newListCrls =
  ListCrls'
    { $sel:nextToken:ListCrls' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:pageSize:ListCrls' :: Maybe Int
pageSize = forall a. Maybe a
Prelude.Nothing
    }

-- | A token that indicates where the output should continue from, if a
-- previous operation did not show all results. To get the next results,
-- call the operation again with this value.
listCrls_nextToken :: Lens.Lens' ListCrls (Prelude.Maybe Prelude.Text)
listCrls_nextToken :: Lens' ListCrls (Maybe Text)
listCrls_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCrls' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListCrls' :: ListCrls -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListCrls
s@ListCrls' {} Maybe Text
a -> ListCrls
s {$sel:nextToken:ListCrls' :: Maybe Text
nextToken = Maybe Text
a} :: ListCrls)

-- | The number of resources in the paginated list.
listCrls_pageSize :: Lens.Lens' ListCrls (Prelude.Maybe Prelude.Int)
listCrls_pageSize :: Lens' ListCrls (Maybe Int)
listCrls_pageSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCrls' {Maybe Int
pageSize :: Maybe Int
$sel:pageSize:ListCrls' :: ListCrls -> Maybe Int
pageSize} -> Maybe Int
pageSize) (\s :: ListCrls
s@ListCrls' {} Maybe Int
a -> ListCrls
s {$sel:pageSize:ListCrls' :: Maybe Int
pageSize = Maybe Int
a} :: ListCrls)

instance Core.AWSPager ListCrls where
  page :: ListCrls -> AWSResponse ListCrls -> Maybe ListCrls
page ListCrls
rq AWSResponse ListCrls
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListCrls
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListCrlsResponse (Maybe Text)
listCrlsResponse_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 ListCrls
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListCrlsResponse (Maybe [CrlDetail])
listCrlsResponse_crls
            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
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListCrls
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListCrls (Maybe Text)
listCrls_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListCrls
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListCrlsResponse (Maybe Text)
listCrlsResponse_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 ListCrls where
  type AWSResponse ListCrls = ListCrlsResponse
  request :: (Service -> Service) -> ListCrls -> Request ListCrls
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 ListCrls
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListCrls)))
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 [CrlDetail] -> Maybe Text -> Int -> ListCrlsResponse
ListCrlsResponse'
            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
"crls" 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 ListCrls where
  hashWithSalt :: Int -> ListCrls -> Int
hashWithSalt Int
_salt ListCrls' {Maybe Int
Maybe Text
pageSize :: Maybe Int
nextToken :: Maybe Text
$sel:pageSize:ListCrls' :: ListCrls -> Maybe Int
$sel:nextToken:ListCrls' :: ListCrls -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
pageSize

instance Prelude.NFData ListCrls where
  rnf :: ListCrls -> ()
rnf ListCrls' {Maybe Int
Maybe Text
pageSize :: Maybe Int
nextToken :: Maybe Text
$sel:pageSize:ListCrls' :: ListCrls -> Maybe Int
$sel:nextToken:ListCrls' :: ListCrls -> 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 Maybe Int
pageSize

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

instance Data.ToPath ListCrls where
  toPath :: ListCrls -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/crls"

instance Data.ToQuery ListCrls where
  toQuery :: ListCrls -> QueryString
toQuery ListCrls' {Maybe Int
Maybe Text
pageSize :: Maybe Int
nextToken :: Maybe Text
$sel:pageSize:ListCrls' :: ListCrls -> Maybe Int
$sel:nextToken:ListCrls' :: ListCrls -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken,
        ByteString
"pageSize" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
pageSize
      ]

-- | /See:/ 'newListCrlsResponse' smart constructor.
data ListCrlsResponse = ListCrlsResponse'
  { -- | A list of certificate revocation lists (CRL).
    ListCrlsResponse -> Maybe [CrlDetail]
crls :: Prelude.Maybe [CrlDetail],
    -- | A token that indicates where the output should continue from, if a
    -- previous operation did not show all results. To get the next results,
    -- call the operation again with this value.
    ListCrlsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListCrlsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListCrlsResponse -> ListCrlsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListCrlsResponse -> ListCrlsResponse -> Bool
$c/= :: ListCrlsResponse -> ListCrlsResponse -> Bool
== :: ListCrlsResponse -> ListCrlsResponse -> Bool
$c== :: ListCrlsResponse -> ListCrlsResponse -> Bool
Prelude.Eq, ReadPrec [ListCrlsResponse]
ReadPrec ListCrlsResponse
Int -> ReadS ListCrlsResponse
ReadS [ListCrlsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListCrlsResponse]
$creadListPrec :: ReadPrec [ListCrlsResponse]
readPrec :: ReadPrec ListCrlsResponse
$creadPrec :: ReadPrec ListCrlsResponse
readList :: ReadS [ListCrlsResponse]
$creadList :: ReadS [ListCrlsResponse]
readsPrec :: Int -> ReadS ListCrlsResponse
$creadsPrec :: Int -> ReadS ListCrlsResponse
Prelude.Read, Int -> ListCrlsResponse -> ShowS
[ListCrlsResponse] -> ShowS
ListCrlsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListCrlsResponse] -> ShowS
$cshowList :: [ListCrlsResponse] -> ShowS
show :: ListCrlsResponse -> String
$cshow :: ListCrlsResponse -> String
showsPrec :: Int -> ListCrlsResponse -> ShowS
$cshowsPrec :: Int -> ListCrlsResponse -> ShowS
Prelude.Show, forall x. Rep ListCrlsResponse x -> ListCrlsResponse
forall x. ListCrlsResponse -> Rep ListCrlsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListCrlsResponse x -> ListCrlsResponse
$cfrom :: forall x. ListCrlsResponse -> Rep ListCrlsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListCrlsResponse' 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:
--
-- 'crls', 'listCrlsResponse_crls' - A list of certificate revocation lists (CRL).
--
-- 'nextToken', 'listCrlsResponse_nextToken' - A token that indicates where the output should continue from, if a
-- previous operation did not show all results. To get the next results,
-- call the operation again with this value.
--
-- 'httpStatus', 'listCrlsResponse_httpStatus' - The response's http status code.
newListCrlsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListCrlsResponse
newListCrlsResponse :: Int -> ListCrlsResponse
newListCrlsResponse Int
pHttpStatus_ =
  ListCrlsResponse'
    { $sel:crls:ListCrlsResponse' :: Maybe [CrlDetail]
crls = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListCrlsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListCrlsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of certificate revocation lists (CRL).
listCrlsResponse_crls :: Lens.Lens' ListCrlsResponse (Prelude.Maybe [CrlDetail])
listCrlsResponse_crls :: Lens' ListCrlsResponse (Maybe [CrlDetail])
listCrlsResponse_crls = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCrlsResponse' {Maybe [CrlDetail]
crls :: Maybe [CrlDetail]
$sel:crls:ListCrlsResponse' :: ListCrlsResponse -> Maybe [CrlDetail]
crls} -> Maybe [CrlDetail]
crls) (\s :: ListCrlsResponse
s@ListCrlsResponse' {} Maybe [CrlDetail]
a -> ListCrlsResponse
s {$sel:crls:ListCrlsResponse' :: Maybe [CrlDetail]
crls = Maybe [CrlDetail]
a} :: ListCrlsResponse) 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

-- | A token that indicates where the output should continue from, if a
-- previous operation did not show all results. To get the next results,
-- call the operation again with this value.
listCrlsResponse_nextToken :: Lens.Lens' ListCrlsResponse (Prelude.Maybe Prelude.Text)
listCrlsResponse_nextToken :: Lens' ListCrlsResponse (Maybe Text)
listCrlsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListCrlsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListCrlsResponse' :: ListCrlsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListCrlsResponse
s@ListCrlsResponse' {} Maybe Text
a -> ListCrlsResponse
s {$sel:nextToken:ListCrlsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListCrlsResponse)

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

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