{-# 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.WorkMail.AssociateMemberToGroup
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Adds a member (user or group) to the group\'s set.
module Amazonka.WorkMail.AssociateMemberToGroup
  ( -- * Creating a Request
    AssociateMemberToGroup (..),
    newAssociateMemberToGroup,

    -- * Request Lenses
    associateMemberToGroup_organizationId,
    associateMemberToGroup_groupId,
    associateMemberToGroup_memberId,

    -- * Destructuring the Response
    AssociateMemberToGroupResponse (..),
    newAssociateMemberToGroupResponse,

    -- * Response Lenses
    associateMemberToGroupResponse_httpStatus,
  )
where

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

-- | /See:/ 'newAssociateMemberToGroup' smart constructor.
data AssociateMemberToGroup = AssociateMemberToGroup'
  { -- | The organization under which the group exists.
    AssociateMemberToGroup -> Text
organizationId :: Prelude.Text,
    -- | The group to which the member (user or group) is associated.
    AssociateMemberToGroup -> Text
groupId :: Prelude.Text,
    -- | The member (user or group) to associate to the group.
    AssociateMemberToGroup -> Text
memberId :: Prelude.Text
  }
  deriving (AssociateMemberToGroup -> AssociateMemberToGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateMemberToGroup -> AssociateMemberToGroup -> Bool
$c/= :: AssociateMemberToGroup -> AssociateMemberToGroup -> Bool
== :: AssociateMemberToGroup -> AssociateMemberToGroup -> Bool
$c== :: AssociateMemberToGroup -> AssociateMemberToGroup -> Bool
Prelude.Eq, ReadPrec [AssociateMemberToGroup]
ReadPrec AssociateMemberToGroup
Int -> ReadS AssociateMemberToGroup
ReadS [AssociateMemberToGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateMemberToGroup]
$creadListPrec :: ReadPrec [AssociateMemberToGroup]
readPrec :: ReadPrec AssociateMemberToGroup
$creadPrec :: ReadPrec AssociateMemberToGroup
readList :: ReadS [AssociateMemberToGroup]
$creadList :: ReadS [AssociateMemberToGroup]
readsPrec :: Int -> ReadS AssociateMemberToGroup
$creadsPrec :: Int -> ReadS AssociateMemberToGroup
Prelude.Read, Int -> AssociateMemberToGroup -> ShowS
[AssociateMemberToGroup] -> ShowS
AssociateMemberToGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateMemberToGroup] -> ShowS
$cshowList :: [AssociateMemberToGroup] -> ShowS
show :: AssociateMemberToGroup -> String
$cshow :: AssociateMemberToGroup -> String
showsPrec :: Int -> AssociateMemberToGroup -> ShowS
$cshowsPrec :: Int -> AssociateMemberToGroup -> ShowS
Prelude.Show, forall x. Rep AssociateMemberToGroup x -> AssociateMemberToGroup
forall x. AssociateMemberToGroup -> Rep AssociateMemberToGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateMemberToGroup x -> AssociateMemberToGroup
$cfrom :: forall x. AssociateMemberToGroup -> Rep AssociateMemberToGroup x
Prelude.Generic)

-- |
-- Create a value of 'AssociateMemberToGroup' 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:
--
-- 'organizationId', 'associateMemberToGroup_organizationId' - The organization under which the group exists.
--
-- 'groupId', 'associateMemberToGroup_groupId' - The group to which the member (user or group) is associated.
--
-- 'memberId', 'associateMemberToGroup_memberId' - The member (user or group) to associate to the group.
newAssociateMemberToGroup ::
  -- | 'organizationId'
  Prelude.Text ->
  -- | 'groupId'
  Prelude.Text ->
  -- | 'memberId'
  Prelude.Text ->
  AssociateMemberToGroup
newAssociateMemberToGroup :: Text -> Text -> Text -> AssociateMemberToGroup
newAssociateMemberToGroup
  Text
pOrganizationId_
  Text
pGroupId_
  Text
pMemberId_ =
    AssociateMemberToGroup'
      { $sel:organizationId:AssociateMemberToGroup' :: Text
organizationId =
          Text
pOrganizationId_,
        $sel:groupId:AssociateMemberToGroup' :: Text
groupId = Text
pGroupId_,
        $sel:memberId:AssociateMemberToGroup' :: Text
memberId = Text
pMemberId_
      }

-- | The organization under which the group exists.
associateMemberToGroup_organizationId :: Lens.Lens' AssociateMemberToGroup Prelude.Text
associateMemberToGroup_organizationId :: Lens' AssociateMemberToGroup Text
associateMemberToGroup_organizationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateMemberToGroup' {Text
organizationId :: Text
$sel:organizationId:AssociateMemberToGroup' :: AssociateMemberToGroup -> Text
organizationId} -> Text
organizationId) (\s :: AssociateMemberToGroup
s@AssociateMemberToGroup' {} Text
a -> AssociateMemberToGroup
s {$sel:organizationId:AssociateMemberToGroup' :: Text
organizationId = Text
a} :: AssociateMemberToGroup)

-- | The group to which the member (user or group) is associated.
associateMemberToGroup_groupId :: Lens.Lens' AssociateMemberToGroup Prelude.Text
associateMemberToGroup_groupId :: Lens' AssociateMemberToGroup Text
associateMemberToGroup_groupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateMemberToGroup' {Text
groupId :: Text
$sel:groupId:AssociateMemberToGroup' :: AssociateMemberToGroup -> Text
groupId} -> Text
groupId) (\s :: AssociateMemberToGroup
s@AssociateMemberToGroup' {} Text
a -> AssociateMemberToGroup
s {$sel:groupId:AssociateMemberToGroup' :: Text
groupId = Text
a} :: AssociateMemberToGroup)

-- | The member (user or group) to associate to the group.
associateMemberToGroup_memberId :: Lens.Lens' AssociateMemberToGroup Prelude.Text
associateMemberToGroup_memberId :: Lens' AssociateMemberToGroup Text
associateMemberToGroup_memberId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateMemberToGroup' {Text
memberId :: Text
$sel:memberId:AssociateMemberToGroup' :: AssociateMemberToGroup -> Text
memberId} -> Text
memberId) (\s :: AssociateMemberToGroup
s@AssociateMemberToGroup' {} Text
a -> AssociateMemberToGroup
s {$sel:memberId:AssociateMemberToGroup' :: Text
memberId = Text
a} :: AssociateMemberToGroup)

instance Core.AWSRequest AssociateMemberToGroup where
  type
    AWSResponse AssociateMemberToGroup =
      AssociateMemberToGroupResponse
  request :: (Service -> Service)
-> AssociateMemberToGroup -> Request AssociateMemberToGroup
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy AssociateMemberToGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateMemberToGroup)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> AssociateMemberToGroupResponse
AssociateMemberToGroupResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable AssociateMemberToGroup where
  hashWithSalt :: Int -> AssociateMemberToGroup -> Int
hashWithSalt Int
_salt AssociateMemberToGroup' {Text
memberId :: Text
groupId :: Text
organizationId :: Text
$sel:memberId:AssociateMemberToGroup' :: AssociateMemberToGroup -> Text
$sel:groupId:AssociateMemberToGroup' :: AssociateMemberToGroup -> Text
$sel:organizationId:AssociateMemberToGroup' :: AssociateMemberToGroup -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
organizationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
groupId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
memberId

instance Prelude.NFData AssociateMemberToGroup where
  rnf :: AssociateMemberToGroup -> ()
rnf AssociateMemberToGroup' {Text
memberId :: Text
groupId :: Text
organizationId :: Text
$sel:memberId:AssociateMemberToGroup' :: AssociateMemberToGroup -> Text
$sel:groupId:AssociateMemberToGroup' :: AssociateMemberToGroup -> Text
$sel:organizationId:AssociateMemberToGroup' :: AssociateMemberToGroup -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
organizationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
groupId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
memberId

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

instance Data.ToJSON AssociateMemberToGroup where
  toJSON :: AssociateMemberToGroup -> Value
toJSON AssociateMemberToGroup' {Text
memberId :: Text
groupId :: Text
organizationId :: Text
$sel:memberId:AssociateMemberToGroup' :: AssociateMemberToGroup -> Text
$sel:groupId:AssociateMemberToGroup' :: AssociateMemberToGroup -> Text
$sel:organizationId:AssociateMemberToGroup' :: AssociateMemberToGroup -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"OrganizationId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
organizationId),
            forall a. a -> Maybe a
Prelude.Just (Key
"GroupId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
groupId),
            forall a. a -> Maybe a
Prelude.Just (Key
"MemberId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
memberId)
          ]
      )

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

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

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

-- |
-- Create a value of 'AssociateMemberToGroupResponse' 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:
--
-- 'httpStatus', 'associateMemberToGroupResponse_httpStatus' - The response's http status code.
newAssociateMemberToGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AssociateMemberToGroupResponse
newAssociateMemberToGroupResponse :: Int -> AssociateMemberToGroupResponse
newAssociateMemberToGroupResponse Int
pHttpStatus_ =
  AssociateMemberToGroupResponse'
    { $sel:httpStatus:AssociateMemberToGroupResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
associateMemberToGroupResponse_httpStatus :: Lens.Lens' AssociateMemberToGroupResponse Prelude.Int
associateMemberToGroupResponse_httpStatus :: Lens' AssociateMemberToGroupResponse Int
associateMemberToGroupResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateMemberToGroupResponse' {Int
httpStatus :: Int
$sel:httpStatus:AssociateMemberToGroupResponse' :: AssociateMemberToGroupResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AssociateMemberToGroupResponse
s@AssociateMemberToGroupResponse' {} Int
a -> AssociateMemberToGroupResponse
s {$sel:httpStatus:AssociateMemberToGroupResponse' :: Int
httpStatus = Int
a} :: AssociateMemberToGroupResponse)

instance
  Prelude.NFData
    AssociateMemberToGroupResponse
  where
  rnf :: AssociateMemberToGroupResponse -> ()
rnf AssociateMemberToGroupResponse' {Int
httpStatus :: Int
$sel:httpStatus:AssociateMemberToGroupResponse' :: AssociateMemberToGroupResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus