{-# 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
(GetDataProtectionPolicy -> GetDataProtectionPolicy -> Bool)
-> (GetDataProtectionPolicy -> GetDataProtectionPolicy -> Bool)
-> Eq GetDataProtectionPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetDataProtectionPolicy -> GetDataProtectionPolicy -> Bool
== :: GetDataProtectionPolicy -> GetDataProtectionPolicy -> Bool
$c/= :: GetDataProtectionPolicy -> GetDataProtectionPolicy -> Bool
/= :: GetDataProtectionPolicy -> GetDataProtectionPolicy -> Bool
Prelude.Eq, ReadPrec [GetDataProtectionPolicy]
ReadPrec GetDataProtectionPolicy
Int -> ReadS GetDataProtectionPolicy
ReadS [GetDataProtectionPolicy]
(Int -> ReadS GetDataProtectionPolicy)
-> ReadS [GetDataProtectionPolicy]
-> ReadPrec GetDataProtectionPolicy
-> ReadPrec [GetDataProtectionPolicy]
-> Read GetDataProtectionPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS GetDataProtectionPolicy
readsPrec :: Int -> ReadS GetDataProtectionPolicy
$creadList :: ReadS [GetDataProtectionPolicy]
readList :: ReadS [GetDataProtectionPolicy]
$creadPrec :: ReadPrec GetDataProtectionPolicy
readPrec :: ReadPrec GetDataProtectionPolicy
$creadListPrec :: ReadPrec [GetDataProtectionPolicy]
readListPrec :: ReadPrec [GetDataProtectionPolicy]
Prelude.Read, Int -> GetDataProtectionPolicy -> ShowS
[GetDataProtectionPolicy] -> ShowS
GetDataProtectionPolicy -> String
(Int -> GetDataProtectionPolicy -> ShowS)
-> (GetDataProtectionPolicy -> String)
-> ([GetDataProtectionPolicy] -> ShowS)
-> Show GetDataProtectionPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetDataProtectionPolicy -> ShowS
showsPrec :: Int -> GetDataProtectionPolicy -> ShowS
$cshow :: GetDataProtectionPolicy -> String
show :: GetDataProtectionPolicy -> String
$cshowList :: [GetDataProtectionPolicy] -> ShowS
showList :: [GetDataProtectionPolicy] -> ShowS
Prelude.Show, (forall x.
 GetDataProtectionPolicy -> Rep GetDataProtectionPolicy x)
-> (forall x.
    Rep GetDataProtectionPolicy x -> GetDataProtectionPolicy)
-> Generic GetDataProtectionPolicy
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
$cfrom :: forall x. GetDataProtectionPolicy -> Rep GetDataProtectionPolicy x
from :: forall x. GetDataProtectionPolicy -> Rep GetDataProtectionPolicy x
$cto :: forall x. Rep GetDataProtectionPolicy x -> GetDataProtectionPolicy
to :: forall x. Rep GetDataProtectionPolicy x -> GetDataProtectionPolicy
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'
    { resourceArn :: 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 = (GetDataProtectionPolicy -> Text)
-> (GetDataProtectionPolicy -> Text -> GetDataProtectionPolicy)
-> Lens' GetDataProtectionPolicy Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDataProtectionPolicy' {Text
resourceArn :: GetDataProtectionPolicy -> Text
resourceArn :: Text
resourceArn} -> Text
resourceArn) (\s :: GetDataProtectionPolicy
s@GetDataProtectionPolicy' {} Text
a -> GetDataProtectionPolicy
s {resourceArn = a} :: GetDataProtectionPolicy)

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

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

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

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

instance Data.ToQuery GetDataProtectionPolicy where
  toQuery :: GetDataProtectionPolicy -> QueryString
toQuery GetDataProtectionPolicy' {Text
resourceArn :: GetDataProtectionPolicy -> Text
resourceArn :: Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"GetDataProtectionPolicy" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-03-31" :: Prelude.ByteString),
        ByteString
"ResourceArn" ByteString -> Text -> QueryString
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
(GetDataProtectionPolicyResponse
 -> GetDataProtectionPolicyResponse -> Bool)
-> (GetDataProtectionPolicyResponse
    -> GetDataProtectionPolicyResponse -> Bool)
-> Eq GetDataProtectionPolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetDataProtectionPolicyResponse
-> GetDataProtectionPolicyResponse -> Bool
== :: GetDataProtectionPolicyResponse
-> GetDataProtectionPolicyResponse -> Bool
$c/= :: GetDataProtectionPolicyResponse
-> GetDataProtectionPolicyResponse -> Bool
/= :: GetDataProtectionPolicyResponse
-> GetDataProtectionPolicyResponse -> Bool
Prelude.Eq, ReadPrec [GetDataProtectionPolicyResponse]
ReadPrec GetDataProtectionPolicyResponse
Int -> ReadS GetDataProtectionPolicyResponse
ReadS [GetDataProtectionPolicyResponse]
(Int -> ReadS GetDataProtectionPolicyResponse)
-> ReadS [GetDataProtectionPolicyResponse]
-> ReadPrec GetDataProtectionPolicyResponse
-> ReadPrec [GetDataProtectionPolicyResponse]
-> Read GetDataProtectionPolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS GetDataProtectionPolicyResponse
readsPrec :: Int -> ReadS GetDataProtectionPolicyResponse
$creadList :: ReadS [GetDataProtectionPolicyResponse]
readList :: ReadS [GetDataProtectionPolicyResponse]
$creadPrec :: ReadPrec GetDataProtectionPolicyResponse
readPrec :: ReadPrec GetDataProtectionPolicyResponse
$creadListPrec :: ReadPrec [GetDataProtectionPolicyResponse]
readListPrec :: ReadPrec [GetDataProtectionPolicyResponse]
Prelude.Read, Int -> GetDataProtectionPolicyResponse -> ShowS
[GetDataProtectionPolicyResponse] -> ShowS
GetDataProtectionPolicyResponse -> String
(Int -> GetDataProtectionPolicyResponse -> ShowS)
-> (GetDataProtectionPolicyResponse -> String)
-> ([GetDataProtectionPolicyResponse] -> ShowS)
-> Show GetDataProtectionPolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetDataProtectionPolicyResponse -> ShowS
showsPrec :: Int -> GetDataProtectionPolicyResponse -> ShowS
$cshow :: GetDataProtectionPolicyResponse -> String
show :: GetDataProtectionPolicyResponse -> String
$cshowList :: [GetDataProtectionPolicyResponse] -> ShowS
showList :: [GetDataProtectionPolicyResponse] -> ShowS
Prelude.Show, (forall x.
 GetDataProtectionPolicyResponse
 -> Rep GetDataProtectionPolicyResponse x)
-> (forall x.
    Rep GetDataProtectionPolicyResponse x
    -> GetDataProtectionPolicyResponse)
-> Generic GetDataProtectionPolicyResponse
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
$cfrom :: forall x.
GetDataProtectionPolicyResponse
-> Rep GetDataProtectionPolicyResponse x
from :: forall x.
GetDataProtectionPolicyResponse
-> Rep GetDataProtectionPolicyResponse x
$cto :: forall x.
Rep GetDataProtectionPolicyResponse x
-> GetDataProtectionPolicyResponse
to :: forall x.
Rep GetDataProtectionPolicyResponse x
-> GetDataProtectionPolicyResponse
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'
    { dataProtectionPolicy :: Maybe Text
dataProtectionPolicy =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      httpStatus :: 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 = (GetDataProtectionPolicyResponse -> Maybe Text)
-> (GetDataProtectionPolicyResponse
    -> Maybe Text -> GetDataProtectionPolicyResponse)
-> Lens' GetDataProtectionPolicyResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDataProtectionPolicyResponse' {Maybe Text
dataProtectionPolicy :: GetDataProtectionPolicyResponse -> Maybe Text
dataProtectionPolicy :: Maybe Text
dataProtectionPolicy} -> Maybe Text
dataProtectionPolicy) (\s :: GetDataProtectionPolicyResponse
s@GetDataProtectionPolicyResponse' {} Maybe Text
a -> GetDataProtectionPolicyResponse
s {dataProtectionPolicy = a} :: GetDataProtectionPolicyResponse)

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

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