{-# 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-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 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.Lens as Lens
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
(AssociateMemberToGroup -> AssociateMemberToGroup -> Bool)
-> (AssociateMemberToGroup -> AssociateMemberToGroup -> Bool)
-> Eq AssociateMemberToGroup
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]
(Int -> ReadS AssociateMemberToGroup)
-> ReadS [AssociateMemberToGroup]
-> ReadPrec AssociateMemberToGroup
-> ReadPrec [AssociateMemberToGroup]
-> Read 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
(Int -> AssociateMemberToGroup -> ShowS)
-> (AssociateMemberToGroup -> String)
-> ([AssociateMemberToGroup] -> ShowS)
-> Show AssociateMemberToGroup
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. AssociateMemberToGroup -> Rep AssociateMemberToGroup x)
-> (forall x.
    Rep AssociateMemberToGroup x -> AssociateMemberToGroup)
-> Generic AssociateMemberToGroup
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' :: Text -> Text -> Text -> AssociateMemberToGroup
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 :: (Text -> f Text)
-> AssociateMemberToGroup -> f AssociateMemberToGroup
associateMemberToGroup_organizationId = (AssociateMemberToGroup -> Text)
-> (AssociateMemberToGroup -> Text -> AssociateMemberToGroup)
-> Lens AssociateMemberToGroup AssociateMemberToGroup Text Text
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 :: (Text -> f Text)
-> AssociateMemberToGroup -> f AssociateMemberToGroup
associateMemberToGroup_groupId = (AssociateMemberToGroup -> Text)
-> (AssociateMemberToGroup -> Text -> AssociateMemberToGroup)
-> Lens AssociateMemberToGroup AssociateMemberToGroup Text Text
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 :: (Text -> f Text)
-> AssociateMemberToGroup -> f AssociateMemberToGroup
associateMemberToGroup_memberId = (AssociateMemberToGroup -> Text)
-> (AssociateMemberToGroup -> Text -> AssociateMemberToGroup)
-> Lens AssociateMemberToGroup AssociateMemberToGroup Text Text
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 :: AssociateMemberToGroup -> Request AssociateMemberToGroup
request = Service -> AssociateMemberToGroup -> Request AssociateMemberToGroup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateMemberToGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateMemberToGroup)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse AssociateMemberToGroup))
-> Logger
-> Service
-> Proxy AssociateMemberToGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateMemberToGroup)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> AssociateMemberToGroupResponse
AssociateMemberToGroupResponse'
            (Int -> AssociateMemberToGroupResponse)
-> Either String Int
-> Either String AssociateMemberToGroupResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable AssociateMemberToGroup

instance Prelude.NFData AssociateMemberToGroup

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"OrganizationId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
organizationId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"GroupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
groupId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MemberId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
memberId)
          ]
      )

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

instance Core.ToQuery AssociateMemberToGroup where
  toQuery :: AssociateMemberToGroup -> QueryString
toQuery = QueryString -> AssociateMemberToGroup -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(AssociateMemberToGroupResponse
 -> AssociateMemberToGroupResponse -> Bool)
-> (AssociateMemberToGroupResponse
    -> AssociateMemberToGroupResponse -> Bool)
-> Eq AssociateMemberToGroupResponse
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]
(Int -> ReadS AssociateMemberToGroupResponse)
-> ReadS [AssociateMemberToGroupResponse]
-> ReadPrec AssociateMemberToGroupResponse
-> ReadPrec [AssociateMemberToGroupResponse]
-> Read 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
(Int -> AssociateMemberToGroupResponse -> ShowS)
-> (AssociateMemberToGroupResponse -> String)
-> ([AssociateMemberToGroupResponse] -> ShowS)
-> Show AssociateMemberToGroupResponse
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.
 AssociateMemberToGroupResponse
 -> Rep AssociateMemberToGroupResponse x)
-> (forall x.
    Rep AssociateMemberToGroupResponse x
    -> AssociateMemberToGroupResponse)
-> Generic AssociateMemberToGroupResponse
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' :: Int -> AssociateMemberToGroupResponse
AssociateMemberToGroupResponse'
    { $sel:httpStatus:AssociateMemberToGroupResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
associateMemberToGroupResponse_httpStatus :: Lens.Lens' AssociateMemberToGroupResponse Prelude.Int
associateMemberToGroupResponse_httpStatus :: (Int -> f Int)
-> AssociateMemberToGroupResponse
-> f AssociateMemberToGroupResponse
associateMemberToGroupResponse_httpStatus = (AssociateMemberToGroupResponse -> Int)
-> (AssociateMemberToGroupResponse
    -> Int -> AssociateMemberToGroupResponse)
-> Lens
     AssociateMemberToGroupResponse
     AssociateMemberToGroupResponse
     Int
     Int
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