{-# 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.CloudFormation.SetStackPolicy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Sets a stack policy for a specified stack.
module Amazonka.CloudFormation.SetStackPolicy
  ( -- * Creating a Request
    SetStackPolicy (..),
    newSetStackPolicy,

    -- * Request Lenses
    setStackPolicy_stackPolicyBody,
    setStackPolicy_stackPolicyURL,
    setStackPolicy_stackName,

    -- * Destructuring the Response
    SetStackPolicyResponse (..),
    newSetStackPolicyResponse,
  )
where

import Amazonka.CloudFormation.Types
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

-- | The input for the SetStackPolicy action.
--
-- /See:/ 'newSetStackPolicy' smart constructor.
data SetStackPolicy = SetStackPolicy'
  { -- | Structure containing the stack policy body. For more information, go to
    -- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/protect-stack-resources.html Prevent updates to stack resources>
    -- in the CloudFormation User Guide. You can specify either the
    -- @StackPolicyBody@ or the @StackPolicyURL@ parameter, but not both.
    SetStackPolicy -> Maybe Text
stackPolicyBody :: Prelude.Maybe Prelude.Text,
    -- | Location of a file containing the stack policy. The URL must point to a
    -- policy (maximum size: 16 KB) located in an Amazon S3 bucket in the same
    -- Amazon Web Services Region as the stack. You can specify either the
    -- @StackPolicyBody@ or the @StackPolicyURL@ parameter, but not both.
    SetStackPolicy -> Maybe Text
stackPolicyURL :: Prelude.Maybe Prelude.Text,
    -- | The name or unique stack ID that you want to associate a policy with.
    SetStackPolicy -> Text
stackName :: Prelude.Text
  }
  deriving (SetStackPolicy -> SetStackPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SetStackPolicy -> SetStackPolicy -> Bool
$c/= :: SetStackPolicy -> SetStackPolicy -> Bool
== :: SetStackPolicy -> SetStackPolicy -> Bool
$c== :: SetStackPolicy -> SetStackPolicy -> Bool
Prelude.Eq, ReadPrec [SetStackPolicy]
ReadPrec SetStackPolicy
Int -> ReadS SetStackPolicy
ReadS [SetStackPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SetStackPolicy]
$creadListPrec :: ReadPrec [SetStackPolicy]
readPrec :: ReadPrec SetStackPolicy
$creadPrec :: ReadPrec SetStackPolicy
readList :: ReadS [SetStackPolicy]
$creadList :: ReadS [SetStackPolicy]
readsPrec :: Int -> ReadS SetStackPolicy
$creadsPrec :: Int -> ReadS SetStackPolicy
Prelude.Read, Int -> SetStackPolicy -> ShowS
[SetStackPolicy] -> ShowS
SetStackPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SetStackPolicy] -> ShowS
$cshowList :: [SetStackPolicy] -> ShowS
show :: SetStackPolicy -> String
$cshow :: SetStackPolicy -> String
showsPrec :: Int -> SetStackPolicy -> ShowS
$cshowsPrec :: Int -> SetStackPolicy -> ShowS
Prelude.Show, forall x. Rep SetStackPolicy x -> SetStackPolicy
forall x. SetStackPolicy -> Rep SetStackPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SetStackPolicy x -> SetStackPolicy
$cfrom :: forall x. SetStackPolicy -> Rep SetStackPolicy x
Prelude.Generic)

-- |
-- Create a value of 'SetStackPolicy' 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:
--
-- 'stackPolicyBody', 'setStackPolicy_stackPolicyBody' - Structure containing the stack policy body. For more information, go to
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/protect-stack-resources.html Prevent updates to stack resources>
-- in the CloudFormation User Guide. You can specify either the
-- @StackPolicyBody@ or the @StackPolicyURL@ parameter, but not both.
--
-- 'stackPolicyURL', 'setStackPolicy_stackPolicyURL' - Location of a file containing the stack policy. The URL must point to a
-- policy (maximum size: 16 KB) located in an Amazon S3 bucket in the same
-- Amazon Web Services Region as the stack. You can specify either the
-- @StackPolicyBody@ or the @StackPolicyURL@ parameter, but not both.
--
-- 'stackName', 'setStackPolicy_stackName' - The name or unique stack ID that you want to associate a policy with.
newSetStackPolicy ::
  -- | 'stackName'
  Prelude.Text ->
  SetStackPolicy
newSetStackPolicy :: Text -> SetStackPolicy
newSetStackPolicy Text
pStackName_ =
  SetStackPolicy'
    { $sel:stackPolicyBody:SetStackPolicy' :: Maybe Text
stackPolicyBody = forall a. Maybe a
Prelude.Nothing,
      $sel:stackPolicyURL:SetStackPolicy' :: Maybe Text
stackPolicyURL = forall a. Maybe a
Prelude.Nothing,
      $sel:stackName:SetStackPolicy' :: Text
stackName = Text
pStackName_
    }

-- | Structure containing the stack policy body. For more information, go to
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/protect-stack-resources.html Prevent updates to stack resources>
-- in the CloudFormation User Guide. You can specify either the
-- @StackPolicyBody@ or the @StackPolicyURL@ parameter, but not both.
setStackPolicy_stackPolicyBody :: Lens.Lens' SetStackPolicy (Prelude.Maybe Prelude.Text)
setStackPolicy_stackPolicyBody :: Lens' SetStackPolicy (Maybe Text)
setStackPolicy_stackPolicyBody = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetStackPolicy' {Maybe Text
stackPolicyBody :: Maybe Text
$sel:stackPolicyBody:SetStackPolicy' :: SetStackPolicy -> Maybe Text
stackPolicyBody} -> Maybe Text
stackPolicyBody) (\s :: SetStackPolicy
s@SetStackPolicy' {} Maybe Text
a -> SetStackPolicy
s {$sel:stackPolicyBody:SetStackPolicy' :: Maybe Text
stackPolicyBody = Maybe Text
a} :: SetStackPolicy)

-- | Location of a file containing the stack policy. The URL must point to a
-- policy (maximum size: 16 KB) located in an Amazon S3 bucket in the same
-- Amazon Web Services Region as the stack. You can specify either the
-- @StackPolicyBody@ or the @StackPolicyURL@ parameter, but not both.
setStackPolicy_stackPolicyURL :: Lens.Lens' SetStackPolicy (Prelude.Maybe Prelude.Text)
setStackPolicy_stackPolicyURL :: Lens' SetStackPolicy (Maybe Text)
setStackPolicy_stackPolicyURL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetStackPolicy' {Maybe Text
stackPolicyURL :: Maybe Text
$sel:stackPolicyURL:SetStackPolicy' :: SetStackPolicy -> Maybe Text
stackPolicyURL} -> Maybe Text
stackPolicyURL) (\s :: SetStackPolicy
s@SetStackPolicy' {} Maybe Text
a -> SetStackPolicy
s {$sel:stackPolicyURL:SetStackPolicy' :: Maybe Text
stackPolicyURL = Maybe Text
a} :: SetStackPolicy)

-- | The name or unique stack ID that you want to associate a policy with.
setStackPolicy_stackName :: Lens.Lens' SetStackPolicy Prelude.Text
setStackPolicy_stackName :: Lens' SetStackPolicy Text
setStackPolicy_stackName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SetStackPolicy' {Text
stackName :: Text
$sel:stackName:SetStackPolicy' :: SetStackPolicy -> Text
stackName} -> Text
stackName) (\s :: SetStackPolicy
s@SetStackPolicy' {} Text
a -> SetStackPolicy
s {$sel:stackName:SetStackPolicy' :: Text
stackName = Text
a} :: SetStackPolicy)

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

instance Prelude.Hashable SetStackPolicy where
  hashWithSalt :: Int -> SetStackPolicy -> Int
hashWithSalt Int
_salt SetStackPolicy' {Maybe Text
Text
stackName :: Text
stackPolicyURL :: Maybe Text
stackPolicyBody :: Maybe Text
$sel:stackName:SetStackPolicy' :: SetStackPolicy -> Text
$sel:stackPolicyURL:SetStackPolicy' :: SetStackPolicy -> Maybe Text
$sel:stackPolicyBody:SetStackPolicy' :: SetStackPolicy -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
stackPolicyBody
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
stackPolicyURL
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
stackName

instance Prelude.NFData SetStackPolicy where
  rnf :: SetStackPolicy -> ()
rnf SetStackPolicy' {Maybe Text
Text
stackName :: Text
stackPolicyURL :: Maybe Text
stackPolicyBody :: Maybe Text
$sel:stackName:SetStackPolicy' :: SetStackPolicy -> Text
$sel:stackPolicyURL:SetStackPolicy' :: SetStackPolicy -> Maybe Text
$sel:stackPolicyBody:SetStackPolicy' :: SetStackPolicy -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
stackPolicyBody
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
stackPolicyURL
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
stackName

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

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

instance Data.ToQuery SetStackPolicy where
  toQuery :: SetStackPolicy -> QueryString
toQuery SetStackPolicy' {Maybe Text
Text
stackName :: Text
stackPolicyURL :: Maybe Text
stackPolicyBody :: Maybe Text
$sel:stackName:SetStackPolicy' :: SetStackPolicy -> Text
$sel:stackPolicyURL:SetStackPolicy' :: SetStackPolicy -> Maybe Text
$sel:stackPolicyBody:SetStackPolicy' :: SetStackPolicy -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"SetStackPolicy" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-05-15" :: Prelude.ByteString),
        ByteString
"StackPolicyBody" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
stackPolicyBody,
        ByteString
"StackPolicyURL" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
stackPolicyURL,
        ByteString
"StackName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
stackName
      ]

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

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

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