{-# 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.Chime.CreateAttendee
-- 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)
--
-- Creates a new attendee for an active Amazon Chime SDK meeting. For more
-- information about the Amazon Chime SDK, see
-- <https://docs.aws.amazon.com/chime/latest/dg/meetings-sdk.html Using the Amazon Chime SDK>
-- in the /Amazon Chime Developer Guide/.
module Amazonka.Chime.CreateAttendee
  ( -- * Creating a Request
    CreateAttendee (..),
    newCreateAttendee,

    -- * Request Lenses
    createAttendee_tags,
    createAttendee_meetingId,
    createAttendee_externalUserId,

    -- * Destructuring the Response
    CreateAttendeeResponse (..),
    newCreateAttendeeResponse,

    -- * Response Lenses
    createAttendeeResponse_attendee,
    createAttendeeResponse_httpStatus,
  )
where

import Amazonka.Chime.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:/ 'newCreateAttendee' smart constructor.
data CreateAttendee = CreateAttendee'
  { -- | The tag key-value pairs.
    CreateAttendee -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | The Amazon Chime SDK meeting ID.
    CreateAttendee -> Text
meetingId :: Prelude.Text,
    -- | The Amazon Chime SDK external user ID. An idempotency token. Links the
    -- attendee to an identity managed by a builder application.
    CreateAttendee -> Sensitive Text
externalUserId :: Core.Sensitive Prelude.Text
  }
  deriving (CreateAttendee -> CreateAttendee -> Bool
(CreateAttendee -> CreateAttendee -> Bool)
-> (CreateAttendee -> CreateAttendee -> Bool) -> Eq CreateAttendee
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAttendee -> CreateAttendee -> Bool
$c/= :: CreateAttendee -> CreateAttendee -> Bool
== :: CreateAttendee -> CreateAttendee -> Bool
$c== :: CreateAttendee -> CreateAttendee -> Bool
Prelude.Eq, Int -> CreateAttendee -> ShowS
[CreateAttendee] -> ShowS
CreateAttendee -> String
(Int -> CreateAttendee -> ShowS)
-> (CreateAttendee -> String)
-> ([CreateAttendee] -> ShowS)
-> Show CreateAttendee
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAttendee] -> ShowS
$cshowList :: [CreateAttendee] -> ShowS
show :: CreateAttendee -> String
$cshow :: CreateAttendee -> String
showsPrec :: Int -> CreateAttendee -> ShowS
$cshowsPrec :: Int -> CreateAttendee -> ShowS
Prelude.Show, (forall x. CreateAttendee -> Rep CreateAttendee x)
-> (forall x. Rep CreateAttendee x -> CreateAttendee)
-> Generic CreateAttendee
forall x. Rep CreateAttendee x -> CreateAttendee
forall x. CreateAttendee -> Rep CreateAttendee x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAttendee x -> CreateAttendee
$cfrom :: forall x. CreateAttendee -> Rep CreateAttendee x
Prelude.Generic)

-- |
-- Create a value of 'CreateAttendee' 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:
--
-- 'tags', 'createAttendee_tags' - The tag key-value pairs.
--
-- 'meetingId', 'createAttendee_meetingId' - The Amazon Chime SDK meeting ID.
--
-- 'externalUserId', 'createAttendee_externalUserId' - The Amazon Chime SDK external user ID. An idempotency token. Links the
-- attendee to an identity managed by a builder application.
newCreateAttendee ::
  -- | 'meetingId'
  Prelude.Text ->
  -- | 'externalUserId'
  Prelude.Text ->
  CreateAttendee
newCreateAttendee :: Text -> Text -> CreateAttendee
newCreateAttendee Text
pMeetingId_ Text
pExternalUserId_ =
  CreateAttendee' :: Maybe (NonEmpty Tag) -> Text -> Sensitive Text -> CreateAttendee
CreateAttendee'
    { $sel:tags:CreateAttendee' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
      $sel:meetingId:CreateAttendee' :: Text
meetingId = Text
pMeetingId_,
      $sel:externalUserId:CreateAttendee' :: Sensitive Text
externalUserId =
        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
pExternalUserId_
    }

-- | The tag key-value pairs.
createAttendee_tags :: Lens.Lens' CreateAttendee (Prelude.Maybe (Prelude.NonEmpty Tag))
createAttendee_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateAttendee -> f CreateAttendee
createAttendee_tags = (CreateAttendee -> Maybe (NonEmpty Tag))
-> (CreateAttendee -> Maybe (NonEmpty Tag) -> CreateAttendee)
-> Lens
     CreateAttendee
     CreateAttendee
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAttendee' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateAttendee' :: CreateAttendee -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateAttendee
s@CreateAttendee' {} Maybe (NonEmpty Tag)
a -> CreateAttendee
s {$sel:tags:CreateAttendee' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateAttendee) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> CreateAttendee -> f CreateAttendee)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateAttendee
-> f CreateAttendee
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
-> Iso
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
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 AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Chime SDK meeting ID.
createAttendee_meetingId :: Lens.Lens' CreateAttendee Prelude.Text
createAttendee_meetingId :: (Text -> f Text) -> CreateAttendee -> f CreateAttendee
createAttendee_meetingId = (CreateAttendee -> Text)
-> (CreateAttendee -> Text -> CreateAttendee)
-> Lens CreateAttendee CreateAttendee Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAttendee' {Text
meetingId :: Text
$sel:meetingId:CreateAttendee' :: CreateAttendee -> Text
meetingId} -> Text
meetingId) (\s :: CreateAttendee
s@CreateAttendee' {} Text
a -> CreateAttendee
s {$sel:meetingId:CreateAttendee' :: Text
meetingId = Text
a} :: CreateAttendee)

-- | The Amazon Chime SDK external user ID. An idempotency token. Links the
-- attendee to an identity managed by a builder application.
createAttendee_externalUserId :: Lens.Lens' CreateAttendee Prelude.Text
createAttendee_externalUserId :: (Text -> f Text) -> CreateAttendee -> f CreateAttendee
createAttendee_externalUserId = (CreateAttendee -> Sensitive Text)
-> (CreateAttendee -> Sensitive Text -> CreateAttendee)
-> Lens
     CreateAttendee CreateAttendee (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAttendee' {Sensitive Text
externalUserId :: Sensitive Text
$sel:externalUserId:CreateAttendee' :: CreateAttendee -> Sensitive Text
externalUserId} -> Sensitive Text
externalUserId) (\s :: CreateAttendee
s@CreateAttendee' {} Sensitive Text
a -> CreateAttendee
s {$sel:externalUserId:CreateAttendee' :: Sensitive Text
externalUserId = Sensitive Text
a} :: CreateAttendee) ((Sensitive Text -> f (Sensitive Text))
 -> CreateAttendee -> f CreateAttendee)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> CreateAttendee
-> f CreateAttendee
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

instance Core.AWSRequest CreateAttendee where
  type
    AWSResponse CreateAttendee =
      CreateAttendeeResponse
  request :: CreateAttendee -> Request CreateAttendee
request = Service -> CreateAttendee -> Request CreateAttendee
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateAttendee
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateAttendee)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateAttendee))
-> Logger
-> Service
-> Proxy CreateAttendee
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateAttendee)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Attendee -> Int -> CreateAttendeeResponse
CreateAttendeeResponse'
            (Maybe Attendee -> Int -> CreateAttendeeResponse)
-> Either String (Maybe Attendee)
-> Either String (Int -> CreateAttendeeResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Attendee)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Attendee")
            Either String (Int -> CreateAttendeeResponse)
-> Either String Int -> Either String CreateAttendeeResponse
forall (f :: * -> *) a b. Applicative f => 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 CreateAttendee

instance Prelude.NFData CreateAttendee

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

instance Core.ToJSON CreateAttendee where
  toJSON :: CreateAttendee -> Value
toJSON CreateAttendee' {Maybe (NonEmpty Tag)
Text
Sensitive Text
externalUserId :: Sensitive Text
meetingId :: Text
tags :: Maybe (NonEmpty Tag)
$sel:externalUserId:CreateAttendee' :: CreateAttendee -> Sensitive Text
$sel:meetingId:CreateAttendee' :: CreateAttendee -> Text
$sel:tags:CreateAttendee' :: CreateAttendee -> Maybe (NonEmpty Tag)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Tags" Text -> NonEmpty Tag -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Tag -> Pair) -> Maybe (NonEmpty Tag) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Tag)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ExternalUserId" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
externalUserId)
          ]
      )

instance Core.ToPath CreateAttendee where
  toPath :: CreateAttendee -> ByteString
toPath CreateAttendee' {Maybe (NonEmpty Tag)
Text
Sensitive Text
externalUserId :: Sensitive Text
meetingId :: Text
tags :: Maybe (NonEmpty Tag)
$sel:externalUserId:CreateAttendee' :: CreateAttendee -> Sensitive Text
$sel:meetingId:CreateAttendee' :: CreateAttendee -> Text
$sel:tags:CreateAttendee' :: CreateAttendee -> Maybe (NonEmpty Tag)
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/meetings/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
meetingId, ByteString
"/attendees"]

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

-- | /See:/ 'newCreateAttendeeResponse' smart constructor.
data CreateAttendeeResponse = CreateAttendeeResponse'
  { -- | The attendee information, including attendee ID and join token.
    CreateAttendeeResponse -> Maybe Attendee
attendee :: Prelude.Maybe Attendee,
    -- | The response's http status code.
    CreateAttendeeResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateAttendeeResponse -> CreateAttendeeResponse -> Bool
(CreateAttendeeResponse -> CreateAttendeeResponse -> Bool)
-> (CreateAttendeeResponse -> CreateAttendeeResponse -> Bool)
-> Eq CreateAttendeeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAttendeeResponse -> CreateAttendeeResponse -> Bool
$c/= :: CreateAttendeeResponse -> CreateAttendeeResponse -> Bool
== :: CreateAttendeeResponse -> CreateAttendeeResponse -> Bool
$c== :: CreateAttendeeResponse -> CreateAttendeeResponse -> Bool
Prelude.Eq, Int -> CreateAttendeeResponse -> ShowS
[CreateAttendeeResponse] -> ShowS
CreateAttendeeResponse -> String
(Int -> CreateAttendeeResponse -> ShowS)
-> (CreateAttendeeResponse -> String)
-> ([CreateAttendeeResponse] -> ShowS)
-> Show CreateAttendeeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAttendeeResponse] -> ShowS
$cshowList :: [CreateAttendeeResponse] -> ShowS
show :: CreateAttendeeResponse -> String
$cshow :: CreateAttendeeResponse -> String
showsPrec :: Int -> CreateAttendeeResponse -> ShowS
$cshowsPrec :: Int -> CreateAttendeeResponse -> ShowS
Prelude.Show, (forall x. CreateAttendeeResponse -> Rep CreateAttendeeResponse x)
-> (forall x.
    Rep CreateAttendeeResponse x -> CreateAttendeeResponse)
-> Generic CreateAttendeeResponse
forall x. Rep CreateAttendeeResponse x -> CreateAttendeeResponse
forall x. CreateAttendeeResponse -> Rep CreateAttendeeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAttendeeResponse x -> CreateAttendeeResponse
$cfrom :: forall x. CreateAttendeeResponse -> Rep CreateAttendeeResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateAttendeeResponse' 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:
--
-- 'attendee', 'createAttendeeResponse_attendee' - The attendee information, including attendee ID and join token.
--
-- 'httpStatus', 'createAttendeeResponse_httpStatus' - The response's http status code.
newCreateAttendeeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateAttendeeResponse
newCreateAttendeeResponse :: Int -> CreateAttendeeResponse
newCreateAttendeeResponse Int
pHttpStatus_ =
  CreateAttendeeResponse' :: Maybe Attendee -> Int -> CreateAttendeeResponse
CreateAttendeeResponse'
    { $sel:attendee:CreateAttendeeResponse' :: Maybe Attendee
attendee = Maybe Attendee
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateAttendeeResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The attendee information, including attendee ID and join token.
createAttendeeResponse_attendee :: Lens.Lens' CreateAttendeeResponse (Prelude.Maybe Attendee)
createAttendeeResponse_attendee :: (Maybe Attendee -> f (Maybe Attendee))
-> CreateAttendeeResponse -> f CreateAttendeeResponse
createAttendeeResponse_attendee = (CreateAttendeeResponse -> Maybe Attendee)
-> (CreateAttendeeResponse
    -> Maybe Attendee -> CreateAttendeeResponse)
-> Lens
     CreateAttendeeResponse
     CreateAttendeeResponse
     (Maybe Attendee)
     (Maybe Attendee)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAttendeeResponse' {Maybe Attendee
attendee :: Maybe Attendee
$sel:attendee:CreateAttendeeResponse' :: CreateAttendeeResponse -> Maybe Attendee
attendee} -> Maybe Attendee
attendee) (\s :: CreateAttendeeResponse
s@CreateAttendeeResponse' {} Maybe Attendee
a -> CreateAttendeeResponse
s {$sel:attendee:CreateAttendeeResponse' :: Maybe Attendee
attendee = Maybe Attendee
a} :: CreateAttendeeResponse)

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

instance Prelude.NFData CreateAttendeeResponse