{-# 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.SNS.GetDataProtectionPolicy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the specified inline @DataProtectionPolicy@ document that is
-- stored in the specified Amazon SNS topic.
module Amazonka.SNS.GetDataProtectionPolicy
  ( -- * Creating a Request
    GetDataProtectionPolicy (..),
    newGetDataProtectionPolicy,

    -- * Request Lenses
    getDataProtectionPolicy_resourceArn,

    -- * Destructuring the Response
    GetDataProtectionPolicyResponse (..),
    newGetDataProtectionPolicyResponse,

    -- * Response Lenses
    getDataProtectionPolicyResponse_dataProtectionPolicy,
    getDataProtectionPolicyResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SNS.Types

-- | /See:/ 'newGetDataProtectionPolicy' smart constructor.
data GetDataProtectionPolicy = GetDataProtectionPolicy'
  { -- | The ARN of the topic whose @DataProtectionPolicy@ you want to get.
    --
    -- For more information about ARNs, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
    -- in the Amazon Web Services General Reference.
    GetDataProtectionPolicy -> Text
resourceArn :: Prelude.Text
  }
  deriving (GetDataProtectionPolicy -> GetDataProtectionPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDataProtectionPolicy -> GetDataProtectionPolicy -> Bool
$c/= :: GetDataProtectionPolicy -> GetDataProtectionPolicy -> Bool
== :: GetDataProtectionPolicy -> GetDataProtectionPolicy -> Bool
$c== :: GetDataProtectionPolicy -> GetDataProtectionPolicy -> Bool
Prelude.Eq, ReadPrec [GetDataProtectionPolicy]
ReadPrec GetDataProtectionPolicy
Int -> ReadS GetDataProtectionPolicy
ReadS [GetDataProtectionPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDataProtectionPolicy]
$creadListPrec :: ReadPrec [GetDataProtectionPolicy]
readPrec :: ReadPrec GetDataProtectionPolicy
$creadPrec :: ReadPrec GetDataProtectionPolicy
readList :: ReadS [GetDataProtectionPolicy]
$creadList :: ReadS [GetDataProtectionPolicy]
readsPrec :: Int -> ReadS GetDataProtectionPolicy
$creadsPrec :: Int -> ReadS GetDataProtectionPolicy
Prelude.Read, Int -> GetDataProtectionPolicy -> ShowS
[GetDataProtectionPolicy] -> ShowS
GetDataProtectionPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDataProtectionPolicy] -> ShowS
$cshowList :: [GetDataProtectionPolicy] -> ShowS
show :: GetDataProtectionPolicy -> String
$cshow :: GetDataProtectionPolicy -> String
showsPrec :: Int -> GetDataProtectionPolicy -> ShowS
$cshowsPrec :: Int -> GetDataProtectionPolicy -> ShowS
Prelude.Show, forall x. Rep GetDataProtectionPolicy x -> GetDataProtectionPolicy
forall x. GetDataProtectionPolicy -> Rep GetDataProtectionPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDataProtectionPolicy x -> GetDataProtectionPolicy
$cfrom :: forall x. GetDataProtectionPolicy -> Rep GetDataProtectionPolicy x
Prelude.Generic)

-- |
-- Create a value of 'GetDataProtectionPolicy' 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:
--
-- 'resourceArn', 'getDataProtectionPolicy_resourceArn' - The ARN of the topic whose @DataProtectionPolicy@ you want to get.
--
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the Amazon Web Services General Reference.
newGetDataProtectionPolicy ::
  -- | 'resourceArn'
  Prelude.Text ->
  GetDataProtectionPolicy
newGetDataProtectionPolicy :: Text -> GetDataProtectionPolicy
newGetDataProtectionPolicy Text
pResourceArn_ =
  GetDataProtectionPolicy'
    { $sel:resourceArn:GetDataProtectionPolicy' :: Text
resourceArn =
        Text
pResourceArn_
    }

-- | The ARN of the topic whose @DataProtectionPolicy@ you want to get.
--
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>
-- in the Amazon Web Services General Reference.
getDataProtectionPolicy_resourceArn :: Lens.Lens' GetDataProtectionPolicy Prelude.Text
getDataProtectionPolicy_resourceArn :: Lens' GetDataProtectionPolicy Text
getDataProtectionPolicy_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDataProtectionPolicy' {Text
resourceArn :: Text
$sel:resourceArn:GetDataProtectionPolicy' :: GetDataProtectionPolicy -> Text
resourceArn} -> Text
resourceArn) (\s :: GetDataProtectionPolicy
s@GetDataProtectionPolicy' {} Text
a -> GetDataProtectionPolicy
s {$sel:resourceArn:GetDataProtectionPolicy' :: Text
resourceArn = Text
a} :: GetDataProtectionPolicy)

instance Core.AWSRequest GetDataProtectionPolicy where
  type
    AWSResponse GetDataProtectionPolicy =
      GetDataProtectionPolicyResponse
  request :: (Service -> Service)
-> GetDataProtectionPolicy -> Request GetDataProtectionPolicy
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetDataProtectionPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDataProtectionPolicy)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"GetDataProtectionPolicyResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text -> Int -> GetDataProtectionPolicyResponse
GetDataProtectionPolicyResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"DataProtectionPolicy")
            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 GetDataProtectionPolicy where
  hashWithSalt :: Int -> GetDataProtectionPolicy -> Int
hashWithSalt Int
_salt GetDataProtectionPolicy' {Text
resourceArn :: Text
$sel:resourceArn:GetDataProtectionPolicy' :: GetDataProtectionPolicy -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceArn

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

instance Data.ToHeaders GetDataProtectionPolicy where
  toHeaders :: GetDataProtectionPolicy -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery GetDataProtectionPolicy where
  toQuery :: GetDataProtectionPolicy -> QueryString
toQuery GetDataProtectionPolicy' {Text
resourceArn :: Text
$sel:resourceArn:GetDataProtectionPolicy' :: GetDataProtectionPolicy -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"GetDataProtectionPolicy" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-03-31" :: Prelude.ByteString),
        ByteString
"ResourceArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
resourceArn
      ]

-- | /See:/ 'newGetDataProtectionPolicyResponse' smart constructor.
data GetDataProtectionPolicyResponse = GetDataProtectionPolicyResponse'
  { -- | Retrieves the @DataProtectionPolicy@ in JSON string format.
    GetDataProtectionPolicyResponse -> Maybe Text
dataProtectionPolicy :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetDataProtectionPolicyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDataProtectionPolicyResponse
-> GetDataProtectionPolicyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDataProtectionPolicyResponse
-> GetDataProtectionPolicyResponse -> Bool
$c/= :: GetDataProtectionPolicyResponse
-> GetDataProtectionPolicyResponse -> Bool
== :: GetDataProtectionPolicyResponse
-> GetDataProtectionPolicyResponse -> Bool
$c== :: GetDataProtectionPolicyResponse
-> GetDataProtectionPolicyResponse -> Bool
Prelude.Eq, ReadPrec [GetDataProtectionPolicyResponse]
ReadPrec GetDataProtectionPolicyResponse
Int -> ReadS GetDataProtectionPolicyResponse
ReadS [GetDataProtectionPolicyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDataProtectionPolicyResponse]
$creadListPrec :: ReadPrec [GetDataProtectionPolicyResponse]
readPrec :: ReadPrec GetDataProtectionPolicyResponse
$creadPrec :: ReadPrec GetDataProtectionPolicyResponse
readList :: ReadS [GetDataProtectionPolicyResponse]
$creadList :: ReadS [GetDataProtectionPolicyResponse]
readsPrec :: Int -> ReadS GetDataProtectionPolicyResponse
$creadsPrec :: Int -> ReadS GetDataProtectionPolicyResponse
Prelude.Read, Int -> GetDataProtectionPolicyResponse -> ShowS
[GetDataProtectionPolicyResponse] -> ShowS
GetDataProtectionPolicyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDataProtectionPolicyResponse] -> ShowS
$cshowList :: [GetDataProtectionPolicyResponse] -> ShowS
show :: GetDataProtectionPolicyResponse -> String
$cshow :: GetDataProtectionPolicyResponse -> String
showsPrec :: Int -> GetDataProtectionPolicyResponse -> ShowS
$cshowsPrec :: Int -> GetDataProtectionPolicyResponse -> ShowS
Prelude.Show, forall x.
Rep GetDataProtectionPolicyResponse x
-> GetDataProtectionPolicyResponse
forall x.
GetDataProtectionPolicyResponse
-> Rep GetDataProtectionPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDataProtectionPolicyResponse x
-> GetDataProtectionPolicyResponse
$cfrom :: forall x.
GetDataProtectionPolicyResponse
-> Rep GetDataProtectionPolicyResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDataProtectionPolicyResponse' 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:
--
-- 'dataProtectionPolicy', 'getDataProtectionPolicyResponse_dataProtectionPolicy' - Retrieves the @DataProtectionPolicy@ in JSON string format.
--
-- 'httpStatus', 'getDataProtectionPolicyResponse_httpStatus' - The response's http status code.
newGetDataProtectionPolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDataProtectionPolicyResponse
newGetDataProtectionPolicyResponse :: Int -> GetDataProtectionPolicyResponse
newGetDataProtectionPolicyResponse Int
pHttpStatus_ =
  GetDataProtectionPolicyResponse'
    { $sel:dataProtectionPolicy:GetDataProtectionPolicyResponse' :: Maybe Text
dataProtectionPolicy =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDataProtectionPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Retrieves the @DataProtectionPolicy@ in JSON string format.
getDataProtectionPolicyResponse_dataProtectionPolicy :: Lens.Lens' GetDataProtectionPolicyResponse (Prelude.Maybe Prelude.Text)
getDataProtectionPolicyResponse_dataProtectionPolicy :: Lens' GetDataProtectionPolicyResponse (Maybe Text)
getDataProtectionPolicyResponse_dataProtectionPolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDataProtectionPolicyResponse' {Maybe Text
dataProtectionPolicy :: Maybe Text
$sel:dataProtectionPolicy:GetDataProtectionPolicyResponse' :: GetDataProtectionPolicyResponse -> Maybe Text
dataProtectionPolicy} -> Maybe Text
dataProtectionPolicy) (\s :: GetDataProtectionPolicyResponse
s@GetDataProtectionPolicyResponse' {} Maybe Text
a -> GetDataProtectionPolicyResponse
s {$sel:dataProtectionPolicy:GetDataProtectionPolicyResponse' :: Maybe Text
dataProtectionPolicy = Maybe Text
a} :: GetDataProtectionPolicyResponse)

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

instance
  Prelude.NFData
    GetDataProtectionPolicyResponse
  where
  rnf :: GetDataProtectionPolicyResponse -> ()
rnf GetDataProtectionPolicyResponse' {Int
Maybe Text
httpStatus :: Int
dataProtectionPolicy :: Maybe Text
$sel:httpStatus:GetDataProtectionPolicyResponse' :: GetDataProtectionPolicyResponse -> Int
$sel:dataProtectionPolicy:GetDataProtectionPolicyResponse' :: GetDataProtectionPolicyResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dataProtectionPolicy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus