{-# 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.CognitoIdentityProvider.AdminAddUserToGroup
-- 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)
--
-- Adds the specified user to the specified group.
--
-- Calling this action requires developer credentials.
module Amazonka.CognitoIdentityProvider.AdminAddUserToGroup
  ( -- * Creating a Request
    AdminAddUserToGroup (..),
    newAdminAddUserToGroup,

    -- * Request Lenses
    adminAddUserToGroup_userPoolId,
    adminAddUserToGroup_username,
    adminAddUserToGroup_groupName,

    -- * Destructuring the Response
    AdminAddUserToGroupResponse (..),
    newAdminAddUserToGroupResponse,
  )
where

import Amazonka.CognitoIdentityProvider.Types
import qualified Amazonka.Core as Core
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:/ 'newAdminAddUserToGroup' smart constructor.
data AdminAddUserToGroup = AdminAddUserToGroup'
  { -- | The user pool ID for the user pool.
    AdminAddUserToGroup -> Text
userPoolId :: Prelude.Text,
    -- | The username for the user.
    AdminAddUserToGroup -> Sensitive Text
username :: Core.Sensitive Prelude.Text,
    -- | The group name.
    AdminAddUserToGroup -> Text
groupName :: Prelude.Text
  }
  deriving (AdminAddUserToGroup -> AdminAddUserToGroup -> Bool
(AdminAddUserToGroup -> AdminAddUserToGroup -> Bool)
-> (AdminAddUserToGroup -> AdminAddUserToGroup -> Bool)
-> Eq AdminAddUserToGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AdminAddUserToGroup -> AdminAddUserToGroup -> Bool
$c/= :: AdminAddUserToGroup -> AdminAddUserToGroup -> Bool
== :: AdminAddUserToGroup -> AdminAddUserToGroup -> Bool
$c== :: AdminAddUserToGroup -> AdminAddUserToGroup -> Bool
Prelude.Eq, Int -> AdminAddUserToGroup -> ShowS
[AdminAddUserToGroup] -> ShowS
AdminAddUserToGroup -> String
(Int -> AdminAddUserToGroup -> ShowS)
-> (AdminAddUserToGroup -> String)
-> ([AdminAddUserToGroup] -> ShowS)
-> Show AdminAddUserToGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AdminAddUserToGroup] -> ShowS
$cshowList :: [AdminAddUserToGroup] -> ShowS
show :: AdminAddUserToGroup -> String
$cshow :: AdminAddUserToGroup -> String
showsPrec :: Int -> AdminAddUserToGroup -> ShowS
$cshowsPrec :: Int -> AdminAddUserToGroup -> ShowS
Prelude.Show, (forall x. AdminAddUserToGroup -> Rep AdminAddUserToGroup x)
-> (forall x. Rep AdminAddUserToGroup x -> AdminAddUserToGroup)
-> Generic AdminAddUserToGroup
forall x. Rep AdminAddUserToGroup x -> AdminAddUserToGroup
forall x. AdminAddUserToGroup -> Rep AdminAddUserToGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AdminAddUserToGroup x -> AdminAddUserToGroup
$cfrom :: forall x. AdminAddUserToGroup -> Rep AdminAddUserToGroup x
Prelude.Generic)

-- |
-- Create a value of 'AdminAddUserToGroup' 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:
--
-- 'userPoolId', 'adminAddUserToGroup_userPoolId' - The user pool ID for the user pool.
--
-- 'username', 'adminAddUserToGroup_username' - The username for the user.
--
-- 'groupName', 'adminAddUserToGroup_groupName' - The group name.
newAdminAddUserToGroup ::
  -- | 'userPoolId'
  Prelude.Text ->
  -- | 'username'
  Prelude.Text ->
  -- | 'groupName'
  Prelude.Text ->
  AdminAddUserToGroup
newAdminAddUserToGroup :: Text -> Text -> Text -> AdminAddUserToGroup
newAdminAddUserToGroup
  Text
pUserPoolId_
  Text
pUsername_
  Text
pGroupName_ =
    AdminAddUserToGroup' :: Text -> Sensitive Text -> Text -> AdminAddUserToGroup
AdminAddUserToGroup'
      { $sel:userPoolId:AdminAddUserToGroup' :: Text
userPoolId = Text
pUserPoolId_,
        $sel:username:AdminAddUserToGroup' :: Sensitive Text
username = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pUsername_,
        $sel:groupName:AdminAddUserToGroup' :: Text
groupName = Text
pGroupName_
      }

-- | The user pool ID for the user pool.
adminAddUserToGroup_userPoolId :: Lens.Lens' AdminAddUserToGroup Prelude.Text
adminAddUserToGroup_userPoolId :: (Text -> f Text) -> AdminAddUserToGroup -> f AdminAddUserToGroup
adminAddUserToGroup_userPoolId = (AdminAddUserToGroup -> Text)
-> (AdminAddUserToGroup -> Text -> AdminAddUserToGroup)
-> Lens AdminAddUserToGroup AdminAddUserToGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminAddUserToGroup' {Text
userPoolId :: Text
$sel:userPoolId:AdminAddUserToGroup' :: AdminAddUserToGroup -> Text
userPoolId} -> Text
userPoolId) (\s :: AdminAddUserToGroup
s@AdminAddUserToGroup' {} Text
a -> AdminAddUserToGroup
s {$sel:userPoolId:AdminAddUserToGroup' :: Text
userPoolId = Text
a} :: AdminAddUserToGroup)

-- | The username for the user.
adminAddUserToGroup_username :: Lens.Lens' AdminAddUserToGroup Prelude.Text
adminAddUserToGroup_username :: (Text -> f Text) -> AdminAddUserToGroup -> f AdminAddUserToGroup
adminAddUserToGroup_username = (AdminAddUserToGroup -> Sensitive Text)
-> (AdminAddUserToGroup -> Sensitive Text -> AdminAddUserToGroup)
-> Lens
     AdminAddUserToGroup
     AdminAddUserToGroup
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminAddUserToGroup' {Sensitive Text
username :: Sensitive Text
$sel:username:AdminAddUserToGroup' :: AdminAddUserToGroup -> Sensitive Text
username} -> Sensitive Text
username) (\s :: AdminAddUserToGroup
s@AdminAddUserToGroup' {} Sensitive Text
a -> AdminAddUserToGroup
s {$sel:username:AdminAddUserToGroup' :: Sensitive Text
username = Sensitive Text
a} :: AdminAddUserToGroup) ((Sensitive Text -> f (Sensitive Text))
 -> AdminAddUserToGroup -> f AdminAddUserToGroup)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> AdminAddUserToGroup
-> f AdminAddUserToGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The group name.
adminAddUserToGroup_groupName :: Lens.Lens' AdminAddUserToGroup Prelude.Text
adminAddUserToGroup_groupName :: (Text -> f Text) -> AdminAddUserToGroup -> f AdminAddUserToGroup
adminAddUserToGroup_groupName = (AdminAddUserToGroup -> Text)
-> (AdminAddUserToGroup -> Text -> AdminAddUserToGroup)
-> Lens AdminAddUserToGroup AdminAddUserToGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminAddUserToGroup' {Text
groupName :: Text
$sel:groupName:AdminAddUserToGroup' :: AdminAddUserToGroup -> Text
groupName} -> Text
groupName) (\s :: AdminAddUserToGroup
s@AdminAddUserToGroup' {} Text
a -> AdminAddUserToGroup
s {$sel:groupName:AdminAddUserToGroup' :: Text
groupName = Text
a} :: AdminAddUserToGroup)

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

instance Prelude.Hashable AdminAddUserToGroup

instance Prelude.NFData AdminAddUserToGroup

instance Core.ToHeaders AdminAddUserToGroup where
  toHeaders :: AdminAddUserToGroup -> [Header]
toHeaders =
    [Header] -> AdminAddUserToGroup -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"AWSCognitoIdentityProviderService.AdminAddUserToGroup" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON AdminAddUserToGroup where
  toJSON :: AdminAddUserToGroup -> Value
toJSON AdminAddUserToGroup' {Text
Sensitive Text
groupName :: Text
username :: Sensitive Text
userPoolId :: Text
$sel:groupName:AdminAddUserToGroup' :: AdminAddUserToGroup -> Text
$sel:username:AdminAddUserToGroup' :: AdminAddUserToGroup -> Sensitive Text
$sel:userPoolId:AdminAddUserToGroup' :: AdminAddUserToGroup -> Text
..} =
    [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
"UserPoolId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userPoolId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Username" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
username),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"GroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
groupName)
          ]
      )

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

instance Core.ToQuery AdminAddUserToGroup where
  toQuery :: AdminAddUserToGroup -> QueryString
toQuery = QueryString -> AdminAddUserToGroup -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

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

instance Prelude.NFData AdminAddUserToGroupResponse