{-# 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.ElastiCache.ModifyUserGroup
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Changes the list of users that belong to the user group.
module Amazonka.ElastiCache.ModifyUserGroup
  ( -- * Creating a Request
    ModifyUserGroup (..),
    newModifyUserGroup,

    -- * Request Lenses
    modifyUserGroup_userIdsToAdd,
    modifyUserGroup_userIdsToRemove,
    modifyUserGroup_userGroupId,

    -- * Destructuring the Response
    UserGroup (..),
    newUserGroup,

    -- * Response Lenses
    userGroup_arn,
    userGroup_engine,
    userGroup_minimumEngineVersion,
    userGroup_pendingChanges,
    userGroup_replicationGroups,
    userGroup_status,
    userGroup_userGroupId,
    userGroup_userIds,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ElastiCache.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newModifyUserGroup' smart constructor.
data ModifyUserGroup = ModifyUserGroup'
  { -- | The list of user IDs to add to the user group.
    ModifyUserGroup -> Maybe (NonEmpty Text)
userIdsToAdd :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The list of user IDs to remove from the user group.
    ModifyUserGroup -> Maybe (NonEmpty Text)
userIdsToRemove :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The ID of the user group.
    ModifyUserGroup -> Text
userGroupId :: Prelude.Text
  }
  deriving (ModifyUserGroup -> ModifyUserGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyUserGroup -> ModifyUserGroup -> Bool
$c/= :: ModifyUserGroup -> ModifyUserGroup -> Bool
== :: ModifyUserGroup -> ModifyUserGroup -> Bool
$c== :: ModifyUserGroup -> ModifyUserGroup -> Bool
Prelude.Eq, ReadPrec [ModifyUserGroup]
ReadPrec ModifyUserGroup
Int -> ReadS ModifyUserGroup
ReadS [ModifyUserGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyUserGroup]
$creadListPrec :: ReadPrec [ModifyUserGroup]
readPrec :: ReadPrec ModifyUserGroup
$creadPrec :: ReadPrec ModifyUserGroup
readList :: ReadS [ModifyUserGroup]
$creadList :: ReadS [ModifyUserGroup]
readsPrec :: Int -> ReadS ModifyUserGroup
$creadsPrec :: Int -> ReadS ModifyUserGroup
Prelude.Read, Int -> ModifyUserGroup -> ShowS
[ModifyUserGroup] -> ShowS
ModifyUserGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyUserGroup] -> ShowS
$cshowList :: [ModifyUserGroup] -> ShowS
show :: ModifyUserGroup -> String
$cshow :: ModifyUserGroup -> String
showsPrec :: Int -> ModifyUserGroup -> ShowS
$cshowsPrec :: Int -> ModifyUserGroup -> ShowS
Prelude.Show, forall x. Rep ModifyUserGroup x -> ModifyUserGroup
forall x. ModifyUserGroup -> Rep ModifyUserGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModifyUserGroup x -> ModifyUserGroup
$cfrom :: forall x. ModifyUserGroup -> Rep ModifyUserGroup x
Prelude.Generic)

-- |
-- Create a value of 'ModifyUserGroup' 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:
--
-- 'userIdsToAdd', 'modifyUserGroup_userIdsToAdd' - The list of user IDs to add to the user group.
--
-- 'userIdsToRemove', 'modifyUserGroup_userIdsToRemove' - The list of user IDs to remove from the user group.
--
-- 'userGroupId', 'modifyUserGroup_userGroupId' - The ID of the user group.
newModifyUserGroup ::
  -- | 'userGroupId'
  Prelude.Text ->
  ModifyUserGroup
newModifyUserGroup :: Text -> ModifyUserGroup
newModifyUserGroup Text
pUserGroupId_ =
  ModifyUserGroup'
    { $sel:userIdsToAdd:ModifyUserGroup' :: Maybe (NonEmpty Text)
userIdsToAdd = forall a. Maybe a
Prelude.Nothing,
      $sel:userIdsToRemove:ModifyUserGroup' :: Maybe (NonEmpty Text)
userIdsToRemove = forall a. Maybe a
Prelude.Nothing,
      $sel:userGroupId:ModifyUserGroup' :: Text
userGroupId = Text
pUserGroupId_
    }

-- | The list of user IDs to add to the user group.
modifyUserGroup_userIdsToAdd :: Lens.Lens' ModifyUserGroup (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
modifyUserGroup_userIdsToAdd :: Lens' ModifyUserGroup (Maybe (NonEmpty Text))
modifyUserGroup_userIdsToAdd = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyUserGroup' {Maybe (NonEmpty Text)
userIdsToAdd :: Maybe (NonEmpty Text)
$sel:userIdsToAdd:ModifyUserGroup' :: ModifyUserGroup -> Maybe (NonEmpty Text)
userIdsToAdd} -> Maybe (NonEmpty Text)
userIdsToAdd) (\s :: ModifyUserGroup
s@ModifyUserGroup' {} Maybe (NonEmpty Text)
a -> ModifyUserGroup
s {$sel:userIdsToAdd:ModifyUserGroup' :: Maybe (NonEmpty Text)
userIdsToAdd = Maybe (NonEmpty Text)
a} :: ModifyUserGroup) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The list of user IDs to remove from the user group.
modifyUserGroup_userIdsToRemove :: Lens.Lens' ModifyUserGroup (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
modifyUserGroup_userIdsToRemove :: Lens' ModifyUserGroup (Maybe (NonEmpty Text))
modifyUserGroup_userIdsToRemove = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyUserGroup' {Maybe (NonEmpty Text)
userIdsToRemove :: Maybe (NonEmpty Text)
$sel:userIdsToRemove:ModifyUserGroup' :: ModifyUserGroup -> Maybe (NonEmpty Text)
userIdsToRemove} -> Maybe (NonEmpty Text)
userIdsToRemove) (\s :: ModifyUserGroup
s@ModifyUserGroup' {} Maybe (NonEmpty Text)
a -> ModifyUserGroup
s {$sel:userIdsToRemove:ModifyUserGroup' :: Maybe (NonEmpty Text)
userIdsToRemove = Maybe (NonEmpty Text)
a} :: ModifyUserGroup) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the user group.
modifyUserGroup_userGroupId :: Lens.Lens' ModifyUserGroup Prelude.Text
modifyUserGroup_userGroupId :: Lens' ModifyUserGroup Text
modifyUserGroup_userGroupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyUserGroup' {Text
userGroupId :: Text
$sel:userGroupId:ModifyUserGroup' :: ModifyUserGroup -> Text
userGroupId} -> Text
userGroupId) (\s :: ModifyUserGroup
s@ModifyUserGroup' {} Text
a -> ModifyUserGroup
s {$sel:userGroupId:ModifyUserGroup' :: Text
userGroupId = Text
a} :: ModifyUserGroup)

instance Core.AWSRequest ModifyUserGroup where
  type AWSResponse ModifyUserGroup = UserGroup
  request :: (Service -> Service) -> ModifyUserGroup -> Request ModifyUserGroup
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ModifyUserGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ModifyUserGroup)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ModifyUserGroupResult"
      (\Int
s ResponseHeaders
h [Node]
x -> forall a. FromXML a => [Node] -> Either String a
Data.parseXML [Node]
x)

instance Prelude.Hashable ModifyUserGroup where
  hashWithSalt :: Int -> ModifyUserGroup -> Int
hashWithSalt Int
_salt ModifyUserGroup' {Maybe (NonEmpty Text)
Text
userGroupId :: Text
userIdsToRemove :: Maybe (NonEmpty Text)
userIdsToAdd :: Maybe (NonEmpty Text)
$sel:userGroupId:ModifyUserGroup' :: ModifyUserGroup -> Text
$sel:userIdsToRemove:ModifyUserGroup' :: ModifyUserGroup -> Maybe (NonEmpty Text)
$sel:userIdsToAdd:ModifyUserGroup' :: ModifyUserGroup -> Maybe (NonEmpty Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
userIdsToAdd
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
userIdsToRemove
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userGroupId

instance Prelude.NFData ModifyUserGroup where
  rnf :: ModifyUserGroup -> ()
rnf ModifyUserGroup' {Maybe (NonEmpty Text)
Text
userGroupId :: Text
userIdsToRemove :: Maybe (NonEmpty Text)
userIdsToAdd :: Maybe (NonEmpty Text)
$sel:userGroupId:ModifyUserGroup' :: ModifyUserGroup -> Text
$sel:userIdsToRemove:ModifyUserGroup' :: ModifyUserGroup -> Maybe (NonEmpty Text)
$sel:userIdsToAdd:ModifyUserGroup' :: ModifyUserGroup -> Maybe (NonEmpty Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
userIdsToAdd
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
userIdsToRemove
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userGroupId

instance Data.ToHeaders ModifyUserGroup where
  toHeaders :: ModifyUserGroup -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery ModifyUserGroup where
  toQuery :: ModifyUserGroup -> QueryString
toQuery ModifyUserGroup' {Maybe (NonEmpty Text)
Text
userGroupId :: Text
userIdsToRemove :: Maybe (NonEmpty Text)
userIdsToAdd :: Maybe (NonEmpty Text)
$sel:userGroupId:ModifyUserGroup' :: ModifyUserGroup -> Text
$sel:userIdsToRemove:ModifyUserGroup' :: ModifyUserGroup -> Maybe (NonEmpty Text)
$sel:userIdsToAdd:ModifyUserGroup' :: ModifyUserGroup -> Maybe (NonEmpty Text)
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"ModifyUserGroup" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2015-02-02" :: Prelude.ByteString),
        ByteString
"UserIdsToAdd"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            (forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
userIdsToAdd),
        ByteString
"UserIdsToRemove"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
            ( forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member"
                forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
userIdsToRemove
            ),
        ByteString
"UserGroupId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
userGroupId
      ]