diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/Conversations.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/Conversations.java index 3660d1f4f..f08a64bce 100644 --- a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/Conversations.java +++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/Conversations.java @@ -16,6 +16,7 @@ import com.microsoft.bot.schema.models.ConversationParameters; import com.microsoft.bot.schema.models.ConversationResourceResponse; import com.microsoft.bot.schema.models.ConversationsResult; +import com.microsoft.bot.schema.models.TeammateAccount; import com.microsoft.bot.connector.models.ErrorResponseException; import com.microsoft.bot.schema.models.ResourceResponse; import com.microsoft.rest.ServiceCallback; @@ -490,6 +491,19 @@ This is slightly different from SendToConversation(). */ List getConversationMembers(String conversationId); + /** + * GetTeamsConversationMembers. + * Enumerate the members of a team. + This REST API takes a TeamId and returns an array of TeammateAccount objects representing the members of the team. + * + * @param teamId Team ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<TeammateAccount> object if successful. + */ + List getTeamsConversationMembers(String teamId); + /** * GetConversationMembers. * Enumerate the members of a converstion. @@ -513,6 +527,17 @@ This is slightly different from SendToConversation(). */ Observable> getConversationMembersAsync(String conversationId); + /** + * GetTeamsConversationMembers. + * Enumerate the members of a team. + This REST API takes a TeamId and returns an array of TeammateAccount objects representing the members of the team. + * + * @param teamId Team ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TeammateAccount> object + */ + Observable> getTeamsConversationMembersAsync(String teamId); + /** * GetConversationMembers. * Enumerate the members of a converstion. @@ -524,6 +549,17 @@ This is slightly different from SendToConversation(). */ Observable>> getConversationMembersWithServiceResponseAsync(String conversationId); + /** + * GetTeamsConversationMembers. + * Enumerate the members of a team. + This REST API takes a teamId and returns an array of TeammateAccount objects representing the members of the team. + * + * @param teamId Team ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TeammateAccount> object + */ + Observable>> getTeamsConversationMembersWithServiceResponseAsync(String teamId); + /** * DeleteConversationMember. * Deletes a member from a converstion. diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/implementation/ConversationsImpl.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/implementation/ConversationsImpl.java index b8889cec5..dac6131e0 100644 --- a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/implementation/ConversationsImpl.java +++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/implementation/ConversationsImpl.java @@ -18,6 +18,7 @@ import com.microsoft.bot.schema.models.ConversationParameters; import com.microsoft.bot.schema.models.ConversationResourceResponse; import com.microsoft.bot.schema.models.ConversationsResult; +import com.microsoft.bot.schema.models.TeammateAccount; import com.microsoft.bot.connector.models.ErrorResponseException; import com.microsoft.bot.schema.models.ResourceResponse; import com.microsoft.rest.ServiceCallback; @@ -97,6 +98,10 @@ interface ConversationsService { @GET("v3/conversations/{conversationId}/members") Observable> getConversationMembers(@Path("conversationId") String conversationId, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.bot.schema.Conversations getTeamConversationMembers" }) + @GET("v3/conversations/{teamId}/members") + Observable> getTeamConversationMembers(@Path("teamId") String teamId, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.bot.schema.Conversations deleteConversationMember" }) @HTTP(path = "v3/conversations/{conversationId}/members/{memberId}", method = "DELETE", hasBody = true) Observable> deleteConversationMember(@Path("conversationId") String conversationId, @Path("memberId") String memberId, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); @@ -108,7 +113,6 @@ interface ConversationsService { @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.bot.schema.Conversations uploadAttachment" }) @POST("v3/conversations/{conversationId}/attachments") Observable> uploadAttachment(@Path("conversationId") String conversationId, @Body AttachmentData attachmentUpload, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); - } public static CompletableFuture> completableFutureFromObservable(Observable observable) { @@ -846,6 +850,21 @@ public List getConversationMembers(String conversationId) { return getConversationMembersWithServiceResponseAsync(conversationId).toBlocking().single().body(); } + /** + * GetTeamsConversationMembers. + * Enumerate the members of a team. + This REST API takes a TeamId and returns an array of TeammateAccount objects representing the members of the team. + * + * @param teamId Team ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the List<TeammateAccount> object if successful. + */ + public List getTeamsConversationMembers(String teamId) { + return getTeamsConversationMembersWithServiceResponseAsync(teamId).toBlocking().single().body(); + } + /** * GetConversationMembers. * Enumerate the members of a converstion. @@ -878,6 +897,24 @@ public List call(ServiceResponse> response) }); } + /** + * GetTeamsConversationMembers. + * Enumerate the members of a team. + This REST API takes a TeamId and returns an array of TeammateAccount objects representing the members of the team. + * + * @param teamId Team ID + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the List<TeammateAccount> object + */ + public Observable> getTeamsConversationMembersAsync(String teamId) { + return getTeamsConversationMembersWithServiceResponseAsync(teamId).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.body(); + } + }); + } + /** * GetConversationMembers. * Enumerate the members of a converstion. @@ -905,6 +942,33 @@ public Observable>> call(Response>> getTeamsConversationMembersWithServiceResponseAsync(String teamId) { + if (teamId == null) { + throw new IllegalArgumentException("Parameter teamId is required and cannot be null."); + } + return service.getTeamConversationMembers(teamId, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> clientResponse = getTeamsConversationMembersDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + private ServiceResponse> getConversationMembersDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) .register(200, new TypeToken>() { }.getType()) @@ -912,6 +976,13 @@ private ServiceResponse> getConversationMembersDelegate(Res .build(response); } + private ServiceResponse> getTeamsConversationMembersDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + /** * DeleteConversationMember. * Deletes a member from a converstion. diff --git a/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/TeammateAccount.java b/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/TeammateAccount.java new file mode 100644 index 000000000..9fb8d3d6a --- /dev/null +++ b/libraries/botbuilder-schema/src/main/java/com/microsoft/bot/schema/models/TeammateAccount.java @@ -0,0 +1,199 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + */ + +package com.microsoft.bot.schema.models; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; + +import java.util.HashMap; +import java.util.Map; + +/** + * Teammate account information needed to fetch team members. + */ +public class TeammateAccount { + /** + * Channel id for the user on this channel (Example: joe@smith.com, + * or @joesmith or 123456). + */ + @JsonProperty(value = "id") + private String id; + + @JsonProperty(value = "objectId") + private String objectId; + + @JsonProperty(value = "givenName") + private String givenName; + + @JsonProperty(value = "surname") + private String surname; + + @JsonProperty(value = "email") + private String email; + + @JsonProperty(value = "userPrincipalName") + private String userPrincipalName; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the TeammateAccount object itself. + */ + public TeammateAccount withId(String id) { + this.id = id; + return this; + } + + /** + * Get the objectId value. + * + * @return the objectId value + */ + public String objectId() { + return this.objectId; + } + + /** + * Set the objectId value. + * + * @param objectId the name value to set + * @return the TeammateAccount object itself. + */ + public TeammateAccount withObjectId(String objectId) { + this.objectId = objectId; + return this; + } + + /** + * Get the givenName value. + * + * @return the givenName value + */ + public String givenName() { + return this.givenName; + } + + /** + * Set the givenName value. + * + * @param givenName the name value to set + * @return the TeammateAccount object itself. + */ + public TeammateAccount withGivenName(String givenName) { + this.givenName = givenName; + return this; + } + + /** + * Get the surname value. + * + * @return the surname value + */ + public String surname() { + return this.givenName; + } + + /** + * Set the surname value. + * + * @param surname the name value to set + * @return the TeammateAccount object itself. + */ + public TeammateAccount withSurname(String surname) { + this.surname = surname; + return this; + } + + /** + * Get the email value. + * + * @return the email value + */ + public String email() { + return this.email; + } + + /** + * Set the email value. + * + * @param email the name value to set + * @return the TeammateAccount object itself. + */ + public TeammateAccount withEmail(String email) { + this.email = email; + return this; + } + + /** + * Get the userPrincipalName value. + * + * @return the userPrincipalName value + */ + public String userPrincipalName() { + return this.userPrincipalName; + } + + /** + * Set the email value. + * + * @param userPrincipalName the name value to set + * @return the TeammateAccount object itself. + */ + public TeammateAccount withUserPrincipalName(String userPrincipalName) { + this.userPrincipalName = userPrincipalName; + return this; + } + + + /** + * Holds the overflow properties that aren't first class + * properties in the object. This allows extensibility + * while maintaining the object. + * + */ + private HashMap properties = new HashMap(); + + /** + * Overflow properties. + * Properties that are not modelled as first class properties in the object are accessible here. + * Note: A property value can be be nested. + * + * @return A Key-Value map of the properties + */ + @JsonAnyGetter + public Map properties() { + return this.properties; + } + + /** + * Set overflow properties. + * + * @param key Key for the property + * @param value JsonNode of value (can be nested) + * + */ + + @JsonAnySetter + public void setProperties(String key, JsonNode value) { + this.properties.put(key, value); + } + + +}