{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.IoT.Types.ReplaceDefaultPolicyVersionParams
-- 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)
module Amazonka.IoT.Types.ReplaceDefaultPolicyVersionParams where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.PolicyTemplateName
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Parameters to define a mitigation action that adds a blank policy to
-- restrict permissions.
--
-- /See:/ 'newReplaceDefaultPolicyVersionParams' smart constructor.
data ReplaceDefaultPolicyVersionParams = ReplaceDefaultPolicyVersionParams'
  { -- | The name of the template to be applied. The only supported value is
    -- @BLANK_POLICY@.
    ReplaceDefaultPolicyVersionParams -> PolicyTemplateName
templateName :: PolicyTemplateName
  }
  deriving (ReplaceDefaultPolicyVersionParams
-> ReplaceDefaultPolicyVersionParams -> Bool
(ReplaceDefaultPolicyVersionParams
 -> ReplaceDefaultPolicyVersionParams -> Bool)
-> (ReplaceDefaultPolicyVersionParams
    -> ReplaceDefaultPolicyVersionParams -> Bool)
-> Eq ReplaceDefaultPolicyVersionParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReplaceDefaultPolicyVersionParams
-> ReplaceDefaultPolicyVersionParams -> Bool
$c/= :: ReplaceDefaultPolicyVersionParams
-> ReplaceDefaultPolicyVersionParams -> Bool
== :: ReplaceDefaultPolicyVersionParams
-> ReplaceDefaultPolicyVersionParams -> Bool
$c== :: ReplaceDefaultPolicyVersionParams
-> ReplaceDefaultPolicyVersionParams -> Bool
Prelude.Eq, ReadPrec [ReplaceDefaultPolicyVersionParams]
ReadPrec ReplaceDefaultPolicyVersionParams
Int -> ReadS ReplaceDefaultPolicyVersionParams
ReadS [ReplaceDefaultPolicyVersionParams]
(Int -> ReadS ReplaceDefaultPolicyVersionParams)
-> ReadS [ReplaceDefaultPolicyVersionParams]
-> ReadPrec ReplaceDefaultPolicyVersionParams
-> ReadPrec [ReplaceDefaultPolicyVersionParams]
-> Read ReplaceDefaultPolicyVersionParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReplaceDefaultPolicyVersionParams]
$creadListPrec :: ReadPrec [ReplaceDefaultPolicyVersionParams]
readPrec :: ReadPrec ReplaceDefaultPolicyVersionParams
$creadPrec :: ReadPrec ReplaceDefaultPolicyVersionParams
readList :: ReadS [ReplaceDefaultPolicyVersionParams]
$creadList :: ReadS [ReplaceDefaultPolicyVersionParams]
readsPrec :: Int -> ReadS ReplaceDefaultPolicyVersionParams
$creadsPrec :: Int -> ReadS ReplaceDefaultPolicyVersionParams
Prelude.Read, Int -> ReplaceDefaultPolicyVersionParams -> ShowS
[ReplaceDefaultPolicyVersionParams] -> ShowS
ReplaceDefaultPolicyVersionParams -> String
(Int -> ReplaceDefaultPolicyVersionParams -> ShowS)
-> (ReplaceDefaultPolicyVersionParams -> String)
-> ([ReplaceDefaultPolicyVersionParams] -> ShowS)
-> Show ReplaceDefaultPolicyVersionParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReplaceDefaultPolicyVersionParams] -> ShowS
$cshowList :: [ReplaceDefaultPolicyVersionParams] -> ShowS
show :: ReplaceDefaultPolicyVersionParams -> String
$cshow :: ReplaceDefaultPolicyVersionParams -> String
showsPrec :: Int -> ReplaceDefaultPolicyVersionParams -> ShowS
$cshowsPrec :: Int -> ReplaceDefaultPolicyVersionParams -> ShowS
Prelude.Show, (forall x.
 ReplaceDefaultPolicyVersionParams
 -> Rep ReplaceDefaultPolicyVersionParams x)
-> (forall x.
    Rep ReplaceDefaultPolicyVersionParams x
    -> ReplaceDefaultPolicyVersionParams)
-> Generic ReplaceDefaultPolicyVersionParams
forall x.
Rep ReplaceDefaultPolicyVersionParams x
-> ReplaceDefaultPolicyVersionParams
forall x.
ReplaceDefaultPolicyVersionParams
-> Rep ReplaceDefaultPolicyVersionParams x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ReplaceDefaultPolicyVersionParams x
-> ReplaceDefaultPolicyVersionParams
$cfrom :: forall x.
ReplaceDefaultPolicyVersionParams
-> Rep ReplaceDefaultPolicyVersionParams x
Prelude.Generic)

-- |
-- Create a value of 'ReplaceDefaultPolicyVersionParams' 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:
--
-- 'templateName', 'replaceDefaultPolicyVersionParams_templateName' - The name of the template to be applied. The only supported value is
-- @BLANK_POLICY@.
newReplaceDefaultPolicyVersionParams ::
  -- | 'templateName'
  PolicyTemplateName ->
  ReplaceDefaultPolicyVersionParams
newReplaceDefaultPolicyVersionParams :: PolicyTemplateName -> ReplaceDefaultPolicyVersionParams
newReplaceDefaultPolicyVersionParams PolicyTemplateName
pTemplateName_ =
  ReplaceDefaultPolicyVersionParams' :: PolicyTemplateName -> ReplaceDefaultPolicyVersionParams
ReplaceDefaultPolicyVersionParams'
    { $sel:templateName:ReplaceDefaultPolicyVersionParams' :: PolicyTemplateName
templateName =
        PolicyTemplateName
pTemplateName_
    }

-- | The name of the template to be applied. The only supported value is
-- @BLANK_POLICY@.
replaceDefaultPolicyVersionParams_templateName :: Lens.Lens' ReplaceDefaultPolicyVersionParams PolicyTemplateName
replaceDefaultPolicyVersionParams_templateName :: (PolicyTemplateName -> f PolicyTemplateName)
-> ReplaceDefaultPolicyVersionParams
-> f ReplaceDefaultPolicyVersionParams
replaceDefaultPolicyVersionParams_templateName = (ReplaceDefaultPolicyVersionParams -> PolicyTemplateName)
-> (ReplaceDefaultPolicyVersionParams
    -> PolicyTemplateName -> ReplaceDefaultPolicyVersionParams)
-> Lens
     ReplaceDefaultPolicyVersionParams
     ReplaceDefaultPolicyVersionParams
     PolicyTemplateName
     PolicyTemplateName
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplaceDefaultPolicyVersionParams' {PolicyTemplateName
templateName :: PolicyTemplateName
$sel:templateName:ReplaceDefaultPolicyVersionParams' :: ReplaceDefaultPolicyVersionParams -> PolicyTemplateName
templateName} -> PolicyTemplateName
templateName) (\s :: ReplaceDefaultPolicyVersionParams
s@ReplaceDefaultPolicyVersionParams' {} PolicyTemplateName
a -> ReplaceDefaultPolicyVersionParams
s {$sel:templateName:ReplaceDefaultPolicyVersionParams' :: PolicyTemplateName
templateName = PolicyTemplateName
a} :: ReplaceDefaultPolicyVersionParams)

instance
  Core.FromJSON
    ReplaceDefaultPolicyVersionParams
  where
  parseJSON :: Value -> Parser ReplaceDefaultPolicyVersionParams
parseJSON =
    String
-> (Object -> Parser ReplaceDefaultPolicyVersionParams)
-> Value
-> Parser ReplaceDefaultPolicyVersionParams
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ReplaceDefaultPolicyVersionParams"
      ( \Object
x ->
          PolicyTemplateName -> ReplaceDefaultPolicyVersionParams
ReplaceDefaultPolicyVersionParams'
            (PolicyTemplateName -> ReplaceDefaultPolicyVersionParams)
-> Parser PolicyTemplateName
-> Parser ReplaceDefaultPolicyVersionParams
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser PolicyTemplateName
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"templateName")
      )

instance
  Prelude.Hashable
    ReplaceDefaultPolicyVersionParams

instance
  Prelude.NFData
    ReplaceDefaultPolicyVersionParams

instance
  Core.ToJSON
    ReplaceDefaultPolicyVersionParams
  where
  toJSON :: ReplaceDefaultPolicyVersionParams -> Value
toJSON ReplaceDefaultPolicyVersionParams' {PolicyTemplateName
templateName :: PolicyTemplateName
$sel:templateName:ReplaceDefaultPolicyVersionParams' :: ReplaceDefaultPolicyVersionParams -> PolicyTemplateName
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"templateName" Text -> PolicyTemplateName -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PolicyTemplateName
templateName)]
      )