RestConnectorClient 类

实现

public class RestConnectorClient
extends ServiceClient
implements ConnectorClient

机器人连接器 REST API 允许机器人向 [Bot Framework 开发人员门户](https://dev.botframework.com)中配置的通道发送和接收消息。 连接器服务通过 HTTPS 使用行业标准 REST 和 JSON。 此 REST API 的客户端库可用。 有关列表,请参阅下文。 许多机器人同时使用 Bot Connector REST API 和关联的 [Bot State REST API](/en-us/restapi/state)。 机器人状态 REST API 允许机器人存储和检索与用户和对话关联的状态。 Bot Connector 和 Bot State REST API 的身份验证都是使用 JWT 持有者令牌完成的,详述了 [连接器身份验证](/en-us/restapi/authentication) 文档中的说明。

构造函数摘要

构造函数 说明
RestConnectorClient(RestClient restClient)

初始化连接器客户端的实例。

RestConnectorClient(ServiceClientCredentials credentials)

初始化连接器客户端的实例。

RestConnectorClient(String baseUrl, ServiceClientCredentials credentials)

初始化连接器客户端的实例。

方法摘要

修饰符和类型 方法和描述
java.lang.String baseUrl()

返回此连接器客户端的基 URL。

void close()

自动可释放关闭。

ServiceClientCredentials credentials()

返回正在使用的凭据。

java.lang.String getAcceptLanguage()

获取响应的首选语言。

Attachments getAttachments()

获取 Attachments 对象以访问其作。

Conversations getConversations()

获取用于访问其作的 Conversations 对象。

static Builder getDefaultRestClientBuilder(String baseUrl, ServiceClientCredentials credentials)

这是 Azure 客户端创建 Rest客户端所执行的作的副本。

boolean getGenerateClientRequestId()

设置为 true 时,将生成唯一的 x-ms-client-request-id 值并将其包含在每个请求中。

int getLongRunningOperationRetryTimeout()

获取长时间运行作的重试超时(以秒为单位)。

RestClient getRestClient()

获取 REST 客户端。

RetryStrategy getRestRetryStrategy()

获取 Rest 重试策略。

java.lang.String getUserAgent()

获取客户端的 User-Agent 标头。

protected void initialize()

初始化对象构造后。

void setAcceptLanguage(String withAcceptLanguage)

设置响应的首选语言。

void setGenerateClientRequestId(boolean requestId)

设置为 true 时,将生成唯一的 x-ms-client-request-id 值并将其包含在每个请求中。

void setLongRunningOperationRetryTimeout(int timeout)

设置长时间运行作的重试超时(以秒为单位)。

void setRestRetryStrategy(RetryStrategy strategy)

设置 Rest 重试策略。

java.lang.String userAgent()

这是为了替代 Azure服务客户端版本。

方法继承自 ServiceClient

方法继承自 java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

构造函数详细信息

RestConnectorClient

public RestConnectorClient(RestClient restClient)

初始化 ConnectorClient 客户端的实例。

参数:

restClient - 要连接到 Azure 的 REST 客户端。

RestConnectorClient

public RestConnectorClient(ServiceClientCredentials credentials)

初始化 ConnectorClient 客户端的实例。

参数:

credentials - Azure 的管理凭据

RestConnectorClient

public RestConnectorClient(String baseUrl, ServiceClientCredentials credentials)

初始化 ConnectorClient 客户端的实例。

参数:

baseUrl - 主机的基 URL
credentials - Azure 的管理凭据

方法详细信息

baseUrl

public String baseUrl()

返回此 ConnectorClient 的基 URL。

返回:

基 URL。

close

public void close()

自动关闭。

credentials

public ServiceClientCredentials credentials()

返回正在使用的凭据。

返回:

正在使用的 ServiceClientCredentials。

getAcceptLanguage

public String getAcceptLanguage()

获取响应的首选语言。

返回:

acceptLanguage 值。

getAttachments

public Attachments getAttachments()

获取 Attachments 对象以访问其作。

返回:

Attachments 对象。

getConversations

public Conversations getConversations()

获取用于访问其作的 Conversations 对象。

返回:

Conversations 对象。

getDefaultRestClientBuilder

public static RestClient.Builder getDefaultRestClientBuilder(String baseUrl, ServiceClientCredentials credentials)

这是 Azure 客户端创建 RestClient 所执行的作的副本。 这会返回 RestClient.Builder,以便应用可以创建自定义 RestClient,并在构造过程中将其提供给 ConnectorClient。 其中一个用例是向 RestClient 提供代理。 尽管建议通过 Java 系统属性设置代理信息。

参数:

baseUrl - 服务终结点
credentials - 身份验证凭据。

返回:

RestClient.Builder。

getGenerateClientRequestId

public boolean getGenerateClientRequestId()

设置为 true 时,将生成唯一的 x-ms-client-request-id 值并将其包含在每个请求中。

返回:

generateClientRequestId 值。

getLongRunningOperationRetryTimeout

public int getLongRunningOperationRetryTimeout()

获取长时间运行作的重试超时(以秒为单位)。 默认值为 30。

返回:

超时值。

getRestClient

public RestClient getRestClient()

获取 REST 客户端。

返回:

RestClient 对象。

getRestRetryStrategy

public RetryStrategy getRestRetryStrategy()

获取 Rest 重试策略。

返回:

正在使用 RetryStrategy

getUserAgent

public String getUserAgent()

获取客户端的 User-Agent 标头。

返回:

用户代理字符串。

initialize

protected void initialize()

初始化对象构造后。

setAcceptLanguage

public void setAcceptLanguage(String withAcceptLanguage)

设置响应的首选语言。

参数:

withAcceptLanguage - acceptLanguage 值。

setGenerateClientRequestId

public void setGenerateClientRequestId(boolean requestId)

设置为 true 时,将生成唯一的 x-ms-client-request-id 值并将其包含在每个请求中。

参数:

requestId - generateClientRequestId 值。

setLongRunningOperationRetryTimeout

public void setLongRunningOperationRetryTimeout(int timeout)

设置长时间运行作的重试超时(以秒为单位)。 默认值为 30。

参数:

timeout - longRunningOperationRetryTimeout 值。

setRestRetryStrategy

public void setRestRetryStrategy(RetryStrategy strategy)

设置 Rest 重试策略。

参数:

strategy - 要使用的 RetryStrategy

userAgent

public String userAgent()

这是替代 AzureServiceClient 版本。

替代:

RestConnectorClient.userAgent()

返回:

用户代理。 与 getUserAgent() 相同

适用于