{-# 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.DescribeBackup
-- 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)
--
-- Describes an existing backup of a table.
--
-- You can call @DescribeBackup@ at a maximum rate of 10 times per second.
module Amazonka.DynamoDB.DescribeBackup
  ( -- * Creating a Request
    DescribeBackup (..),
    newDescribeBackup,

    -- * Request Lenses
    describeBackup_backupArn,

    -- * Destructuring the Response
    DescribeBackupResponse (..),
    newDescribeBackupResponse,

    -- * Response Lenses
    describeBackupResponse_backupDescription,
    describeBackupResponse_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:/ 'newDescribeBackup' smart constructor.
data DescribeBackup = DescribeBackup'
  { -- | The Amazon Resource Name (ARN) associated with the backup.
    DescribeBackup -> Text
backupArn :: Prelude.Text
  }
  deriving (DescribeBackup -> DescribeBackup -> Bool
(DescribeBackup -> DescribeBackup -> Bool)
-> (DescribeBackup -> DescribeBackup -> Bool) -> Eq DescribeBackup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeBackup -> DescribeBackup -> Bool
$c/= :: DescribeBackup -> DescribeBackup -> Bool
== :: DescribeBackup -> DescribeBackup -> Bool
$c== :: DescribeBackup -> DescribeBackup -> Bool
Prelude.Eq, ReadPrec [DescribeBackup]
ReadPrec DescribeBackup
Int -> ReadS DescribeBackup
ReadS [DescribeBackup]
(Int -> ReadS DescribeBackup)
-> ReadS [DescribeBackup]
-> ReadPrec DescribeBackup
-> ReadPrec [DescribeBackup]
-> Read DescribeBackup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeBackup]
$creadListPrec :: ReadPrec [DescribeBackup]
readPrec :: ReadPrec DescribeBackup
$creadPrec :: ReadPrec DescribeBackup
readList :: ReadS [DescribeBackup]
$creadList :: ReadS [DescribeBackup]
readsPrec :: Int -> ReadS DescribeBackup
$creadsPrec :: Int -> ReadS DescribeBackup
Prelude.Read, Int -> DescribeBackup -> ShowS
[DescribeBackup] -> ShowS
DescribeBackup -> String
(Int -> DescribeBackup -> ShowS)
-> (DescribeBackup -> String)
-> ([DescribeBackup] -> ShowS)
-> Show DescribeBackup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeBackup] -> ShowS
$cshowList :: [DescribeBackup] -> ShowS
show :: DescribeBackup -> String
$cshow :: DescribeBackup -> String
showsPrec :: Int -> DescribeBackup -> ShowS
$cshowsPrec :: Int -> DescribeBackup -> ShowS
Prelude.Show, (forall x. DescribeBackup -> Rep DescribeBackup x)
-> (forall x. Rep DescribeBackup x -> DescribeBackup)
-> Generic DescribeBackup
forall x. Rep DescribeBackup x -> DescribeBackup
forall x. DescribeBackup -> Rep DescribeBackup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeBackup x -> DescribeBackup
$cfrom :: forall x. DescribeBackup -> Rep DescribeBackup x
Prelude.Generic)

-- |
-- Create a value of 'DescribeBackup' 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:
--
-- 'backupArn', 'describeBackup_backupArn' - The Amazon Resource Name (ARN) associated with the backup.
newDescribeBackup ::
  -- | 'backupArn'
  Prelude.Text ->
  DescribeBackup
newDescribeBackup :: Text -> DescribeBackup
newDescribeBackup Text
pBackupArn_ =
  DescribeBackup' :: Text -> DescribeBackup
DescribeBackup' {$sel:backupArn:DescribeBackup' :: Text
backupArn = Text
pBackupArn_}

-- | The Amazon Resource Name (ARN) associated with the backup.
describeBackup_backupArn :: Lens.Lens' DescribeBackup Prelude.Text
describeBackup_backupArn :: (Text -> f Text) -> DescribeBackup -> f DescribeBackup
describeBackup_backupArn = (DescribeBackup -> Text)
-> (DescribeBackup -> Text -> DescribeBackup)
-> Lens DescribeBackup DescribeBackup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBackup' {Text
backupArn :: Text
$sel:backupArn:DescribeBackup' :: DescribeBackup -> Text
backupArn} -> Text
backupArn) (\s :: DescribeBackup
s@DescribeBackup' {} Text
a -> DescribeBackup
s {$sel:backupArn:DescribeBackup' :: Text
backupArn = Text
a} :: DescribeBackup)

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

instance Prelude.NFData DescribeBackup

instance Core.ToHeaders DescribeBackup where
  toHeaders :: DescribeBackup -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeBackup -> 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.DescribeBackup" ::
                          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 DescribeBackup where
  toJSON :: DescribeBackup -> Value
toJSON DescribeBackup' {Text
backupArn :: Text
$sel:backupArn:DescribeBackup' :: DescribeBackup -> 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
"BackupArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
backupArn)]
      )

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

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

-- | /See:/ 'newDescribeBackupResponse' smart constructor.
data DescribeBackupResponse = DescribeBackupResponse'
  { -- | Contains the description of the backup created for the table.
    DescribeBackupResponse -> Maybe BackupDescription
backupDescription :: Prelude.Maybe BackupDescription,
    -- | The response's http status code.
    DescribeBackupResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeBackupResponse -> DescribeBackupResponse -> Bool
(DescribeBackupResponse -> DescribeBackupResponse -> Bool)
-> (DescribeBackupResponse -> DescribeBackupResponse -> Bool)
-> Eq DescribeBackupResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeBackupResponse -> DescribeBackupResponse -> Bool
$c/= :: DescribeBackupResponse -> DescribeBackupResponse -> Bool
== :: DescribeBackupResponse -> DescribeBackupResponse -> Bool
$c== :: DescribeBackupResponse -> DescribeBackupResponse -> Bool
Prelude.Eq, ReadPrec [DescribeBackupResponse]
ReadPrec DescribeBackupResponse
Int -> ReadS DescribeBackupResponse
ReadS [DescribeBackupResponse]
(Int -> ReadS DescribeBackupResponse)
-> ReadS [DescribeBackupResponse]
-> ReadPrec DescribeBackupResponse
-> ReadPrec [DescribeBackupResponse]
-> Read DescribeBackupResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeBackupResponse]
$creadListPrec :: ReadPrec [DescribeBackupResponse]
readPrec :: ReadPrec DescribeBackupResponse
$creadPrec :: ReadPrec DescribeBackupResponse
readList :: ReadS [DescribeBackupResponse]
$creadList :: ReadS [DescribeBackupResponse]
readsPrec :: Int -> ReadS DescribeBackupResponse
$creadsPrec :: Int -> ReadS DescribeBackupResponse
Prelude.Read, Int -> DescribeBackupResponse -> ShowS
[DescribeBackupResponse] -> ShowS
DescribeBackupResponse -> String
(Int -> DescribeBackupResponse -> ShowS)
-> (DescribeBackupResponse -> String)
-> ([DescribeBackupResponse] -> ShowS)
-> Show DescribeBackupResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeBackupResponse] -> ShowS
$cshowList :: [DescribeBackupResponse] -> ShowS
show :: DescribeBackupResponse -> String
$cshow :: DescribeBackupResponse -> String
showsPrec :: Int -> DescribeBackupResponse -> ShowS
$cshowsPrec :: Int -> DescribeBackupResponse -> ShowS
Prelude.Show, (forall x. DescribeBackupResponse -> Rep DescribeBackupResponse x)
-> (forall x.
    Rep DescribeBackupResponse x -> DescribeBackupResponse)
-> Generic DescribeBackupResponse
forall x. Rep DescribeBackupResponse x -> DescribeBackupResponse
forall x. DescribeBackupResponse -> Rep DescribeBackupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeBackupResponse x -> DescribeBackupResponse
$cfrom :: forall x. DescribeBackupResponse -> Rep DescribeBackupResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeBackupResponse' 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:
--
-- 'backupDescription', 'describeBackupResponse_backupDescription' - Contains the description of the backup created for the table.
--
-- 'httpStatus', 'describeBackupResponse_httpStatus' - The response's http status code.
newDescribeBackupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeBackupResponse
newDescribeBackupResponse :: Int -> DescribeBackupResponse
newDescribeBackupResponse Int
pHttpStatus_ =
  DescribeBackupResponse' :: Maybe BackupDescription -> Int -> DescribeBackupResponse
DescribeBackupResponse'
    { $sel:backupDescription:DescribeBackupResponse' :: Maybe BackupDescription
backupDescription =
        Maybe BackupDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeBackupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Contains the description of the backup created for the table.
describeBackupResponse_backupDescription :: Lens.Lens' DescribeBackupResponse (Prelude.Maybe BackupDescription)
describeBackupResponse_backupDescription :: (Maybe BackupDescription -> f (Maybe BackupDescription))
-> DescribeBackupResponse -> f DescribeBackupResponse
describeBackupResponse_backupDescription = (DescribeBackupResponse -> Maybe BackupDescription)
-> (DescribeBackupResponse
    -> Maybe BackupDescription -> DescribeBackupResponse)
-> Lens
     DescribeBackupResponse
     DescribeBackupResponse
     (Maybe BackupDescription)
     (Maybe BackupDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBackupResponse' {Maybe BackupDescription
backupDescription :: Maybe BackupDescription
$sel:backupDescription:DescribeBackupResponse' :: DescribeBackupResponse -> Maybe BackupDescription
backupDescription} -> Maybe BackupDescription
backupDescription) (\s :: DescribeBackupResponse
s@DescribeBackupResponse' {} Maybe BackupDescription
a -> DescribeBackupResponse
s {$sel:backupDescription:DescribeBackupResponse' :: Maybe BackupDescription
backupDescription = Maybe BackupDescription
a} :: DescribeBackupResponse)

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

instance Prelude.NFData DescribeBackupResponse