{-# 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.QLDB.ListJournalS3Exports
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns an array of journal export job descriptions for all ledgers that
-- are associated with the current Amazon Web Services account and Region.
--
-- This action returns a maximum of @MaxResults@ items, and is paginated so
-- that you can retrieve all the items by calling @ListJournalS3Exports@
-- multiple times.
--
-- This action does not return any expired export jobs. For more
-- information, see
-- <https://docs.aws.amazon.com/qldb/latest/developerguide/export-journal.request.html#export-journal.request.expiration Export job expiration>
-- in the /Amazon QLDB Developer Guide/.
module Amazonka.QLDB.ListJournalS3Exports
  ( -- * Creating a Request
    ListJournalS3Exports (..),
    newListJournalS3Exports,

    -- * Request Lenses
    listJournalS3Exports_maxResults,
    listJournalS3Exports_nextToken,

    -- * Destructuring the Response
    ListJournalS3ExportsResponse (..),
    newListJournalS3ExportsResponse,

    -- * Response Lenses
    listJournalS3ExportsResponse_journalS3Exports,
    listJournalS3ExportsResponse_nextToken,
    listJournalS3ExportsResponse_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 Amazonka.QLDB.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListJournalS3Exports' smart constructor.
data ListJournalS3Exports = ListJournalS3Exports'
  { -- | The maximum number of results to return in a single
    -- @ListJournalS3Exports@ request. (The actual number of results returned
    -- might be fewer.)
    ListJournalS3Exports -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A pagination token, indicating that you want to retrieve the next page
    -- of results. If you received a value for @NextToken@ in the response from
    -- a previous @ListJournalS3Exports@ call, then you should use that value
    -- as input here.
    ListJournalS3Exports -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListJournalS3Exports -> ListJournalS3Exports -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListJournalS3Exports -> ListJournalS3Exports -> Bool
$c/= :: ListJournalS3Exports -> ListJournalS3Exports -> Bool
== :: ListJournalS3Exports -> ListJournalS3Exports -> Bool
$c== :: ListJournalS3Exports -> ListJournalS3Exports -> Bool
Prelude.Eq, ReadPrec [ListJournalS3Exports]
ReadPrec ListJournalS3Exports
Int -> ReadS ListJournalS3Exports
ReadS [ListJournalS3Exports]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListJournalS3Exports]
$creadListPrec :: ReadPrec [ListJournalS3Exports]
readPrec :: ReadPrec ListJournalS3Exports
$creadPrec :: ReadPrec ListJournalS3Exports
readList :: ReadS [ListJournalS3Exports]
$creadList :: ReadS [ListJournalS3Exports]
readsPrec :: Int -> ReadS ListJournalS3Exports
$creadsPrec :: Int -> ReadS ListJournalS3Exports
Prelude.Read, Int -> ListJournalS3Exports -> ShowS
[ListJournalS3Exports] -> ShowS
ListJournalS3Exports -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListJournalS3Exports] -> ShowS
$cshowList :: [ListJournalS3Exports] -> ShowS
show :: ListJournalS3Exports -> String
$cshow :: ListJournalS3Exports -> String
showsPrec :: Int -> ListJournalS3Exports -> ShowS
$cshowsPrec :: Int -> ListJournalS3Exports -> ShowS
Prelude.Show, forall x. Rep ListJournalS3Exports x -> ListJournalS3Exports
forall x. ListJournalS3Exports -> Rep ListJournalS3Exports x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListJournalS3Exports x -> ListJournalS3Exports
$cfrom :: forall x. ListJournalS3Exports -> Rep ListJournalS3Exports x
Prelude.Generic)

-- |
-- Create a value of 'ListJournalS3Exports' 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', 'listJournalS3Exports_maxResults' - The maximum number of results to return in a single
-- @ListJournalS3Exports@ request. (The actual number of results returned
-- might be fewer.)
--
-- 'nextToken', 'listJournalS3Exports_nextToken' - A pagination token, indicating that you want to retrieve the next page
-- of results. If you received a value for @NextToken@ in the response from
-- a previous @ListJournalS3Exports@ call, then you should use that value
-- as input here.
newListJournalS3Exports ::
  ListJournalS3Exports
newListJournalS3Exports :: ListJournalS3Exports
newListJournalS3Exports =
  ListJournalS3Exports'
    { $sel:maxResults:ListJournalS3Exports' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListJournalS3Exports' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of results to return in a single
-- @ListJournalS3Exports@ request. (The actual number of results returned
-- might be fewer.)
listJournalS3Exports_maxResults :: Lens.Lens' ListJournalS3Exports (Prelude.Maybe Prelude.Natural)
listJournalS3Exports_maxResults :: Lens' ListJournalS3Exports (Maybe Natural)
listJournalS3Exports_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJournalS3Exports' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListJournalS3Exports' :: ListJournalS3Exports -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListJournalS3Exports
s@ListJournalS3Exports' {} Maybe Natural
a -> ListJournalS3Exports
s {$sel:maxResults:ListJournalS3Exports' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListJournalS3Exports)

-- | A pagination token, indicating that you want to retrieve the next page
-- of results. If you received a value for @NextToken@ in the response from
-- a previous @ListJournalS3Exports@ call, then you should use that value
-- as input here.
listJournalS3Exports_nextToken :: Lens.Lens' ListJournalS3Exports (Prelude.Maybe Prelude.Text)
listJournalS3Exports_nextToken :: Lens' ListJournalS3Exports (Maybe Text)
listJournalS3Exports_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJournalS3Exports' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListJournalS3Exports' :: ListJournalS3Exports -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListJournalS3Exports
s@ListJournalS3Exports' {} Maybe Text
a -> ListJournalS3Exports
s {$sel:nextToken:ListJournalS3Exports' :: Maybe Text
nextToken = Maybe Text
a} :: ListJournalS3Exports)

instance Core.AWSRequest ListJournalS3Exports where
  type
    AWSResponse ListJournalS3Exports =
      ListJournalS3ExportsResponse
  request :: (Service -> Service)
-> ListJournalS3Exports -> Request ListJournalS3Exports
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 ListJournalS3Exports
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListJournalS3Exports)))
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 [JournalS3ExportDescription]
-> Maybe Text -> Int -> ListJournalS3ExportsResponse
ListJournalS3ExportsResponse'
            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
"JournalS3Exports"
                            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 ListJournalS3Exports where
  hashWithSalt :: Int -> ListJournalS3Exports -> Int
hashWithSalt Int
_salt ListJournalS3Exports' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListJournalS3Exports' :: ListJournalS3Exports -> Maybe Text
$sel:maxResults:ListJournalS3Exports' :: ListJournalS3Exports -> 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 Text
nextToken

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

instance Data.ToHeaders ListJournalS3Exports where
  toHeaders :: ListJournalS3Exports -> 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.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath ListJournalS3Exports where
  toPath :: ListJournalS3Exports -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/journal-s3-exports"

instance Data.ToQuery ListJournalS3Exports where
  toQuery :: ListJournalS3Exports -> QueryString
toQuery ListJournalS3Exports' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListJournalS3Exports' :: ListJournalS3Exports -> Maybe Text
$sel:maxResults:ListJournalS3Exports' :: ListJournalS3Exports -> 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 Text
nextToken
      ]

-- | /See:/ 'newListJournalS3ExportsResponse' smart constructor.
data ListJournalS3ExportsResponse = ListJournalS3ExportsResponse'
  { -- | The array of journal export job descriptions for all ledgers that are
    -- associated with the current Amazon Web Services account and Region.
    ListJournalS3ExportsResponse -> Maybe [JournalS3ExportDescription]
journalS3Exports :: Prelude.Maybe [JournalS3ExportDescription],
    -- | -   If @NextToken@ is empty, then the last page of results has been
    --     processed and there are no more results to be retrieved.
    --
    -- -   If @NextToken@ is /not/ empty, then there are more results
    --     available. To retrieve the next page of results, use the value of
    --     @NextToken@ in a subsequent @ListJournalS3Exports@ call.
    ListJournalS3ExportsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListJournalS3ExportsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListJournalS3ExportsResponse
-> ListJournalS3ExportsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListJournalS3ExportsResponse
-> ListJournalS3ExportsResponse -> Bool
$c/= :: ListJournalS3ExportsResponse
-> ListJournalS3ExportsResponse -> Bool
== :: ListJournalS3ExportsResponse
-> ListJournalS3ExportsResponse -> Bool
$c== :: ListJournalS3ExportsResponse
-> ListJournalS3ExportsResponse -> Bool
Prelude.Eq, ReadPrec [ListJournalS3ExportsResponse]
ReadPrec ListJournalS3ExportsResponse
Int -> ReadS ListJournalS3ExportsResponse
ReadS [ListJournalS3ExportsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListJournalS3ExportsResponse]
$creadListPrec :: ReadPrec [ListJournalS3ExportsResponse]
readPrec :: ReadPrec ListJournalS3ExportsResponse
$creadPrec :: ReadPrec ListJournalS3ExportsResponse
readList :: ReadS [ListJournalS3ExportsResponse]
$creadList :: ReadS [ListJournalS3ExportsResponse]
readsPrec :: Int -> ReadS ListJournalS3ExportsResponse
$creadsPrec :: Int -> ReadS ListJournalS3ExportsResponse
Prelude.Read, Int -> ListJournalS3ExportsResponse -> ShowS
[ListJournalS3ExportsResponse] -> ShowS
ListJournalS3ExportsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListJournalS3ExportsResponse] -> ShowS
$cshowList :: [ListJournalS3ExportsResponse] -> ShowS
show :: ListJournalS3ExportsResponse -> String
$cshow :: ListJournalS3ExportsResponse -> String
showsPrec :: Int -> ListJournalS3ExportsResponse -> ShowS
$cshowsPrec :: Int -> ListJournalS3ExportsResponse -> ShowS
Prelude.Show, forall x.
Rep ListJournalS3ExportsResponse x -> ListJournalS3ExportsResponse
forall x.
ListJournalS3ExportsResponse -> Rep ListJournalS3ExportsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListJournalS3ExportsResponse x -> ListJournalS3ExportsResponse
$cfrom :: forall x.
ListJournalS3ExportsResponse -> Rep ListJournalS3ExportsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListJournalS3ExportsResponse' 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:
--
-- 'journalS3Exports', 'listJournalS3ExportsResponse_journalS3Exports' - The array of journal export job descriptions for all ledgers that are
-- associated with the current Amazon Web Services account and Region.
--
-- 'nextToken', 'listJournalS3ExportsResponse_nextToken' - -   If @NextToken@ is empty, then the last page of results has been
--     processed and there are no more results to be retrieved.
--
-- -   If @NextToken@ is /not/ empty, then there are more results
--     available. To retrieve the next page of results, use the value of
--     @NextToken@ in a subsequent @ListJournalS3Exports@ call.
--
-- 'httpStatus', 'listJournalS3ExportsResponse_httpStatus' - The response's http status code.
newListJournalS3ExportsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListJournalS3ExportsResponse
newListJournalS3ExportsResponse :: Int -> ListJournalS3ExportsResponse
newListJournalS3ExportsResponse Int
pHttpStatus_ =
  ListJournalS3ExportsResponse'
    { $sel:journalS3Exports:ListJournalS3ExportsResponse' :: Maybe [JournalS3ExportDescription]
journalS3Exports =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListJournalS3ExportsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListJournalS3ExportsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The array of journal export job descriptions for all ledgers that are
-- associated with the current Amazon Web Services account and Region.
listJournalS3ExportsResponse_journalS3Exports :: Lens.Lens' ListJournalS3ExportsResponse (Prelude.Maybe [JournalS3ExportDescription])
listJournalS3ExportsResponse_journalS3Exports :: Lens'
  ListJournalS3ExportsResponse (Maybe [JournalS3ExportDescription])
listJournalS3ExportsResponse_journalS3Exports = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJournalS3ExportsResponse' {Maybe [JournalS3ExportDescription]
journalS3Exports :: Maybe [JournalS3ExportDescription]
$sel:journalS3Exports:ListJournalS3ExportsResponse' :: ListJournalS3ExportsResponse -> Maybe [JournalS3ExportDescription]
journalS3Exports} -> Maybe [JournalS3ExportDescription]
journalS3Exports) (\s :: ListJournalS3ExportsResponse
s@ListJournalS3ExportsResponse' {} Maybe [JournalS3ExportDescription]
a -> ListJournalS3ExportsResponse
s {$sel:journalS3Exports:ListJournalS3ExportsResponse' :: Maybe [JournalS3ExportDescription]
journalS3Exports = Maybe [JournalS3ExportDescription]
a} :: ListJournalS3ExportsResponse) 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

-- | -   If @NextToken@ is empty, then the last page of results has been
--     processed and there are no more results to be retrieved.
--
-- -   If @NextToken@ is /not/ empty, then there are more results
--     available. To retrieve the next page of results, use the value of
--     @NextToken@ in a subsequent @ListJournalS3Exports@ call.
listJournalS3ExportsResponse_nextToken :: Lens.Lens' ListJournalS3ExportsResponse (Prelude.Maybe Prelude.Text)
listJournalS3ExportsResponse_nextToken :: Lens' ListJournalS3ExportsResponse (Maybe Text)
listJournalS3ExportsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListJournalS3ExportsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListJournalS3ExportsResponse' :: ListJournalS3ExportsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListJournalS3ExportsResponse
s@ListJournalS3ExportsResponse' {} Maybe Text
a -> ListJournalS3ExportsResponse
s {$sel:nextToken:ListJournalS3ExportsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListJournalS3ExportsResponse)

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

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