azure-communication-chat: step_1: onboarding to new module system, as first step using callback for async

This commit is contained in:
Anu Thomas Chandy 2021-03-04 17:28:29 -08:00
Родитель 8ea9cb409d
Коммит 075186f995
43 изменённых файлов: 2599 добавлений и 1474 удалений

Просмотреть файл

@ -26,11 +26,13 @@ android {
dependencies {
// <!-- begin: api Dependencies -->
// api project(":sdk:core:azure-core")
// api project(":sdk:core:azure-core-logging")
// api project(":sdk:core:azure-core-credential")
api("com.azure:azure-core:1.13.0")
api("com.azure:azure-communication-common:1.0.0-beta.5")
api project(":sdk:core:azure-core")
api project(":sdk:core:azure-core-logging")
api project(":sdk:core:azure-core-credential")
api project(":sdk:core:azure-core-rest")
api project(":sdk:core:azure-core-http")
// api("com.azure:azure-core:1.13.0")
// api("com.azure:azure-communication-common:1.0.0-beta.5")
// <!-- end: api Dependencies -->
// <!-- begin: implementation Dependencies -->
@ -40,9 +42,9 @@ dependencies {
// <!-- begin: test Dependencies -->
testImplementation ("com.azure:azure-core-test:1.5.3")
testImplementation ("com.azure:azure-communication-identity:1.0.0-beta.5")
testImplementation ("com.nimbusds:nimbus-jose-jwt:8.19")
// testImplementation ("com.azure:azure-core-test:1.5.3")
// testImplementation ("com.azure:azure-communication-identity:1.0.0-beta.5")
// testImplementation ("com.nimbusds:nimbus-jose-jwt:8.19")
testRuntimeOnly ("org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion")
testImplementation ("org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion")

Просмотреть файл

@ -4,13 +4,12 @@
package com.azure.android.communication.chat.implementation;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.policy.CookiePolicy;
import com.azure.core.http.policy.RetryPolicy;
import com.azure.core.http.policy.UserAgentPolicy;
import com.azure.core.util.serializer.JacksonAdapter;
import com.azure.core.util.serializer.SerializerAdapter;
import com.azure.android.core.http.HttpPipeline;
import com.azure.android.core.http.HttpPipelineBuilder;
import com.azure.android.core.http.policy.CookiePolicy;
import com.azure.android.core.http.policy.RetryPolicy;
import com.azure.android.core.http.policy.UserAgentPolicy;
import com.azure.android.core.serde.jackson.JacksonSerder;
/** Initializes a new instance of the AzureCommunicationChatService type. */
public final class AzureCommunicationChatServiceImpl {
@ -51,15 +50,15 @@ public final class AzureCommunicationChatServiceImpl {
}
/** The serializer to serialize an object into a string. */
private final SerializerAdapter serializerAdapter;
private final JacksonSerder jacksonSerder;
/**
* Gets The serializer to serialize an object into a string.
*
* @return the serializerAdapter value.
* @return the jacksonSerder value.
*/
public SerializerAdapter getSerializerAdapter() {
return this.serializerAdapter;
public JacksonSerder getJacksonSerder() {
return this.jacksonSerder;
}
/** The ChatThreadsImpl object to access its operations. */
@ -94,9 +93,9 @@ public final class AzureCommunicationChatServiceImpl {
AzureCommunicationChatServiceImpl(String endpoint) {
this(
new HttpPipelineBuilder()
.policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy())
.policies(new UserAgentPolicy(), RetryPolicy.withExponentialBackoff(), new CookiePolicy())
.build(),
JacksonAdapter.createDefaultSerializerAdapter(),
JacksonSerder.createDefault(),
endpoint);
}
@ -107,19 +106,19 @@ public final class AzureCommunicationChatServiceImpl {
* @param endpoint The endpoint of the Azure Communication resource.
*/
AzureCommunicationChatServiceImpl(HttpPipeline httpPipeline, String endpoint) {
this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint);
this(httpPipeline, JacksonSerder.createDefault(), endpoint);
}
/**
* Initializes an instance of AzureCommunicationChatService client.
*
* @param httpPipeline The HTTP pipeline to send requests through.
* @param serializerAdapter The serializer to serialize an object into a string.
* @param jacksonSerder The serializer to serialize an object into a string.
* @param endpoint The endpoint of the Azure Communication resource.
*/
AzureCommunicationChatServiceImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint) {
AzureCommunicationChatServiceImpl(HttpPipeline httpPipeline, JacksonSerder jacksonSerder, String endpoint) {
this.httpPipeline = httpPipeline;
this.serializerAdapter = serializerAdapter;
this.jacksonSerder = jacksonSerder;
this.endpoint = endpoint;
this.apiVersion = "2021-01-27-preview4";
this.chatThreadClient = new ChatThreadImpl(this);

Просмотреть файл

@ -4,20 +4,18 @@
package com.azure.android.communication.chat.implementation;
import com.azure.core.annotation.ServiceClientBuilder;
import com.azure.core.http.HttpClient;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.policy.CookiePolicy;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.policy.HttpLoggingPolicy;
import com.azure.core.http.policy.HttpPipelinePolicy;
import com.azure.core.http.policy.HttpPolicyProviders;
import com.azure.core.http.policy.RetryPolicy;
import com.azure.core.http.policy.UserAgentPolicy;
import com.azure.core.util.Configuration;
import com.azure.core.util.serializer.JacksonAdapter;
import com.azure.core.util.serializer.SerializerAdapter;
import com.azure.android.core.rest.annotation.ServiceClientBuilder;
import com.azure.android.core.http.HttpClient;
import com.azure.android.core.http.HttpPipeline;
import com.azure.android.core.http.HttpPipelineBuilder;
import com.azure.android.core.http.policy.CookiePolicy;
import com.azure.android.core.http.policy.HttpLogOptions;
import com.azure.android.core.http.policy.HttpLoggingPolicy;
import com.azure.android.core.http.HttpPipelinePolicy;
import com.azure.android.core.http.policy.RetryPolicy;
import com.azure.android.core.http.policy.UserAgentPolicy;
import com.azure.android.core.serde.jackson.JacksonSerder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -72,18 +70,18 @@ public final class AzureCommunicationChatServiceImplBuilder {
/*
* The serializer to serialize an object into a string
*/
private SerializerAdapter serializerAdapter;
private JacksonSerder jacksonSerder;
/**
* Sets The serializer to serialize an object into a string.
*
* @param serializerAdapter the serializerAdapter value.
* @return the AzureCommunicationChatServiceImplBuilder.
*/
public AzureCommunicationChatServiceImplBuilder serializerAdapter(SerializerAdapter serializerAdapter) {
this.serializerAdapter = serializerAdapter;
return this;
}
// /**
// * Sets The serializer to serialize an object into a string.
// *
// * @param serializerAdapter the serializerAdapter value.
// * @return the AzureCommunicationChatServiceImplBuilder.
// */
// public AzureCommunicationChatServiceImplBuilder serializerAdapter(JacksonSerder serializerAdapter) {
// this.serializerAdapter = serializerAdapter;
// return this;
// }
/*
* The HTTP client used to send the request.
@ -101,22 +99,22 @@ public final class AzureCommunicationChatServiceImplBuilder {
return this;
}
/*
* The configuration store that is used during construction of the service
* client.
*/
private Configuration configuration;
/**
* Sets The configuration store that is used during construction of the service client.
*
* @param configuration the configuration value.
* @return the AzureCommunicationChatServiceImplBuilder.
*/
public AzureCommunicationChatServiceImplBuilder configuration(Configuration configuration) {
this.configuration = configuration;
return this;
}
// /*
// * The configuration store that is used during construction of the service
// * client.
// */
// private Configuration configuration;
//
// /**
// * Sets The configuration store that is used during construction of the service client.
// *
// * @param configuration the configuration value.
// * @return the AzureCommunicationChatServiceImplBuilder.
// */
// public AzureCommunicationChatServiceImplBuilder configuration(Configuration configuration) {
// this.configuration = configuration;
// return this;
// }
/*
* The logging configuration for HTTP requests and responses.
@ -176,17 +174,17 @@ public final class AzureCommunicationChatServiceImplBuilder {
if (pipeline == null) {
this.pipeline = createHttpPipeline();
}
if (serializerAdapter == null) {
this.serializerAdapter = JacksonAdapter.createDefaultSerializerAdapter();
if (jacksonSerder == null) {
this.jacksonSerder = JacksonSerder.createDefault();
}
AzureCommunicationChatServiceImpl client =
new AzureCommunicationChatServiceImpl(pipeline, serializerAdapter, endpoint);
new AzureCommunicationChatServiceImpl(pipeline, jacksonSerder, endpoint);
return client;
}
private HttpPipeline createHttpPipeline() {
Configuration buildConfiguration =
(configuration == null) ? Configuration.getGlobalConfiguration() : configuration;
// Configuration buildConfiguration =
// (configuration == null) ? Configuration.getGlobalConfiguration() : configuration;
if (httpLogOptions == null) {
httpLogOptions = new HttpLogOptions();
}
@ -194,12 +192,12 @@ public final class AzureCommunicationChatServiceImplBuilder {
String clientName = properties.getOrDefault(SDK_NAME, "UnknownName");
String clientVersion = properties.getOrDefault(SDK_VERSION, "UnknownVersion");
policies.add(
new UserAgentPolicy(httpLogOptions.getApplicationId(), clientName, clientVersion, buildConfiguration));
HttpPolicyProviders.addBeforeRetryPolicies(policies);
policies.add(retryPolicy == null ? new RetryPolicy() : retryPolicy);
new UserAgentPolicy(null, clientName, clientVersion));
// HttpPolicyProviders.addBeforeRetryPolicies(policies);
policies.add(retryPolicy == null ? RetryPolicy.withExponentialBackoff() : retryPolicy);
policies.add(new CookiePolicy());
policies.addAll(this.pipelinePolicies);
HttpPolicyProviders.addAfterRetryPolicies(policies);
// HttpPolicyProviders.addAfterRetryPolicies(policies);
policies.add(new HttpLoggingPolicy(httpLogOptions));
HttpPipeline httpPipeline =
new HttpPipelineBuilder()

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

Просмотреть файл

@ -5,7 +5,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.android.communication.chat.models.ChatMessageType;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

Просмотреть файл

@ -5,7 +5,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.android.communication.chat.models.ChatThreadInfo;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.util.ExpandableStringEnum;
import com.azure.android.core.util.ExpandableStringEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import java.util.Collection;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
/**

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
/** A user that got created with an Azure Communication Services resource. */

Просмотреть файл

@ -5,7 +5,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.android.communication.chat.models.Error;
import com.azure.core.annotation.Immutable;
import com.azure.android.core.rest.annotation.Immutable;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

Просмотреть файл

@ -5,7 +5,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.android.communication.chat.models.CreateChatThreadErrors;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
/** Result of the create chat thread operation. */

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Immutable;
import com.azure.android.core.rest.annotation.Immutable;
import com.fasterxml.jackson.annotation.JsonProperty;
/** The IndividualStatusResponse model. */

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
/** A Microsoft Teams user. */

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Immutable;
import com.azure.android.core.rest.annotation.Immutable;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
/** A phone number. */

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
/** Result of the send message operation. */

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.implementation.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
/** Request payload for sending a read receipt. */

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
/** Result of the add chat participants operation. */

Просмотреть файл

@ -6,7 +6,7 @@ package com.azure.android.communication.chat.models;
import com.azure.android.communication.chat.implementation.models.ChatParticipant;
import com.azure.android.communication.chat.implementation.models.CommunicationIdentifierModel;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.models;
import com.azure.core.util.ExpandableStringEnum;
import com.azure.android.core.util.ExpandableStringEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import java.util.Collection;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
/** The Communication Services error. */

Просмотреть файл

@ -4,8 +4,8 @@
package com.azure.android.communication.chat.models;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.http.HttpResponse;
import com.azure.android.core.http.HttpResponse;
import com.azure.android.core.http.exception.HttpResponseException;
/** Exception thrown for an invalid response with CommunicationErrorResponse information. */
public final class CommunicationErrorResponseException extends HttpResponseException {
@ -62,23 +62,25 @@ public final class CommunicationErrorResponseException extends HttpResponseExcep
super(response, cause);
}
/**
* Initializes a new instance of the CommunicationErrorResponseException class.
*
* @param message the exception message or the response content if a message is not available.
* @param response the HTTP response.
* @param cause the inner exception.
* @param enableSuppression suppress the exception.
* @param writableStackTrace write to the stacktrace.
*/
public CommunicationErrorResponseException(
String message,
HttpResponse response,
Throwable cause,
boolean enableSuppression,
boolean writableStackTrace) {
super(message, response, cause, enableSuppression, writableStackTrace);
}
// anuchan: The Ctr with stack trace info is not available for android.
//
// /**
// * Initializes a new instance of the CommunicationErrorResponseException class.
// *
// * @param message the exception message or the response content if a message is not available.
// * @param response the HTTP response.
// * @param cause the inner exception.
// * @param enableSuppression suppress the exception.
// * @param writableStackTrace write to the stacktrace.
// */
// public CommunicationErrorResponseException(
// String message,
// HttpResponse response,
// Throwable cause,
// boolean enableSuppression,
// boolean writableStackTrace) {
// super(message, response, cause, enableSuppression, writableStackTrace);
// }
@Override
public CommunicationErrorResponse getValue() {

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.models;
import com.azure.core.annotation.Immutable;
import com.azure.android.core.rest.annotation.Immutable;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.models;
import com.azure.core.annotation.Immutable;
import com.azure.android.core.rest.annotation.Immutable;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

Просмотреть файл

@ -4,8 +4,8 @@
package com.azure.android.communication.chat.models;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.http.HttpResponse;
import com.azure.android.core.http.HttpResponse;
import com.azure.android.core.http.exception.HttpResponseException;
/** Exception thrown for an invalid response with Error information. */
public final class ErrorException extends HttpResponseException {

Просмотреть файл

@ -4,7 +4,8 @@
package com.azure.android.communication.chat.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import java.time.OffsetDateTime;
/**

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import java.time.OffsetDateTime;
/**

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
/** Details of the message to send. */

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
/** Request payload for updating a chat message. */

Просмотреть файл

@ -4,7 +4,7 @@
package com.azure.android.communication.chat.models;
import com.azure.core.annotation.Fluent;
import com.azure.android.core.rest.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
/** Request payload for updating a chat thread. */