本文整理了Java中com.ibm.watson.developer_cloud.http.RequestBuilder.query
方法的一些代码示例,展示了RequestBuilder.query
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RequestBuilder.query
方法的具体详情如下:
包路径:com.ibm.watson.developer_cloud.http.RequestBuilder
类名称:RequestBuilder
方法名:query
[英]Adds query parameters.
[中]添加查询参数。
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Test with nested arrays.
*/
@Test
public void testWithNestedArray() {
Request request = RequestBuilder.post(HttpUrl.parse(url)).query("foo", new String[] { "bar", "bar2" }).build();
assertEquals(url + "?foo=bar&foo=bar2", request.url().toString());
request = RequestBuilder.post(HttpUrl.parse(url)).query("foo", Arrays.asList("bar", "bar2")).build();
assertEquals(url + "?foo=bar&foo=bar2", request.url().toString());
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Test with query object array.
*/
@Test
public void testWithQueryObjectArray() {
final Request request = RequestBuilder.post(HttpUrl.parse(url)).query("foo", "bar", "p2", "p2").build();
assertEquals(urlWithQuery, request.url().toString());
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Test requests with special characters in the query string.
*/
@Test
public void testSpecialCharacterQuery() {
final Request request = RequestBuilder.get(HttpUrl.parse(url)).query("ä&ö", "ö=ü").build();
assertEquals(url + "?%C3%A4%26%C3%B6=%C3%B6%3D%C3%BC", request.url().toString());
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Deletes a specified feedback entry.
*
* @param deleteFeedbackOptions the {@link DeleteFeedbackOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of Void
*/
public ServiceCall<Void> deleteFeedback(DeleteFeedbackOptions deleteFeedbackOptions) {
Validator.notNull(deleteFeedbackOptions, "deleteFeedbackOptions cannot be null");
String[] pathSegments = { "v1/feedback" };
String[] pathParameters = { deleteFeedbackOptions.feedbackId() };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query(VERSION, versionDate);
if (deleteFeedbackOptions.modelId() != null) {
builder.query("model_id", deleteFeedbackOptions.modelId());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Gets an authorization token that can be use to authorize API calls.
*
*
* @return the token
*/
public ServiceCall<String> getToken() {
HttpUrl url = HttpUrl.parse(getEndPoint()).newBuilder()
.setPathSegment(0, AUTHORIZATION)
.addPathSegment(PATH_AUTHORIZATION_V1_TOKEN)
.build();
Request request = RequestBuilder.get(url)
.header(HttpHeaders.ACCEPT, HttpMediaType.TEXT_PLAIN).query(URL, getEndPoint()).build();
return createServiceCall(request, ResponseConverterUtils.getString());
}
代码示例来源:origin: com.ibm.watson.developer_cloud/core
/**
* Gets an authorization token that can be use to authorize API calls.
*
*
* @return the token
*/
public ServiceCall<String> getToken() {
HttpUrl url = HttpUrl.parse(getEndPoint()).newBuilder()
.setPathSegment(0, AUTHORIZATION)
.addPathSegment(PATH_AUTHORIZATION_V1_TOKEN)
.build();
Request request = RequestBuilder.get(url)
.header(HttpHeaders.ACCEPT, HttpMediaType.TEXT_PLAIN).query(URL, getEndPoint()).build();
return createServiceCall(request, ResponseConverterUtils.getString());
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Gets the list of submitted batch-processing jobs.
*
* Gets the list of batch-processing jobs submitted by users.
*
* @param listBatchesOptions the {@link ListBatchesOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Batches}
*/
public ServiceCall<Batches> listBatches(ListBatchesOptions listBatchesOptions) {
String[] pathSegments = { "v1/batches" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query(VERSION, versionDate);
if (listBatchesOptions != null) {
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Batches.class));
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Delete environment.
*
* @param deleteEnvironmentOptions the {@link DeleteEnvironmentOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of Void
*/
public ServiceCall<Void> deleteEnvironment(DeleteEnvironmentOptions deleteEnvironmentOptions) {
Validator.notNull(deleteEnvironmentOptions, "deleteEnvironmentOptions cannot be null");
String[] pathSegments = { "v1/environments" };
String[] pathParameters = { deleteEnvironmentOptions.environmentId() };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Delete a classifier.
*
* @param deleteClassifierOptions the {@link DeleteClassifierOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of Void
*/
public ServiceCall<Void> deleteClassifier(DeleteClassifierOptions deleteClassifierOptions) {
Validator.notNull(deleteClassifierOptions, "deleteClassifierOptions cannot be null");
String[] pathSegments = { "v3/classifiers" };
String[] pathParameters = { deleteClassifierOptions.classifierId() };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Get environment info.
*
* @param getEnvironmentOptions the {@link GetEnvironmentOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Environment}
*/
public ServiceCall<Environment> getEnvironment(GetEnvironmentOptions getEnvironmentOptions) {
Validator.notNull(getEnvironmentOptions, "getEnvironmentOptions cannot be null");
String[] pathSegments = { "v1/environments" };
String[] pathParameters = { getEnvironmentOptions.environmentId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Environment.class));
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Delete model.
*
* Deletes a custom model.
*
* @param deleteModelOptions the {@link DeleteModelOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of Void
*/
public ServiceCall<Void> deleteModel(DeleteModelOptions deleteModelOptions) {
Validator.notNull(deleteModelOptions, "deleteModelOptions cannot be null");
String[] pathSegments = { "v1/models" };
String[] pathParameters = { deleteModelOptions.modelId() };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Gets information about a specific batch-processing request.
*
* Gets information about a batch-processing request with a specified ID.
*
* @param getBatchOptions the {@link GetBatchOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link BatchStatus}
*/
public ServiceCall<BatchStatus> getBatch(GetBatchOptions getBatchOptions) {
Validator.notNull(getBatchOptions, "getBatchOptions cannot be null");
String[] pathSegments = { "v1/batches" };
String[] pathParameters = { getBatchOptions.batchId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(BatchStatus.class));
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* List Gateways.
*
* List the currently configured gateways.
*
* @param listGatewaysOptions the {@link ListGatewaysOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link GatewayList}
*/
public ServiceCall<GatewayList> listGateways(ListGatewaysOptions listGatewaysOptions) {
Validator.notNull(listGatewaysOptions, "listGatewaysOptions cannot be null");
String[] pathSegments = { "v1/environments", "gateways" };
String[] pathParameters = { listGatewaysOptions.environmentId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(GatewayList.class));
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Get collection details.
*
* @param getCollectionOptions the {@link GetCollectionOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Collection}
*/
public ServiceCall<Collection> getCollection(GetCollectionOptions getCollectionOptions) {
Validator.notNull(getCollectionOptions, "getCollectionOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections" };
String[] pathParameters = { getCollectionOptions.environmentId(), getCollectionOptions.collectionId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Collection.class));
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Get configuration details.
*
* @param getConfigurationOptions the {@link GetConfigurationOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link Configuration}
*/
public ServiceCall<Configuration> getConfiguration(GetConfigurationOptions getConfigurationOptions) {
Validator.notNull(getConfigurationOptions, "getConfigurationOptions cannot be null");
String[] pathSegments = { "v1/environments", "configurations" };
String[] pathParameters = { getConfigurationOptions.environmentId(), getConfigurationOptions.configurationId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Configuration.class));
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Delete a collection.
*
* @param deleteCollectionOptions the {@link DeleteCollectionOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of Void
*/
public ServiceCall<Void> deleteCollection(DeleteCollectionOptions deleteCollectionOptions) {
Validator.notNull(deleteCollectionOptions, "deleteCollectionOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections" };
String[] pathParameters = { deleteCollectionOptions.environmentId(), deleteCollectionOptions.collectionId() };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Delete Gateway.
*
* Delete the specified gateway configuration.
*
* @param deleteGatewayOptions the {@link DeleteGatewayOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of Void
*/
public ServiceCall<Void> deleteGateway(DeleteGatewayOptions deleteGatewayOptions) {
Validator.notNull(deleteGatewayOptions, "deleteGatewayOptions cannot be null");
String[] pathSegments = { "v1/environments", "gateways" };
String[] pathParameters = { deleteGatewayOptions.environmentId(), deleteGatewayOptions.gatewayId() };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Identify language.
*
* Identifies the language of the input text.
*
* @param identifyOptions the {@link IdentifyOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link IdentifiedLanguages}
*/
public ServiceCall<IdentifiedLanguages> identify(IdentifyOptions identifyOptions) {
Validator.notNull(identifyOptions, "identifyOptions cannot be null");
String[] pathSegments = { "v3/identify" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query(VERSION, versionDate);
builder.bodyContent(identifyOptions.text(), "text/plain");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IdentifiedLanguages.class));
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* Delete session.
*
* Deletes a session explicitly before it times out.
*
* @param deleteSessionOptions the {@link DeleteSessionOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of Void
*/
public ServiceCall<Void> deleteSession(DeleteSessionOptions deleteSessionOptions) {
Validator.notNull(deleteSessionOptions, "deleteSessionOptions cannot be null");
String[] pathSegments = { "v2/assistants", "sessions" };
String[] pathParameters = { deleteSessionOptions.assistantId(), deleteSessionOptions.sessionId() };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
}
代码示例来源:origin: watson-developer-cloud/java-sdk
/**
* List training data.
*
* Lists the training data for the specified collection.
*
* @param listTrainingDataOptions the {@link ListTrainingDataOptions} containing the options for the call
* @return a {@link ServiceCall} with a response type of {@link TrainingDataSet}
*/
public ServiceCall<TrainingDataSet> listTrainingData(ListTrainingDataOptions listTrainingDataOptions) {
Validator.notNull(listTrainingDataOptions, "listTrainingDataOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "training_data" };
String[] pathParameters = { listTrainingDataOptions.environmentId(), listTrainingDataOptions.collectionId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query(VERSION, versionDate);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingDataSet.class));
}
内容来源于网络,如有侵权,请联系作者删除!