{-# 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.DetachGroupPolicy
-- 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 managed policy from the specified IAM group.
--
-- A group can also have inline policies embedded with it. To delete an
-- inline policy, use DeleteGroupPolicy. For information about policies,
-- see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html Managed policies and inline policies>
-- in the /IAM User Guide/.
module Amazonka.IAM.DetachGroupPolicy
  ( -- * Creating a Request
    DetachGroupPolicy (..),
    newDetachGroupPolicy,

    -- * Request Lenses
    detachGroupPolicy_groupName,
    detachGroupPolicy_policyArn,

    -- * Destructuring the Response
    DetachGroupPolicyResponse (..),
    newDetachGroupPolicyResponse,
  )
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:/ 'newDetachGroupPolicy' smart constructor.
data DetachGroupPolicy = DetachGroupPolicy'
  { -- | The name (friendly name, not ARN) of the IAM group to detach the policy
    -- from.
    --
    -- 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: _+=,.\@-
    DetachGroupPolicy -> Text
groupName :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the IAM policy you want to detach.
    --
    -- 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/.
    DetachGroupPolicy -> Text
policyArn :: Prelude.Text
  }
  deriving (DetachGroupPolicy -> DetachGroupPolicy -> Bool
(DetachGroupPolicy -> DetachGroupPolicy -> Bool)
-> (DetachGroupPolicy -> DetachGroupPolicy -> Bool)
-> Eq DetachGroupPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetachGroupPolicy -> DetachGroupPolicy -> Bool
$c/= :: DetachGroupPolicy -> DetachGroupPolicy -> Bool
== :: DetachGroupPolicy -> DetachGroupPolicy -> Bool
$c== :: DetachGroupPolicy -> DetachGroupPolicy -> Bool
Prelude.Eq, ReadPrec [DetachGroupPolicy]
ReadPrec DetachGroupPolicy
Int -> ReadS DetachGroupPolicy
ReadS [DetachGroupPolicy]
(Int -> ReadS DetachGroupPolicy)
-> ReadS [DetachGroupPolicy]
-> ReadPrec DetachGroupPolicy
-> ReadPrec [DetachGroupPolicy]
-> Read DetachGroupPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetachGroupPolicy]
$creadListPrec :: ReadPrec [DetachGroupPolicy]
readPrec :: ReadPrec DetachGroupPolicy
$creadPrec :: ReadPrec DetachGroupPolicy
readList :: ReadS [DetachGroupPolicy]
$creadList :: ReadS [DetachGroupPolicy]
readsPrec :: Int -> ReadS DetachGroupPolicy
$creadsPrec :: Int -> ReadS DetachGroupPolicy
Prelude.Read, Int -> DetachGroupPolicy -> ShowS
[DetachGroupPolicy] -> ShowS
DetachGroupPolicy -> String
(Int -> DetachGroupPolicy -> ShowS)
-> (DetachGroupPolicy -> String)
-> ([DetachGroupPolicy] -> ShowS)
-> Show DetachGroupPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetachGroupPolicy] -> ShowS
$cshowList :: [DetachGroupPolicy] -> ShowS
show :: DetachGroupPolicy -> String
$cshow :: DetachGroupPolicy -> String
showsPrec :: Int -> DetachGroupPolicy -> ShowS
$cshowsPrec :: Int -> DetachGroupPolicy -> ShowS
Prelude.Show, (forall x. DetachGroupPolicy -> Rep DetachGroupPolicy x)
-> (forall x. Rep DetachGroupPolicy x -> DetachGroupPolicy)
-> Generic DetachGroupPolicy
forall x. Rep DetachGroupPolicy x -> DetachGroupPolicy
forall x. DetachGroupPolicy -> Rep DetachGroupPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetachGroupPolicy x -> DetachGroupPolicy
$cfrom :: forall x. DetachGroupPolicy -> Rep DetachGroupPolicy x
Prelude.Generic)

-- |
-- Create a value of 'DetachGroupPolicy' 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:
--
-- 'groupName', 'detachGroupPolicy_groupName' - The name (friendly name, not ARN) of the IAM group to detach the policy
-- from.
--
-- 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: _+=,.\@-
--
-- 'policyArn', 'detachGroupPolicy_policyArn' - The Amazon Resource Name (ARN) of the IAM policy you want to detach.
--
-- 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/.
newDetachGroupPolicy ::
  -- | 'groupName'
  Prelude.Text ->
  -- | 'policyArn'
  Prelude.Text ->
  DetachGroupPolicy
newDetachGroupPolicy :: Text -> Text -> DetachGroupPolicy
newDetachGroupPolicy Text
pGroupName_ Text
pPolicyArn_ =
  DetachGroupPolicy' :: Text -> Text -> DetachGroupPolicy
DetachGroupPolicy'
    { $sel:groupName:DetachGroupPolicy' :: Text
groupName = Text
pGroupName_,
      $sel:policyArn:DetachGroupPolicy' :: Text
policyArn = Text
pPolicyArn_
    }

-- | The name (friendly name, not ARN) of the IAM group to detach the policy
-- from.
--
-- 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: _+=,.\@-
detachGroupPolicy_groupName :: Lens.Lens' DetachGroupPolicy Prelude.Text
detachGroupPolicy_groupName :: (Text -> f Text) -> DetachGroupPolicy -> f DetachGroupPolicy
detachGroupPolicy_groupName = (DetachGroupPolicy -> Text)
-> (DetachGroupPolicy -> Text -> DetachGroupPolicy)
-> Lens DetachGroupPolicy DetachGroupPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachGroupPolicy' {Text
groupName :: Text
$sel:groupName:DetachGroupPolicy' :: DetachGroupPolicy -> Text
groupName} -> Text
groupName) (\s :: DetachGroupPolicy
s@DetachGroupPolicy' {} Text
a -> DetachGroupPolicy
s {$sel:groupName:DetachGroupPolicy' :: Text
groupName = Text
a} :: DetachGroupPolicy)

-- | The Amazon Resource Name (ARN) of the IAM policy you want to detach.
--
-- 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/.
detachGroupPolicy_policyArn :: Lens.Lens' DetachGroupPolicy Prelude.Text
detachGroupPolicy_policyArn :: (Text -> f Text) -> DetachGroupPolicy -> f DetachGroupPolicy
detachGroupPolicy_policyArn = (DetachGroupPolicy -> Text)
-> (DetachGroupPolicy -> Text -> DetachGroupPolicy)
-> Lens DetachGroupPolicy DetachGroupPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetachGroupPolicy' {Text
policyArn :: Text
$sel:policyArn:DetachGroupPolicy' :: DetachGroupPolicy -> Text
policyArn} -> Text
policyArn) (\s :: DetachGroupPolicy
s@DetachGroupPolicy' {} Text
a -> DetachGroupPolicy
s {$sel:policyArn:DetachGroupPolicy' :: Text
policyArn = Text
a} :: DetachGroupPolicy)

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

instance Prelude.Hashable DetachGroupPolicy

instance Prelude.NFData DetachGroupPolicy

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

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

instance Core.ToQuery DetachGroupPolicy where
  toQuery :: DetachGroupPolicy -> QueryString
toQuery DetachGroupPolicy' {Text
policyArn :: Text
groupName :: Text
$sel:policyArn:DetachGroupPolicy' :: DetachGroupPolicy -> Text
$sel:groupName:DetachGroupPolicy' :: DetachGroupPolicy -> 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
"DetachGroupPolicy" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"GroupName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
groupName,
        ByteString
"PolicyArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
policyArn
      ]

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

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

instance Prelude.NFData DetachGroupPolicyResponse