{-# 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.UpdateGroup
-- 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)
--
-- Updates the name and\/or the path of the specified IAM group.
--
-- You should understand the implications of changing a group\'s path or
-- name. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_WorkingWithGroupsAndUsers.html Renaming users and groups>
-- in the /IAM User Guide/.
--
-- The person making the request (the principal), must have permission to
-- change the role group with the old name and the new name. For example,
-- to change the group named @Managers@ to @MGRs@, the principal must have
-- a policy that allows them to update both groups. If the principal has
-- permission to update the @Managers@ group, but not the @MGRs@ group,
-- then the update fails. For more information about permissions, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access.html Access management>.
module Amazonka.IAM.UpdateGroup
  ( -- * Creating a Request
    UpdateGroup (..),
    newUpdateGroup,

    -- * Request Lenses
    updateGroup_newGroupName,
    updateGroup_newPath,
    updateGroup_groupName,

    -- * Destructuring the Response
    UpdateGroupResponse (..),
    newUpdateGroupResponse,
  )
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:/ 'newUpdateGroup' smart constructor.
data UpdateGroup = UpdateGroup'
  { -- | New name for the IAM group. Only include this if changing the group\'s
    -- name.
    --
    -- IAM user, group, role, and policy names must be unique within the
    -- account. Names are not distinguished by case. For example, you cannot
    -- create resources named both \"MyResource\" and \"myresource\".
    UpdateGroup -> Maybe Text
newGroupName' :: Prelude.Maybe Prelude.Text,
    -- | New path for the IAM group. Only include this if changing the group\'s
    -- path.
    --
    -- This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- consisting of either a forward slash (\/) by itself or a string that
    -- must begin and end with forward slashes. In addition, it can contain any
    -- ASCII character from the ! (@\\u0021@) through the DEL character
    -- (@\\u007F@), including most punctuation characters, digits, and upper
    -- and lowercased letters.
    UpdateGroup -> Maybe Text
newPath' :: Prelude.Maybe Prelude.Text,
    -- | Name of the IAM group to update. If you\'re changing the name of the
    -- group, this is the original name.
    --
    -- 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: _+=,.\@-
    UpdateGroup -> Text
groupName :: Prelude.Text
  }
  deriving (UpdateGroup -> UpdateGroup -> Bool
(UpdateGroup -> UpdateGroup -> Bool)
-> (UpdateGroup -> UpdateGroup -> Bool) -> Eq UpdateGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateGroup -> UpdateGroup -> Bool
$c/= :: UpdateGroup -> UpdateGroup -> Bool
== :: UpdateGroup -> UpdateGroup -> Bool
$c== :: UpdateGroup -> UpdateGroup -> Bool
Prelude.Eq, ReadPrec [UpdateGroup]
ReadPrec UpdateGroup
Int -> ReadS UpdateGroup
ReadS [UpdateGroup]
(Int -> ReadS UpdateGroup)
-> ReadS [UpdateGroup]
-> ReadPrec UpdateGroup
-> ReadPrec [UpdateGroup]
-> Read UpdateGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateGroup]
$creadListPrec :: ReadPrec [UpdateGroup]
readPrec :: ReadPrec UpdateGroup
$creadPrec :: ReadPrec UpdateGroup
readList :: ReadS [UpdateGroup]
$creadList :: ReadS [UpdateGroup]
readsPrec :: Int -> ReadS UpdateGroup
$creadsPrec :: Int -> ReadS UpdateGroup
Prelude.Read, Int -> UpdateGroup -> ShowS
[UpdateGroup] -> ShowS
UpdateGroup -> String
(Int -> UpdateGroup -> ShowS)
-> (UpdateGroup -> String)
-> ([UpdateGroup] -> ShowS)
-> Show UpdateGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateGroup] -> ShowS
$cshowList :: [UpdateGroup] -> ShowS
show :: UpdateGroup -> String
$cshow :: UpdateGroup -> String
showsPrec :: Int -> UpdateGroup -> ShowS
$cshowsPrec :: Int -> UpdateGroup -> ShowS
Prelude.Show, (forall x. UpdateGroup -> Rep UpdateGroup x)
-> (forall x. Rep UpdateGroup x -> UpdateGroup)
-> Generic UpdateGroup
forall x. Rep UpdateGroup x -> UpdateGroup
forall x. UpdateGroup -> Rep UpdateGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateGroup x -> UpdateGroup
$cfrom :: forall x. UpdateGroup -> Rep UpdateGroup x
Prelude.Generic)

-- |
-- Create a value of 'UpdateGroup' 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:
--
-- 'newGroupName'', 'updateGroup_newGroupName' - New name for the IAM group. Only include this if changing the group\'s
-- name.
--
-- IAM user, group, role, and policy names must be unique within the
-- account. Names are not distinguished by case. For example, you cannot
-- create resources named both \"MyResource\" and \"myresource\".
--
-- 'newPath'', 'updateGroup_newPath' - New path for the IAM group. Only include this if changing the group\'s
-- path.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of either a forward slash (\/) by itself or a string that
-- must begin and end with forward slashes. In addition, it can contain any
-- ASCII character from the ! (@\\u0021@) through the DEL character
-- (@\\u007F@), including most punctuation characters, digits, and upper
-- and lowercased letters.
--
-- 'groupName', 'updateGroup_groupName' - Name of the IAM group to update. If you\'re changing the name of the
-- group, this is the original name.
--
-- 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: _+=,.\@-
newUpdateGroup ::
  -- | 'groupName'
  Prelude.Text ->
  UpdateGroup
newUpdateGroup :: Text -> UpdateGroup
newUpdateGroup Text
pGroupName_ =
  UpdateGroup' :: Maybe Text -> Maybe Text -> Text -> UpdateGroup
UpdateGroup'
    { $sel:newGroupName':UpdateGroup' :: Maybe Text
newGroupName' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:newPath':UpdateGroup' :: Maybe Text
newPath' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:UpdateGroup' :: Text
groupName = Text
pGroupName_
    }

-- | New name for the IAM group. Only include this if changing the group\'s
-- name.
--
-- IAM user, group, role, and policy names must be unique within the
-- account. Names are not distinguished by case. For example, you cannot
-- create resources named both \"MyResource\" and \"myresource\".
updateGroup_newGroupName :: Lens.Lens' UpdateGroup (Prelude.Maybe Prelude.Text)
updateGroup_newGroupName :: (Maybe Text -> f (Maybe Text)) -> UpdateGroup -> f UpdateGroup
updateGroup_newGroupName = (UpdateGroup -> Maybe Text)
-> (UpdateGroup -> Maybe Text -> UpdateGroup)
-> Lens UpdateGroup UpdateGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGroup' {Maybe Text
newGroupName' :: Maybe Text
$sel:newGroupName':UpdateGroup' :: UpdateGroup -> Maybe Text
newGroupName'} -> Maybe Text
newGroupName') (\s :: UpdateGroup
s@UpdateGroup' {} Maybe Text
a -> UpdateGroup
s {$sel:newGroupName':UpdateGroup' :: Maybe Text
newGroupName' = Maybe Text
a} :: UpdateGroup)

-- | New path for the IAM group. Only include this if changing the group\'s
-- path.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of either a forward slash (\/) by itself or a string that
-- must begin and end with forward slashes. In addition, it can contain any
-- ASCII character from the ! (@\\u0021@) through the DEL character
-- (@\\u007F@), including most punctuation characters, digits, and upper
-- and lowercased letters.
updateGroup_newPath :: Lens.Lens' UpdateGroup (Prelude.Maybe Prelude.Text)
updateGroup_newPath :: (Maybe Text -> f (Maybe Text)) -> UpdateGroup -> f UpdateGroup
updateGroup_newPath = (UpdateGroup -> Maybe Text)
-> (UpdateGroup -> Maybe Text -> UpdateGroup)
-> Lens UpdateGroup UpdateGroup (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGroup' {Maybe Text
newPath' :: Maybe Text
$sel:newPath':UpdateGroup' :: UpdateGroup -> Maybe Text
newPath'} -> Maybe Text
newPath') (\s :: UpdateGroup
s@UpdateGroup' {} Maybe Text
a -> UpdateGroup
s {$sel:newPath':UpdateGroup' :: Maybe Text
newPath' = Maybe Text
a} :: UpdateGroup)

-- | Name of the IAM group to update. If you\'re changing the name of the
-- group, this is the original name.
--
-- 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: _+=,.\@-
updateGroup_groupName :: Lens.Lens' UpdateGroup Prelude.Text
updateGroup_groupName :: (Text -> f Text) -> UpdateGroup -> f UpdateGroup
updateGroup_groupName = (UpdateGroup -> Text)
-> (UpdateGroup -> Text -> UpdateGroup)
-> Lens UpdateGroup UpdateGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateGroup' {Text
groupName :: Text
$sel:groupName:UpdateGroup' :: UpdateGroup -> Text
groupName} -> Text
groupName) (\s :: UpdateGroup
s@UpdateGroup' {} Text
a -> UpdateGroup
s {$sel:groupName:UpdateGroup' :: Text
groupName = Text
a} :: UpdateGroup)

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

instance Prelude.Hashable UpdateGroup

instance Prelude.NFData UpdateGroup

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

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

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

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

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

instance Prelude.NFData UpdateGroupResponse