{-# 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.DescribeContinuousBackups
-- 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)
--
-- Checks the status of continuous backups and point in time recovery on
-- the specified table. Continuous backups are @ENABLED@ on all tables at
-- table creation. If point in time recovery is enabled,
-- @PointInTimeRecoveryStatus@ will be set to ENABLED.
--
-- After continuous backups and point in time recovery are enabled, you can
-- restore to any point in time within @EarliestRestorableDateTime@ and
-- @LatestRestorableDateTime@.
--
-- @LatestRestorableDateTime@ is typically 5 minutes before the current
-- time. You can restore your table to any point in time during the last 35
-- days.
--
-- You can call @DescribeContinuousBackups@ at a maximum rate of 10 times
-- per second.
module Amazonka.DynamoDB.DescribeContinuousBackups
  ( -- * Creating a Request
    DescribeContinuousBackups (..),
    newDescribeContinuousBackups,

    -- * Request Lenses
    describeContinuousBackups_tableName,

    -- * Destructuring the Response
    DescribeContinuousBackupsResponse (..),
    newDescribeContinuousBackupsResponse,

    -- * Response Lenses
    describeContinuousBackupsResponse_continuousBackupsDescription,
    describeContinuousBackupsResponse_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:/ 'newDescribeContinuousBackups' smart constructor.
data DescribeContinuousBackups = DescribeContinuousBackups'
  { -- | Name of the table for which the customer wants to check the continuous
    -- backups and point in time recovery settings.
    DescribeContinuousBackups -> Text
tableName :: Prelude.Text
  }
  deriving (DescribeContinuousBackups -> DescribeContinuousBackups -> Bool
(DescribeContinuousBackups -> DescribeContinuousBackups -> Bool)
-> (DescribeContinuousBackups -> DescribeContinuousBackups -> Bool)
-> Eq DescribeContinuousBackups
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeContinuousBackups -> DescribeContinuousBackups -> Bool
$c/= :: DescribeContinuousBackups -> DescribeContinuousBackups -> Bool
== :: DescribeContinuousBackups -> DescribeContinuousBackups -> Bool
$c== :: DescribeContinuousBackups -> DescribeContinuousBackups -> Bool
Prelude.Eq, ReadPrec [DescribeContinuousBackups]
ReadPrec DescribeContinuousBackups
Int -> ReadS DescribeContinuousBackups
ReadS [DescribeContinuousBackups]
(Int -> ReadS DescribeContinuousBackups)
-> ReadS [DescribeContinuousBackups]
-> ReadPrec DescribeContinuousBackups
-> ReadPrec [DescribeContinuousBackups]
-> Read DescribeContinuousBackups
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeContinuousBackups]
$creadListPrec :: ReadPrec [DescribeContinuousBackups]
readPrec :: ReadPrec DescribeContinuousBackups
$creadPrec :: ReadPrec DescribeContinuousBackups
readList :: ReadS [DescribeContinuousBackups]
$creadList :: ReadS [DescribeContinuousBackups]
readsPrec :: Int -> ReadS DescribeContinuousBackups
$creadsPrec :: Int -> ReadS DescribeContinuousBackups
Prelude.Read, Int -> DescribeContinuousBackups -> ShowS
[DescribeContinuousBackups] -> ShowS
DescribeContinuousBackups -> String
(Int -> DescribeContinuousBackups -> ShowS)
-> (DescribeContinuousBackups -> String)
-> ([DescribeContinuousBackups] -> ShowS)
-> Show DescribeContinuousBackups
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeContinuousBackups] -> ShowS
$cshowList :: [DescribeContinuousBackups] -> ShowS
show :: DescribeContinuousBackups -> String
$cshow :: DescribeContinuousBackups -> String
showsPrec :: Int -> DescribeContinuousBackups -> ShowS
$cshowsPrec :: Int -> DescribeContinuousBackups -> ShowS
Prelude.Show, (forall x.
 DescribeContinuousBackups -> Rep DescribeContinuousBackups x)
-> (forall x.
    Rep DescribeContinuousBackups x -> DescribeContinuousBackups)
-> Generic DescribeContinuousBackups
forall x.
Rep DescribeContinuousBackups x -> DescribeContinuousBackups
forall x.
DescribeContinuousBackups -> Rep DescribeContinuousBackups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeContinuousBackups x -> DescribeContinuousBackups
$cfrom :: forall x.
DescribeContinuousBackups -> Rep DescribeContinuousBackups x
Prelude.Generic)

-- |
-- Create a value of 'DescribeContinuousBackups' 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:
--
-- 'tableName', 'describeContinuousBackups_tableName' - Name of the table for which the customer wants to check the continuous
-- backups and point in time recovery settings.
newDescribeContinuousBackups ::
  -- | 'tableName'
  Prelude.Text ->
  DescribeContinuousBackups
newDescribeContinuousBackups :: Text -> DescribeContinuousBackups
newDescribeContinuousBackups Text
pTableName_ =
  DescribeContinuousBackups' :: Text -> DescribeContinuousBackups
DescribeContinuousBackups' {$sel:tableName:DescribeContinuousBackups' :: Text
tableName = Text
pTableName_}

-- | Name of the table for which the customer wants to check the continuous
-- backups and point in time recovery settings.
describeContinuousBackups_tableName :: Lens.Lens' DescribeContinuousBackups Prelude.Text
describeContinuousBackups_tableName :: (Text -> f Text)
-> DescribeContinuousBackups -> f DescribeContinuousBackups
describeContinuousBackups_tableName = (DescribeContinuousBackups -> Text)
-> (DescribeContinuousBackups -> Text -> DescribeContinuousBackups)
-> Lens
     DescribeContinuousBackups DescribeContinuousBackups Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeContinuousBackups' {Text
tableName :: Text
$sel:tableName:DescribeContinuousBackups' :: DescribeContinuousBackups -> Text
tableName} -> Text
tableName) (\s :: DescribeContinuousBackups
s@DescribeContinuousBackups' {} Text
a -> DescribeContinuousBackups
s {$sel:tableName:DescribeContinuousBackups' :: Text
tableName = Text
a} :: DescribeContinuousBackups)

instance Core.AWSRequest DescribeContinuousBackups where
  type
    AWSResponse DescribeContinuousBackups =
      DescribeContinuousBackupsResponse
  request :: DescribeContinuousBackups -> Request DescribeContinuousBackups
request = Service
-> DescribeContinuousBackups -> Request DescribeContinuousBackups
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeContinuousBackups
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeContinuousBackups)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeContinuousBackups))
-> Logger
-> Service
-> Proxy DescribeContinuousBackups
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeContinuousBackups)))
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 ContinuousBackupsDescription
-> Int -> DescribeContinuousBackupsResponse
DescribeContinuousBackupsResponse'
            (Maybe ContinuousBackupsDescription
 -> Int -> DescribeContinuousBackupsResponse)
-> Either String (Maybe ContinuousBackupsDescription)
-> Either String (Int -> DescribeContinuousBackupsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Either String (Maybe ContinuousBackupsDescription)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ContinuousBackupsDescription")
            Either String (Int -> DescribeContinuousBackupsResponse)
-> Either String Int
-> Either String DescribeContinuousBackupsResponse
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 DescribeContinuousBackups

instance Prelude.NFData DescribeContinuousBackups

instance Core.ToHeaders DescribeContinuousBackups where
  toHeaders :: DescribeContinuousBackups -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeContinuousBackups -> 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.DescribeContinuousBackups" ::
                          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 DescribeContinuousBackups where
  toJSON :: DescribeContinuousBackups -> Value
toJSON DescribeContinuousBackups' {Text
tableName :: Text
$sel:tableName:DescribeContinuousBackups' :: DescribeContinuousBackups -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TableName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
tableName)]
      )

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

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

-- | /See:/ 'newDescribeContinuousBackupsResponse' smart constructor.
data DescribeContinuousBackupsResponse = DescribeContinuousBackupsResponse'
  { -- | Represents the continuous backups and point in time recovery settings on
    -- the table.
    DescribeContinuousBackupsResponse
-> Maybe ContinuousBackupsDescription
continuousBackupsDescription :: Prelude.Maybe ContinuousBackupsDescription,
    -- | The response's http status code.
    DescribeContinuousBackupsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeContinuousBackupsResponse
-> DescribeContinuousBackupsResponse -> Bool
(DescribeContinuousBackupsResponse
 -> DescribeContinuousBackupsResponse -> Bool)
-> (DescribeContinuousBackupsResponse
    -> DescribeContinuousBackupsResponse -> Bool)
-> Eq DescribeContinuousBackupsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeContinuousBackupsResponse
-> DescribeContinuousBackupsResponse -> Bool
$c/= :: DescribeContinuousBackupsResponse
-> DescribeContinuousBackupsResponse -> Bool
== :: DescribeContinuousBackupsResponse
-> DescribeContinuousBackupsResponse -> Bool
$c== :: DescribeContinuousBackupsResponse
-> DescribeContinuousBackupsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeContinuousBackupsResponse]
ReadPrec DescribeContinuousBackupsResponse
Int -> ReadS DescribeContinuousBackupsResponse
ReadS [DescribeContinuousBackupsResponse]
(Int -> ReadS DescribeContinuousBackupsResponse)
-> ReadS [DescribeContinuousBackupsResponse]
-> ReadPrec DescribeContinuousBackupsResponse
-> ReadPrec [DescribeContinuousBackupsResponse]
-> Read DescribeContinuousBackupsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeContinuousBackupsResponse]
$creadListPrec :: ReadPrec [DescribeContinuousBackupsResponse]
readPrec :: ReadPrec DescribeContinuousBackupsResponse
$creadPrec :: ReadPrec DescribeContinuousBackupsResponse
readList :: ReadS [DescribeContinuousBackupsResponse]
$creadList :: ReadS [DescribeContinuousBackupsResponse]
readsPrec :: Int -> ReadS DescribeContinuousBackupsResponse
$creadsPrec :: Int -> ReadS DescribeContinuousBackupsResponse
Prelude.Read, Int -> DescribeContinuousBackupsResponse -> ShowS
[DescribeContinuousBackupsResponse] -> ShowS
DescribeContinuousBackupsResponse -> String
(Int -> DescribeContinuousBackupsResponse -> ShowS)
-> (DescribeContinuousBackupsResponse -> String)
-> ([DescribeContinuousBackupsResponse] -> ShowS)
-> Show DescribeContinuousBackupsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeContinuousBackupsResponse] -> ShowS
$cshowList :: [DescribeContinuousBackupsResponse] -> ShowS
show :: DescribeContinuousBackupsResponse -> String
$cshow :: DescribeContinuousBackupsResponse -> String
showsPrec :: Int -> DescribeContinuousBackupsResponse -> ShowS
$cshowsPrec :: Int -> DescribeContinuousBackupsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeContinuousBackupsResponse
 -> Rep DescribeContinuousBackupsResponse x)
-> (forall x.
    Rep DescribeContinuousBackupsResponse x
    -> DescribeContinuousBackupsResponse)
-> Generic DescribeContinuousBackupsResponse
forall x.
Rep DescribeContinuousBackupsResponse x
-> DescribeContinuousBackupsResponse
forall x.
DescribeContinuousBackupsResponse
-> Rep DescribeContinuousBackupsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeContinuousBackupsResponse x
-> DescribeContinuousBackupsResponse
$cfrom :: forall x.
DescribeContinuousBackupsResponse
-> Rep DescribeContinuousBackupsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeContinuousBackupsResponse' 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:
--
-- 'continuousBackupsDescription', 'describeContinuousBackupsResponse_continuousBackupsDescription' - Represents the continuous backups and point in time recovery settings on
-- the table.
--
-- 'httpStatus', 'describeContinuousBackupsResponse_httpStatus' - The response's http status code.
newDescribeContinuousBackupsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeContinuousBackupsResponse
newDescribeContinuousBackupsResponse :: Int -> DescribeContinuousBackupsResponse
newDescribeContinuousBackupsResponse Int
pHttpStatus_ =
  DescribeContinuousBackupsResponse' :: Maybe ContinuousBackupsDescription
-> Int -> DescribeContinuousBackupsResponse
DescribeContinuousBackupsResponse'
    { $sel:continuousBackupsDescription:DescribeContinuousBackupsResponse' :: Maybe ContinuousBackupsDescription
continuousBackupsDescription =
        Maybe ContinuousBackupsDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeContinuousBackupsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Represents the continuous backups and point in time recovery settings on
-- the table.
describeContinuousBackupsResponse_continuousBackupsDescription :: Lens.Lens' DescribeContinuousBackupsResponse (Prelude.Maybe ContinuousBackupsDescription)
describeContinuousBackupsResponse_continuousBackupsDescription :: (Maybe ContinuousBackupsDescription
 -> f (Maybe ContinuousBackupsDescription))
-> DescribeContinuousBackupsResponse
-> f DescribeContinuousBackupsResponse
describeContinuousBackupsResponse_continuousBackupsDescription = (DescribeContinuousBackupsResponse
 -> Maybe ContinuousBackupsDescription)
-> (DescribeContinuousBackupsResponse
    -> Maybe ContinuousBackupsDescription
    -> DescribeContinuousBackupsResponse)
-> Lens
     DescribeContinuousBackupsResponse
     DescribeContinuousBackupsResponse
     (Maybe ContinuousBackupsDescription)
     (Maybe ContinuousBackupsDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeContinuousBackupsResponse' {Maybe ContinuousBackupsDescription
continuousBackupsDescription :: Maybe ContinuousBackupsDescription
$sel:continuousBackupsDescription:DescribeContinuousBackupsResponse' :: DescribeContinuousBackupsResponse
-> Maybe ContinuousBackupsDescription
continuousBackupsDescription} -> Maybe ContinuousBackupsDescription
continuousBackupsDescription) (\s :: DescribeContinuousBackupsResponse
s@DescribeContinuousBackupsResponse' {} Maybe ContinuousBackupsDescription
a -> DescribeContinuousBackupsResponse
s {$sel:continuousBackupsDescription:DescribeContinuousBackupsResponse' :: Maybe ContinuousBackupsDescription
continuousBackupsDescription = Maybe ContinuousBackupsDescription
a} :: DescribeContinuousBackupsResponse)

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

instance
  Prelude.NFData
    DescribeContinuousBackupsResponse