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

    -- * Request Lenses
    putDataProtectionPolicy_resourceArn,
    putDataProtectionPolicy_dataProtectionPolicy,

    -- * Destructuring the Response
    PutDataProtectionPolicyResponse (..),
    newPutDataProtectionPolicyResponse,
  )
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:/ 'newPutDataProtectionPolicy' smart constructor.
data PutDataProtectionPolicy = PutDataProtectionPolicy'
  { -- | The ARN of the topic whose @DataProtectionPolicy@ you want to add or
    -- update.
    --
    -- 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.
    PutDataProtectionPolicy -> Text
resourceArn :: Prelude.Text,
    -- | The JSON serialization of the topic\'s @DataProtectionPolicy@.
    --
    -- The @DataProtectionPolicy@ must be in JSON string format.
    --
    -- Length Constraints: Maximum length of 30,720.
    PutDataProtectionPolicy -> Text
dataProtectionPolicy :: Prelude.Text
  }
  deriving (PutDataProtectionPolicy -> PutDataProtectionPolicy -> Bool
(PutDataProtectionPolicy -> PutDataProtectionPolicy -> Bool)
-> (PutDataProtectionPolicy -> PutDataProtectionPolicy -> Bool)
-> Eq PutDataProtectionPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PutDataProtectionPolicy -> PutDataProtectionPolicy -> Bool
== :: PutDataProtectionPolicy -> PutDataProtectionPolicy -> Bool
$c/= :: PutDataProtectionPolicy -> PutDataProtectionPolicy -> Bool
/= :: PutDataProtectionPolicy -> PutDataProtectionPolicy -> Bool
Prelude.Eq, ReadPrec [PutDataProtectionPolicy]
ReadPrec PutDataProtectionPolicy
Int -> ReadS PutDataProtectionPolicy
ReadS [PutDataProtectionPolicy]
(Int -> ReadS PutDataProtectionPolicy)
-> ReadS [PutDataProtectionPolicy]
-> ReadPrec PutDataProtectionPolicy
-> ReadPrec [PutDataProtectionPolicy]
-> Read PutDataProtectionPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS PutDataProtectionPolicy
readsPrec :: Int -> ReadS PutDataProtectionPolicy
$creadList :: ReadS [PutDataProtectionPolicy]
readList :: ReadS [PutDataProtectionPolicy]
$creadPrec :: ReadPrec PutDataProtectionPolicy
readPrec :: ReadPrec PutDataProtectionPolicy
$creadListPrec :: ReadPrec [PutDataProtectionPolicy]
readListPrec :: ReadPrec [PutDataProtectionPolicy]
Prelude.Read, Int -> PutDataProtectionPolicy -> ShowS
[PutDataProtectionPolicy] -> ShowS
PutDataProtectionPolicy -> String
(Int -> PutDataProtectionPolicy -> ShowS)
-> (PutDataProtectionPolicy -> String)
-> ([PutDataProtectionPolicy] -> ShowS)
-> Show PutDataProtectionPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PutDataProtectionPolicy -> ShowS
showsPrec :: Int -> PutDataProtectionPolicy -> ShowS
$cshow :: PutDataProtectionPolicy -> String
show :: PutDataProtectionPolicy -> String
$cshowList :: [PutDataProtectionPolicy] -> ShowS
showList :: [PutDataProtectionPolicy] -> ShowS
Prelude.Show, (forall x.
 PutDataProtectionPolicy -> Rep PutDataProtectionPolicy x)
-> (forall x.
    Rep PutDataProtectionPolicy x -> PutDataProtectionPolicy)
-> Generic PutDataProtectionPolicy
forall x. Rep PutDataProtectionPolicy x -> PutDataProtectionPolicy
forall x. PutDataProtectionPolicy -> Rep PutDataProtectionPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PutDataProtectionPolicy -> Rep PutDataProtectionPolicy x
from :: forall x. PutDataProtectionPolicy -> Rep PutDataProtectionPolicy x
$cto :: forall x. Rep PutDataProtectionPolicy x -> PutDataProtectionPolicy
to :: forall x. Rep PutDataProtectionPolicy x -> PutDataProtectionPolicy
Prelude.Generic)

-- |
-- Create a value of 'PutDataProtectionPolicy' 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', 'putDataProtectionPolicy_resourceArn' - The ARN of the topic whose @DataProtectionPolicy@ you want to add or
-- update.
--
-- 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.
--
-- 'dataProtectionPolicy', 'putDataProtectionPolicy_dataProtectionPolicy' - The JSON serialization of the topic\'s @DataProtectionPolicy@.
--
-- The @DataProtectionPolicy@ must be in JSON string format.
--
-- Length Constraints: Maximum length of 30,720.
newPutDataProtectionPolicy ::
  -- | 'resourceArn'
  Prelude.Text ->
  -- | 'dataProtectionPolicy'
  Prelude.Text ->
  PutDataProtectionPolicy
newPutDataProtectionPolicy :: Text -> Text -> PutDataProtectionPolicy
newPutDataProtectionPolicy
  Text
pResourceArn_
  Text
pDataProtectionPolicy_ =
    PutDataProtectionPolicy'
      { resourceArn :: Text
resourceArn =
          Text
pResourceArn_,
        dataProtectionPolicy :: Text
dataProtectionPolicy = Text
pDataProtectionPolicy_
      }

-- | The ARN of the topic whose @DataProtectionPolicy@ you want to add or
-- update.
--
-- 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.
putDataProtectionPolicy_resourceArn :: Lens.Lens' PutDataProtectionPolicy Prelude.Text
putDataProtectionPolicy_resourceArn :: Lens' PutDataProtectionPolicy Text
putDataProtectionPolicy_resourceArn = (PutDataProtectionPolicy -> Text)
-> (PutDataProtectionPolicy -> Text -> PutDataProtectionPolicy)
-> Lens' PutDataProtectionPolicy Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutDataProtectionPolicy' {Text
resourceArn :: PutDataProtectionPolicy -> Text
resourceArn :: Text
resourceArn} -> Text
resourceArn) (\s :: PutDataProtectionPolicy
s@PutDataProtectionPolicy' {} Text
a -> PutDataProtectionPolicy
s {resourceArn = a} :: PutDataProtectionPolicy)

-- | The JSON serialization of the topic\'s @DataProtectionPolicy@.
--
-- The @DataProtectionPolicy@ must be in JSON string format.
--
-- Length Constraints: Maximum length of 30,720.
putDataProtectionPolicy_dataProtectionPolicy :: Lens.Lens' PutDataProtectionPolicy Prelude.Text
putDataProtectionPolicy_dataProtectionPolicy :: Lens' PutDataProtectionPolicy Text
putDataProtectionPolicy_dataProtectionPolicy = (PutDataProtectionPolicy -> Text)
-> (PutDataProtectionPolicy -> Text -> PutDataProtectionPolicy)
-> Lens' PutDataProtectionPolicy Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutDataProtectionPolicy' {Text
dataProtectionPolicy :: PutDataProtectionPolicy -> Text
dataProtectionPolicy :: Text
dataProtectionPolicy} -> Text
dataProtectionPolicy) (\s :: PutDataProtectionPolicy
s@PutDataProtectionPolicy' {} Text
a -> PutDataProtectionPolicy
s {dataProtectionPolicy = a} :: PutDataProtectionPolicy)

instance Core.AWSRequest PutDataProtectionPolicy where
  type
    AWSResponse PutDataProtectionPolicy =
      PutDataProtectionPolicyResponse
  request :: (Service -> Service)
-> PutDataProtectionPolicy -> Request PutDataProtectionPolicy
request Service -> Service
overrides =
    Service
-> PutDataProtectionPolicy -> Request PutDataProtectionPolicy
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 PutDataProtectionPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutDataProtectionPolicy)))
response =
    AWSResponse PutDataProtectionPolicy
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PutDataProtectionPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutDataProtectionPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse PutDataProtectionPolicy
PutDataProtectionPolicyResponse
PutDataProtectionPolicyResponse'

instance Prelude.Hashable PutDataProtectionPolicy where
  hashWithSalt :: Int -> PutDataProtectionPolicy -> Int
hashWithSalt Int
_salt PutDataProtectionPolicy' {Text
resourceArn :: PutDataProtectionPolicy -> Text
dataProtectionPolicy :: PutDataProtectionPolicy -> Text
resourceArn :: Text
dataProtectionPolicy :: Text
..} =
    Int
_salt
      Int -> Text -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceArn
      Int -> Text -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
dataProtectionPolicy

instance Prelude.NFData PutDataProtectionPolicy where
  rnf :: PutDataProtectionPolicy -> ()
rnf PutDataProtectionPolicy' {Text
resourceArn :: PutDataProtectionPolicy -> Text
dataProtectionPolicy :: PutDataProtectionPolicy -> Text
resourceArn :: Text
dataProtectionPolicy :: Text
..} =
    Text -> ()
forall a. NFData a => a -> ()
Prelude.rnf Text
resourceArn () -> () -> ()
forall a b. a -> b -> b
`Prelude.seq`
      Text -> ()
forall a. NFData a => a -> ()
Prelude.rnf Text
dataProtectionPolicy

instance Data.ToHeaders PutDataProtectionPolicy where
  toHeaders :: PutDataProtectionPolicy -> [Header]
toHeaders = [Header] -> PutDataProtectionPolicy -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery PutDataProtectionPolicy where
  toQuery :: PutDataProtectionPolicy -> QueryString
toQuery PutDataProtectionPolicy' {Text
resourceArn :: PutDataProtectionPolicy -> Text
dataProtectionPolicy :: PutDataProtectionPolicy -> Text
resourceArn :: Text
dataProtectionPolicy :: 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
"PutDataProtectionPolicy" :: 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,
        ByteString
"DataProtectionPolicy" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
dataProtectionPolicy
      ]

-- | /See:/ 'newPutDataProtectionPolicyResponse' smart constructor.
data PutDataProtectionPolicyResponse = PutDataProtectionPolicyResponse'
  {
  }
  deriving (PutDataProtectionPolicyResponse
-> PutDataProtectionPolicyResponse -> Bool
(PutDataProtectionPolicyResponse
 -> PutDataProtectionPolicyResponse -> Bool)
-> (PutDataProtectionPolicyResponse
    -> PutDataProtectionPolicyResponse -> Bool)
-> Eq PutDataProtectionPolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PutDataProtectionPolicyResponse
-> PutDataProtectionPolicyResponse -> Bool
== :: PutDataProtectionPolicyResponse
-> PutDataProtectionPolicyResponse -> Bool
$c/= :: PutDataProtectionPolicyResponse
-> PutDataProtectionPolicyResponse -> Bool
/= :: PutDataProtectionPolicyResponse
-> PutDataProtectionPolicyResponse -> Bool
Prelude.Eq, ReadPrec [PutDataProtectionPolicyResponse]
ReadPrec PutDataProtectionPolicyResponse
Int -> ReadS PutDataProtectionPolicyResponse
ReadS [PutDataProtectionPolicyResponse]
(Int -> ReadS PutDataProtectionPolicyResponse)
-> ReadS [PutDataProtectionPolicyResponse]
-> ReadPrec PutDataProtectionPolicyResponse
-> ReadPrec [PutDataProtectionPolicyResponse]
-> Read PutDataProtectionPolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS PutDataProtectionPolicyResponse
readsPrec :: Int -> ReadS PutDataProtectionPolicyResponse
$creadList :: ReadS [PutDataProtectionPolicyResponse]
readList :: ReadS [PutDataProtectionPolicyResponse]
$creadPrec :: ReadPrec PutDataProtectionPolicyResponse
readPrec :: ReadPrec PutDataProtectionPolicyResponse
$creadListPrec :: ReadPrec [PutDataProtectionPolicyResponse]
readListPrec :: ReadPrec [PutDataProtectionPolicyResponse]
Prelude.Read, Int -> PutDataProtectionPolicyResponse -> ShowS
[PutDataProtectionPolicyResponse] -> ShowS
PutDataProtectionPolicyResponse -> String
(Int -> PutDataProtectionPolicyResponse -> ShowS)
-> (PutDataProtectionPolicyResponse -> String)
-> ([PutDataProtectionPolicyResponse] -> ShowS)
-> Show PutDataProtectionPolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PutDataProtectionPolicyResponse -> ShowS
showsPrec :: Int -> PutDataProtectionPolicyResponse -> ShowS
$cshow :: PutDataProtectionPolicyResponse -> String
show :: PutDataProtectionPolicyResponse -> String
$cshowList :: [PutDataProtectionPolicyResponse] -> ShowS
showList :: [PutDataProtectionPolicyResponse] -> ShowS
Prelude.Show, (forall x.
 PutDataProtectionPolicyResponse
 -> Rep PutDataProtectionPolicyResponse x)
-> (forall x.
    Rep PutDataProtectionPolicyResponse x
    -> PutDataProtectionPolicyResponse)
-> Generic PutDataProtectionPolicyResponse
forall x.
Rep PutDataProtectionPolicyResponse x
-> PutDataProtectionPolicyResponse
forall x.
PutDataProtectionPolicyResponse
-> Rep PutDataProtectionPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
PutDataProtectionPolicyResponse
-> Rep PutDataProtectionPolicyResponse x
from :: forall x.
PutDataProtectionPolicyResponse
-> Rep PutDataProtectionPolicyResponse x
$cto :: forall x.
Rep PutDataProtectionPolicyResponse x
-> PutDataProtectionPolicyResponse
to :: forall x.
Rep PutDataProtectionPolicyResponse x
-> PutDataProtectionPolicyResponse
Prelude.Generic)

-- |
-- Create a value of 'PutDataProtectionPolicyResponse' 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.
newPutDataProtectionPolicyResponse ::
  PutDataProtectionPolicyResponse
newPutDataProtectionPolicyResponse :: PutDataProtectionPolicyResponse
newPutDataProtectionPolicyResponse =
  PutDataProtectionPolicyResponse
PutDataProtectionPolicyResponse'

instance
  Prelude.NFData
    PutDataProtectionPolicyResponse
  where
  rnf :: PutDataProtectionPolicyResponse -> ()
rnf PutDataProtectionPolicyResponse
_ = ()