@azure/communication-rooms 1.0.0-beta.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -8
- package/dist/index.js +500 -332
- package/dist/index.js.map +1 -1
- package/dist-esm/src/generated/src/index.js +1 -1
- package/dist-esm/src/generated/src/index.js.map +1 -1
- package/dist-esm/src/generated/src/models/index.js.map +1 -1
- package/dist-esm/src/generated/src/models/mappers.js +80 -148
- package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/src/models/parameters.js +44 -18
- package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/src/operations/index.js +1 -0
- package/dist-esm/src/generated/src/operations/index.js.map +1 -1
- package/dist-esm/src/generated/src/operations/participants.js +112 -0
- package/dist-esm/src/generated/src/operations/participants.js.map +1 -0
- package/dist-esm/src/generated/src/operations/rooms.js +76 -112
- package/dist-esm/src/generated/src/operations/rooms.js.map +1 -1
- package/dist-esm/src/generated/src/operationsInterfaces/index.js +1 -0
- package/dist-esm/src/generated/src/operationsInterfaces/index.js.map +1 -1
- package/dist-esm/src/generated/src/operationsInterfaces/participants.js +9 -0
- package/dist-esm/src/generated/src/operationsInterfaces/participants.js.map +1 -0
- package/dist-esm/src/generated/src/operationsInterfaces/rooms.js.map +1 -1
- package/dist-esm/src/generated/src/pagingHelper.js +32 -0
- package/dist-esm/src/generated/src/pagingHelper.js.map +1 -0
- package/dist-esm/src/generated/src/{roomsApiClient.js → roomsRestClient.js} +8 -7
- package/dist-esm/src/generated/src/roomsRestClient.js.map +1 -0
- package/dist-esm/src/generated/src/tracing.js +14 -0
- package/dist-esm/src/generated/src/tracing.js.map +1 -0
- package/dist-esm/src/models/mappers.js +39 -14
- package/dist-esm/src/models/mappers.js.map +1 -1
- package/dist-esm/src/models/models.js.map +1 -1
- package/dist-esm/src/models/options.js.map +1 -1
- package/dist-esm/src/roomsClient.js +170 -43
- package/dist-esm/src/roomsClient.js.map +1 -1
- package/package.json +29 -31
- package/types/communication-rooms.d.ts +57 -66
- package/dist-esm/src/generated/src/roomsApiClient.js.map +0 -1
- package/dist-esm/src/generated/src/roomsApiClientContext.js +0 -40
- package/dist-esm/src/generated/src/roomsApiClientContext.js.map +0 -1
package/README.md
CHANGED
|
@@ -12,30 +12,193 @@ Communication Rooms Client
|
|
|
12
12
|
|
|
13
13
|
### Currently supported environments
|
|
14
14
|
|
|
15
|
-
- [LTS versions of Node.js](https://
|
|
15
|
+
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
|
|
16
16
|
- Latest versions of Safari, Chrome, Edge and Firefox.
|
|
17
17
|
|
|
18
18
|
### Prerequisites
|
|
19
19
|
|
|
20
20
|
- An [Azure subscription][azure_sub].
|
|
21
|
+
- An existing Communication Services resource. If you need to create the resource, you can use the [Azure Portal][azure_portal], the [Azure PowerShell][azure_powershell], or the [Azure CLI][azure_cli].
|
|
21
22
|
|
|
22
|
-
###
|
|
23
|
+
### JavaScript Bundle
|
|
24
|
+
|
|
25
|
+
To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling).
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
### Installing
|
|
25
28
|
|
|
26
29
|
```bash
|
|
27
30
|
npm install @azure/communication-rooms
|
|
28
31
|
```
|
|
29
32
|
|
|
30
|
-
### JavaScript Bundle
|
|
31
|
-
|
|
32
|
-
To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling).
|
|
33
|
-
|
|
34
33
|
## Key concepts
|
|
35
34
|
|
|
36
35
|
### RoomsApiClient
|
|
37
36
|
|
|
38
|
-
`
|
|
37
|
+
`RoomsClient` is the primary interface for developers using the Azure RoomsApi client library. Explore the methods on this client object to understand the different features of the Azure RoomsApi service that you can access.
|
|
38
|
+
|
|
39
|
+
## Examples
|
|
40
|
+
|
|
41
|
+
## Authentication
|
|
42
|
+
|
|
43
|
+
You can get a key and/or connection string from your Communication Services resource in [Azure Portal][azure_portal]. Once you have a key, you can authenticate the `RoomsClient` with any of the following methods:
|
|
44
|
+
|
|
45
|
+
### Create `KeyCredential` with `AzureKeyCredential` before initializing the client
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { AzureKeyCredential } from "@azure/core-auth";
|
|
49
|
+
import { RoomsClient } from "@azure/communication-rooms";
|
|
50
|
+
|
|
51
|
+
const credential = new AzureKeyCredential(KEY);
|
|
52
|
+
const client = new RoomsClient(ENDPOINT, credential);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Using a connection string
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { RoomsClient } from "@azure/communication-rooms";
|
|
59
|
+
|
|
60
|
+
const connectionString = `endpoint=ENDPOINT;accessKey=KEY`;
|
|
61
|
+
const client = new RoomsClient(connectionString);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Using a `TokenCredential`
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
68
|
+
import { RoomsClient } from "@azure/communication-rooms";
|
|
69
|
+
|
|
70
|
+
const credential = new DefaultAzureCredential();
|
|
71
|
+
const client = new RoomsClient(ENDPOINT, credential);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
If you use a key to initialize the client you will also need to provide the appropriate endpoint. You can get this endpoint from your Communication Services resource in [Azure Portal][azure_portal].
|
|
75
|
+
|
|
76
|
+
## Usage
|
|
77
|
+
|
|
78
|
+
### Create a room
|
|
79
|
+
|
|
80
|
+
To create a room, call the `createRoom` method. All settings are optional.
|
|
81
|
+
|
|
82
|
+
If `validFrom` is not provided, it is defaulted to the current datetime. If `validUntil` is not provided, the default is `validFrom + 180 days`.
|
|
83
|
+
|
|
84
|
+
When defining `participants`, if `role` is not specified, then it will be `attendee` by default.
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
// create users with CommunicationIdentityClient
|
|
88
|
+
const identityClient = new CommunicationIdentityClient(connectionString);
|
|
89
|
+
const user1 = await identityClient.createUserAndToken(["voip"]);
|
|
90
|
+
|
|
91
|
+
// create RoomsClient
|
|
92
|
+
const roomsClient: RoomsClient = new RoomsClient(CONNECTION_STRING);
|
|
93
|
+
|
|
94
|
+
const validFrom = new Date(Date.now());
|
|
95
|
+
let validForDays = 10;
|
|
96
|
+
let validUntil = new Date(validFrom.getTime());
|
|
97
|
+
validUntil.setDate(validFrom.getDate() + validForDays);
|
|
98
|
+
|
|
99
|
+
// options payload to create a room
|
|
100
|
+
const createRoomOptions: CreateRoomOptions = {
|
|
101
|
+
validFrom,
|
|
102
|
+
validUntil,
|
|
103
|
+
participants: [
|
|
104
|
+
{
|
|
105
|
+
id: user1.user,
|
|
106
|
+
role: "Attendee",
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// create room
|
|
112
|
+
const room = await roomsClient.createRoom(createRoomOptions);
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
[Find CommunicationIdentityClient here](https://github.com/Azure/azure-sdk-for-js/edit/main/sdk/communication/communication-identity)
|
|
116
|
+
|
|
117
|
+
### Update a room
|
|
118
|
+
|
|
119
|
+
To update the `validFrom` and `validUntil` settings of a room use the `updateRoom` method.
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
validForDays = 60;
|
|
123
|
+
validUntil.setDate(validFrom.getDate() + validForDays);
|
|
124
|
+
const updateRoomOptions: UpdateRoomOptions = {
|
|
125
|
+
validFrom,
|
|
126
|
+
validUntil,
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// update the room using the room id from the creation operation
|
|
130
|
+
const updatedRoom = await roomsClient.updateRoom(room.id, updateRoomOptions);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Get a room
|
|
134
|
+
|
|
135
|
+
To get a room use the `getRoom` method.
|
|
136
|
+
|
|
137
|
+
```js
|
|
138
|
+
const roomId = "ROOM_ID";
|
|
139
|
+
room = await roomsClient.getRoom(roomId);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### List rooms
|
|
143
|
+
|
|
144
|
+
List all rooms using the `listRooms` method.
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
const roomsList = await roomsClient.listRooms();
|
|
148
|
+
for await (const currentRoom of roomsList) {
|
|
149
|
+
// access room data
|
|
150
|
+
console.log(`The room id is ${currentRoom.id}.`);
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Add or update participants
|
|
155
|
+
|
|
156
|
+
To add new participants, or update existing participants, use the `addOrUpdateParticipants` method.
|
|
157
|
+
|
|
158
|
+
```js
|
|
159
|
+
const user2 = await identityClient.createUserAndToken(["voip"]);
|
|
160
|
+
const updateParticipantsList: InvitedRoomParticipant[] = [
|
|
161
|
+
{
|
|
162
|
+
id: user1.user,
|
|
163
|
+
role: "Presenter",
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: user2.user,
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
// run addOrUpdate operation
|
|
171
|
+
await roomsClient.addOrUpdateParticipants(room.id, updateParticipantsList);
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Remove participants
|
|
175
|
+
|
|
176
|
+
To remove participants call the `removeParticipants` method.
|
|
177
|
+
|
|
178
|
+
```js
|
|
179
|
+
const participantsToRemove = [user1.user, user2.user];
|
|
180
|
+
await roomsClient.removeParticipants(room.id, participantsToRemove);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Get participants in a room
|
|
184
|
+
|
|
185
|
+
To list all the participants in a room call the `listParticipants` method.
|
|
186
|
+
|
|
187
|
+
```js
|
|
188
|
+
const participantsList = await roomsClient.listParticipants(room.id);
|
|
189
|
+
for await (const participant of participantsList) {
|
|
190
|
+
// access participant data
|
|
191
|
+
console.log(`The participant's role is ${participant.role}.`);
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Delete a room
|
|
196
|
+
|
|
197
|
+
Use the `deleteRoom` method to delete a room.
|
|
198
|
+
|
|
199
|
+
```js
|
|
200
|
+
await roomsClient.deleteRoom(room.id);
|
|
201
|
+
```
|
|
39
202
|
|
|
40
203
|
## Troubleshooting
|
|
41
204
|
|
|
@@ -70,3 +233,4 @@ If you'd like to contribute to this library, please read the [contributing guide
|
|
|
70
233
|
[azure_portal]: https://portal.azure.com
|
|
71
234
|
[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity
|
|
72
235
|
[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential
|
|
236
|
+
[communication_identity]: https://github.com/Azure/azure-sdk-for-js/edit/main/sdk/communication/communication-identity
|