Skip to content

Commit

Permalink
Added missing OBO services (#667)
Browse files Browse the repository at this point in the history
Some apis that, are OBO enabled, were missing in OboServices interfaces.
We added them in this PR.
Fixed some warnings as well.
  • Loading branch information
symphony-soufiane authored Jun 15, 2022
1 parent ed29c29 commit e213571
Show file tree
Hide file tree
Showing 6 changed files with 390 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,15 @@ public V4Message send(@Nonnull String streamId, @Nonnull Message message) {
() -> this.doSendMessage(streamId, message));
}

/**
* {@inheritDoc}
*/
@Override
public List<String> getAttachmentTypes() {
return executeAndRetry("getAttachmentTypes", podApi.getApiClient().getBasePath(),
() -> podApi.v1FilesAllowedTypesGet(authSession.getSessionToken()));
}

/**
* Update an existing message. The existing message must be a valid social message, that has not been deleted.
*
Expand Down Expand Up @@ -449,17 +458,6 @@ public MessageStatus getMessageStatus(@Nonnull String messageId) {
() -> messageApi.v1MessageMidStatusGet(toUrlSafeIdIfNeeded(messageId), authSession.getSessionToken()));
}

/**
* Retrieves a list of supported file extensions for attachments.
*
* @return a list of String containing all allowed file extensions for attachments
* @see <a href="https://developers.symphony.com/restapi/reference#attachment-types">Attachment Types</a>
*/
public List<String> getAttachmentTypes() {
return executeAndRetry("getAttachmentTypes", podApi.getApiClient().getBasePath(),
() -> podApi.v1FilesAllowedTypesGet(authSession.getSessionToken()));
}

/**
* Retrieves the details of a message given its message ID.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import org.apiguardian.api.API;

import java.util.List;

import javax.annotation.Nonnull;

/**
Expand Down Expand Up @@ -74,4 +76,12 @@ public interface OboMessageService {
* @see <a href="https://developers.symphony.com/restapi/reference/suppress-message">Suppress Message</a>
*/
MessageSuppressionResponse suppressMessage(@Nonnull String messageId);

/**
* Retrieves a list of supported file extensions for attachments.
*
* @return a list of String containing all allowed file extensions for attachments
* @see <a href="https://developers.symphony.com/restapi/reference#attachment-types">Attachment Types</a>
*/
List<String> getAttachmentTypes();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
import com.symphony.bdk.core.service.pagination.model.PaginationAttribute;
import com.symphony.bdk.core.service.pagination.model.StreamPaginationAttribute;
import com.symphony.bdk.gen.api.model.ShareContent;
import com.symphony.bdk.gen.api.model.Stream;
import com.symphony.bdk.gen.api.model.StreamAttributes;
import com.symphony.bdk.gen.api.model.StreamFilter;
import com.symphony.bdk.gen.api.model.V2Message;
import com.symphony.bdk.gen.api.model.V2RoomSearchCriteria;
import com.symphony.bdk.gen.api.model.V2StreamAttributes;
import com.symphony.bdk.gen.api.model.V3RoomAttributes;
import com.symphony.bdk.gen.api.model.V3RoomDetail;
import com.symphony.bdk.gen.api.model.V3RoomSearchResults;

import org.apiguardian.api.API;

import java.util.List;
import java.util.stream.Stream;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -22,6 +26,44 @@
@API(status = API.Status.STABLE)
public interface OboStreamService {

/**
* {@link StreamService#create(List)}
*
* @param uids User ids of the participant
* @return The created IM
* @see <a href="https://developers.symphony.com/restapi/reference/create-im-or-mim">Create IM or MIM</a>
*/
Stream create(@Nonnull Long... uids);

/**
* Create a new single or multi party instant message conversation between the caller and specified users.
* <p>
* The caller is implicitly included in the members of the created chat.
* <p>
* Duplicate users will be included in the membership of the chat but
* the duplication will be silently ignored.
* <p>
* If there is an existing IM conversation with the same set of participants then
* the id of that existing stream will be returned.
* <p>
* If the given list of user ids contains only one id, an IM will be created, otherwise, a MIM will be created.
*
* @param uids List of user ids of the participants.
* @return The created IM or MIM
* @see <a href="https://developers.symphony.com/restapi/reference/create-im-or-mim">Create IM or MIM</a>
*/
Stream create(@Nonnull List<Long> uids);

/**
* Create a new chatroom.
* If no attributes are specified, the room is created as a private chatroom.
*
* @param roomAttributes Attributes of the created room
* @return The created chatroom
* @see <a href="https://developers.symphony.com/restapi/reference/create-room-v3">Create Room V3</a>
*/
V3RoomDetail create(@Nonnull V3RoomAttributes roomAttributes);

/**
* {@link StreamService#getStream(String)}
*
Expand All @@ -31,6 +73,15 @@ public interface OboStreamService {
*/
V2StreamAttributes getStream(@Nonnull String streamId);

/**
* Get information about a particular room.
*
* @param roomId The room id.
* @return The information about the room with the given room id.
* @see <a href="https://developers.symphony.com/restapi/reference#room-info-v3">Room Info V3</a>
*/
V3RoomDetail getRoomInfo(@Nonnull String roomId);

/**
* {@link StreamService#listStreams(StreamFilter)}
*
Expand All @@ -54,22 +105,74 @@ public interface OboStreamService {
* {@link StreamService#listAllStreams(StreamFilter)}
*
* @param filter The stream searching criteria.
* @return a {@link Stream} of matching streams according to the searching criteria.
* @return a {@link java.util.stream.Stream} of matching streams according to the searching criteria.
* @see <a href="https://developers.symphony.com/restapi/reference/list-user-streams">List Streams</a>
*/
@API(status = API.Status.EXPERIMENTAL)
Stream<StreamAttributes> listAllStreams(@Nullable StreamFilter filter);
java.util.stream.Stream<StreamAttributes> listAllStreams(@Nullable StreamFilter filter);

/**
* {@link StreamService#listAllStreams(StreamFilter, StreamPaginationAttribute)}
*
* @param filter The stream searching criteria.
* @param pagination The chunkSize and totalSize for pagination.
* @return a {@link Stream} of matching streams according to the searching criteria.
* @return a {@link java.util.stream.Stream} of matching streams according to the searching criteria.
* @see <a href="https://developers.symphony.com/restapi/reference/list-user-streams">List Streams</a>
*/
@API(status = API.Status.EXPERIMENTAL)
Stream<StreamAttributes> listAllStreams(@Nullable StreamFilter filter, @Nonnull StreamPaginationAttribute pagination);
java.util.stream.Stream<StreamAttributes> listAllStreams(@Nullable StreamFilter filter,
@Nonnull StreamPaginationAttribute pagination);

/**
* Search rooms according to the specified criteria.
*
* @param query The room searching criteria
* @return The rooms returned according to the given criteria.
* @see <a href="https://developers.symphony.com/restapi/reference/search-rooms-v3">Search Rooms V3</a>
*/
V3RoomSearchResults searchRooms(@Nonnull V2RoomSearchCriteria query);

/**
* Search rooms according to the specified criteria.
*
* @param query The room searching criteria.
* @param pagination The skip and limit for pagination.
* @return The rooms returned according to the given criteria.
* @see <a href="https://developers.symphony.com/restapi/reference/search-rooms-v3">Search Rooms V3</a>
*/
V3RoomSearchResults searchRooms(@Nonnull V2RoomSearchCriteria query, @Nonnull PaginationAttribute pagination);

/**
* Search rooms and return in a {@link java.util.stream.Stream} according to the specified criteria.
*
* @param query The room searching criteria.
* @return A {@link java.util.stream.Stream} of rooms returned according to the given criteria.
* @see <a href="https://developers.symphony.com/restapi/reference/search-rooms-v3">Search Rooms V3</a>
*/
@API(status = API.Status.EXPERIMENTAL)
java.util.stream.Stream<V3RoomDetail> searchAllRooms(@Nonnull V2RoomSearchCriteria query);

/**
* Search rooms and return in a {@link java.util.stream.Stream} according to the specified criteria.
*
* @param query The room searching criteria.
* @param pagination The chunkSize and totalSize for stream pagination.
* @return A {@link java.util.stream.Stream} of rooms returned according to the given criteria.
* @see <a href="https://developers.symphony.com/restapi/reference/search-rooms-v3">Search Rooms V3</a>
*/
@API(status = API.Status.EXPERIMENTAL)
java.util.stream.Stream<V3RoomDetail> searchAllRooms(@Nonnull V2RoomSearchCriteria query,
@Nonnull StreamPaginationAttribute pagination);

/**
* Update the attributes of an existing chatroom.
*
* @param roomId The id of the room to be updated
* @param roomAttributes The attributes to be updated to the room
* @return The information of the room after being updated.
* @see <a href="https://developers.symphony.com/restapi/reference#update-room-v3">Update Room V3</a>
*/
V3RoomDetail updateRoom(@Nonnull String roomId, @Nonnull V3RoomAttributes roomAttributes);

/**
* {@link StreamService#addMemberToRoom(Long, String)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,85 +199,76 @@ public void demoteUserToRoomParticipant(@Nonnull Long userId, @Nonnull String ro
}

/**
* Create a new single or multi party instant message conversation between the caller and specified users.
* <p>
* The caller is implicitly included in the members of the created chat.
* <p>
* Duplicate users will be included in the membership of the chat but
* the duplication will be silently ignored.
* <p>
* If there is an existing IM conversation with the same set of participants then
* the id of that existing stream will be returned.
* <p>
* If the given list of user ids contains only one id, an IM will be created, otherwise, a MIM will be created.
*
* @param uids List of user ids of the participants.
* @return The created IM or MIM
* @see <a href="https://developers.symphony.com/restapi/reference/create-im-or-mim">Create IM or MIM</a>
* {@inheritDoc}
*/
@Override
public Stream create(@Nonnull Long... uids) {
return this.create(Arrays.asList(uids));
}

/**
* {@inheritDoc}
*/
@Override
public Stream create(@Nonnull List<Long> uids) {
return executeAndRetry("createStreamByUserIds", streamsApi.getApiClient().getBasePath(),
() -> streamsApi.v1ImCreatePost(authSession.getSessionToken(), uids));
}

/**
* {@link StreamService#create(List)}
*
* @param uids User ids of the participant
* @return The created IM
* @see <a href="https://developers.symphony.com/restapi/reference/create-im-or-mim">Create IM or MIM</a>
* {@inheritDoc}
*/
public Stream create(@Nonnull Long... uids) {
return this.create(Arrays.asList(uids));
@Override
public V3RoomDetail create(@Nonnull V3RoomAttributes roomAttributes) {
return executeAndRetry("createStream", streamsApi.getApiClient().getBasePath(),
() -> streamsApi.v3RoomCreatePost(authSession.getSessionToken(), roomAttributes));
}

/**
* Create a new chatroom.
* If no attributes are specified, the room is created as a private chatroom.
*
* @param roomAttributes Attributes of the created room
* @return The created chatroom
* @see <a href="https://developers.symphony.com/restapi/reference/create-room-v3">Create Room V3</a>
* {@inheritDoc}
*/
public V3RoomDetail create(@Nonnull V3RoomAttributes roomAttributes) {
return executeAndRetry("createStream", streamsApi.getApiClient().getBasePath(),
() -> streamsApi.v3RoomCreatePost(authSession.getSessionToken(), roomAttributes));
@Override
public V3RoomDetail updateRoom(@Nonnull String roomId, @Nonnull V3RoomAttributes roomAttributes) {
if(roomAttributes.getPinnedMessageId() != null) {
String pinnedMessageId = toUrlSafeIdIfNeeded(roomAttributes.getPinnedMessageId());
roomAttributes.setPinnedMessageId(pinnedMessageId);
}
return executeAndRetry("updateRoom", streamsApi.getApiClient().getBasePath(),
() -> streamsApi.v3RoomIdUpdatePost(toUrlSafeIdIfNeeded(roomId), authSession.getSessionToken(), roomAttributes));
}

/**
* Search rooms according to the specified criteria.
*
* @param query The room searching criteria
* @return The rooms returned according to the given criteria.
* @see <a href="https://developers.symphony.com/restapi/reference/search-rooms-v3">Search Rooms V3</a>
* {@inheritDoc}
*/
@Override
public V3RoomDetail getRoomInfo(@Nonnull String roomId) {
return executeAndRetry("getRoomInfo", streamsApi.getApiClient().getBasePath(),
() -> streamsApi.v3RoomIdInfoGet(toUrlSafeIdIfNeeded(roomId), authSession.getSessionToken()));
}

/**
* {@inheritDoc}
*/
@Override
public V3RoomSearchResults searchRooms(@Nonnull V2RoomSearchCriteria query) {
return executeAndRetry("searchRooms", streamsApi.getApiClient().getBasePath(),
() -> streamsApi.v3RoomSearchPost(authSession.getSessionToken(), query, null, null));
}

/**
* Search rooms according to the specified criteria.
*
* @param query The room searching criteria.
* @param pagination The skip and limit for pagination.
* @return The rooms returned according to the given criteria.
* @see <a href="https://developers.symphony.com/restapi/reference/search-rooms-v3">Search Rooms V3</a>
* {@inheritDoc}
*/
@Override
public V3RoomSearchResults searchRooms(@Nonnull V2RoomSearchCriteria query, @Nonnull PaginationAttribute pagination) {
return executeAndRetry("searchRooms", streamsApi.getApiClient().getBasePath(),
() -> streamsApi.v3RoomSearchPost(authSession.getSessionToken(), query, pagination.getSkip(),
pagination.getLimit()));
}

/**
* Search rooms and return in a {@link java.util.stream.Stream} according to the specified criteria.
*
* @param query The room searching criteria.
* @return A {@link java.util.stream.Stream} of rooms returned according to the given criteria.
* @see <a href="https://developers.symphony.com/restapi/reference/search-rooms-v3">Search Rooms V3</a>
* {@inheritDoc}
*/
@Override
@API(status = API.Status.EXPERIMENTAL)
public java.util.stream.Stream<V3RoomDetail> searchAllRooms(@Nonnull V2RoomSearchCriteria query) {
OffsetBasedPaginatedApi<V3RoomDetail> api =
Expand All @@ -287,13 +278,9 @@ public java.util.stream.Stream<V3RoomDetail> searchAllRooms(@Nonnull V2RoomSearc
}

/**
* Search rooms and return in a {@link java.util.stream.Stream} according to the specified criteria.
*
* @param query The room searching criteria.
* @param pagination The chunkSize and totalSize for stream pagination.
* @return A {@link java.util.stream.Stream} of rooms returned according to the given criteria.
* @see <a href="https://developers.symphony.com/restapi/reference/search-rooms-v3">Search Rooms V3</a>
* {@inheritDoc}
*/
@Override
@API(status = API.Status.EXPERIMENTAL)
public java.util.stream.Stream<V3RoomDetail> searchAllRooms(@Nonnull V2RoomSearchCriteria query,
@Nonnull StreamPaginationAttribute pagination) {
Expand All @@ -302,18 +289,6 @@ public java.util.stream.Stream<V3RoomDetail> searchAllRooms(@Nonnull V2RoomSearc
return new OffsetBasedPaginatedService<>(api, pagination.getChunkSize(), pagination.getTotalSize()).stream();
}

/**
* Get information about a particular room.
*
* @param roomId The room id.
* @return The information about the room with the given room id.
* @see <a href="https://developers.symphony.com/restapi/reference#room-info-v3">Room Info V3</a>
*/
public V3RoomDetail getRoomInfo(@Nonnull String roomId) {
return executeAndRetry("getRoomInfo", streamsApi.getApiClient().getBasePath(),
() -> streamsApi.v3RoomIdInfoGet(toUrlSafeIdIfNeeded(roomId), authSession.getSessionToken()));
}

/**
* Deactivate or reactivate a chatroom. At the creation, the chatroom is activated by default.
*
Expand All @@ -327,23 +302,6 @@ public RoomDetail setRoomActive(@Nonnull String roomId, @Nonnull Boolean active)
() -> streamsApi.v1RoomIdSetActivePost(toUrlSafeIdIfNeeded(roomId), active, authSession.getSessionToken()));
}

/**
* Update the attributes of an existing chatroom.
*
* @param roomId The id of the room to be updated
* @param roomAttributes The attributes to be updated to the room
* @return The information of the room after being updated.
* @see <a href="https://developers.symphony.com/restapi/reference#update-room-v3">Update Room V3</a>
*/
public V3RoomDetail updateRoom(@Nonnull String roomId, @Nonnull V3RoomAttributes roomAttributes) {
if(roomAttributes.getPinnedMessageId() != null) {
String pinnedMessageId = toUrlSafeIdIfNeeded(roomAttributes.getPinnedMessageId());
roomAttributes.setPinnedMessageId(pinnedMessageId);
}
return executeAndRetry("updateRoom", streamsApi.getApiClient().getBasePath(),
() -> streamsApi.v3RoomIdUpdatePost(toUrlSafeIdIfNeeded(roomId), authSession.getSessionToken(), roomAttributes));
}

/**
* Create a new single or multi party instant message conversation.
* At least two user IDs must be provided or an error response will be sent.
Expand Down
Loading

0 comments on commit e213571

Please sign in to comment.