Skip to content

Commit 4dc93b8

Browse files
Mrayyant-siddiquim
andauthored
[Rooms] Introducing Rooms General Availability Preview (#34258)
* New API gen + client changes * build issues fix * flux response changes * Introducing GA version * more fixes * Introduce createRoomOptions * address api comments * Update RoomsErrorResponseException.java * Update RoomParticipant.java * Update test cases * Test recordings * Update README.md * Update CHANGELOG.md * Update based on DexEx comments * renaming changes * remove participants tmp fix * clean up * Update CHANGELOG.md * Review changes * clean up * address ARB comments * Update Tests. * Update module-info.java * update recordings * readme change * RoomsTestBase refactoring * Update test recordings --------- Co-authored-by: t-siddiquim <[email protected]>
1 parent 21ebe32 commit 4dc93b8

File tree

118 files changed

+6086
-7011
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+6086
-7011
lines changed

sdk/communication/azure-communication-rooms/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,20 @@
44

55
### Features Added
66

7+
- Added new function `listRooms` to list all created rooms by returning `PagedIterable<CommunicationRoom>`,
8+
- Added pagination support for `listParticipants` by returning `PagedIterable<RoomParticipant>`.
9+
710
### Breaking Changes
811

12+
- Removed `participants` from `CommunicationRoom` model.
13+
- Removed `roomJoinPolicy`, all rooms are invite-only by default.
14+
- `updateRoom` no longer accepts participant list as input.
15+
- Replaced `addParticipants` and `updateParticipants` with `addOrUpdateParticipants`
16+
- Renamed `RoleType` to `ParticipantRole`
17+
- Renamed `getParticipants` to `listParticipants`
18+
- Renamed `CreatedOn` to `CreatedAt` in `CommunicationRoom`
19+
- `removeParticipants` now takes in a `Iterable<CommunicationIdentifier>` instead of `Iterable<RoomParticipant>`
20+
921
### Bugs Fixed
1022

1123
### Other Changes

sdk/communication/azure-communication-rooms/README.md

Lines changed: 64 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ add the direct dependency to your project as follows.
2525
<dependency>
2626
<groupId>com.azure</groupId>
2727
<artifactId>azure-communication-rooms</artifactId>
28-
<version>1.0.0-beta.2</version>
28+
<version>1.0.0-beta.3</version>
2929
</dependency>
3030
```
3131
[//]: # ({x-version-update-end})
@@ -53,71 +53,80 @@ public RoomsClient createRoomsClientWithConnectionString() {
5353

5454
## Key concepts
5555

56-
There are four operations to interact with the Azure Communication Rooms Service.
56+
### Rooms
57+
- Create room
58+
- Update room
59+
- Get room
60+
- Delete room
61+
- List all rooms
62+
63+
### Participants
64+
- Add or update participants
65+
- Remove participants
66+
- List all participants
5767

5868
## Examples
5969

6070
### Create a new room
61-
Use the `createRoom` function to create a new Room on Azure Communication Service.
71+
Use the `createRoom` function to create a new Room on Azure Communication Service.
6272

6373
```java readme-sample-createRoomWithValidInput
6474
public void createRoomWithValidInput() {
65-
OffsetDateTime validFrom = OffsetDateTime.of(2021, 8, 1, 5, 30, 20, 10, ZoneOffset.UTC);
66-
OffsetDateTime validUntil = OffsetDateTime.of(2021, 9, 1, 5, 30, 20, 10, ZoneOffset.UTC);
75+
OffsetDateTime validFrom = OffsetDateTime.now();
76+
OffsetDateTime validUntil = validFrom.plusDays(30);
6777
List<RoomParticipant> participants = new ArrayList<>();
68-
// Add two participants
69-
participants.add(new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("<ACS User MRI identity 1>")).setRole(RoleType.ATTENDEE));
70-
participants.add(new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("<ACS User MRI identity 2>")).setRole(RoleType.CONSUMER));
7178

72-
RoomsClient roomsClient = createRoomsClientWithConnectionString();
73-
CommunicationRoom roomResult = roomsClient.createRoom(validFrom, validUntil, RoomJoinPolicy.INVITE_ONLY, participants);
74-
System.out.println("Room Id: " + roomResult.getRoomId());
75-
}
76-
```
79+
// Add two participants
80+
participant1 = new RoomParticipant(new CommunicationUserIdentifier("<ACS User MRI identity 1>")).setRole(ParticipantRole.ATTENDEE);
81+
participant2 = new RoomParticipant(new CommunicationUserIdentifier("<ACS User MRI identity 2>")).setRole(ParticipantRole.CONSUMER);
7782

78-
### Create a new open room
79-
Use the `createRoom` function to create a new Open Room on Azure Communication Service.
83+
participants.add(participant1);
84+
participants.add(participant2);
8085

81-
```java readme-sample-createOpenRoomWithValidInput
82-
public void createOpenRoomWithValidInput() {
83-
OffsetDateTime validFrom = OffsetDateTime.of(2021, 8, 1, 5, 30, 20, 10, ZoneOffset.UTC);
84-
OffsetDateTime validUntil = OffsetDateTime.of(2021, 9, 1, 5, 30, 20, 10, ZoneOffset.UTC);
86+
// Create Room options
87+
CreateRoomOptions roomOptions = new CreateRoomOptions()
88+
.setValidFrom(validFrom)
89+
.setValidUntil(validUntil)
90+
.setParticipants(participants);
8591

8692
RoomsClient roomsClient = createRoomsClientWithConnectionString();
87-
CommunicationRoom roomResult = roomsClient.createRoom(validFrom, validUntil, RoomJoinPolicy.INVITE_ONLY, null);
93+
94+
CommunicationRoom roomResult = roomsClient.createRoom(roomOptions);
8895
System.out.println("Room Id: " + roomResult.getRoomId());
8996
}
9097
```
9198

9299
### Update an existing room
93-
Use the `updateRoom` function to create a new Room on Azure Communication Service.
100+
Use the `updateRoom` function to update an existing Room on Azure Communication Service.
94101

95102
```java readme-sample-updateRoomWithRoomId
96103
public void updateRoomWithRoomId() {
97-
OffsetDateTime validFrom = OffsetDateTime.of(2021, 8, 1, 5, 30, 20, 10, ZoneOffset.UTC);
98-
OffsetDateTime validUntil = OffsetDateTime.of(2021, 9, 1, 5, 30, 20, 10, ZoneOffset.UTC);
99-
List<RoomParticipant> participants = new ArrayList<>();
100-
participants.add(new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("<ACS User MRI identity 1>")).setRole(RoleType.ATTENDEE));
101-
participants.add(new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("<ACS User MRI identity 2>")).setRole(RoleType.CONSUMER));
104+
OffsetDateTime validFrom = OffsetDateTime.now();
105+
OffsetDateTime validUntil = validFrom.plusDays(30);
106+
107+
// Update Room options
108+
UpdateRoomOptions updateRoomOptions = new UpdateRoomOptions()
109+
.setValidFrom(validFrom)
110+
.setValidUntil(validUntil);
102111

103112
RoomsClient roomsClient = createRoomsClientWithConnectionString();
104113

105114
try {
106-
CommunicationRoom roomResult = roomsClient.updateRoom("<Room Id in String>", validFrom, validUntil, null, participants);
115+
CommunicationRoom roomResult = roomsClient.updateRoom("<Room Id in String>", updateRoomOptions);
107116
System.out.println("Room Id: " + roomResult.getRoomId());
108-
109117
} catch (RuntimeException ex) {
110118
System.out.println(ex);
111119
}
112120
}
113121
```
114122

115123
### Get an existing room
116-
Use the `getRoom` function to get an existing Room on Azure Communication Service.
124+
Use the `getRoom` function to get an existing Room on Azure Communication Service.
117125

118126
```java readme-sample-getRoomWithRoomId
119127
public void getRoomWithRoomId() {
120128
RoomsClient roomsClient = createRoomsClientWithConnectionString();
129+
121130
try {
122131
CommunicationRoom roomResult = roomsClient.getRoom("<Room Id in String>");
123132
System.out.println("Room Id: " + roomResult.getRoomId());
@@ -128,56 +137,61 @@ public void getRoomWithRoomId() {
128137
```
129138

130139
### Delete an existing room
131-
Use the `deleteRoomWithResponse` function to delete an existing Room on Azure Communication Service.
140+
Use the `deleteRoom` function to delete an existing Room on Azure Communication Service.
132141

133142
```java readme-sample-deleteRoomWithRoomId
134143
public void deleteRoomWithRoomId() {
135144
RoomsClient roomsClient = createRoomsClientWithConnectionString();
145+
136146
try {
137-
roomsClient.deleteRoomWithResponse("<Room Id in String>", Context.NONE);
147+
roomsClient.deleteRoom("<Room Id in String>");
138148
} catch (RuntimeException ex) {
139149
System.out.println(ex);
140150
}
141151
}
142152
```
143153

144-
### Add participants an existing room
145-
Use the `addParticipants` function to add participants to an existing Room on Azure Communication Service.
154+
### Add or Update participants an existing room
155+
Use the `addOrUpdateParticipants` function to add or update participants in an existing Room on Azure Communication Service.
156+
157+
```java readme-sample-addOrUpdateRoomParticipantsWithRoomId
158+
public void addOrUpdateRoomParticipantsWithRoomId() {
159+
List<RoomParticipant> participantsToaddOrUpdate = new ArrayList<>();
160+
161+
// New participant to add
162+
RoomParticipant participantToAdd = new RoomParticipant(new CommunicationUserIdentifier("<ACS User MRI identity 3>")).setRole(ParticipantRole.ATTENDEE);
146163

147-
```java readme-sample-addRoomParticipantsWithRoomId
148-
public void addRoomParticipantsWithRoomId() {
149-
RoomParticipant user1 = new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("8:acs:b6372803-0c35-4ec0-833b-c19b798cef2d_0000000e-3240-55cf-9806-113a0d001dd9")).setRole(RoleType.ATTENDEE);
150-
RoomParticipant user2 = new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("8:acs:b6372803-0c35-4ec0-833b-c19b798cef2d_0000000e-3240-55cf-9806-113a0d001dd7")).setRole(RoleType.PRESENTER);
151-
RoomParticipant user3 = new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("8:acs:b6372803-0c35-4ec0-833b-c19b798cef2d_0000000e-3240-55cf-9806-113a0d001dd5")).setRole(RoleType.CONSUMER);
164+
// Existing participant to update, assume participant2 is part of the room as a
165+
// consumer
166+
participant2 = new RoomParticipant(new CommunicationUserIdentifier("<ACS User MRI identity 2>")).setRole(ParticipantRole.ATTENDEE);
167+
168+
participantsToaddOrUpdate.add(participantToAdd); // Adding new participant to room
169+
participantsToaddOrUpdate.add(participant2); // Update participant from Consumer -> Attendee
152170

153-
List<RoomParticipant> participants = new ArrayList<RoomParticipant>(Arrays.asList(user1, user2, user3));
154171
RoomsClient roomsClient = createRoomsClientWithConnectionString();
155172

156173
try {
157-
ParticipantsCollection roomParticipants = roomsClient.addParticipants("<Room Id>", participants);
158-
System.out.println("No. of Participants in Room: " + roomParticipants.getParticipants().size());
159-
174+
AddOrUpdateParticipantsResult addOrUpdateResult = roomsClient.addOrUpdateParticipants("<Room Id>", participantsToaddOrUpdate);
160175
} catch (RuntimeException ex) {
161176
System.out.println(ex);
162177
}
163178
}
164179
```
165180

166-
### Remove participants an existing room
167-
Use the `removeParticipants` function to remove participants from an existing Room on Azure Communication Service.
181+
### Remove participants from an existing room
182+
Use the `removeParticipants` function to remove participants from an existing Room on Azure Communication Service.
168183

169184
```java readme-sample-removeRoomParticipantsWithRoomId
170185
public void removeRoomParticipantsWithRoomId() {
171-
RoomParticipant user1 = new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("8:acs:b6372803-0c35-4ec0-833b-c19b798cef2d_0000000e-3240-55cf-9806-113a0d001dd9")).setRole(RoleType.ATTENDEE);
172-
RoomParticipant user2 = new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("8:acs:b6372803-0c35-4ec0-833b-c19b798cef2d_0000000e-3240-55cf-9806-113a0d001dd7")).setRole(RoleType.PRESENTER);
186+
List<CommunicationIdentifier> participantsToRemove = new ArrayList<>();
187+
188+
participantsToRemove.add(participant1.getCommunicationIdentifier());
189+
participantsToRemove.add(participant2.getCommunicationIdentifier());
173190

174-
List<RoomParticipant> participants = new ArrayList<RoomParticipant>(Arrays.asList(user1, user2));
175191
RoomsClient roomsClient = createRoomsClientWithConnectionString();
176192

177193
try {
178-
ParticipantsCollection roomParticipants = roomsClient.removeParticipants("<Room Id>", participants);
179-
System.out.println("Room Id: " + roomParticipants.getParticipants().size());
180-
194+
RemoveParticipantsResult removeResult = roomsClient.removeParticipants("<Room Id>", participantsToRemove);
181195
} catch (RuntimeException ex) {
182196
System.out.println(ex);
183197
}

0 commit comments

Comments
 (0)