{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DynamoDB.Types
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
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]
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
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. 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' {$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 :: Lens' DescribeBackup Text
describeBackup_backupArn = 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 :: (Service -> Service) -> DescribeBackup -> Request DescribeBackup
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeBackup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeBackup)))
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 BackupDescription -> Int -> DescribeBackupResponse
DescribeBackupResponse'
            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
"BackupDescription")
            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 DescribeBackup where
  hashWithSalt :: Int -> DescribeBackup -> Int
hashWithSalt Int
_salt DescribeBackup' {Text
backupArn :: Text
$sel:backupArn:DescribeBackup' :: DescribeBackup -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
backupArn

instance Prelude.NFData DescribeBackup where
  rnf :: DescribeBackup -> ()
rnf DescribeBackup' {Text
backupArn :: Text
$sel:backupArn:DescribeBackup' :: DescribeBackup -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
backupArn

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

instance Data.ToJSON DescribeBackup where
  toJSON :: DescribeBackup -> Value
toJSON DescribeBackup' {Text
backupArn :: Text
$sel:backupArn:DescribeBackup' :: DescribeBackup -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"BackupArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
backupArn)]
      )

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

instance Data.ToQuery DescribeBackup where
  toQuery :: DescribeBackup -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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'
    { $sel:backupDescription:DescribeBackupResponse' :: Maybe BackupDescription
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 :: Lens' DescribeBackupResponse (Maybe BackupDescription)
describeBackupResponse_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 :: Lens' DescribeBackupResponse Int
describeBackupResponse_httpStatus = 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 where
  rnf :: DescribeBackupResponse -> ()
rnf DescribeBackupResponse' {Int
Maybe BackupDescription
httpStatus :: Int
backupDescription :: Maybe BackupDescription
$sel:httpStatus:DescribeBackupResponse' :: DescribeBackupResponse -> Int
$sel:backupDescription:DescribeBackupResponse' :: DescribeBackupResponse -> Maybe BackupDescription
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe BackupDescription
backupDescription
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus