{-# 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.ChimeSdkMeetings.BatchCreateAttendee
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates up to 100 attendees 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.ChimeSdkMeetings.BatchCreateAttendee
  ( -- * Creating a Request
    BatchCreateAttendee (..),
    newBatchCreateAttendee,

    -- * Request Lenses
    batchCreateAttendee_meetingId,
    batchCreateAttendee_attendees,

    -- * Destructuring the Response
    BatchCreateAttendeeResponse (..),
    newBatchCreateAttendeeResponse,

    -- * Response Lenses
    batchCreateAttendeeResponse_attendees,
    batchCreateAttendeeResponse_errors,
    batchCreateAttendeeResponse_httpStatus,
  )
where

import Amazonka.ChimeSdkMeetings.Types
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

-- | /See:/ 'newBatchCreateAttendee' smart constructor.
data BatchCreateAttendee = BatchCreateAttendee'
  { -- | The Amazon Chime SDK ID of the meeting to which you\'re adding
    -- attendees.
    BatchCreateAttendee -> Text
meetingId :: Prelude.Text,
    -- | The attendee information, including attendees\' IDs and join tokens.
    BatchCreateAttendee -> NonEmpty CreateAttendeeRequestItem
attendees :: Prelude.NonEmpty CreateAttendeeRequestItem
  }
  deriving (BatchCreateAttendee -> BatchCreateAttendee -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchCreateAttendee -> BatchCreateAttendee -> Bool
$c/= :: BatchCreateAttendee -> BatchCreateAttendee -> Bool
== :: BatchCreateAttendee -> BatchCreateAttendee -> Bool
$c== :: BatchCreateAttendee -> BatchCreateAttendee -> Bool
Prelude.Eq, Int -> BatchCreateAttendee -> ShowS
[BatchCreateAttendee] -> ShowS
BatchCreateAttendee -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchCreateAttendee] -> ShowS
$cshowList :: [BatchCreateAttendee] -> ShowS
show :: BatchCreateAttendee -> String
$cshow :: BatchCreateAttendee -> String
showsPrec :: Int -> BatchCreateAttendee -> ShowS
$cshowsPrec :: Int -> BatchCreateAttendee -> ShowS
Prelude.Show, forall x. Rep BatchCreateAttendee x -> BatchCreateAttendee
forall x. BatchCreateAttendee -> Rep BatchCreateAttendee x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchCreateAttendee x -> BatchCreateAttendee
$cfrom :: forall x. BatchCreateAttendee -> Rep BatchCreateAttendee x
Prelude.Generic)

-- |
-- Create a value of 'BatchCreateAttendee' 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:
--
-- 'meetingId', 'batchCreateAttendee_meetingId' - The Amazon Chime SDK ID of the meeting to which you\'re adding
-- attendees.
--
-- 'attendees', 'batchCreateAttendee_attendees' - The attendee information, including attendees\' IDs and join tokens.
newBatchCreateAttendee ::
  -- | 'meetingId'
  Prelude.Text ->
  -- | 'attendees'
  Prelude.NonEmpty CreateAttendeeRequestItem ->
  BatchCreateAttendee
newBatchCreateAttendee :: Text -> NonEmpty CreateAttendeeRequestItem -> BatchCreateAttendee
newBatchCreateAttendee Text
pMeetingId_ NonEmpty CreateAttendeeRequestItem
pAttendees_ =
  BatchCreateAttendee'
    { $sel:meetingId:BatchCreateAttendee' :: Text
meetingId = Text
pMeetingId_,
      $sel:attendees:BatchCreateAttendee' :: NonEmpty CreateAttendeeRequestItem
attendees = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty CreateAttendeeRequestItem
pAttendees_
    }

-- | The Amazon Chime SDK ID of the meeting to which you\'re adding
-- attendees.
batchCreateAttendee_meetingId :: Lens.Lens' BatchCreateAttendee Prelude.Text
batchCreateAttendee_meetingId :: Lens' BatchCreateAttendee Text
batchCreateAttendee_meetingId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateAttendee' {Text
meetingId :: Text
$sel:meetingId:BatchCreateAttendee' :: BatchCreateAttendee -> Text
meetingId} -> Text
meetingId) (\s :: BatchCreateAttendee
s@BatchCreateAttendee' {} Text
a -> BatchCreateAttendee
s {$sel:meetingId:BatchCreateAttendee' :: Text
meetingId = Text
a} :: BatchCreateAttendee)

-- | The attendee information, including attendees\' IDs and join tokens.
batchCreateAttendee_attendees :: Lens.Lens' BatchCreateAttendee (Prelude.NonEmpty CreateAttendeeRequestItem)
batchCreateAttendee_attendees :: Lens' BatchCreateAttendee (NonEmpty CreateAttendeeRequestItem)
batchCreateAttendee_attendees = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateAttendee' {NonEmpty CreateAttendeeRequestItem
attendees :: NonEmpty CreateAttendeeRequestItem
$sel:attendees:BatchCreateAttendee' :: BatchCreateAttendee -> NonEmpty CreateAttendeeRequestItem
attendees} -> NonEmpty CreateAttendeeRequestItem
attendees) (\s :: BatchCreateAttendee
s@BatchCreateAttendee' {} NonEmpty CreateAttendeeRequestItem
a -> BatchCreateAttendee
s {$sel:attendees:BatchCreateAttendee' :: NonEmpty CreateAttendeeRequestItem
attendees = NonEmpty CreateAttendeeRequestItem
a} :: BatchCreateAttendee) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest BatchCreateAttendee where
  type
    AWSResponse BatchCreateAttendee =
      BatchCreateAttendeeResponse
  request :: (Service -> Service)
-> BatchCreateAttendee -> Request BatchCreateAttendee
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 BatchCreateAttendee
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchCreateAttendee)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Attendee]
-> Maybe [CreateAttendeeError]
-> Int
-> BatchCreateAttendeeResponse
BatchCreateAttendeeResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Attendees" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Errors" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => 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 BatchCreateAttendee where
  hashWithSalt :: Int -> BatchCreateAttendee -> Int
hashWithSalt Int
_salt BatchCreateAttendee' {NonEmpty CreateAttendeeRequestItem
Text
attendees :: NonEmpty CreateAttendeeRequestItem
meetingId :: Text
$sel:attendees:BatchCreateAttendee' :: BatchCreateAttendee -> NonEmpty CreateAttendeeRequestItem
$sel:meetingId:BatchCreateAttendee' :: BatchCreateAttendee -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
meetingId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty CreateAttendeeRequestItem
attendees

instance Prelude.NFData BatchCreateAttendee where
  rnf :: BatchCreateAttendee -> ()
rnf BatchCreateAttendee' {NonEmpty CreateAttendeeRequestItem
Text
attendees :: NonEmpty CreateAttendeeRequestItem
meetingId :: Text
$sel:attendees:BatchCreateAttendee' :: BatchCreateAttendee -> NonEmpty CreateAttendeeRequestItem
$sel:meetingId:BatchCreateAttendee' :: BatchCreateAttendee -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
meetingId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty CreateAttendeeRequestItem
attendees

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

instance Data.ToJSON BatchCreateAttendee where
  toJSON :: BatchCreateAttendee -> Value
toJSON BatchCreateAttendee' {NonEmpty CreateAttendeeRequestItem
Text
attendees :: NonEmpty CreateAttendeeRequestItem
meetingId :: Text
$sel:attendees:BatchCreateAttendee' :: BatchCreateAttendee -> NonEmpty CreateAttendeeRequestItem
$sel:meetingId:BatchCreateAttendee' :: BatchCreateAttendee -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Attendees" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty CreateAttendeeRequestItem
attendees)]
      )

instance Data.ToPath BatchCreateAttendee where
  toPath :: BatchCreateAttendee -> ByteString
toPath BatchCreateAttendee' {NonEmpty CreateAttendeeRequestItem
Text
attendees :: NonEmpty CreateAttendeeRequestItem
meetingId :: Text
$sel:attendees:BatchCreateAttendee' :: BatchCreateAttendee -> NonEmpty CreateAttendeeRequestItem
$sel:meetingId:BatchCreateAttendee' :: BatchCreateAttendee -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/meetings/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
meetingId, ByteString
"/attendees"]

instance Data.ToQuery BatchCreateAttendee where
  toQuery :: BatchCreateAttendee -> QueryString
toQuery =
    forall a b. a -> b -> a
Prelude.const
      (forall a. Monoid a => [a] -> a
Prelude.mconcat [QueryString
"operation=batch-create"])

-- | /See:/ 'newBatchCreateAttendeeResponse' smart constructor.
data BatchCreateAttendeeResponse = BatchCreateAttendeeResponse'
  { -- | The attendee information, including attendees\' IDs and join tokens.
    BatchCreateAttendeeResponse -> Maybe [Attendee]
attendees :: Prelude.Maybe [Attendee],
    -- | If the action fails for one or more of the attendees in the request, a
    -- list of the attendees is returned, along with error codes and error
    -- messages.
    BatchCreateAttendeeResponse -> Maybe [CreateAttendeeError]
errors :: Prelude.Maybe [CreateAttendeeError],
    -- | The response's http status code.
    BatchCreateAttendeeResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchCreateAttendeeResponse -> BatchCreateAttendeeResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchCreateAttendeeResponse -> BatchCreateAttendeeResponse -> Bool
$c/= :: BatchCreateAttendeeResponse -> BatchCreateAttendeeResponse -> Bool
== :: BatchCreateAttendeeResponse -> BatchCreateAttendeeResponse -> Bool
$c== :: BatchCreateAttendeeResponse -> BatchCreateAttendeeResponse -> Bool
Prelude.Eq, Int -> BatchCreateAttendeeResponse -> ShowS
[BatchCreateAttendeeResponse] -> ShowS
BatchCreateAttendeeResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchCreateAttendeeResponse] -> ShowS
$cshowList :: [BatchCreateAttendeeResponse] -> ShowS
show :: BatchCreateAttendeeResponse -> String
$cshow :: BatchCreateAttendeeResponse -> String
showsPrec :: Int -> BatchCreateAttendeeResponse -> ShowS
$cshowsPrec :: Int -> BatchCreateAttendeeResponse -> ShowS
Prelude.Show, forall x.
Rep BatchCreateAttendeeResponse x -> BatchCreateAttendeeResponse
forall x.
BatchCreateAttendeeResponse -> Rep BatchCreateAttendeeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchCreateAttendeeResponse x -> BatchCreateAttendeeResponse
$cfrom :: forall x.
BatchCreateAttendeeResponse -> Rep BatchCreateAttendeeResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchCreateAttendeeResponse' 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:
--
-- 'attendees', 'batchCreateAttendeeResponse_attendees' - The attendee information, including attendees\' IDs and join tokens.
--
-- 'errors', 'batchCreateAttendeeResponse_errors' - If the action fails for one or more of the attendees in the request, a
-- list of the attendees is returned, along with error codes and error
-- messages.
--
-- 'httpStatus', 'batchCreateAttendeeResponse_httpStatus' - The response's http status code.
newBatchCreateAttendeeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchCreateAttendeeResponse
newBatchCreateAttendeeResponse :: Int -> BatchCreateAttendeeResponse
newBatchCreateAttendeeResponse Int
pHttpStatus_ =
  BatchCreateAttendeeResponse'
    { $sel:attendees:BatchCreateAttendeeResponse' :: Maybe [Attendee]
attendees =
        forall a. Maybe a
Prelude.Nothing,
      $sel:errors:BatchCreateAttendeeResponse' :: Maybe [CreateAttendeeError]
errors = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchCreateAttendeeResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The attendee information, including attendees\' IDs and join tokens.
batchCreateAttendeeResponse_attendees :: Lens.Lens' BatchCreateAttendeeResponse (Prelude.Maybe [Attendee])
batchCreateAttendeeResponse_attendees :: Lens' BatchCreateAttendeeResponse (Maybe [Attendee])
batchCreateAttendeeResponse_attendees = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateAttendeeResponse' {Maybe [Attendee]
attendees :: Maybe [Attendee]
$sel:attendees:BatchCreateAttendeeResponse' :: BatchCreateAttendeeResponse -> Maybe [Attendee]
attendees} -> Maybe [Attendee]
attendees) (\s :: BatchCreateAttendeeResponse
s@BatchCreateAttendeeResponse' {} Maybe [Attendee]
a -> BatchCreateAttendeeResponse
s {$sel:attendees:BatchCreateAttendeeResponse' :: Maybe [Attendee]
attendees = Maybe [Attendee]
a} :: BatchCreateAttendeeResponse) 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

-- | If the action fails for one or more of the attendees in the request, a
-- list of the attendees is returned, along with error codes and error
-- messages.
batchCreateAttendeeResponse_errors :: Lens.Lens' BatchCreateAttendeeResponse (Prelude.Maybe [CreateAttendeeError])
batchCreateAttendeeResponse_errors :: Lens' BatchCreateAttendeeResponse (Maybe [CreateAttendeeError])
batchCreateAttendeeResponse_errors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateAttendeeResponse' {Maybe [CreateAttendeeError]
errors :: Maybe [CreateAttendeeError]
$sel:errors:BatchCreateAttendeeResponse' :: BatchCreateAttendeeResponse -> Maybe [CreateAttendeeError]
errors} -> Maybe [CreateAttendeeError]
errors) (\s :: BatchCreateAttendeeResponse
s@BatchCreateAttendeeResponse' {} Maybe [CreateAttendeeError]
a -> BatchCreateAttendeeResponse
s {$sel:errors:BatchCreateAttendeeResponse' :: Maybe [CreateAttendeeError]
errors = Maybe [CreateAttendeeError]
a} :: BatchCreateAttendeeResponse) 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 response's http status code.
batchCreateAttendeeResponse_httpStatus :: Lens.Lens' BatchCreateAttendeeResponse Prelude.Int
batchCreateAttendeeResponse_httpStatus :: Lens' BatchCreateAttendeeResponse Int
batchCreateAttendeeResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchCreateAttendeeResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchCreateAttendeeResponse' :: BatchCreateAttendeeResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchCreateAttendeeResponse
s@BatchCreateAttendeeResponse' {} Int
a -> BatchCreateAttendeeResponse
s {$sel:httpStatus:BatchCreateAttendeeResponse' :: Int
httpStatus = Int
a} :: BatchCreateAttendeeResponse)

instance Prelude.NFData BatchCreateAttendeeResponse where
  rnf :: BatchCreateAttendeeResponse -> ()
rnf BatchCreateAttendeeResponse' {Int
Maybe [CreateAttendeeError]
Maybe [Attendee]
httpStatus :: Int
errors :: Maybe [CreateAttendeeError]
attendees :: Maybe [Attendee]
$sel:httpStatus:BatchCreateAttendeeResponse' :: BatchCreateAttendeeResponse -> Int
$sel:errors:BatchCreateAttendeeResponse' :: BatchCreateAttendeeResponse -> Maybe [CreateAttendeeError]
$sel:attendees:BatchCreateAttendeeResponse' :: BatchCreateAttendeeResponse -> Maybe [Attendee]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Attendee]
attendees
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [CreateAttendeeError]
errors
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus