Skip to content

Commit

Permalink
[Rooms] Introducing Rooms General Availability Preview (#34258)
Browse files Browse the repository at this point in the history
* 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 <t-siddiquime@microsoft.com>
  • Loading branch information
Mrayyan and t-siddiquim committed Apr 28, 2023
1 parent 21ebe32 commit 4dc93b8
Show file tree
Hide file tree
Showing 118 changed files with 6,086 additions and 7,011 deletions.
12 changes: 12 additions & 0 deletions sdk/communication/azure-communication-rooms/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@

### Features Added

- Added new function `listRooms` to list all created rooms by returning `PagedIterable<CommunicationRoom>`,
- Added pagination support for `listParticipants` by returning `PagedIterable<RoomParticipant>`.

### Breaking Changes

- Removed `participants` from `CommunicationRoom` model.
- Removed `roomJoinPolicy`, all rooms are invite-only by default.
- `updateRoom` no longer accepts participant list as input.
- Replaced `addParticipants` and `updateParticipants` with `addOrUpdateParticipants`
- Renamed `RoleType` to `ParticipantRole`
- Renamed `getParticipants` to `listParticipants`
- Renamed `CreatedOn` to `CreatedAt` in `CommunicationRoom`
- `removeParticipants` now takes in a `Iterable<CommunicationIdentifier>` instead of `Iterable<RoomParticipant>`

### Bugs Fixed

### Other Changes
Expand Down
114 changes: 64 additions & 50 deletions sdk/communication/azure-communication-rooms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ add the direct dependency to your project as follows.
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-communication-rooms</artifactId>
<version>1.0.0-beta.2</version>
<version>1.0.0-beta.3</version>
</dependency>
```
[//]: # ({x-version-update-end})
Expand Down Expand Up @@ -53,71 +53,80 @@ public RoomsClient createRoomsClientWithConnectionString() {

## Key concepts

There are four operations to interact with the Azure Communication Rooms Service.
### Rooms
- Create room
- Update room
- Get room
- Delete room
- List all rooms

### Participants
- Add or update participants
- Remove participants
- List all participants

## Examples

### Create a new room
Use the `createRoom` function to create a new Room on Azure Communication Service.
Use the `createRoom` function to create a new Room on Azure Communication Service.

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

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

### Create a new open room
Use the `createRoom` function to create a new Open Room on Azure Communication Service.
participants.add(participant1);
participants.add(participant2);

```java readme-sample-createOpenRoomWithValidInput
public void createOpenRoomWithValidInput() {
OffsetDateTime validFrom = OffsetDateTime.of(2021, 8, 1, 5, 30, 20, 10, ZoneOffset.UTC);
OffsetDateTime validUntil = OffsetDateTime.of(2021, 9, 1, 5, 30, 20, 10, ZoneOffset.UTC);
// Create Room options
CreateRoomOptions roomOptions = new CreateRoomOptions()
.setValidFrom(validFrom)
.setValidUntil(validUntil)
.setParticipants(participants);

RoomsClient roomsClient = createRoomsClientWithConnectionString();
CommunicationRoom roomResult = roomsClient.createRoom(validFrom, validUntil, RoomJoinPolicy.INVITE_ONLY, null);

CommunicationRoom roomResult = roomsClient.createRoom(roomOptions);
System.out.println("Room Id: " + roomResult.getRoomId());
}
```

### Update an existing room
Use the `updateRoom` function to create a new Room on Azure Communication Service.
Use the `updateRoom` function to update an existing Room on Azure Communication Service.

```java readme-sample-updateRoomWithRoomId
public void updateRoomWithRoomId() {
OffsetDateTime validFrom = OffsetDateTime.of(2021, 8, 1, 5, 30, 20, 10, ZoneOffset.UTC);
OffsetDateTime validUntil = OffsetDateTime.of(2021, 9, 1, 5, 30, 20, 10, ZoneOffset.UTC);
List<RoomParticipant> participants = new ArrayList<>();
participants.add(new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("<ACS User MRI identity 1>")).setRole(RoleType.ATTENDEE));
participants.add(new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("<ACS User MRI identity 2>")).setRole(RoleType.CONSUMER));
OffsetDateTime validFrom = OffsetDateTime.now();
OffsetDateTime validUntil = validFrom.plusDays(30);

// Update Room options
UpdateRoomOptions updateRoomOptions = new UpdateRoomOptions()
.setValidFrom(validFrom)
.setValidUntil(validUntil);

RoomsClient roomsClient = createRoomsClientWithConnectionString();

try {
CommunicationRoom roomResult = roomsClient.updateRoom("<Room Id in String>", validFrom, validUntil, null, participants);
CommunicationRoom roomResult = roomsClient.updateRoom("<Room Id in String>", updateRoomOptions);
System.out.println("Room Id: " + roomResult.getRoomId());

} catch (RuntimeException ex) {
System.out.println(ex);
}
}
```

### Get an existing room
Use the `getRoom` function to get an existing Room on Azure Communication Service.
Use the `getRoom` function to get an existing Room on Azure Communication Service.

```java readme-sample-getRoomWithRoomId
public void getRoomWithRoomId() {
RoomsClient roomsClient = createRoomsClientWithConnectionString();

try {
CommunicationRoom roomResult = roomsClient.getRoom("<Room Id in String>");
System.out.println("Room Id: " + roomResult.getRoomId());
Expand All @@ -128,56 +137,61 @@ public void getRoomWithRoomId() {
```

### Delete an existing room
Use the `deleteRoomWithResponse` function to delete an existing Room on Azure Communication Service.
Use the `deleteRoom` function to delete an existing Room on Azure Communication Service.

```java readme-sample-deleteRoomWithRoomId
public void deleteRoomWithRoomId() {
RoomsClient roomsClient = createRoomsClientWithConnectionString();

try {
roomsClient.deleteRoomWithResponse("<Room Id in String>", Context.NONE);
roomsClient.deleteRoom("<Room Id in String>");
} catch (RuntimeException ex) {
System.out.println(ex);
}
}
```

### Add participants an existing room
Use the `addParticipants` function to add participants to an existing Room on Azure Communication Service.
### Add or Update participants an existing room
Use the `addOrUpdateParticipants` function to add or update participants in an existing Room on Azure Communication Service.

```java readme-sample-addOrUpdateRoomParticipantsWithRoomId
public void addOrUpdateRoomParticipantsWithRoomId() {
List<RoomParticipant> participantsToaddOrUpdate = new ArrayList<>();

// New participant to add
RoomParticipant participantToAdd = new RoomParticipant(new CommunicationUserIdentifier("<ACS User MRI identity 3>")).setRole(ParticipantRole.ATTENDEE);

```java readme-sample-addRoomParticipantsWithRoomId
public void addRoomParticipantsWithRoomId() {
RoomParticipant user1 = new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("8:acs:b6372803-0c35-4ec0-833b-c19b798cef2d_0000000e-3240-55cf-9806-113a0d001dd9")).setRole(RoleType.ATTENDEE);
RoomParticipant user2 = new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("8:acs:b6372803-0c35-4ec0-833b-c19b798cef2d_0000000e-3240-55cf-9806-113a0d001dd7")).setRole(RoleType.PRESENTER);
RoomParticipant user3 = new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("8:acs:b6372803-0c35-4ec0-833b-c19b798cef2d_0000000e-3240-55cf-9806-113a0d001dd5")).setRole(RoleType.CONSUMER);
// Existing participant to update, assume participant2 is part of the room as a
// consumer
participant2 = new RoomParticipant(new CommunicationUserIdentifier("<ACS User MRI identity 2>")).setRole(ParticipantRole.ATTENDEE);

participantsToaddOrUpdate.add(participantToAdd); // Adding new participant to room
participantsToaddOrUpdate.add(participant2); // Update participant from Consumer -> Attendee

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

try {
ParticipantsCollection roomParticipants = roomsClient.addParticipants("<Room Id>", participants);
System.out.println("No. of Participants in Room: " + roomParticipants.getParticipants().size());

AddOrUpdateParticipantsResult addOrUpdateResult = roomsClient.addOrUpdateParticipants("<Room Id>", participantsToaddOrUpdate);
} catch (RuntimeException ex) {
System.out.println(ex);
}
}
```

### Remove participants an existing room
Use the `removeParticipants` function to remove participants from an existing Room on Azure Communication Service.
### Remove participants from an existing room
Use the `removeParticipants` function to remove participants from an existing Room on Azure Communication Service.

```java readme-sample-removeRoomParticipantsWithRoomId
public void removeRoomParticipantsWithRoomId() {
RoomParticipant user1 = new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("8:acs:b6372803-0c35-4ec0-833b-c19b798cef2d_0000000e-3240-55cf-9806-113a0d001dd9")).setRole(RoleType.ATTENDEE);
RoomParticipant user2 = new RoomParticipant().setCommunicationIdentifier(new CommunicationUserIdentifier("8:acs:b6372803-0c35-4ec0-833b-c19b798cef2d_0000000e-3240-55cf-9806-113a0d001dd7")).setRole(RoleType.PRESENTER);
List<CommunicationIdentifier> participantsToRemove = new ArrayList<>();

participantsToRemove.add(participant1.getCommunicationIdentifier());
participantsToRemove.add(participant2.getCommunicationIdentifier());

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

try {
ParticipantsCollection roomParticipants = roomsClient.removeParticipants("<Room Id>", participants);
System.out.println("Room Id: " + roomParticipants.getParticipants().size());

RemoveParticipantsResult removeResult = roomsClient.removeParticipants("<Room Id>", participantsToRemove);
} catch (RuntimeException ex) {
System.out.println(ex);
}
Expand Down

0 comments on commit 4dc93b8

Please sign in to comment.