{-# 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.DynamoDB.ListExports
-- 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 completed exports within the past 90 days.
module Amazonka.DynamoDB.ListExports
  ( -- * Creating a Request
    ListExports (..),
    newListExports,

    -- * Request Lenses
    listExports_tableArn,
    listExports_nextToken,
    listExports_maxResults,

    -- * Destructuring the Response
    ListExportsResponse (..),
    newListExportsResponse,

    -- * Response Lenses
    listExportsResponse_exportSummaries,
    listExportsResponse_nextToken,
    listExportsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types
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:/ 'newListExports' smart constructor.
data ListExports = ListExports'
  { -- | The Amazon Resource Name (ARN) associated with the exported table.
    ListExports -> Maybe Text
tableArn :: Prelude.Maybe Prelude.Text,
    -- | An optional string that, if supplied, must be copied from the output of
    -- a previous call to @ListExports@. When provided in this manner, the API
    -- fetches the next page of results.
    ListExports -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | Maximum number of results to return per page.
    ListExports -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListExports -> ListExports -> Bool
(ListExports -> ListExports -> Bool)
-> (ListExports -> ListExports -> Bool) -> Eq ListExports
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListExports -> ListExports -> Bool
$c/= :: ListExports -> ListExports -> Bool
== :: ListExports -> ListExports -> Bool
$c== :: ListExports -> ListExports -> Bool
Prelude.Eq, ReadPrec [ListExports]
ReadPrec ListExports
Int -> ReadS ListExports
ReadS [ListExports]
(Int -> ReadS ListExports)
-> ReadS [ListExports]
-> ReadPrec ListExports
-> ReadPrec [ListExports]
-> Read ListExports
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListExports]
$creadListPrec :: ReadPrec [ListExports]
readPrec :: ReadPrec ListExports
$creadPrec :: ReadPrec ListExports
readList :: ReadS [ListExports]
$creadList :: ReadS [ListExports]
readsPrec :: Int -> ReadS ListExports
$creadsPrec :: Int -> ReadS ListExports
Prelude.Read, Int -> ListExports -> ShowS
[ListExports] -> ShowS
ListExports -> String
(Int -> ListExports -> ShowS)
-> (ListExports -> String)
-> ([ListExports] -> ShowS)
-> Show ListExports
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListExports] -> ShowS
$cshowList :: [ListExports] -> ShowS
show :: ListExports -> String
$cshow :: ListExports -> String
showsPrec :: Int -> ListExports -> ShowS
$cshowsPrec :: Int -> ListExports -> ShowS
Prelude.Show, (forall x. ListExports -> Rep ListExports x)
-> (forall x. Rep ListExports x -> ListExports)
-> Generic ListExports
forall x. Rep ListExports x -> ListExports
forall x. ListExports -> Rep ListExports x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListExports x -> ListExports
$cfrom :: forall x. ListExports -> Rep ListExports x
Prelude.Generic)

-- |
-- Create a value of 'ListExports' 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:
--
-- 'tableArn', 'listExports_tableArn' - The Amazon Resource Name (ARN) associated with the exported table.
--
-- 'nextToken', 'listExports_nextToken' - An optional string that, if supplied, must be copied from the output of
-- a previous call to @ListExports@. When provided in this manner, the API
-- fetches the next page of results.
--
-- 'maxResults', 'listExports_maxResults' - Maximum number of results to return per page.
newListExports ::
  ListExports
newListExports :: ListExports
newListExports =
  ListExports' :: Maybe Text -> Maybe Text -> Maybe Natural -> ListExports
ListExports'
    { $sel:tableArn:ListExports' :: Maybe Text
tableArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListExports' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListExports' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) associated with the exported table.
listExports_tableArn :: Lens.Lens' ListExports (Prelude.Maybe Prelude.Text)
listExports_tableArn :: (Maybe Text -> f (Maybe Text)) -> ListExports -> f ListExports
listExports_tableArn = (ListExports -> Maybe Text)
-> (ListExports -> Maybe Text -> ListExports)
-> Lens ListExports ListExports (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListExports' {Maybe Text
tableArn :: Maybe Text
$sel:tableArn:ListExports' :: ListExports -> Maybe Text
tableArn} -> Maybe Text
tableArn) (\s :: ListExports
s@ListExports' {} Maybe Text
a -> ListExports
s {$sel:tableArn:ListExports' :: Maybe Text
tableArn = Maybe Text
a} :: ListExports)

-- | An optional string that, if supplied, must be copied from the output of
-- a previous call to @ListExports@. When provided in this manner, the API
-- fetches the next page of results.
listExports_nextToken :: Lens.Lens' ListExports (Prelude.Maybe Prelude.Text)
listExports_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListExports -> f ListExports
listExports_nextToken = (ListExports -> Maybe Text)
-> (ListExports -> Maybe Text -> ListExports)
-> Lens ListExports ListExports (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListExports' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListExports' :: ListExports -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListExports
s@ListExports' {} Maybe Text
a -> ListExports
s {$sel:nextToken:ListExports' :: Maybe Text
nextToken = Maybe Text
a} :: ListExports)

-- | Maximum number of results to return per page.
listExports_maxResults :: Lens.Lens' ListExports (Prelude.Maybe Prelude.Natural)
listExports_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListExports -> f ListExports
listExports_maxResults = (ListExports -> Maybe Natural)
-> (ListExports -> Maybe Natural -> ListExports)
-> Lens ListExports ListExports (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListExports' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListExports' :: ListExports -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListExports
s@ListExports' {} Maybe Natural
a -> ListExports
s {$sel:maxResults:ListExports' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListExports)

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

instance Prelude.NFData ListExports

instance Core.ToHeaders ListExports where
  toHeaders :: ListExports -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListExports -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"DynamoDB_20120810.ListExports" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON ListExports where
  toJSON :: ListExports -> Value
toJSON ListExports' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
tableArn :: Maybe Text
$sel:maxResults:ListExports' :: ListExports -> Maybe Natural
$sel:nextToken:ListExports' :: ListExports -> Maybe Text
$sel:tableArn:ListExports' :: ListExports -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TableArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
tableArn,
            (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults
          ]
      )

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

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

-- | /See:/ 'newListExportsResponse' smart constructor.
data ListExportsResponse = ListExportsResponse'
  { -- | A list of @ExportSummary@ objects.
    ListExportsResponse -> Maybe [ExportSummary]
exportSummaries :: Prelude.Maybe [ExportSummary],
    -- | If this value is returned, there are additional results to be displayed.
    -- To retrieve them, call @ListExports@ again, with @NextToken@ set to this
    -- value.
    ListExportsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListExportsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListExportsResponse -> ListExportsResponse -> Bool
(ListExportsResponse -> ListExportsResponse -> Bool)
-> (ListExportsResponse -> ListExportsResponse -> Bool)
-> Eq ListExportsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListExportsResponse -> ListExportsResponse -> Bool
$c/= :: ListExportsResponse -> ListExportsResponse -> Bool
== :: ListExportsResponse -> ListExportsResponse -> Bool
$c== :: ListExportsResponse -> ListExportsResponse -> Bool
Prelude.Eq, ReadPrec [ListExportsResponse]
ReadPrec ListExportsResponse
Int -> ReadS ListExportsResponse
ReadS [ListExportsResponse]
(Int -> ReadS ListExportsResponse)
-> ReadS [ListExportsResponse]
-> ReadPrec ListExportsResponse
-> ReadPrec [ListExportsResponse]
-> Read ListExportsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListExportsResponse]
$creadListPrec :: ReadPrec [ListExportsResponse]
readPrec :: ReadPrec ListExportsResponse
$creadPrec :: ReadPrec ListExportsResponse
readList :: ReadS [ListExportsResponse]
$creadList :: ReadS [ListExportsResponse]
readsPrec :: Int -> ReadS ListExportsResponse
$creadsPrec :: Int -> ReadS ListExportsResponse
Prelude.Read, Int -> ListExportsResponse -> ShowS
[ListExportsResponse] -> ShowS
ListExportsResponse -> String
(Int -> ListExportsResponse -> ShowS)
-> (ListExportsResponse -> String)
-> ([ListExportsResponse] -> ShowS)
-> Show ListExportsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListExportsResponse] -> ShowS
$cshowList :: [ListExportsResponse] -> ShowS
show :: ListExportsResponse -> String
$cshow :: ListExportsResponse -> String
showsPrec :: Int -> ListExportsResponse -> ShowS
$cshowsPrec :: Int -> ListExportsResponse -> ShowS
Prelude.Show, (forall x. ListExportsResponse -> Rep ListExportsResponse x)
-> (forall x. Rep ListExportsResponse x -> ListExportsResponse)
-> Generic ListExportsResponse
forall x. Rep ListExportsResponse x -> ListExportsResponse
forall x. ListExportsResponse -> Rep ListExportsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListExportsResponse x -> ListExportsResponse
$cfrom :: forall x. ListExportsResponse -> Rep ListExportsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListExportsResponse' 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:
--
-- 'exportSummaries', 'listExportsResponse_exportSummaries' - A list of @ExportSummary@ objects.
--
-- 'nextToken', 'listExportsResponse_nextToken' - If this value is returned, there are additional results to be displayed.
-- To retrieve them, call @ListExports@ again, with @NextToken@ set to this
-- value.
--
-- 'httpStatus', 'listExportsResponse_httpStatus' - The response's http status code.
newListExportsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListExportsResponse
newListExportsResponse :: Int -> ListExportsResponse
newListExportsResponse Int
pHttpStatus_ =
  ListExportsResponse' :: Maybe [ExportSummary] -> Maybe Text -> Int -> ListExportsResponse
ListExportsResponse'
    { $sel:exportSummaries:ListExportsResponse' :: Maybe [ExportSummary]
exportSummaries =
        Maybe [ExportSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListExportsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListExportsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of @ExportSummary@ objects.
listExportsResponse_exportSummaries :: Lens.Lens' ListExportsResponse (Prelude.Maybe [ExportSummary])
listExportsResponse_exportSummaries :: (Maybe [ExportSummary] -> f (Maybe [ExportSummary]))
-> ListExportsResponse -> f ListExportsResponse
listExportsResponse_exportSummaries = (ListExportsResponse -> Maybe [ExportSummary])
-> (ListExportsResponse
    -> Maybe [ExportSummary] -> ListExportsResponse)
-> Lens
     ListExportsResponse
     ListExportsResponse
     (Maybe [ExportSummary])
     (Maybe [ExportSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListExportsResponse' {Maybe [ExportSummary]
exportSummaries :: Maybe [ExportSummary]
$sel:exportSummaries:ListExportsResponse' :: ListExportsResponse -> Maybe [ExportSummary]
exportSummaries} -> Maybe [ExportSummary]
exportSummaries) (\s :: ListExportsResponse
s@ListExportsResponse' {} Maybe [ExportSummary]
a -> ListExportsResponse
s {$sel:exportSummaries:ListExportsResponse' :: Maybe [ExportSummary]
exportSummaries = Maybe [ExportSummary]
a} :: ListExportsResponse) ((Maybe [ExportSummary] -> f (Maybe [ExportSummary]))
 -> ListExportsResponse -> f ListExportsResponse)
-> ((Maybe [ExportSummary] -> f (Maybe [ExportSummary]))
    -> Maybe [ExportSummary] -> f (Maybe [ExportSummary]))
-> (Maybe [ExportSummary] -> f (Maybe [ExportSummary]))
-> ListExportsResponse
-> f ListExportsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ExportSummary] [ExportSummary] [ExportSummary] [ExportSummary]
-> Iso
     (Maybe [ExportSummary])
     (Maybe [ExportSummary])
     (Maybe [ExportSummary])
     (Maybe [ExportSummary])
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
  [ExportSummary] [ExportSummary] [ExportSummary] [ExportSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If this value is returned, there are additional results to be displayed.
-- To retrieve them, call @ListExports@ again, with @NextToken@ set to this
-- value.
listExportsResponse_nextToken :: Lens.Lens' ListExportsResponse (Prelude.Maybe Prelude.Text)
listExportsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListExportsResponse -> f ListExportsResponse
listExportsResponse_nextToken = (ListExportsResponse -> Maybe Text)
-> (ListExportsResponse -> Maybe Text -> ListExportsResponse)
-> Lens
     ListExportsResponse ListExportsResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListExportsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListExportsResponse' :: ListExportsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListExportsResponse
s@ListExportsResponse' {} Maybe Text
a -> ListExportsResponse
s {$sel:nextToken:ListExportsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListExportsResponse)

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

instance Prelude.NFData ListExportsResponse