{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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.Lens as Lens
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 S3 bucket in the same 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
(SetStackPolicy -> SetStackPolicy -> Bool)
-> (SetStackPolicy -> SetStackPolicy -> Bool) -> Eq SetStackPolicy
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]
(Int -> ReadS SetStackPolicy)
-> ReadS [SetStackPolicy]
-> ReadPrec SetStackPolicy
-> ReadPrec [SetStackPolicy]
-> Read 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
(Int -> SetStackPolicy -> ShowS)
-> (SetStackPolicy -> String)
-> ([SetStackPolicy] -> ShowS)
-> Show SetStackPolicy
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. SetStackPolicy -> Rep SetStackPolicy x)
-> (forall x. Rep SetStackPolicy x -> SetStackPolicy)
-> Generic SetStackPolicy
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 S3 bucket in the same 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' :: Maybe Text -> Maybe Text -> Text -> SetStackPolicy
SetStackPolicy'
    { $sel:stackPolicyBody:SetStackPolicy' :: Maybe Text
stackPolicyBody = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:stackPolicyURL:SetStackPolicy' :: Maybe Text
stackPolicyURL = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> SetStackPolicy -> f SetStackPolicy
setStackPolicy_stackPolicyBody = (SetStackPolicy -> Maybe Text)
-> (SetStackPolicy -> Maybe Text -> SetStackPolicy)
-> Lens SetStackPolicy SetStackPolicy (Maybe Text) (Maybe Text)
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 S3 bucket in the same 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 :: (Maybe Text -> f (Maybe Text))
-> SetStackPolicy -> f SetStackPolicy
setStackPolicy_stackPolicyURL = (SetStackPolicy -> Maybe Text)
-> (SetStackPolicy -> Maybe Text -> SetStackPolicy)
-> Lens SetStackPolicy SetStackPolicy (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> SetStackPolicy -> f SetStackPolicy
setStackPolicy_stackName = (SetStackPolicy -> Text)
-> (SetStackPolicy -> Text -> SetStackPolicy)
-> Lens SetStackPolicy SetStackPolicy Text Text
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 :: SetStackPolicy -> Request SetStackPolicy
request = Service -> SetStackPolicy -> Request SetStackPolicy
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy SetStackPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SetStackPolicy)))
response =
    AWSResponse SetStackPolicy
-> Logger
-> Service
-> Proxy SetStackPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SetStackPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse SetStackPolicy
SetStackPolicyResponse
SetStackPolicyResponse'

instance Prelude.Hashable SetStackPolicy

instance Prelude.NFData SetStackPolicy

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

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

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"SetStackPolicy" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-15" :: Prelude.ByteString),
        ByteString
"StackPolicyBody" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
stackPolicyBody,
        ByteString
"StackPolicyURL" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
stackPolicyURL,
        ByteString
"StackName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
stackName
      ]

-- | /See:/ 'newSetStackPolicyResponse' smart constructor.
data SetStackPolicyResponse = SetStackPolicyResponse'
  {
  }
  deriving (SetStackPolicyResponse -> SetStackPolicyResponse -> Bool
(SetStackPolicyResponse -> SetStackPolicyResponse -> Bool)
-> (SetStackPolicyResponse -> SetStackPolicyResponse -> Bool)
-> Eq SetStackPolicyResponse
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]
(Int -> ReadS SetStackPolicyResponse)
-> ReadS [SetStackPolicyResponse]
-> ReadPrec SetStackPolicyResponse
-> ReadPrec [SetStackPolicyResponse]
-> Read 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
(Int -> SetStackPolicyResponse -> ShowS)
-> (SetStackPolicyResponse -> String)
-> ([SetStackPolicyResponse] -> ShowS)
-> Show SetStackPolicyResponse
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. SetStackPolicyResponse -> Rep SetStackPolicyResponse x)
-> (forall x.
    Rep SetStackPolicyResponse x -> SetStackPolicyResponse)
-> Generic SetStackPolicyResponse
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