{-# 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.ListBackups
-- 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)
--
-- List backups associated with an AWS account. To list backups for a given
-- table, specify @TableName@. @ListBackups@ returns a paginated list of
-- results with at most 1 MB worth of items in a page. You can also specify
-- a maximum number of entries to be returned in a page.
--
-- In the request, start time is inclusive, but end time is exclusive. Note
-- that these boundaries are for the time at which the original backup was
-- requested.
--
-- You can call @ListBackups@ a maximum of five times per second.
--
-- This operation returns paginated results.
module Amazonka.DynamoDB.ListBackups
  ( -- * Creating a Request
    ListBackups (..),
    newListBackups,

    -- * Request Lenses
    listBackups_timeRangeUpperBound,
    listBackups_timeRangeLowerBound,
    listBackups_limit,
    listBackups_exclusiveStartBackupArn,
    listBackups_backupType,
    listBackups_tableName,

    -- * Destructuring the Response
    ListBackupsResponse (..),
    newListBackupsResponse,

    -- * Response Lenses
    listBackupsResponse_backupSummaries,
    listBackupsResponse_lastEvaluatedBackupArn,
    listBackupsResponse_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:/ 'newListBackups' smart constructor.
data ListBackups = ListBackups'
  { -- | Only backups created before this time are listed. @TimeRangeUpperBound@
    -- is exclusive.
    ListBackups -> Maybe POSIX
timeRangeUpperBound :: Prelude.Maybe Core.POSIX,
    -- | Only backups created after this time are listed. @TimeRangeLowerBound@
    -- is inclusive.
    ListBackups -> Maybe POSIX
timeRangeLowerBound :: Prelude.Maybe Core.POSIX,
    -- | Maximum number of backups to return at once.
    ListBackups -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | @LastEvaluatedBackupArn@ is the Amazon Resource Name (ARN) of the backup
    -- last evaluated when the current page of results was returned, inclusive
    -- of the current page of results. This value may be specified as the
    -- @ExclusiveStartBackupArn@ of a new @ListBackups@ operation in order to
    -- fetch the next page of results.
    ListBackups -> Maybe Text
exclusiveStartBackupArn :: Prelude.Maybe Prelude.Text,
    -- | The backups from the table specified by @BackupType@ are listed.
    --
    -- Where @BackupType@ can be:
    --
    -- -   @USER@ - On-demand backup created by you.
    --
    -- -   @SYSTEM@ - On-demand backup automatically created by DynamoDB.
    --
    -- -   @ALL@ - All types of on-demand backups (USER and SYSTEM).
    ListBackups -> Maybe BackupTypeFilter
backupType :: Prelude.Maybe BackupTypeFilter,
    -- | The backups from the table specified by @TableName@ are listed.
    ListBackups -> Maybe Text
tableName :: Prelude.Maybe Prelude.Text
  }
  deriving (ListBackups -> ListBackups -> Bool
(ListBackups -> ListBackups -> Bool)
-> (ListBackups -> ListBackups -> Bool) -> Eq ListBackups
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListBackups -> ListBackups -> Bool
$c/= :: ListBackups -> ListBackups -> Bool
== :: ListBackups -> ListBackups -> Bool
$c== :: ListBackups -> ListBackups -> Bool
Prelude.Eq, ReadPrec [ListBackups]
ReadPrec ListBackups
Int -> ReadS ListBackups
ReadS [ListBackups]
(Int -> ReadS ListBackups)
-> ReadS [ListBackups]
-> ReadPrec ListBackups
-> ReadPrec [ListBackups]
-> Read ListBackups
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListBackups]
$creadListPrec :: ReadPrec [ListBackups]
readPrec :: ReadPrec ListBackups
$creadPrec :: ReadPrec ListBackups
readList :: ReadS [ListBackups]
$creadList :: ReadS [ListBackups]
readsPrec :: Int -> ReadS ListBackups
$creadsPrec :: Int -> ReadS ListBackups
Prelude.Read, Int -> ListBackups -> ShowS
[ListBackups] -> ShowS
ListBackups -> String
(Int -> ListBackups -> ShowS)
-> (ListBackups -> String)
-> ([ListBackups] -> ShowS)
-> Show ListBackups
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListBackups] -> ShowS
$cshowList :: [ListBackups] -> ShowS
show :: ListBackups -> String
$cshow :: ListBackups -> String
showsPrec :: Int -> ListBackups -> ShowS
$cshowsPrec :: Int -> ListBackups -> ShowS
Prelude.Show, (forall x. ListBackups -> Rep ListBackups x)
-> (forall x. Rep ListBackups x -> ListBackups)
-> Generic ListBackups
forall x. Rep ListBackups x -> ListBackups
forall x. ListBackups -> Rep ListBackups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListBackups x -> ListBackups
$cfrom :: forall x. ListBackups -> Rep ListBackups x
Prelude.Generic)

-- |
-- Create a value of 'ListBackups' 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:
--
-- 'timeRangeUpperBound', 'listBackups_timeRangeUpperBound' - Only backups created before this time are listed. @TimeRangeUpperBound@
-- is exclusive.
--
-- 'timeRangeLowerBound', 'listBackups_timeRangeLowerBound' - Only backups created after this time are listed. @TimeRangeLowerBound@
-- is inclusive.
--
-- 'limit', 'listBackups_limit' - Maximum number of backups to return at once.
--
-- 'exclusiveStartBackupArn', 'listBackups_exclusiveStartBackupArn' - @LastEvaluatedBackupArn@ is the Amazon Resource Name (ARN) of the backup
-- last evaluated when the current page of results was returned, inclusive
-- of the current page of results. This value may be specified as the
-- @ExclusiveStartBackupArn@ of a new @ListBackups@ operation in order to
-- fetch the next page of results.
--
-- 'backupType', 'listBackups_backupType' - The backups from the table specified by @BackupType@ are listed.
--
-- Where @BackupType@ can be:
--
-- -   @USER@ - On-demand backup created by you.
--
-- -   @SYSTEM@ - On-demand backup automatically created by DynamoDB.
--
-- -   @ALL@ - All types of on-demand backups (USER and SYSTEM).
--
-- 'tableName', 'listBackups_tableName' - The backups from the table specified by @TableName@ are listed.
newListBackups ::
  ListBackups
newListBackups :: ListBackups
newListBackups =
  ListBackups' :: Maybe POSIX
-> Maybe POSIX
-> Maybe Natural
-> Maybe Text
-> Maybe BackupTypeFilter
-> Maybe Text
-> ListBackups
ListBackups'
    { $sel:timeRangeUpperBound:ListBackups' :: Maybe POSIX
timeRangeUpperBound = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:timeRangeLowerBound:ListBackups' :: Maybe POSIX
timeRangeLowerBound = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:ListBackups' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:exclusiveStartBackupArn:ListBackups' :: Maybe Text
exclusiveStartBackupArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:backupType:ListBackups' :: Maybe BackupTypeFilter
backupType = Maybe BackupTypeFilter
forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:ListBackups' :: Maybe Text
tableName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Only backups created before this time are listed. @TimeRangeUpperBound@
-- is exclusive.
listBackups_timeRangeUpperBound :: Lens.Lens' ListBackups (Prelude.Maybe Prelude.UTCTime)
listBackups_timeRangeUpperBound :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListBackups -> f ListBackups
listBackups_timeRangeUpperBound = (ListBackups -> Maybe POSIX)
-> (ListBackups -> Maybe POSIX -> ListBackups)
-> Lens ListBackups ListBackups (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBackups' {Maybe POSIX
timeRangeUpperBound :: Maybe POSIX
$sel:timeRangeUpperBound:ListBackups' :: ListBackups -> Maybe POSIX
timeRangeUpperBound} -> Maybe POSIX
timeRangeUpperBound) (\s :: ListBackups
s@ListBackups' {} Maybe POSIX
a -> ListBackups
s {$sel:timeRangeUpperBound:ListBackups' :: Maybe POSIX
timeRangeUpperBound = Maybe POSIX
a} :: ListBackups) ((Maybe POSIX -> f (Maybe POSIX)) -> ListBackups -> f ListBackups)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListBackups
-> f ListBackups
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Only backups created after this time are listed. @TimeRangeLowerBound@
-- is inclusive.
listBackups_timeRangeLowerBound :: Lens.Lens' ListBackups (Prelude.Maybe Prelude.UTCTime)
listBackups_timeRangeLowerBound :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ListBackups -> f ListBackups
listBackups_timeRangeLowerBound = (ListBackups -> Maybe POSIX)
-> (ListBackups -> Maybe POSIX -> ListBackups)
-> Lens ListBackups ListBackups (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBackups' {Maybe POSIX
timeRangeLowerBound :: Maybe POSIX
$sel:timeRangeLowerBound:ListBackups' :: ListBackups -> Maybe POSIX
timeRangeLowerBound} -> Maybe POSIX
timeRangeLowerBound) (\s :: ListBackups
s@ListBackups' {} Maybe POSIX
a -> ListBackups
s {$sel:timeRangeLowerBound:ListBackups' :: Maybe POSIX
timeRangeLowerBound = Maybe POSIX
a} :: ListBackups) ((Maybe POSIX -> f (Maybe POSIX)) -> ListBackups -> f ListBackups)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ListBackups
-> f ListBackups
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Maximum number of backups to return at once.
listBackups_limit :: Lens.Lens' ListBackups (Prelude.Maybe Prelude.Natural)
listBackups_limit :: (Maybe Natural -> f (Maybe Natural))
-> ListBackups -> f ListBackups
listBackups_limit = (ListBackups -> Maybe Natural)
-> (ListBackups -> Maybe Natural -> ListBackups)
-> Lens ListBackups ListBackups (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBackups' {Maybe Natural
limit :: Maybe Natural
$sel:limit:ListBackups' :: ListBackups -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: ListBackups
s@ListBackups' {} Maybe Natural
a -> ListBackups
s {$sel:limit:ListBackups' :: Maybe Natural
limit = Maybe Natural
a} :: ListBackups)

-- | @LastEvaluatedBackupArn@ is the Amazon Resource Name (ARN) of the backup
-- last evaluated when the current page of results was returned, inclusive
-- of the current page of results. This value may be specified as the
-- @ExclusiveStartBackupArn@ of a new @ListBackups@ operation in order to
-- fetch the next page of results.
listBackups_exclusiveStartBackupArn :: Lens.Lens' ListBackups (Prelude.Maybe Prelude.Text)
listBackups_exclusiveStartBackupArn :: (Maybe Text -> f (Maybe Text)) -> ListBackups -> f ListBackups
listBackups_exclusiveStartBackupArn = (ListBackups -> Maybe Text)
-> (ListBackups -> Maybe Text -> ListBackups)
-> Lens ListBackups ListBackups (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBackups' {Maybe Text
exclusiveStartBackupArn :: Maybe Text
$sel:exclusiveStartBackupArn:ListBackups' :: ListBackups -> Maybe Text
exclusiveStartBackupArn} -> Maybe Text
exclusiveStartBackupArn) (\s :: ListBackups
s@ListBackups' {} Maybe Text
a -> ListBackups
s {$sel:exclusiveStartBackupArn:ListBackups' :: Maybe Text
exclusiveStartBackupArn = Maybe Text
a} :: ListBackups)

-- | The backups from the table specified by @BackupType@ are listed.
--
-- Where @BackupType@ can be:
--
-- -   @USER@ - On-demand backup created by you.
--
-- -   @SYSTEM@ - On-demand backup automatically created by DynamoDB.
--
-- -   @ALL@ - All types of on-demand backups (USER and SYSTEM).
listBackups_backupType :: Lens.Lens' ListBackups (Prelude.Maybe BackupTypeFilter)
listBackups_backupType :: (Maybe BackupTypeFilter -> f (Maybe BackupTypeFilter))
-> ListBackups -> f ListBackups
listBackups_backupType = (ListBackups -> Maybe BackupTypeFilter)
-> (ListBackups -> Maybe BackupTypeFilter -> ListBackups)
-> Lens
     ListBackups
     ListBackups
     (Maybe BackupTypeFilter)
     (Maybe BackupTypeFilter)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBackups' {Maybe BackupTypeFilter
backupType :: Maybe BackupTypeFilter
$sel:backupType:ListBackups' :: ListBackups -> Maybe BackupTypeFilter
backupType} -> Maybe BackupTypeFilter
backupType) (\s :: ListBackups
s@ListBackups' {} Maybe BackupTypeFilter
a -> ListBackups
s {$sel:backupType:ListBackups' :: Maybe BackupTypeFilter
backupType = Maybe BackupTypeFilter
a} :: ListBackups)

-- | The backups from the table specified by @TableName@ are listed.
listBackups_tableName :: Lens.Lens' ListBackups (Prelude.Maybe Prelude.Text)
listBackups_tableName :: (Maybe Text -> f (Maybe Text)) -> ListBackups -> f ListBackups
listBackups_tableName = (ListBackups -> Maybe Text)
-> (ListBackups -> Maybe Text -> ListBackups)
-> Lens ListBackups ListBackups (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBackups' {Maybe Text
tableName :: Maybe Text
$sel:tableName:ListBackups' :: ListBackups -> Maybe Text
tableName} -> Maybe Text
tableName) (\s :: ListBackups
s@ListBackups' {} Maybe Text
a -> ListBackups
s {$sel:tableName:ListBackups' :: Maybe Text
tableName = Maybe Text
a} :: ListBackups)

instance Core.AWSPager ListBackups where
  page :: ListBackups -> AWSResponse ListBackups -> Maybe ListBackups
page ListBackups
rq AWSResponse ListBackups
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListBackups
ListBackupsResponse
rs
            ListBackupsResponse
-> Getting (First Text) ListBackupsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListBackupsResponse -> Const (First Text) ListBackupsResponse
Lens' ListBackupsResponse (Maybe Text)
listBackupsResponse_lastEvaluatedBackupArn
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListBackupsResponse -> Const (First Text) ListBackupsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListBackupsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListBackups
forall a. Maybe a
Prelude.Nothing
    | Maybe [BackupSummary] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListBackups
ListBackupsResponse
rs
            ListBackupsResponse
-> Getting
     (First [BackupSummary]) ListBackupsResponse [BackupSummary]
-> Maybe [BackupSummary]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [BackupSummary]
 -> Const (First [BackupSummary]) (Maybe [BackupSummary]))
-> ListBackupsResponse
-> Const (First [BackupSummary]) ListBackupsResponse
Lens' ListBackupsResponse (Maybe [BackupSummary])
listBackupsResponse_backupSummaries
              ((Maybe [BackupSummary]
  -> Const (First [BackupSummary]) (Maybe [BackupSummary]))
 -> ListBackupsResponse
 -> Const (First [BackupSummary]) ListBackupsResponse)
-> (([BackupSummary]
     -> Const (First [BackupSummary]) [BackupSummary])
    -> Maybe [BackupSummary]
    -> Const (First [BackupSummary]) (Maybe [BackupSummary]))
-> Getting
     (First [BackupSummary]) ListBackupsResponse [BackupSummary]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([BackupSummary] -> Const (First [BackupSummary]) [BackupSummary])
-> Maybe [BackupSummary]
-> Const (First [BackupSummary]) (Maybe [BackupSummary])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListBackups
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListBackups -> Maybe ListBackups
forall a. a -> Maybe a
Prelude.Just (ListBackups -> Maybe ListBackups)
-> ListBackups -> Maybe ListBackups
forall a b. (a -> b) -> a -> b
Prelude.$
        ListBackups
rq
          ListBackups -> (ListBackups -> ListBackups) -> ListBackups
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListBackups -> Identity ListBackups
Lens ListBackups ListBackups (Maybe Text) (Maybe Text)
listBackups_exclusiveStartBackupArn
          ((Maybe Text -> Identity (Maybe Text))
 -> ListBackups -> Identity ListBackups)
-> Maybe Text -> ListBackups -> ListBackups
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListBackups
ListBackupsResponse
rs
          ListBackupsResponse
-> Getting (First Text) ListBackupsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListBackupsResponse -> Const (First Text) ListBackupsResponse
Lens' ListBackupsResponse (Maybe Text)
listBackupsResponse_lastEvaluatedBackupArn
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListBackupsResponse -> Const (First Text) ListBackupsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListBackupsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

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

instance Prelude.NFData ListBackups

instance Core.ToHeaders ListBackups where
  toHeaders :: ListBackups -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListBackups -> 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.ListBackups" ::
                          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 ListBackups where
  toJSON :: ListBackups -> Value
toJSON ListBackups' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe BackupTypeFilter
tableName :: Maybe Text
backupType :: Maybe BackupTypeFilter
exclusiveStartBackupArn :: Maybe Text
limit :: Maybe Natural
timeRangeLowerBound :: Maybe POSIX
timeRangeUpperBound :: Maybe POSIX
$sel:tableName:ListBackups' :: ListBackups -> Maybe Text
$sel:backupType:ListBackups' :: ListBackups -> Maybe BackupTypeFilter
$sel:exclusiveStartBackupArn:ListBackups' :: ListBackups -> Maybe Text
$sel:limit:ListBackups' :: ListBackups -> Maybe Natural
$sel:timeRangeLowerBound:ListBackups' :: ListBackups -> Maybe POSIX
$sel:timeRangeUpperBound:ListBackups' :: ListBackups -> Maybe POSIX
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TimeRangeUpperBound" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
timeRangeUpperBound,
            (Text
"TimeRangeLowerBound" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
timeRangeLowerBound,
            (Text
"Limit" 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
limit,
            (Text
"ExclusiveStartBackupArn" 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
exclusiveStartBackupArn,
            (Text
"BackupType" Text -> BackupTypeFilter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (BackupTypeFilter -> Pair) -> Maybe BackupTypeFilter -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe BackupTypeFilter
backupType,
            (Text
"TableName" 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
tableName
          ]
      )

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

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

-- | /See:/ 'newListBackupsResponse' smart constructor.
data ListBackupsResponse = ListBackupsResponse'
  { -- | List of @BackupSummary@ objects.
    ListBackupsResponse -> Maybe [BackupSummary]
backupSummaries :: Prelude.Maybe [BackupSummary],
    -- | The ARN of the backup last evaluated when the current page of results
    -- was returned, inclusive of the current page of results. This value may
    -- be specified as the @ExclusiveStartBackupArn@ of a new @ListBackups@
    -- operation in order to fetch the next page of results.
    --
    -- If @LastEvaluatedBackupArn@ is empty, then the last page of results has
    -- been processed and there are no more results to be retrieved.
    --
    -- If @LastEvaluatedBackupArn@ is not empty, this may or may not indicate
    -- that there is more data to be returned. All results are guaranteed to
    -- have been returned if and only if no value for @LastEvaluatedBackupArn@
    -- is returned.
    ListBackupsResponse -> Maybe Text
lastEvaluatedBackupArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListBackupsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListBackupsResponse -> ListBackupsResponse -> Bool
(ListBackupsResponse -> ListBackupsResponse -> Bool)
-> (ListBackupsResponse -> ListBackupsResponse -> Bool)
-> Eq ListBackupsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListBackupsResponse -> ListBackupsResponse -> Bool
$c/= :: ListBackupsResponse -> ListBackupsResponse -> Bool
== :: ListBackupsResponse -> ListBackupsResponse -> Bool
$c== :: ListBackupsResponse -> ListBackupsResponse -> Bool
Prelude.Eq, ReadPrec [ListBackupsResponse]
ReadPrec ListBackupsResponse
Int -> ReadS ListBackupsResponse
ReadS [ListBackupsResponse]
(Int -> ReadS ListBackupsResponse)
-> ReadS [ListBackupsResponse]
-> ReadPrec ListBackupsResponse
-> ReadPrec [ListBackupsResponse]
-> Read ListBackupsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListBackupsResponse]
$creadListPrec :: ReadPrec [ListBackupsResponse]
readPrec :: ReadPrec ListBackupsResponse
$creadPrec :: ReadPrec ListBackupsResponse
readList :: ReadS [ListBackupsResponse]
$creadList :: ReadS [ListBackupsResponse]
readsPrec :: Int -> ReadS ListBackupsResponse
$creadsPrec :: Int -> ReadS ListBackupsResponse
Prelude.Read, Int -> ListBackupsResponse -> ShowS
[ListBackupsResponse] -> ShowS
ListBackupsResponse -> String
(Int -> ListBackupsResponse -> ShowS)
-> (ListBackupsResponse -> String)
-> ([ListBackupsResponse] -> ShowS)
-> Show ListBackupsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListBackupsResponse] -> ShowS
$cshowList :: [ListBackupsResponse] -> ShowS
show :: ListBackupsResponse -> String
$cshow :: ListBackupsResponse -> String
showsPrec :: Int -> ListBackupsResponse -> ShowS
$cshowsPrec :: Int -> ListBackupsResponse -> ShowS
Prelude.Show, (forall x. ListBackupsResponse -> Rep ListBackupsResponse x)
-> (forall x. Rep ListBackupsResponse x -> ListBackupsResponse)
-> Generic ListBackupsResponse
forall x. Rep ListBackupsResponse x -> ListBackupsResponse
forall x. ListBackupsResponse -> Rep ListBackupsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListBackupsResponse x -> ListBackupsResponse
$cfrom :: forall x. ListBackupsResponse -> Rep ListBackupsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListBackupsResponse' 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:
--
-- 'backupSummaries', 'listBackupsResponse_backupSummaries' - List of @BackupSummary@ objects.
--
-- 'lastEvaluatedBackupArn', 'listBackupsResponse_lastEvaluatedBackupArn' - The ARN of the backup last evaluated when the current page of results
-- was returned, inclusive of the current page of results. This value may
-- be specified as the @ExclusiveStartBackupArn@ of a new @ListBackups@
-- operation in order to fetch the next page of results.
--
-- If @LastEvaluatedBackupArn@ is empty, then the last page of results has
-- been processed and there are no more results to be retrieved.
--
-- If @LastEvaluatedBackupArn@ is not empty, this may or may not indicate
-- that there is more data to be returned. All results are guaranteed to
-- have been returned if and only if no value for @LastEvaluatedBackupArn@
-- is returned.
--
-- 'httpStatus', 'listBackupsResponse_httpStatus' - The response's http status code.
newListBackupsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListBackupsResponse
newListBackupsResponse :: Int -> ListBackupsResponse
newListBackupsResponse Int
pHttpStatus_ =
  ListBackupsResponse' :: Maybe [BackupSummary] -> Maybe Text -> Int -> ListBackupsResponse
ListBackupsResponse'
    { $sel:backupSummaries:ListBackupsResponse' :: Maybe [BackupSummary]
backupSummaries =
        Maybe [BackupSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:lastEvaluatedBackupArn:ListBackupsResponse' :: Maybe Text
lastEvaluatedBackupArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListBackupsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | List of @BackupSummary@ objects.
listBackupsResponse_backupSummaries :: Lens.Lens' ListBackupsResponse (Prelude.Maybe [BackupSummary])
listBackupsResponse_backupSummaries :: (Maybe [BackupSummary] -> f (Maybe [BackupSummary]))
-> ListBackupsResponse -> f ListBackupsResponse
listBackupsResponse_backupSummaries = (ListBackupsResponse -> Maybe [BackupSummary])
-> (ListBackupsResponse
    -> Maybe [BackupSummary] -> ListBackupsResponse)
-> Lens' ListBackupsResponse (Maybe [BackupSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBackupsResponse' {Maybe [BackupSummary]
backupSummaries :: Maybe [BackupSummary]
$sel:backupSummaries:ListBackupsResponse' :: ListBackupsResponse -> Maybe [BackupSummary]
backupSummaries} -> Maybe [BackupSummary]
backupSummaries) (\s :: ListBackupsResponse
s@ListBackupsResponse' {} Maybe [BackupSummary]
a -> ListBackupsResponse
s {$sel:backupSummaries:ListBackupsResponse' :: Maybe [BackupSummary]
backupSummaries = Maybe [BackupSummary]
a} :: ListBackupsResponse) ((Maybe [BackupSummary] -> f (Maybe [BackupSummary]))
 -> ListBackupsResponse -> f ListBackupsResponse)
-> ((Maybe [BackupSummary] -> f (Maybe [BackupSummary]))
    -> Maybe [BackupSummary] -> f (Maybe [BackupSummary]))
-> (Maybe [BackupSummary] -> f (Maybe [BackupSummary]))
-> ListBackupsResponse
-> f ListBackupsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [BackupSummary] [BackupSummary] [BackupSummary] [BackupSummary]
-> Iso
     (Maybe [BackupSummary])
     (Maybe [BackupSummary])
     (Maybe [BackupSummary])
     (Maybe [BackupSummary])
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
  [BackupSummary] [BackupSummary] [BackupSummary] [BackupSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ARN of the backup last evaluated when the current page of results
-- was returned, inclusive of the current page of results. This value may
-- be specified as the @ExclusiveStartBackupArn@ of a new @ListBackups@
-- operation in order to fetch the next page of results.
--
-- If @LastEvaluatedBackupArn@ is empty, then the last page of results has
-- been processed and there are no more results to be retrieved.
--
-- If @LastEvaluatedBackupArn@ is not empty, this may or may not indicate
-- that there is more data to be returned. All results are guaranteed to
-- have been returned if and only if no value for @LastEvaluatedBackupArn@
-- is returned.
listBackupsResponse_lastEvaluatedBackupArn :: Lens.Lens' ListBackupsResponse (Prelude.Maybe Prelude.Text)
listBackupsResponse_lastEvaluatedBackupArn :: (Maybe Text -> f (Maybe Text))
-> ListBackupsResponse -> f ListBackupsResponse
listBackupsResponse_lastEvaluatedBackupArn = (ListBackupsResponse -> Maybe Text)
-> (ListBackupsResponse -> Maybe Text -> ListBackupsResponse)
-> Lens' ListBackupsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListBackupsResponse' {Maybe Text
lastEvaluatedBackupArn :: Maybe Text
$sel:lastEvaluatedBackupArn:ListBackupsResponse' :: ListBackupsResponse -> Maybe Text
lastEvaluatedBackupArn} -> Maybe Text
lastEvaluatedBackupArn) (\s :: ListBackupsResponse
s@ListBackupsResponse' {} Maybe Text
a -> ListBackupsResponse
s {$sel:lastEvaluatedBackupArn:ListBackupsResponse' :: Maybe Text
lastEvaluatedBackupArn = Maybe Text
a} :: ListBackupsResponse)

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

instance Prelude.NFData ListBackupsResponse