{-# 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.IAM.UntagPolicy
-- 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)
--
-- Removes the specified tags from the customer managed policy. For more
-- information about tagging, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
-- in the /IAM User Guide/.
module Amazonka.IAM.UntagPolicy
  ( -- * Creating a Request
    UntagPolicy (..),
    newUntagPolicy,

    -- * Request Lenses
    untagPolicy_policyArn,
    untagPolicy_tagKeys,

    -- * Destructuring the Response
    UntagPolicyResponse (..),
    newUntagPolicyResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUntagPolicy' smart constructor.
data UntagPolicy = UntagPolicy'
  { -- | The ARN of the IAM customer managed policy from which you want to remove
    -- tags.
    --
    -- This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- consisting of upper and lowercase alphanumeric characters with no
    -- spaces. You can also include any of the following characters: _+=,.\@-
    UntagPolicy -> Text
policyArn :: Prelude.Text,
    -- | A list of key names as a simple array of strings. The tags with matching
    -- keys are removed from the specified policy.
    UntagPolicy -> [Text]
tagKeys :: [Prelude.Text]
  }
  deriving (UntagPolicy -> UntagPolicy -> Bool
(UntagPolicy -> UntagPolicy -> Bool)
-> (UntagPolicy -> UntagPolicy -> Bool) -> Eq UntagPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UntagPolicy -> UntagPolicy -> Bool
$c/= :: UntagPolicy -> UntagPolicy -> Bool
== :: UntagPolicy -> UntagPolicy -> Bool
$c== :: UntagPolicy -> UntagPolicy -> Bool
Prelude.Eq, ReadPrec [UntagPolicy]
ReadPrec UntagPolicy
Int -> ReadS UntagPolicy
ReadS [UntagPolicy]
(Int -> ReadS UntagPolicy)
-> ReadS [UntagPolicy]
-> ReadPrec UntagPolicy
-> ReadPrec [UntagPolicy]
-> Read UntagPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UntagPolicy]
$creadListPrec :: ReadPrec [UntagPolicy]
readPrec :: ReadPrec UntagPolicy
$creadPrec :: ReadPrec UntagPolicy
readList :: ReadS [UntagPolicy]
$creadList :: ReadS [UntagPolicy]
readsPrec :: Int -> ReadS UntagPolicy
$creadsPrec :: Int -> ReadS UntagPolicy
Prelude.Read, Int -> UntagPolicy -> ShowS
[UntagPolicy] -> ShowS
UntagPolicy -> String
(Int -> UntagPolicy -> ShowS)
-> (UntagPolicy -> String)
-> ([UntagPolicy] -> ShowS)
-> Show UntagPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UntagPolicy] -> ShowS
$cshowList :: [UntagPolicy] -> ShowS
show :: UntagPolicy -> String
$cshow :: UntagPolicy -> String
showsPrec :: Int -> UntagPolicy -> ShowS
$cshowsPrec :: Int -> UntagPolicy -> ShowS
Prelude.Show, (forall x. UntagPolicy -> Rep UntagPolicy x)
-> (forall x. Rep UntagPolicy x -> UntagPolicy)
-> Generic UntagPolicy
forall x. Rep UntagPolicy x -> UntagPolicy
forall x. UntagPolicy -> Rep UntagPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UntagPolicy x -> UntagPolicy
$cfrom :: forall x. UntagPolicy -> Rep UntagPolicy x
Prelude.Generic)

-- |
-- Create a value of 'UntagPolicy' 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:
--
-- 'policyArn', 'untagPolicy_policyArn' - The ARN of the IAM customer managed policy from which you want to remove
-- tags.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
--
-- 'tagKeys', 'untagPolicy_tagKeys' - A list of key names as a simple array of strings. The tags with matching
-- keys are removed from the specified policy.
newUntagPolicy ::
  -- | 'policyArn'
  Prelude.Text ->
  UntagPolicy
newUntagPolicy :: Text -> UntagPolicy
newUntagPolicy Text
pPolicyArn_ =
  UntagPolicy' :: Text -> [Text] -> UntagPolicy
UntagPolicy'
    { $sel:policyArn:UntagPolicy' :: Text
policyArn = Text
pPolicyArn_,
      $sel:tagKeys:UntagPolicy' :: [Text]
tagKeys = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The ARN of the IAM customer managed policy from which you want to remove
-- tags.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
untagPolicy_policyArn :: Lens.Lens' UntagPolicy Prelude.Text
untagPolicy_policyArn :: (Text -> f Text) -> UntagPolicy -> f UntagPolicy
untagPolicy_policyArn = (UntagPolicy -> Text)
-> (UntagPolicy -> Text -> UntagPolicy)
-> Lens UntagPolicy UntagPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagPolicy' {Text
policyArn :: Text
$sel:policyArn:UntagPolicy' :: UntagPolicy -> Text
policyArn} -> Text
policyArn) (\s :: UntagPolicy
s@UntagPolicy' {} Text
a -> UntagPolicy
s {$sel:policyArn:UntagPolicy' :: Text
policyArn = Text
a} :: UntagPolicy)

-- | A list of key names as a simple array of strings. The tags with matching
-- keys are removed from the specified policy.
untagPolicy_tagKeys :: Lens.Lens' UntagPolicy [Prelude.Text]
untagPolicy_tagKeys :: ([Text] -> f [Text]) -> UntagPolicy -> f UntagPolicy
untagPolicy_tagKeys = (UntagPolicy -> [Text])
-> (UntagPolicy -> [Text] -> UntagPolicy)
-> Lens UntagPolicy UntagPolicy [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UntagPolicy' {[Text]
tagKeys :: [Text]
$sel:tagKeys:UntagPolicy' :: UntagPolicy -> [Text]
tagKeys} -> [Text]
tagKeys) (\s :: UntagPolicy
s@UntagPolicy' {} [Text]
a -> UntagPolicy
s {$sel:tagKeys:UntagPolicy' :: [Text]
tagKeys = [Text]
a} :: UntagPolicy) (([Text] -> f [Text]) -> UntagPolicy -> f UntagPolicy)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> UntagPolicy
-> f UntagPolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest UntagPolicy where
  type AWSResponse UntagPolicy = UntagPolicyResponse
  request :: UntagPolicy -> Request UntagPolicy
request = Service -> UntagPolicy -> Request UntagPolicy
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy UntagPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UntagPolicy)))
response = AWSResponse UntagPolicy
-> Logger
-> Service
-> Proxy UntagPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UntagPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UntagPolicy
UntagPolicyResponse
UntagPolicyResponse'

instance Prelude.Hashable UntagPolicy

instance Prelude.NFData UntagPolicy

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

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

instance Core.ToQuery UntagPolicy where
  toQuery :: UntagPolicy -> QueryString
toQuery UntagPolicy' {[Text]
Text
tagKeys :: [Text]
policyArn :: Text
$sel:tagKeys:UntagPolicy' :: UntagPolicy -> [Text]
$sel:policyArn:UntagPolicy' :: UntagPolicy -> 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
"UntagPolicy" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"PolicyArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
policyArn,
        ByteString
"TagKeys" ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" [Text]
tagKeys
      ]

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

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

instance Prelude.NFData UntagPolicyResponse