repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
apiman/apiman | gateway/engine/es/src/main/java/io/apiman/gateway/engine/es/DefaultESClientFactory.java | DefaultESClientFactory.createJestClient | protected JestClient createJestClient(Map<String, String> config, String indexName, String defaultIndexName) {
String host = config.get("client.host"); //$NON-NLS-1$
String port = config.get("client.port"); //$NON-NLS-1$
String protocol = config.get("client.protocol"); //$NON-NLS-1$
String initialize = config.get("client.initialize"); //$NON-NLS-1$
if (initialize == null) {
initialize = "true"; //$NON-NLS-1$
}
if (StringUtils.isBlank(host)) {
throw new RuntimeException("Missing client.host configuration for ESRegistry."); //$NON-NLS-1$
}
if (StringUtils.isBlank(port)) {
throw new RuntimeException("Missing client.port configuration for ESRegistry."); //$NON-NLS-1$
}
if (StringUtils.isBlank(protocol)) {
protocol = "http"; //$NON-NLS-1$
}
String clientKey = "jest:" + host + ':' + port + '/' + indexName; //$NON-NLS-1$
synchronized (clients) {
if (clients.containsKey(clientKey)) {
return clients.get(clientKey);
} else {
StringBuilder builder = new StringBuilder();
builder.append(protocol);
builder.append("://"); //$NON-NLS-1$
builder.append(host);
builder.append(":"); //$NON-NLS-1$
builder.append(String.valueOf(port));
String connectionUrl = builder.toString();
JestClientFactory factory = new JestClientFactory();
Builder httpClientConfig = new HttpClientConfig.Builder(connectionUrl);
updateHttpConfig(httpClientConfig, config);
factory.setHttpClientConfig(httpClientConfig.build());
updateJestClientFactory(factory, config);
JestClient client = factory.getObject();
clients.put(clientKey, client);
if ("true".equals(initialize)) { //$NON-NLS-1$
initializeClient(client, indexName, defaultIndexName);
}
return client;
}
}
} | java | protected JestClient createJestClient(Map<String, String> config, String indexName, String defaultIndexName) {
String host = config.get("client.host"); //$NON-NLS-1$
String port = config.get("client.port"); //$NON-NLS-1$
String protocol = config.get("client.protocol"); //$NON-NLS-1$
String initialize = config.get("client.initialize"); //$NON-NLS-1$
if (initialize == null) {
initialize = "true"; //$NON-NLS-1$
}
if (StringUtils.isBlank(host)) {
throw new RuntimeException("Missing client.host configuration for ESRegistry."); //$NON-NLS-1$
}
if (StringUtils.isBlank(port)) {
throw new RuntimeException("Missing client.port configuration for ESRegistry."); //$NON-NLS-1$
}
if (StringUtils.isBlank(protocol)) {
protocol = "http"; //$NON-NLS-1$
}
String clientKey = "jest:" + host + ':' + port + '/' + indexName; //$NON-NLS-1$
synchronized (clients) {
if (clients.containsKey(clientKey)) {
return clients.get(clientKey);
} else {
StringBuilder builder = new StringBuilder();
builder.append(protocol);
builder.append("://"); //$NON-NLS-1$
builder.append(host);
builder.append(":"); //$NON-NLS-1$
builder.append(String.valueOf(port));
String connectionUrl = builder.toString();
JestClientFactory factory = new JestClientFactory();
Builder httpClientConfig = new HttpClientConfig.Builder(connectionUrl);
updateHttpConfig(httpClientConfig, config);
factory.setHttpClientConfig(httpClientConfig.build());
updateJestClientFactory(factory, config);
JestClient client = factory.getObject();
clients.put(clientKey, client);
if ("true".equals(initialize)) { //$NON-NLS-1$
initializeClient(client, indexName, defaultIndexName);
}
return client;
}
}
} | [
"protected",
"JestClient",
"createJestClient",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"config",
",",
"String",
"indexName",
",",
"String",
"defaultIndexName",
")",
"{",
"String",
"host",
"=",
"config",
".",
"get",
"(",
"\"client.host\"",
")",
";",
"/... | Creates a transport client from a configuration map.
@param config the configuration
@param indexName the name of the index
@param defaultIndexName the default index name
@return the ES client | [
"Creates",
"a",
"transport",
"client",
"from",
"a",
"configuration",
"map",
"."
] | 8c049c2a2f2e4a69bbb6125686a15edd26f29c21 | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/es/src/main/java/io/apiman/gateway/engine/es/DefaultESClientFactory.java#L79-L126 | train |
apiman/apiman | gateway/engine/es/src/main/java/io/apiman/gateway/engine/es/DefaultESClientFactory.java | DefaultESClientFactory.updateHttpConfig | protected void updateHttpConfig(Builder httpClientConfig, Map<String, String> config) {
String username = config.get("client.username"); //$NON-NLS-1$
String password = config.get("client.password"); //$NON-NLS-1$
String timeout = config.get("client.timeout"); //$NON-NLS-1$
if (StringUtils.isBlank(timeout)) {
timeout = "10000"; //$NON-NLS-1$
}
httpClientConfig
.connTimeout(new Integer(timeout))
.readTimeout(new Integer(timeout))
.maxTotalConnection(75)
.defaultMaxTotalConnectionPerRoute(75)
.multiThreaded(true);
if (!StringUtils.isBlank(username)) {
httpClientConfig.defaultCredentials(username, password);
}
if ("https".equals(config.get("protocol"))) { //$NON-NLS-1$ //$NON-NLS-2$
updateSslConfig(httpClientConfig, config);
}
} | java | protected void updateHttpConfig(Builder httpClientConfig, Map<String, String> config) {
String username = config.get("client.username"); //$NON-NLS-1$
String password = config.get("client.password"); //$NON-NLS-1$
String timeout = config.get("client.timeout"); //$NON-NLS-1$
if (StringUtils.isBlank(timeout)) {
timeout = "10000"; //$NON-NLS-1$
}
httpClientConfig
.connTimeout(new Integer(timeout))
.readTimeout(new Integer(timeout))
.maxTotalConnection(75)
.defaultMaxTotalConnectionPerRoute(75)
.multiThreaded(true);
if (!StringUtils.isBlank(username)) {
httpClientConfig.defaultCredentials(username, password);
}
if ("https".equals(config.get("protocol"))) { //$NON-NLS-1$ //$NON-NLS-2$
updateSslConfig(httpClientConfig, config);
}
} | [
"protected",
"void",
"updateHttpConfig",
"(",
"Builder",
"httpClientConfig",
",",
"Map",
"<",
"String",
",",
"String",
">",
"config",
")",
"{",
"String",
"username",
"=",
"config",
".",
"get",
"(",
"\"client.username\"",
")",
";",
"//$NON-NLS-1$",
"String",
"p... | Update the http client config.
@param httpClientConfig
@param config | [
"Update",
"the",
"http",
"client",
"config",
"."
] | 8c049c2a2f2e4a69bbb6125686a15edd26f29c21 | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/engine/es/src/main/java/io/apiman/gateway/engine/es/DefaultESClientFactory.java#L133-L154 | train |
apiman/apiman | manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java | EsStorage.orderPolicies | private void orderPolicies(PoliciesBean policies) {
int idx = 1;
for (PolicyBean policy : policies.getPolicies()) {
policy.setOrderIndex(idx++);
}
} | java | private void orderPolicies(PoliciesBean policies) {
int idx = 1;
for (PolicyBean policy : policies.getPolicies()) {
policy.setOrderIndex(idx++);
}
} | [
"private",
"void",
"orderPolicies",
"(",
"PoliciesBean",
"policies",
")",
"{",
"int",
"idx",
"=",
"1",
";",
"for",
"(",
"PolicyBean",
"policy",
":",
"policies",
".",
"getPolicies",
"(",
")",
")",
"{",
"policy",
".",
"setOrderIndex",
"(",
"idx",
"++",
")"... | Set the order index of all policies.
@param policies | [
"Set",
"the",
"order",
"index",
"of",
"all",
"policies",
"."
] | 8c049c2a2f2e4a69bbb6125686a15edd26f29c21 | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java#L394-L399 | train |
apiman/apiman | manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java | EsStorage.getEntity | private Map<String, Object> getEntity(String type, String id) throws StorageException {
try {
JestResult response = esClient.execute(new Get.Builder(getIndexName(), id).type(type).build());
if (!response.isSucceeded()) {
return null;
}
return response.getSourceAsObject(Map.class);
} catch (Exception e) {
throw new StorageException(e);
}
} | java | private Map<String, Object> getEntity(String type, String id) throws StorageException {
try {
JestResult response = esClient.execute(new Get.Builder(getIndexName(), id).type(type).build());
if (!response.isSucceeded()) {
return null;
}
return response.getSourceAsObject(Map.class);
} catch (Exception e) {
throw new StorageException(e);
}
} | [
"private",
"Map",
"<",
"String",
",",
"Object",
">",
"getEntity",
"(",
"String",
"type",
",",
"String",
"id",
")",
"throws",
"StorageException",
"{",
"try",
"{",
"JestResult",
"response",
"=",
"esClient",
".",
"execute",
"(",
"new",
"Get",
".",
"Builder",
... | Gets an entity. Callers must unmarshal the resulting map.
@param type
@param id
@throws StorageException | [
"Gets",
"an",
"entity",
".",
"Callers",
"must",
"unmarshal",
"the",
"resulting",
"map",
"."
] | 8c049c2a2f2e4a69bbb6125686a15edd26f29c21 | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java#L2023-L2033 | train |
apiman/apiman | manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java | EsStorage.listEntities | private List<Hit<Map<String, Object>, Void>> listEntities(String type,
SearchSourceBuilder searchSourceBuilder) throws StorageException {
try {
String query = searchSourceBuilder.string();
Search search = new Search.Builder(query).addIndex(getIndexName()).addType(type).build();
SearchResult response = esClient.execute(search);
@SuppressWarnings({ "rawtypes", "unchecked" })
List<Hit<Map<String, Object>, Void>> thehits = (List) response.getHits(Map.class);
return thehits;
} catch (Exception e) {
throw new StorageException(e);
}
} | java | private List<Hit<Map<String, Object>, Void>> listEntities(String type,
SearchSourceBuilder searchSourceBuilder) throws StorageException {
try {
String query = searchSourceBuilder.string();
Search search = new Search.Builder(query).addIndex(getIndexName()).addType(type).build();
SearchResult response = esClient.execute(search);
@SuppressWarnings({ "rawtypes", "unchecked" })
List<Hit<Map<String, Object>, Void>> thehits = (List) response.getHits(Map.class);
return thehits;
} catch (Exception e) {
throw new StorageException(e);
}
} | [
"private",
"List",
"<",
"Hit",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
",",
"Void",
">",
">",
"listEntities",
"(",
"String",
"type",
",",
"SearchSourceBuilder",
"searchSourceBuilder",
")",
"throws",
"StorageException",
"{",
"try",
"{",
"String",
"quer... | Returns a list of entities.
@param type
@param searchSourceBuilder
@throws StorageException | [
"Returns",
"a",
"list",
"of",
"entities",
"."
] | 8c049c2a2f2e4a69bbb6125686a15edd26f29c21 | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java#L2041-L2053 | train |
apiman/apiman | manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java | EsStorage.deleteEntity | private void deleteEntity(String type, String id) throws StorageException {
try {
JestResult response = esClient.execute(new Delete.Builder(id).index(getIndexName()).type(type).build());
if (!response.isSucceeded()) {
throw new StorageException("Document could not be deleted because it did not exist:" + response.getErrorMessage()); //$NON-NLS-1$
}
} catch (StorageException e) {
throw e;
} catch (Exception e) {
throw new StorageException(e);
}
} | java | private void deleteEntity(String type, String id) throws StorageException {
try {
JestResult response = esClient.execute(new Delete.Builder(id).index(getIndexName()).type(type).build());
if (!response.isSucceeded()) {
throw new StorageException("Document could not be deleted because it did not exist:" + response.getErrorMessage()); //$NON-NLS-1$
}
} catch (StorageException e) {
throw e;
} catch (Exception e) {
throw new StorageException(e);
}
} | [
"private",
"void",
"deleteEntity",
"(",
"String",
"type",
",",
"String",
"id",
")",
"throws",
"StorageException",
"{",
"try",
"{",
"JestResult",
"response",
"=",
"esClient",
".",
"execute",
"(",
"new",
"Delete",
".",
"Builder",
"(",
"id",
")",
".",
"index"... | Deletes an entity.
@param type
@param id
@throws StorageException | [
"Deletes",
"an",
"entity",
"."
] | 8c049c2a2f2e4a69bbb6125686a15edd26f29c21 | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java#L2061-L2072 | train |
apiman/apiman | manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java | EsStorage.updateEntity | private void updateEntity(String type, String id, XContentBuilder source) throws StorageException {
try {
String doc = source.string();
/* JestResult response = */esClient.execute(new Index.Builder(doc)
.setParameter(Parameters.OP_TYPE, "index").index(getIndexName()).type(type).id(id).build()); //$NON-NLS-1$
} catch (Exception e) {
throw new StorageException(e);
}
} | java | private void updateEntity(String type, String id, XContentBuilder source) throws StorageException {
try {
String doc = source.string();
/* JestResult response = */esClient.execute(new Index.Builder(doc)
.setParameter(Parameters.OP_TYPE, "index").index(getIndexName()).type(type).id(id).build()); //$NON-NLS-1$
} catch (Exception e) {
throw new StorageException(e);
}
} | [
"private",
"void",
"updateEntity",
"(",
"String",
"type",
",",
"String",
"id",
",",
"XContentBuilder",
"source",
")",
"throws",
"StorageException",
"{",
"try",
"{",
"String",
"doc",
"=",
"source",
".",
"string",
"(",
")",
";",
"/* JestResult response = */",
"e... | Updates a single entity.
@param type
@param id
@param source
@throws StorageException | [
"Updates",
"a",
"single",
"entity",
"."
] | 8c049c2a2f2e4a69bbb6125686a15edd26f29c21 | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java#L2081-L2089 | train |
apiman/apiman | manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java | EsStorage.getPoliciesDocType | private static String getPoliciesDocType(PolicyType type) {
String docType = "planPolicies"; //$NON-NLS-1$
if (type == PolicyType.Api) {
docType = "apiPolicies"; //$NON-NLS-1$
} else if (type == PolicyType.Client) {
docType = "clientPolicies"; //$NON-NLS-1$
}
return docType;
} | java | private static String getPoliciesDocType(PolicyType type) {
String docType = "planPolicies"; //$NON-NLS-1$
if (type == PolicyType.Api) {
docType = "apiPolicies"; //$NON-NLS-1$
} else if (type == PolicyType.Client) {
docType = "clientPolicies"; //$NON-NLS-1$
}
return docType;
} | [
"private",
"static",
"String",
"getPoliciesDocType",
"(",
"PolicyType",
"type",
")",
"{",
"String",
"docType",
"=",
"\"planPolicies\"",
";",
"//$NON-NLS-1$",
"if",
"(",
"type",
"==",
"PolicyType",
".",
"Api",
")",
"{",
"docType",
"=",
"\"apiPolicies\"",
";",
"... | Returns the policies document type to use given the policy type.
@param type | [
"Returns",
"the",
"policies",
"document",
"type",
"to",
"use",
"given",
"the",
"policy",
"type",
"."
] | 8c049c2a2f2e4a69bbb6125686a15edd26f29c21 | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java#L2199-L2207 | train |
apiman/apiman | manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java | EsStorage.id | private static String id(String organizationId, String entityId, String version) {
return organizationId + ':' + entityId + ':' + version;
} | java | private static String id(String organizationId, String entityId, String version) {
return organizationId + ':' + entityId + ':' + version;
} | [
"private",
"static",
"String",
"id",
"(",
"String",
"organizationId",
",",
"String",
"entityId",
",",
"String",
"version",
")",
"{",
"return",
"organizationId",
"+",
"'",
"'",
"+",
"entityId",
"+",
"'",
"'",
"+",
"version",
";",
"}"
] | A composite ID created from an organization ID, entity ID, and version.
@param organizationId
@param entityId
@param version | [
"A",
"composite",
"ID",
"created",
"from",
"an",
"organization",
"ID",
"entity",
"ID",
"and",
"version",
"."
] | 8c049c2a2f2e4a69bbb6125686a15edd26f29c21 | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java#L2224-L2226 | train |
apiman/apiman | manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java | EsStorage.getAll | private <T> Iterator<T> getAll(String entityType, IUnmarshaller<T> unmarshaller) throws StorageException {
String query = matchAllQuery();
return getAll(entityType, unmarshaller, query);
} | java | private <T> Iterator<T> getAll(String entityType, IUnmarshaller<T> unmarshaller) throws StorageException {
String query = matchAllQuery();
return getAll(entityType, unmarshaller, query);
} | [
"private",
"<",
"T",
">",
"Iterator",
"<",
"T",
">",
"getAll",
"(",
"String",
"entityType",
",",
"IUnmarshaller",
"<",
"T",
">",
"unmarshaller",
")",
"throws",
"StorageException",
"{",
"String",
"query",
"=",
"matchAllQuery",
"(",
")",
";",
"return",
"getA... | Returns an iterator over all instances of the given entity type.
@param entityType
@param unmarshaller
@throws StorageException | [
"Returns",
"an",
"iterator",
"over",
"all",
"instances",
"of",
"the",
"given",
"entity",
"type",
"."
] | 8c049c2a2f2e4a69bbb6125686a15edd26f29c21 | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/manager/api/es/src/main/java/io/apiman/manager/api/es/EsStorage.java#L2564-L2567 | train |
apiman/apiman | common/servlet/src/main/java/io/apiman/common/servlet/ApimanCorsFilter.java | ApimanCorsFilter.hasOriginHeader | private boolean hasOriginHeader(HttpServletRequest httpReq) {
String origin = httpReq.getHeader("Origin"); //$NON-NLS-1$
return origin != null && origin.trim().length() > 0;
} | java | private boolean hasOriginHeader(HttpServletRequest httpReq) {
String origin = httpReq.getHeader("Origin"); //$NON-NLS-1$
return origin != null && origin.trim().length() > 0;
} | [
"private",
"boolean",
"hasOriginHeader",
"(",
"HttpServletRequest",
"httpReq",
")",
"{",
"String",
"origin",
"=",
"httpReq",
".",
"getHeader",
"(",
"\"Origin\"",
")",
";",
"//$NON-NLS-1$",
"return",
"origin",
"!=",
"null",
"&&",
"origin",
".",
"trim",
"(",
")"... | Returns true if the Origin request header is present.
@param httpReq the http servlet request
@return true if has origin header, else false | [
"Returns",
"true",
"if",
"the",
"Origin",
"request",
"header",
"is",
"present",
"."
] | 8c049c2a2f2e4a69bbb6125686a15edd26f29c21 | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/common/servlet/src/main/java/io/apiman/common/servlet/ApimanCorsFilter.java#L98-L101 | train |
apiman/apiman | gateway/platforms/vertx3/vertx3/src/main/java/io/apiman/gateway/platforms/vertx3/api/auth/AuthFactory.java | AuthFactory.getAuth | public static AuthHandler getAuth(Vertx vertx, Router router, VertxEngineConfig apimanConfig) {
String type = apimanConfig.getAuth().getString("type", "NONE");
JsonObject authConfig = apimanConfig.getAuth().getJsonObject("config", new JsonObject());
switch(AuthType.getType(type)) {
case BASIC:
return BasicAuth.create(authConfig);
case NONE:
return NoneAuth.create();
case KEYCLOAK:
return KeycloakOAuthFactory.create(vertx, router, apimanConfig, authConfig);
default:
return NoneAuth.create();
}
} | java | public static AuthHandler getAuth(Vertx vertx, Router router, VertxEngineConfig apimanConfig) {
String type = apimanConfig.getAuth().getString("type", "NONE");
JsonObject authConfig = apimanConfig.getAuth().getJsonObject("config", new JsonObject());
switch(AuthType.getType(type)) {
case BASIC:
return BasicAuth.create(authConfig);
case NONE:
return NoneAuth.create();
case KEYCLOAK:
return KeycloakOAuthFactory.create(vertx, router, apimanConfig, authConfig);
default:
return NoneAuth.create();
}
} | [
"public",
"static",
"AuthHandler",
"getAuth",
"(",
"Vertx",
"vertx",
",",
"Router",
"router",
",",
"VertxEngineConfig",
"apimanConfig",
")",
"{",
"String",
"type",
"=",
"apimanConfig",
".",
"getAuth",
"(",
")",
".",
"getString",
"(",
"\"type\"",
",",
"\"NONE\"... | Creates an auth handler of the type indicated in the `auth` section of config.
@param vertx the vert.x instance
@param router the vert.x web router to protect
@param apimanConfig the apiman config
@return an auth handler | [
"Creates",
"an",
"auth",
"handler",
"of",
"the",
"type",
"indicated",
"in",
"the",
"auth",
"section",
"of",
"config",
"."
] | 8c049c2a2f2e4a69bbb6125686a15edd26f29c21 | https://github.com/apiman/apiman/blob/8c049c2a2f2e4a69bbb6125686a15edd26f29c21/gateway/platforms/vertx3/vertx3/src/main/java/io/apiman/gateway/platforms/vertx3/api/auth/AuthFactory.java#L54-L68 | train |
OpenVidu/openvidu | openvidu-java-client/src/main/java/io/openvidu/java/client/OpenVidu.java | OpenVidu.createSession | public Session createSession() throws OpenViduJavaClientException, OpenViduHttpException {
Session s = new Session();
OpenVidu.activeSessions.put(s.getSessionId(), s);
return s;
} | java | public Session createSession() throws OpenViduJavaClientException, OpenViduHttpException {
Session s = new Session();
OpenVidu.activeSessions.put(s.getSessionId(), s);
return s;
} | [
"public",
"Session",
"createSession",
"(",
")",
"throws",
"OpenViduJavaClientException",
",",
"OpenViduHttpException",
"{",
"Session",
"s",
"=",
"new",
"Session",
"(",
")",
";",
"OpenVidu",
".",
"activeSessions",
".",
"put",
"(",
"s",
".",
"getSessionId",
"(",
... | Creates an OpenVidu session with the default settings
@return The created session
@throws OpenViduJavaClientException
@throws OpenViduHttpException | [
"Creates",
"an",
"OpenVidu",
"session",
"with",
"the",
"default",
"settings"
] | 89db47dd37949ceab29e5228371a8fcab04d8d55 | https://github.com/OpenVidu/openvidu/blob/89db47dd37949ceab29e5228371a8fcab04d8d55/openvidu-java-client/src/main/java/io/openvidu/java/client/OpenVidu.java#L128-L132 | train |
OpenVidu/openvidu | openvidu-java-client/src/main/java/io/openvidu/java/client/OpenVidu.java | OpenVidu.getRecording | public Recording getRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
HttpGet request = new HttpGet(OpenVidu.urlOpenViduServer + API_RECORDINGS + "/" + recordingId);
HttpResponse response;
try {
response = OpenVidu.httpClient.execute(request);
} catch (IOException e) {
throw new OpenViduJavaClientException(e.getMessage(), e.getCause());
}
try {
int statusCode = response.getStatusLine().getStatusCode();
if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
return new Recording(httpResponseToJson(response));
} else {
throw new OpenViduHttpException(statusCode);
}
} finally {
EntityUtils.consumeQuietly(response.getEntity());
}
} | java | public Recording getRecording(String recordingId) throws OpenViduJavaClientException, OpenViduHttpException {
HttpGet request = new HttpGet(OpenVidu.urlOpenViduServer + API_RECORDINGS + "/" + recordingId);
HttpResponse response;
try {
response = OpenVidu.httpClient.execute(request);
} catch (IOException e) {
throw new OpenViduJavaClientException(e.getMessage(), e.getCause());
}
try {
int statusCode = response.getStatusLine().getStatusCode();
if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
return new Recording(httpResponseToJson(response));
} else {
throw new OpenViduHttpException(statusCode);
}
} finally {
EntityUtils.consumeQuietly(response.getEntity());
}
} | [
"public",
"Recording",
"getRecording",
"(",
"String",
"recordingId",
")",
"throws",
"OpenViduJavaClientException",
",",
"OpenViduHttpException",
"{",
"HttpGet",
"request",
"=",
"new",
"HttpGet",
"(",
"OpenVidu",
".",
"urlOpenViduServer",
"+",
"API_RECORDINGS",
"+",
"\... | Gets an existing recording
@param recordingId The id property of the recording you want to retrieve
@throws OpenViduJavaClientException
@throws OpenViduHttpException Value returned from
{@link io.openvidu.java.client.OpenViduHttpException#getStatus()}
<ul>
<li><code>404</code>: no recording exists
for the passed <i>recordingId</i></li>
</ul> | [
"Gets",
"an",
"existing",
"recording"
] | 89db47dd37949ceab29e5228371a8fcab04d8d55 | https://github.com/OpenVidu/openvidu/blob/89db47dd37949ceab29e5228371a8fcab04d8d55/openvidu-java-client/src/main/java/io/openvidu/java/client/OpenVidu.java#L395-L414 | train |
OpenVidu/openvidu | openvidu-java-client/src/main/java/io/openvidu/java/client/OpenVidu.java | OpenVidu.listRecordings | @SuppressWarnings("unchecked")
public List<Recording> listRecordings() throws OpenViduJavaClientException, OpenViduHttpException {
HttpGet request = new HttpGet(OpenVidu.urlOpenViduServer + API_RECORDINGS);
HttpResponse response;
try {
response = OpenVidu.httpClient.execute(request);
} catch (IOException e) {
throw new OpenViduJavaClientException(e.getMessage(), e.getCause());
}
try {
int statusCode = response.getStatusLine().getStatusCode();
if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
List<Recording> recordings = new ArrayList<>();
JSONObject json = httpResponseToJson(response);
JSONArray array = (JSONArray) json.get("items");
array.forEach(item -> {
recordings.add(new Recording((JSONObject) item));
});
return recordings;
} else {
throw new OpenViduHttpException(statusCode);
}
} finally {
EntityUtils.consumeQuietly(response.getEntity());
}
} | java | @SuppressWarnings("unchecked")
public List<Recording> listRecordings() throws OpenViduJavaClientException, OpenViduHttpException {
HttpGet request = new HttpGet(OpenVidu.urlOpenViduServer + API_RECORDINGS);
HttpResponse response;
try {
response = OpenVidu.httpClient.execute(request);
} catch (IOException e) {
throw new OpenViduJavaClientException(e.getMessage(), e.getCause());
}
try {
int statusCode = response.getStatusLine().getStatusCode();
if ((statusCode == org.apache.http.HttpStatus.SC_OK)) {
List<Recording> recordings = new ArrayList<>();
JSONObject json = httpResponseToJson(response);
JSONArray array = (JSONArray) json.get("items");
array.forEach(item -> {
recordings.add(new Recording((JSONObject) item));
});
return recordings;
} else {
throw new OpenViduHttpException(statusCode);
}
} finally {
EntityUtils.consumeQuietly(response.getEntity());
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"List",
"<",
"Recording",
">",
"listRecordings",
"(",
")",
"throws",
"OpenViduJavaClientException",
",",
"OpenViduHttpException",
"{",
"HttpGet",
"request",
"=",
"new",
"HttpGet",
"(",
"OpenVidu",
".",
... | Lists all existing recordings
@return A {@link java.util.List} with all existing recordings
@throws OpenViduJavaClientException
@throws OpenViduHttpException | [
"Lists",
"all",
"existing",
"recordings"
] | 89db47dd37949ceab29e5228371a8fcab04d8d55 | https://github.com/OpenVidu/openvidu/blob/89db47dd37949ceab29e5228371a8fcab04d8d55/openvidu-java-client/src/main/java/io/openvidu/java/client/OpenVidu.java#L424-L450 | train |
OpenVidu/openvidu | openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoSessionManager.java | KurentoSessionManager.createSession | public void createSession(Session sessionNotActive, KurentoClientSessionInfo kcSessionInfo)
throws OpenViduException {
String sessionId = kcSessionInfo.getRoomName();
KurentoSession session = (KurentoSession) sessions.get(sessionId);
if (session != null) {
throw new OpenViduException(Code.ROOM_CANNOT_BE_CREATED_ERROR_CODE,
"Session '" + sessionId + "' already exists");
}
this.kurentoClient = kcProvider.getKurentoClient(kcSessionInfo);
session = new KurentoSession(sessionNotActive, kurentoClient, kurentoSessionEventsHandler,
kurentoEndpointConfig, kcProvider.destroyWhenUnused());
KurentoSession oldSession = (KurentoSession) sessions.putIfAbsent(sessionId, session);
if (oldSession != null) {
log.warn("Session '{}' has just been created by another thread", sessionId);
return;
}
String kcName = "[NAME NOT AVAILABLE]";
if (kurentoClient.getServerManager() != null) {
kcName = kurentoClient.getServerManager().getName();
}
log.warn("No session '{}' exists yet. Created one using KurentoClient '{}'.", sessionId, kcName);
sessionEventsHandler.onSessionCreated(session);
} | java | public void createSession(Session sessionNotActive, KurentoClientSessionInfo kcSessionInfo)
throws OpenViduException {
String sessionId = kcSessionInfo.getRoomName();
KurentoSession session = (KurentoSession) sessions.get(sessionId);
if (session != null) {
throw new OpenViduException(Code.ROOM_CANNOT_BE_CREATED_ERROR_CODE,
"Session '" + sessionId + "' already exists");
}
this.kurentoClient = kcProvider.getKurentoClient(kcSessionInfo);
session = new KurentoSession(sessionNotActive, kurentoClient, kurentoSessionEventsHandler,
kurentoEndpointConfig, kcProvider.destroyWhenUnused());
KurentoSession oldSession = (KurentoSession) sessions.putIfAbsent(sessionId, session);
if (oldSession != null) {
log.warn("Session '{}' has just been created by another thread", sessionId);
return;
}
String kcName = "[NAME NOT AVAILABLE]";
if (kurentoClient.getServerManager() != null) {
kcName = kurentoClient.getServerManager().getName();
}
log.warn("No session '{}' exists yet. Created one using KurentoClient '{}'.", sessionId, kcName);
sessionEventsHandler.onSessionCreated(session);
} | [
"public",
"void",
"createSession",
"(",
"Session",
"sessionNotActive",
",",
"KurentoClientSessionInfo",
"kcSessionInfo",
")",
"throws",
"OpenViduException",
"{",
"String",
"sessionId",
"=",
"kcSessionInfo",
".",
"getRoomName",
"(",
")",
";",
"KurentoSession",
"session",... | Creates a session if it doesn't already exist. The session's id will be
indicated by the session info bean.
@param kcSessionInfo bean that will be passed to the
{@link KurentoClientProvider} in order to obtain the
{@link KurentoClient} that will be used by the room
@throws OpenViduException in case of error while creating the session | [
"Creates",
"a",
"session",
"if",
"it",
"doesn",
"t",
"already",
"exist",
".",
"The",
"session",
"s",
"id",
"will",
"be",
"indicated",
"by",
"the",
"session",
"info",
"bean",
"."
] | 89db47dd37949ceab29e5228371a8fcab04d8d55 | https://github.com/OpenVidu/openvidu/blob/89db47dd37949ceab29e5228371a8fcab04d8d55/openvidu-server/src/main/java/io/openvidu/server/kurento/core/KurentoSessionManager.java#L503-L527 | train |
OpenVidu/openvidu | openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/MediaEndpoint.java | MediaEndpoint.unregisterElementErrListener | protected void unregisterElementErrListener(MediaElement element, final ListenerSubscription subscription) {
if (element == null || subscription == null) {
return;
}
element.removeErrorListener(subscription);
} | java | protected void unregisterElementErrListener(MediaElement element, final ListenerSubscription subscription) {
if (element == null || subscription == null) {
return;
}
element.removeErrorListener(subscription);
} | [
"protected",
"void",
"unregisterElementErrListener",
"(",
"MediaElement",
"element",
",",
"final",
"ListenerSubscription",
"subscription",
")",
"{",
"if",
"(",
"element",
"==",
"null",
"||",
"subscription",
"==",
"null",
")",
"{",
"return",
";",
"}",
"element",
... | Unregisters the error listener from the media element using the provided
subscription.
@param element the {@link MediaElement}
@param subscription the associated {@link ListenerSubscription} | [
"Unregisters",
"the",
"error",
"listener",
"from",
"the",
"media",
"element",
"using",
"the",
"provided",
"subscription",
"."
] | 89db47dd37949ceab29e5228371a8fcab04d8d55 | https://github.com/OpenVidu/openvidu/blob/89db47dd37949ceab29e5228371a8fcab04d8d55/openvidu-server/src/main/java/io/openvidu/server/kurento/endpoint/MediaEndpoint.java#L335-L340 | train |
OpenVidu/openvidu | openvidu-server/src/main/java/io/openvidu/server/core/SessionManager.java | SessionManager.getParticipants | public Set<Participant> getParticipants(String sessionId) throws OpenViduException {
Session session = sessions.get(sessionId);
if (session == null) {
throw new OpenViduException(Code.ROOM_NOT_FOUND_ERROR_CODE, "Session '" + sessionId + "' not found");
}
Set<Participant> participants = session.getParticipants();
participants.removeIf(p -> p.isClosed());
return participants;
} | java | public Set<Participant> getParticipants(String sessionId) throws OpenViduException {
Session session = sessions.get(sessionId);
if (session == null) {
throw new OpenViduException(Code.ROOM_NOT_FOUND_ERROR_CODE, "Session '" + sessionId + "' not found");
}
Set<Participant> participants = session.getParticipants();
participants.removeIf(p -> p.isClosed());
return participants;
} | [
"public",
"Set",
"<",
"Participant",
">",
"getParticipants",
"(",
"String",
"sessionId",
")",
"throws",
"OpenViduException",
"{",
"Session",
"session",
"=",
"sessions",
".",
"get",
"(",
"sessionId",
")",
";",
"if",
"(",
"session",
"==",
"null",
")",
"{",
"... | Returns all the participants inside a session.
@param sessionId identifier of the session
@return set of {@link Participant}
@throws OpenViduException in case the session doesn't exist | [
"Returns",
"all",
"the",
"participants",
"inside",
"a",
"session",
"."
] | 89db47dd37949ceab29e5228371a8fcab04d8d55 | https://github.com/OpenVidu/openvidu/blob/89db47dd37949ceab29e5228371a8fcab04d8d55/openvidu-server/src/main/java/io/openvidu/server/core/SessionManager.java#L169-L177 | train |
OpenVidu/openvidu | openvidu-server/src/main/java/io/openvidu/server/core/SessionManager.java | SessionManager.getParticipant | public Participant getParticipant(String sessionId, String participantPrivateId) throws OpenViduException {
Session session = sessions.get(sessionId);
if (session == null) {
throw new OpenViduException(Code.ROOM_NOT_FOUND_ERROR_CODE, "Session '" + sessionId + "' not found");
}
Participant participant = session.getParticipantByPrivateId(participantPrivateId);
if (participant == null) {
throw new OpenViduException(Code.USER_NOT_FOUND_ERROR_CODE,
"Participant '" + participantPrivateId + "' not found in session '" + sessionId + "'");
}
return participant;
} | java | public Participant getParticipant(String sessionId, String participantPrivateId) throws OpenViduException {
Session session = sessions.get(sessionId);
if (session == null) {
throw new OpenViduException(Code.ROOM_NOT_FOUND_ERROR_CODE, "Session '" + sessionId + "' not found");
}
Participant participant = session.getParticipantByPrivateId(participantPrivateId);
if (participant == null) {
throw new OpenViduException(Code.USER_NOT_FOUND_ERROR_CODE,
"Participant '" + participantPrivateId + "' not found in session '" + sessionId + "'");
}
return participant;
} | [
"public",
"Participant",
"getParticipant",
"(",
"String",
"sessionId",
",",
"String",
"participantPrivateId",
")",
"throws",
"OpenViduException",
"{",
"Session",
"session",
"=",
"sessions",
".",
"get",
"(",
"sessionId",
")",
";",
"if",
"(",
"session",
"==",
"nul... | Returns a participant in a session
@param sessionId identifier of the session
@param participantPrivateId private identifier of the participant
@return {@link Participant}
@throws OpenViduException in case the session doesn't exist or the
participant doesn't belong to it | [
"Returns",
"a",
"participant",
"in",
"a",
"session"
] | 89db47dd37949ceab29e5228371a8fcab04d8d55 | https://github.com/OpenVidu/openvidu/blob/89db47dd37949ceab29e5228371a8fcab04d8d55/openvidu-server/src/main/java/io/openvidu/server/core/SessionManager.java#L188-L199 | train |
OpenVidu/openvidu | openvidu-server/src/main/java/io/openvidu/server/core/SessionManager.java | SessionManager.getParticipant | public Participant getParticipant(String participantPrivateId) throws OpenViduException {
for (Session session : sessions.values()) {
if (!session.isClosed()) {
if (session.getParticipantByPrivateId(participantPrivateId) != null) {
return session.getParticipantByPrivateId(participantPrivateId);
}
}
}
throw new OpenViduException(Code.USER_NOT_FOUND_ERROR_CODE,
"No participant with private id '" + participantPrivateId + "' was found");
} | java | public Participant getParticipant(String participantPrivateId) throws OpenViduException {
for (Session session : sessions.values()) {
if (!session.isClosed()) {
if (session.getParticipantByPrivateId(participantPrivateId) != null) {
return session.getParticipantByPrivateId(participantPrivateId);
}
}
}
throw new OpenViduException(Code.USER_NOT_FOUND_ERROR_CODE,
"No participant with private id '" + participantPrivateId + "' was found");
} | [
"public",
"Participant",
"getParticipant",
"(",
"String",
"participantPrivateId",
")",
"throws",
"OpenViduException",
"{",
"for",
"(",
"Session",
"session",
":",
"sessions",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"!",
"session",
".",
"isClosed",
"(",
... | Returns a participant
@param participantPrivateId private identifier of the participant
@return {@link Participant}
@throws OpenViduException in case the participant doesn't exist | [
"Returns",
"a",
"participant"
] | 89db47dd37949ceab29e5228371a8fcab04d8d55 | https://github.com/OpenVidu/openvidu/blob/89db47dd37949ceab29e5228371a8fcab04d8d55/openvidu-server/src/main/java/io/openvidu/server/core/SessionManager.java#L208-L218 | train |
OpenVidu/openvidu | openvidu-server/src/main/java/io/openvidu/server/recording/service/RecordingService.java | RecordingService.updateRecordingManagerCollections | protected void updateRecordingManagerCollections(Session session, Recording recording) {
this.recordingManager.sessionHandler.setRecordingStarted(session.getSessionId(), recording);
this.recordingManager.sessionsRecordings.put(session.getSessionId(), recording);
this.recordingManager.startingRecordings.remove(recording.getId());
this.recordingManager.startedRecordings.put(recording.getId(), recording);
} | java | protected void updateRecordingManagerCollections(Session session, Recording recording) {
this.recordingManager.sessionHandler.setRecordingStarted(session.getSessionId(), recording);
this.recordingManager.sessionsRecordings.put(session.getSessionId(), recording);
this.recordingManager.startingRecordings.remove(recording.getId());
this.recordingManager.startedRecordings.put(recording.getId(), recording);
} | [
"protected",
"void",
"updateRecordingManagerCollections",
"(",
"Session",
"session",
",",
"Recording",
"recording",
")",
"{",
"this",
".",
"recordingManager",
".",
"sessionHandler",
".",
"setRecordingStarted",
"(",
"session",
".",
"getSessionId",
"(",
")",
",",
"rec... | Changes recording from starting to started, updates global recording
collections and sends RPC response to clients | [
"Changes",
"recording",
"from",
"starting",
"to",
"started",
"updates",
"global",
"recording",
"collections",
"and",
"sends",
"RPC",
"response",
"to",
"clients"
] | 89db47dd37949ceab29e5228371a8fcab04d8d55 | https://github.com/OpenVidu/openvidu/blob/89db47dd37949ceab29e5228371a8fcab04d8d55/openvidu-server/src/main/java/io/openvidu/server/recording/service/RecordingService.java#L101-L106 | train |
OpenVidu/openvidu | openvidu-server/src/main/java/io/openvidu/server/recording/service/RecordingService.java | RecordingService.sendRecordingStartedNotification | protected void sendRecordingStartedNotification(Session session, Recording recording) {
this.recordingManager.getSessionEventsHandler().sendRecordingStartedNotification(session, recording);
} | java | protected void sendRecordingStartedNotification(Session session, Recording recording) {
this.recordingManager.getSessionEventsHandler().sendRecordingStartedNotification(session, recording);
} | [
"protected",
"void",
"sendRecordingStartedNotification",
"(",
"Session",
"session",
",",
"Recording",
"recording",
")",
"{",
"this",
".",
"recordingManager",
".",
"getSessionEventsHandler",
"(",
")",
".",
"sendRecordingStartedNotification",
"(",
"session",
",",
"recordi... | Sends RPC response for recording started event | [
"Sends",
"RPC",
"response",
"for",
"recording",
"started",
"event"
] | 89db47dd37949ceab29e5228371a8fcab04d8d55 | https://github.com/OpenVidu/openvidu/blob/89db47dd37949ceab29e5228371a8fcab04d8d55/openvidu-server/src/main/java/io/openvidu/server/recording/service/RecordingService.java#L111-L113 | train |
OpenVidu/openvidu | openvidu-client/src/main/java/io/openvidu/client/ServerJsonRpcHandler.java | ServerJsonRpcHandler.getNotification | public Notification getNotification() {
try {
Notification notif = notifications.take();
log.debug("Dequeued notification {}", notif);
return notif;
} catch (InterruptedException e) {
log.info("Interrupted while polling notifications' queue");
return null;
}
} | java | public Notification getNotification() {
try {
Notification notif = notifications.take();
log.debug("Dequeued notification {}", notif);
return notif;
} catch (InterruptedException e) {
log.info("Interrupted while polling notifications' queue");
return null;
}
} | [
"public",
"Notification",
"getNotification",
"(",
")",
"{",
"try",
"{",
"Notification",
"notif",
"=",
"notifications",
".",
"take",
"(",
")",
";",
"log",
".",
"debug",
"(",
"\"Dequeued notification {}\"",
",",
"notif",
")",
";",
"return",
"notif",
";",
"}",
... | Blocks until an element is available and then returns it by removing it from the queue.
@return a {@link Notification} from the queue, null when interrupted
@see BlockingQueue#take() | [
"Blocks",
"until",
"an",
"element",
"is",
"available",
"and",
"then",
"returns",
"it",
"by",
"removing",
"it",
"from",
"the",
"queue",
"."
] | 89db47dd37949ceab29e5228371a8fcab04d8d55 | https://github.com/OpenVidu/openvidu/blob/89db47dd37949ceab29e5228371a8fcab04d8d55/openvidu-client/src/main/java/io/openvidu/client/ServerJsonRpcHandler.java#L212-L221 | train |
watson-developer-cloud/java-sdk | assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java | Assistant.createSession | public ServiceCall<SessionResponse> createSession(CreateSessionOptions createSessionOptions) {
Validator.notNull(createSessionOptions, "createSessionOptions cannot be null");
String[] pathSegments = { "v2/assistants", "sessions" };
String[] pathParameters = { createSessionOptions.assistantId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "createSession");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(SessionResponse.class));
} | java | public ServiceCall<SessionResponse> createSession(CreateSessionOptions createSessionOptions) {
Validator.notNull(createSessionOptions, "createSessionOptions cannot be null");
String[] pathSegments = { "v2/assistants", "sessions" };
String[] pathParameters = { createSessionOptions.assistantId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "createSession");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(SessionResponse.class));
} | [
"public",
"ServiceCall",
"<",
"SessionResponse",
">",
"createSession",
"(",
"CreateSessionOptions",
"createSessionOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"createSessionOptions",
",",
"\"createSessionOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
... | Create a session.
Create a new session. A session is used to send user input to a skill and receive responses. It also maintains the
state of the conversation.
@param createSessionOptions the {@link CreateSessionOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link SessionResponse} | [
"Create",
"a",
"session",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java#L101-L114 | train |
watson-developer-cloud/java-sdk | assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java | Assistant.deleteSession | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "deleteSession");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | java | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "deleteSession");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | [
"public",
"ServiceCall",
"<",
"Void",
">",
"deleteSession",
"(",
"DeleteSessionOptions",
"deleteSessionOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"deleteSessionOptions",
",",
"\"deleteSessionOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegmen... | 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 | [
"Delete",
"session",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java#L124-L137 | train |
watson-developer-cloud/java-sdk | assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java | Assistant.message | public ServiceCall<MessageResponse> message(MessageOptions messageOptions) {
Validator.notNull(messageOptions, "messageOptions cannot be null");
String[] pathSegments = { "v2/assistants", "sessions", "message" };
String[] pathParameters = { messageOptions.assistantId(), messageOptions.sessionId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "message");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (messageOptions.input() != null) {
contentJson.add("input", GsonSingleton.getGson().toJsonTree(messageOptions.input()));
}
if (messageOptions.context() != null) {
contentJson.add("context", GsonSingleton.getGson().toJsonTree(messageOptions.context()));
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(MessageResponse.class));
} | java | public ServiceCall<MessageResponse> message(MessageOptions messageOptions) {
Validator.notNull(messageOptions, "messageOptions cannot be null");
String[] pathSegments = { "v2/assistants", "sessions", "message" };
String[] pathParameters = { messageOptions.assistantId(), messageOptions.sessionId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("conversation", "v2", "message");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (messageOptions.input() != null) {
contentJson.add("input", GsonSingleton.getGson().toJsonTree(messageOptions.input()));
}
if (messageOptions.context() != null) {
contentJson.add("context", GsonSingleton.getGson().toJsonTree(messageOptions.context()));
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(MessageResponse.class));
} | [
"public",
"ServiceCall",
"<",
"MessageResponse",
">",
"message",
"(",
"MessageOptions",
"messageOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"messageOptions",
",",
"\"messageOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegments",
"=",
"{",
... | Send user input to assistant.
Send user input to an assistant and receive a response.
There is no rate limit for this operation.
@param messageOptions the {@link MessageOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link MessageResponse} | [
"Send",
"user",
"input",
"to",
"assistant",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java#L149-L170 | train |
watson-developer-cloud/java-sdk | language-translator/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslator.java | LanguageTranslator.identify | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "identify");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.bodyContent(identifyOptions.text(), "text/plain");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IdentifiedLanguages.class));
} | java | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "identify");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.bodyContent(identifyOptions.text(), "text/plain");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IdentifiedLanguages.class));
} | [
"public",
"ServiceCall",
"<",
"IdentifiedLanguages",
">",
"identify",
"(",
"IdentifyOptions",
"identifyOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"identifyOptions",
",",
"\"identifyOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegments",
"="... | 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} | [
"Identify",
"language",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/language-translator/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslator.java#L145-L157 | train |
watson-developer-cloud/java-sdk | language-translator/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslator.java | LanguageTranslator.listIdentifiableLanguages | public ServiceCall<IdentifiableLanguages> listIdentifiableLanguages(
ListIdentifiableLanguagesOptions listIdentifiableLanguagesOptions) {
String[] pathSegments = { "v3/identifiable_languages" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "listIdentifiableLanguages");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listIdentifiableLanguagesOptions != null) {
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IdentifiableLanguages.class));
} | java | public ServiceCall<IdentifiableLanguages> listIdentifiableLanguages(
ListIdentifiableLanguagesOptions listIdentifiableLanguagesOptions) {
String[] pathSegments = { "v3/identifiable_languages" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "listIdentifiableLanguages");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listIdentifiableLanguagesOptions != null) {
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IdentifiableLanguages.class));
} | [
"public",
"ServiceCall",
"<",
"IdentifiableLanguages",
">",
"listIdentifiableLanguages",
"(",
"ListIdentifiableLanguagesOptions",
"listIdentifiableLanguagesOptions",
")",
"{",
"String",
"[",
"]",
"pathSegments",
"=",
"{",
"\"v3/identifiable_languages\"",
"}",
";",
"RequestBui... | List identifiable languages.
Lists the languages that the service can identify. Returns the language code (for example, `en` for English or `es`
for Spanish) and name of each language.
@param listIdentifiableLanguagesOptions the {@link ListIdentifiableLanguagesOptions} containing the options for the
call
@return a {@link ServiceCall} with a response type of {@link IdentifiableLanguages} | [
"List",
"identifiable",
"languages",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/language-translator/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslator.java#L169-L182 | train |
watson-developer-cloud/java-sdk | language-translator/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslator.java | LanguageTranslator.createModel | public ServiceCall<TranslationModel> createModel(CreateModelOptions createModelOptions) {
Validator.notNull(createModelOptions, "createModelOptions cannot be null");
Validator.isTrue((createModelOptions.forcedGlossary() != null) || (createModelOptions.parallelCorpus() != null),
"At least one of forcedGlossary or parallelCorpus must be supplied.");
String[] pathSegments = { "v3/models" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "createModel");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("base_model_id", createModelOptions.baseModelId());
if (createModelOptions.name() != null) {
builder.query("name", createModelOptions.name());
}
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
if (createModelOptions.forcedGlossary() != null) {
RequestBody forcedGlossaryBody = RequestUtils.inputStreamBody(createModelOptions.forcedGlossary(),
"application/octet-stream");
multipartBuilder.addFormDataPart("forced_glossary", "filename", forcedGlossaryBody);
}
if (createModelOptions.parallelCorpus() != null) {
RequestBody parallelCorpusBody = RequestUtils.inputStreamBody(createModelOptions.parallelCorpus(),
"application/octet-stream");
multipartBuilder.addFormDataPart("parallel_corpus", "filename", parallelCorpusBody);
}
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TranslationModel.class));
} | java | public ServiceCall<TranslationModel> createModel(CreateModelOptions createModelOptions) {
Validator.notNull(createModelOptions, "createModelOptions cannot be null");
Validator.isTrue((createModelOptions.forcedGlossary() != null) || (createModelOptions.parallelCorpus() != null),
"At least one of forcedGlossary or parallelCorpus must be supplied.");
String[] pathSegments = { "v3/models" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("language_translator", "v3", "createModel");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("base_model_id", createModelOptions.baseModelId());
if (createModelOptions.name() != null) {
builder.query("name", createModelOptions.name());
}
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
if (createModelOptions.forcedGlossary() != null) {
RequestBody forcedGlossaryBody = RequestUtils.inputStreamBody(createModelOptions.forcedGlossary(),
"application/octet-stream");
multipartBuilder.addFormDataPart("forced_glossary", "filename", forcedGlossaryBody);
}
if (createModelOptions.parallelCorpus() != null) {
RequestBody parallelCorpusBody = RequestUtils.inputStreamBody(createModelOptions.parallelCorpus(),
"application/octet-stream");
multipartBuilder.addFormDataPart("parallel_corpus", "filename", parallelCorpusBody);
}
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TranslationModel.class));
} | [
"public",
"ServiceCall",
"<",
"TranslationModel",
">",
"createModel",
"(",
"CreateModelOptions",
"createModelOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"createModelOptions",
",",
"\"createModelOptions cannot be null\"",
")",
";",
"Validator",
".",
"isTrue",
"... | Create model.
Uploads Translation Memory eXchange (TMX) files to customize a translation model.
You can either customize a model with a forced glossary or with a corpus that contains parallel sentences. To
create a model that is customized with a parallel corpus <b>and</b> a forced glossary, proceed in two steps:
customize with a parallel corpus first and then customize the resulting model with a glossary. Depending on the
type of customization and the size of the uploaded corpora, training can range from minutes for a glossary to
several hours for a large parallel corpus. You can upload a single forced glossary file and this file must be less
than <b>10 MB</b>. You can upload multiple parallel corpora tmx files. The cumulative file size of all uploaded
files is limited to <b>250 MB</b>. To successfully train with a parallel corpus you must have at least <b>5,000
parallel sentences</b> in your corpus.
You can have a <b>maxium of 10 custom models per language pair</b>.
@param createModelOptions the {@link CreateModelOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link TranslationModel} | [
"Create",
"model",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/language-translator/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslator.java#L215-L245 | train |
watson-developer-cloud/java-sdk | compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java | CompareComply.convertToHtml | public ServiceCall<HTMLReturn> convertToHtml(ConvertToHtmlOptions convertToHtmlOptions) {
Validator.notNull(convertToHtmlOptions, "convertToHtmlOptions cannot be null");
String[] pathSegments = { "v1/html_conversion" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "convertToHtml");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (convertToHtmlOptions.model() != null) {
builder.query("model", convertToHtmlOptions.model());
}
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
RequestBody fileBody = RequestUtils.inputStreamBody(convertToHtmlOptions.file(), convertToHtmlOptions
.fileContentType());
multipartBuilder.addFormDataPart("file", convertToHtmlOptions.filename(), fileBody);
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(HTMLReturn.class));
} | java | public ServiceCall<HTMLReturn> convertToHtml(ConvertToHtmlOptions convertToHtmlOptions) {
Validator.notNull(convertToHtmlOptions, "convertToHtmlOptions cannot be null");
String[] pathSegments = { "v1/html_conversion" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "convertToHtml");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (convertToHtmlOptions.model() != null) {
builder.query("model", convertToHtmlOptions.model());
}
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
RequestBody fileBody = RequestUtils.inputStreamBody(convertToHtmlOptions.file(), convertToHtmlOptions
.fileContentType());
multipartBuilder.addFormDataPart("file", convertToHtmlOptions.filename(), fileBody);
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(HTMLReturn.class));
} | [
"public",
"ServiceCall",
"<",
"HTMLReturn",
">",
"convertToHtml",
"(",
"ConvertToHtmlOptions",
"convertToHtmlOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"convertToHtmlOptions",
",",
"\"convertToHtmlOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"path... | Convert document to HTML.
Converts a document to HTML.
@param convertToHtmlOptions the {@link ConvertToHtmlOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link HTMLReturn} | [
"Convert",
"document",
"to",
"HTML",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java#L106-L126 | train |
watson-developer-cloud/java-sdk | compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java | CompareComply.compareDocuments | public ServiceCall<CompareReturn> compareDocuments(CompareDocumentsOptions compareDocumentsOptions) {
Validator.notNull(compareDocumentsOptions, "compareDocumentsOptions cannot be null");
String[] pathSegments = { "v1/comparison" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "compareDocuments");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (compareDocumentsOptions.file1Label() != null) {
builder.query("file_1_label", compareDocumentsOptions.file1Label());
}
if (compareDocumentsOptions.file2Label() != null) {
builder.query("file_2_label", compareDocumentsOptions.file2Label());
}
if (compareDocumentsOptions.model() != null) {
builder.query("model", compareDocumentsOptions.model());
}
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
RequestBody file1Body = RequestUtils.inputStreamBody(compareDocumentsOptions.file1(), compareDocumentsOptions
.file1ContentType());
multipartBuilder.addFormDataPart("file_1", "filename", file1Body);
RequestBody file2Body = RequestUtils.inputStreamBody(compareDocumentsOptions.file2(), compareDocumentsOptions
.file2ContentType());
multipartBuilder.addFormDataPart("file_2", "filename", file2Body);
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(CompareReturn.class));
} | java | public ServiceCall<CompareReturn> compareDocuments(CompareDocumentsOptions compareDocumentsOptions) {
Validator.notNull(compareDocumentsOptions, "compareDocumentsOptions cannot be null");
String[] pathSegments = { "v1/comparison" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "compareDocuments");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (compareDocumentsOptions.file1Label() != null) {
builder.query("file_1_label", compareDocumentsOptions.file1Label());
}
if (compareDocumentsOptions.file2Label() != null) {
builder.query("file_2_label", compareDocumentsOptions.file2Label());
}
if (compareDocumentsOptions.model() != null) {
builder.query("model", compareDocumentsOptions.model());
}
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
RequestBody file1Body = RequestUtils.inputStreamBody(compareDocumentsOptions.file1(), compareDocumentsOptions
.file1ContentType());
multipartBuilder.addFormDataPart("file_1", "filename", file1Body);
RequestBody file2Body = RequestUtils.inputStreamBody(compareDocumentsOptions.file2(), compareDocumentsOptions
.file2ContentType());
multipartBuilder.addFormDataPart("file_2", "filename", file2Body);
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(CompareReturn.class));
} | [
"public",
"ServiceCall",
"<",
"CompareReturn",
">",
"compareDocuments",
"(",
"CompareDocumentsOptions",
"compareDocumentsOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"compareDocumentsOptions",
",",
"\"compareDocumentsOptions cannot be null\"",
")",
";",
"String",
"... | Compare two documents.
Compares two input documents. Documents must be in the same format.
@param compareDocumentsOptions the {@link CompareDocumentsOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link CompareReturn} | [
"Compare",
"two",
"documents",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java#L196-L225 | train |
watson-developer-cloud/java-sdk | compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java | CompareComply.addFeedback | public ServiceCall<FeedbackReturn> addFeedback(AddFeedbackOptions addFeedbackOptions) {
Validator.notNull(addFeedbackOptions, "addFeedbackOptions cannot be null");
String[] pathSegments = { "v1/feedback" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "addFeedback");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.add("feedback_data", GsonSingleton.getGson().toJsonTree(addFeedbackOptions.feedbackData()));
if (addFeedbackOptions.userId() != null) {
contentJson.addProperty("user_id", addFeedbackOptions.userId());
}
if (addFeedbackOptions.comment() != null) {
contentJson.addProperty("comment", addFeedbackOptions.comment());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(FeedbackReturn.class));
} | java | public ServiceCall<FeedbackReturn> addFeedback(AddFeedbackOptions addFeedbackOptions) {
Validator.notNull(addFeedbackOptions, "addFeedbackOptions cannot be null");
String[] pathSegments = { "v1/feedback" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "addFeedback");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.add("feedback_data", GsonSingleton.getGson().toJsonTree(addFeedbackOptions.feedbackData()));
if (addFeedbackOptions.userId() != null) {
contentJson.addProperty("user_id", addFeedbackOptions.userId());
}
if (addFeedbackOptions.comment() != null) {
contentJson.addProperty("comment", addFeedbackOptions.comment());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(FeedbackReturn.class));
} | [
"public",
"ServiceCall",
"<",
"FeedbackReturn",
">",
"addFeedback",
"(",
"AddFeedbackOptions",
"addFeedbackOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"addFeedbackOptions",
",",
"\"addFeedbackOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegmen... | Add feedback.
Adds feedback in the form of _labels_ from a subject-matter expert (SME) to a governing document.
**Important:** Feedback is not immediately incorporated into the training model, nor is it guaranteed to be
incorporated at a later date. Instead, submitted feedback is used to suggest future updates to the training model.
@param addFeedbackOptions the {@link AddFeedbackOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link FeedbackReturn} | [
"Add",
"feedback",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java#L237-L257 | train |
watson-developer-cloud/java-sdk | compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java | CompareComply.deleteFeedback | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "deleteFeedback");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (deleteFeedbackOptions.model() != null) {
builder.query("model", deleteFeedbackOptions.model());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | java | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "deleteFeedback");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (deleteFeedbackOptions.model() != null) {
builder.query("model", deleteFeedbackOptions.model());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | [
"public",
"ServiceCall",
"<",
"Void",
">",
"deleteFeedback",
"(",
"DeleteFeedbackOptions",
"deleteFeedbackOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"deleteFeedbackOptions",
",",
"\"deleteFeedbackOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathS... | Delete a specified feedback entry.
Deletes a feedback entry with a specified `feedback_id`.
@param deleteFeedbackOptions the {@link DeleteFeedbackOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of Void | [
"Delete",
"a",
"specified",
"feedback",
"entry",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java#L267-L283 | train |
watson-developer-cloud/java-sdk | compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java | CompareComply.getFeedback | public ServiceCall<GetFeedback> getFeedback(GetFeedbackOptions getFeedbackOptions) {
Validator.notNull(getFeedbackOptions, "getFeedbackOptions cannot be null");
String[] pathSegments = { "v1/feedback" };
String[] pathParameters = { getFeedbackOptions.feedbackId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "getFeedback");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (getFeedbackOptions.model() != null) {
builder.query("model", getFeedbackOptions.model());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(GetFeedback.class));
} | java | public ServiceCall<GetFeedback> getFeedback(GetFeedbackOptions getFeedbackOptions) {
Validator.notNull(getFeedbackOptions, "getFeedbackOptions cannot be null");
String[] pathSegments = { "v1/feedback" };
String[] pathParameters = { getFeedbackOptions.feedbackId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "getFeedback");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (getFeedbackOptions.model() != null) {
builder.query("model", getFeedbackOptions.model());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(GetFeedback.class));
} | [
"public",
"ServiceCall",
"<",
"GetFeedback",
">",
"getFeedback",
"(",
"GetFeedbackOptions",
"getFeedbackOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"getFeedbackOptions",
",",
"\"getFeedbackOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegments"... | List a specified feedback entry.
Lists a feedback entry with a specified `feedback_id`.
@param getFeedbackOptions the {@link GetFeedbackOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link GetFeedback} | [
"List",
"a",
"specified",
"feedback",
"entry",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java#L293-L309 | train |
watson-developer-cloud/java-sdk | compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java | CompareComply.createBatch | public ServiceCall<BatchStatus> createBatch(CreateBatchOptions createBatchOptions) {
Validator.notNull(createBatchOptions, "createBatchOptions cannot be null");
String[] pathSegments = { "v1/batches" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "createBatch");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("function", createBatchOptions.function());
if (createBatchOptions.model() != null) {
builder.query("model", createBatchOptions.model());
}
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
RequestBody inputCredentialsFileBody = RequestUtils.inputStreamBody(createBatchOptions.inputCredentialsFile(),
"application/json");
multipartBuilder.addFormDataPart("input_credentials_file", "filename", inputCredentialsFileBody);
multipartBuilder.addFormDataPart("input_bucket_location", createBatchOptions.inputBucketLocation());
multipartBuilder.addFormDataPart("input_bucket_name", createBatchOptions.inputBucketName());
RequestBody outputCredentialsFileBody = RequestUtils.inputStreamBody(createBatchOptions.outputCredentialsFile(),
"application/json");
multipartBuilder.addFormDataPart("output_credentials_file", "filename", outputCredentialsFileBody);
multipartBuilder.addFormDataPart("output_bucket_location", createBatchOptions.outputBucketLocation());
multipartBuilder.addFormDataPart("output_bucket_name", createBatchOptions.outputBucketName());
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(BatchStatus.class));
} | java | public ServiceCall<BatchStatus> createBatch(CreateBatchOptions createBatchOptions) {
Validator.notNull(createBatchOptions, "createBatchOptions cannot be null");
String[] pathSegments = { "v1/batches" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "createBatch");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("function", createBatchOptions.function());
if (createBatchOptions.model() != null) {
builder.query("model", createBatchOptions.model());
}
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
RequestBody inputCredentialsFileBody = RequestUtils.inputStreamBody(createBatchOptions.inputCredentialsFile(),
"application/json");
multipartBuilder.addFormDataPart("input_credentials_file", "filename", inputCredentialsFileBody);
multipartBuilder.addFormDataPart("input_bucket_location", createBatchOptions.inputBucketLocation());
multipartBuilder.addFormDataPart("input_bucket_name", createBatchOptions.inputBucketName());
RequestBody outputCredentialsFileBody = RequestUtils.inputStreamBody(createBatchOptions.outputCredentialsFile(),
"application/json");
multipartBuilder.addFormDataPart("output_credentials_file", "filename", outputCredentialsFileBody);
multipartBuilder.addFormDataPart("output_bucket_location", createBatchOptions.outputBucketLocation());
multipartBuilder.addFormDataPart("output_bucket_name", createBatchOptions.outputBucketName());
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(BatchStatus.class));
} | [
"public",
"ServiceCall",
"<",
"BatchStatus",
">",
"createBatch",
"(",
"CreateBatchOptions",
"createBatchOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"createBatchOptions",
",",
"\"createBatchOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegments"... | Submit a batch-processing request.
Run Compare and Comply methods over a collection of input documents.
**Important:** Batch processing requires the use of the [IBM Cloud Object Storage
service](https://cloud.ibm.com/docs/services/cloud-object-storage/about-cos.html#about-ibm-cloud-object-storage).
The use of IBM Cloud Object Storage with Compare and Comply is discussed at [Using batch
processing](https://cloud.ibm.com/docs/services/compare-comply/batching.html#before-you-batch).
@param createBatchOptions the {@link CreateBatchOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link BatchStatus} | [
"Submit",
"a",
"batch",
"-",
"processing",
"request",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java#L404-L432 | train |
watson-developer-cloud/java-sdk | compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java | CompareComply.getBatch | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "getBatch");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(BatchStatus.class));
} | java | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "getBatch");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(BatchStatus.class));
} | [
"public",
"ServiceCall",
"<",
"BatchStatus",
">",
"getBatch",
"(",
"GetBatchOptions",
"getBatchOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"getBatchOptions",
",",
"\"getBatchOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegments",
"=",
"{",... | Get information about a specific batch-processing job.
Gets information about a batch-processing job 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} | [
"Get",
"information",
"about",
"a",
"specific",
"batch",
"-",
"processing",
"job",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java#L442-L455 | train |
watson-developer-cloud/java-sdk | compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java | CompareComply.listBatches | public ServiceCall<Batches> listBatches(ListBatchesOptions listBatchesOptions) {
String[] pathSegments = { "v1/batches" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "listBatches");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listBatchesOptions != null) {
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Batches.class));
} | java | public ServiceCall<Batches> listBatches(ListBatchesOptions listBatchesOptions) {
String[] pathSegments = { "v1/batches" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "listBatches");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listBatchesOptions != null) {
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Batches.class));
} | [
"public",
"ServiceCall",
"<",
"Batches",
">",
"listBatches",
"(",
"ListBatchesOptions",
"listBatchesOptions",
")",
"{",
"String",
"[",
"]",
"pathSegments",
"=",
"{",
"\"v1/batches\"",
"}",
";",
"RequestBuilder",
"builder",
"=",
"RequestBuilder",
".",
"get",
"(",
... | List submitted batch-processing jobs.
Lists 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} | [
"List",
"submitted",
"batch",
"-",
"processing",
"jobs",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java#L465-L477 | train |
watson-developer-cloud/java-sdk | compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java | CompareComply.updateBatch | public ServiceCall<BatchStatus> updateBatch(UpdateBatchOptions updateBatchOptions) {
Validator.notNull(updateBatchOptions, "updateBatchOptions cannot be null");
String[] pathSegments = { "v1/batches" };
String[] pathParameters = { updateBatchOptions.batchId() };
RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "updateBatch");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("action", updateBatchOptions.action());
if (updateBatchOptions.model() != null) {
builder.query("model", updateBatchOptions.model());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(BatchStatus.class));
} | java | public ServiceCall<BatchStatus> updateBatch(UpdateBatchOptions updateBatchOptions) {
Validator.notNull(updateBatchOptions, "updateBatchOptions cannot be null");
String[] pathSegments = { "v1/batches" };
String[] pathParameters = { updateBatchOptions.batchId() };
RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "updateBatch");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("action", updateBatchOptions.action());
if (updateBatchOptions.model() != null) {
builder.query("model", updateBatchOptions.model());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(BatchStatus.class));
} | [
"public",
"ServiceCall",
"<",
"BatchStatus",
">",
"updateBatch",
"(",
"UpdateBatchOptions",
"updateBatchOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"updateBatchOptions",
",",
"\"updateBatchOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegments"... | Update a pending or active batch-processing job.
Updates a pending or active batch-processing job. You can rescan the input bucket to check for new documents or
cancel a job.
@param updateBatchOptions the {@link UpdateBatchOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link BatchStatus} | [
"Update",
"a",
"pending",
"or",
"active",
"batch",
"-",
"processing",
"job",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/CompareComply.java#L499-L516 | train |
watson-developer-cloud/java-sdk | text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java | TextToSpeech.getVoice | public ServiceCall<Voice> getVoice(GetVoiceOptions getVoiceOptions) {
Validator.notNull(getVoiceOptions, "getVoiceOptions cannot be null");
String[] pathSegments = { "v1/voices" };
String[] pathParameters = { getVoiceOptions.voice() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getVoice");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (getVoiceOptions.customizationId() != null) {
builder.query("customization_id", getVoiceOptions.customizationId());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Voice.class));
} | java | public ServiceCall<Voice> getVoice(GetVoiceOptions getVoiceOptions) {
Validator.notNull(getVoiceOptions, "getVoiceOptions cannot be null");
String[] pathSegments = { "v1/voices" };
String[] pathParameters = { getVoiceOptions.voice() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getVoice");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (getVoiceOptions.customizationId() != null) {
builder.query("customization_id", getVoiceOptions.customizationId());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Voice.class));
} | [
"public",
"ServiceCall",
"<",
"Voice",
">",
"getVoice",
"(",
"GetVoiceOptions",
"getVoiceOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"getVoiceOptions",
",",
"\"getVoiceOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegments",
"=",
"{",
"\"... | Get a voice.
Gets information about the specified voice. The information includes the name, language, gender, and other details
about the voice. Specify a customization ID to obtain information for that custom voice model of the specified
voice. To list information about all available voices, use the **List voices** method.
**See also:** [Listing a specific voice](https://cloud.ibm.com/docs/services/text-to-speech/voices.html#listVoice).
@param getVoiceOptions the {@link GetVoiceOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Voice} | [
"Get",
"a",
"voice",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java#L130-L145 | train |
watson-developer-cloud/java-sdk | text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java | TextToSpeech.listVoices | public ServiceCall<Voices> listVoices(ListVoicesOptions listVoicesOptions) {
String[] pathSegments = { "v1/voices" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "listVoices");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listVoicesOptions != null) {
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Voices.class));
} | java | public ServiceCall<Voices> listVoices(ListVoicesOptions listVoicesOptions) {
String[] pathSegments = { "v1/voices" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "listVoices");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listVoicesOptions != null) {
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Voices.class));
} | [
"public",
"ServiceCall",
"<",
"Voices",
">",
"listVoices",
"(",
"ListVoicesOptions",
"listVoicesOptions",
")",
"{",
"String",
"[",
"]",
"pathSegments",
"=",
"{",
"\"v1/voices\"",
"}",
";",
"RequestBuilder",
"builder",
"=",
"RequestBuilder",
".",
"get",
"(",
"Req... | List voices.
Lists all voices available for use with the service. The information includes the name, language, gender, and other
details about the voice. To see information about a specific voice, use the **Get a voice** method.
**See also:** [Listing all available
voices](https://cloud.ibm.com/docs/services/text-to-speech/voices.html#listVoices).
@param listVoicesOptions the {@link ListVoicesOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Voices} | [
"List",
"voices",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java#L159-L170 | train |
watson-developer-cloud/java-sdk | text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java | TextToSpeech.synthesize | public ServiceCall<InputStream> synthesize(SynthesizeOptions synthesizeOptions) {
Validator.notNull(synthesizeOptions, "synthesizeOptions cannot be null");
String[] pathSegments = { "v1/synthesize" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "synthesize");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
if (synthesizeOptions.accept() != null) {
builder.header("Accept", synthesizeOptions.accept());
}
if (synthesizeOptions.voice() != null) {
builder.query("voice", synthesizeOptions.voice());
}
if (synthesizeOptions.customizationId() != null) {
builder.query("customization_id", synthesizeOptions.customizationId());
}
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("text", synthesizeOptions.text());
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getInputStream());
} | java | public ServiceCall<InputStream> synthesize(SynthesizeOptions synthesizeOptions) {
Validator.notNull(synthesizeOptions, "synthesizeOptions cannot be null");
String[] pathSegments = { "v1/synthesize" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "synthesize");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
if (synthesizeOptions.accept() != null) {
builder.header("Accept", synthesizeOptions.accept());
}
if (synthesizeOptions.voice() != null) {
builder.query("voice", synthesizeOptions.voice());
}
if (synthesizeOptions.customizationId() != null) {
builder.query("customization_id", synthesizeOptions.customizationId());
}
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("text", synthesizeOptions.text());
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getInputStream());
} | [
"public",
"ServiceCall",
"<",
"InputStream",
">",
"synthesize",
"(",
"SynthesizeOptions",
"synthesizeOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"synthesizeOptions",
",",
"\"synthesizeOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegments",
"... | Synthesize audio.
Synthesizes text to audio that is spoken in the specified voice. The service bases its understanding of the
language for the input text on the specified voice. Use a voice that matches the language of the input text.
The method accepts a maximum of 5 KB of input text in the body of the request, and 8 KB for the URL and headers.
The 5 KB limit includes any SSML tags that you specify. The service returns the synthesized audio stream as an
array of bytes.
**See also:** [The HTTP interface](https://cloud.ibm.com/docs/services/text-to-speech/http.html).
### Audio formats (accept types)
The service can return audio in the following formats (MIME types).
* Where indicated, you can optionally specify the sampling rate (`rate`) of the audio. You must specify a sampling
rate for the `audio/l16` and `audio/mulaw` formats. A specified sampling rate must lie in the range of 8 kHz to 192
kHz.
* For the `audio/l16` format, you can optionally specify the endianness (`endianness`) of the audio:
`endianness=big-endian` or `endianness=little-endian`.
Use the `Accept` header or the `accept` parameter to specify the requested format of the response audio. If you
omit an audio format altogether, the service returns the audio in Ogg format with the Opus codec
(`audio/ogg;codecs=opus`). The service always returns single-channel audio.
* `audio/basic`
The service returns audio with a sampling rate of 8000 Hz.
* `audio/flac`
You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz.
* `audio/l16`
You must specify the `rate` of the audio. You can optionally specify the `endianness` of the audio. The default
endianness is `little-endian`.
* `audio/mp3`
You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz.
* `audio/mpeg`
You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz.
* `audio/mulaw`
You must specify the `rate` of the audio.
* `audio/ogg`
The service returns the audio in the `vorbis` codec. You can optionally specify the `rate` of the audio. The
default sampling rate is 22,050 Hz.
* `audio/ogg;codecs=opus`
You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz.
* `audio/ogg;codecs=vorbis`
You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz.
* `audio/wav`
You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz.
* `audio/webm`
The service returns the audio in the `opus` codec. The service returns audio with a sampling rate of 48,000 Hz.
* `audio/webm;codecs=opus`
The service returns audio with a sampling rate of 48,000 Hz.
* `audio/webm;codecs=vorbis`
You can optionally specify the `rate` of the audio. The default sampling rate is 22,050 Hz.
For more information about specifying an audio format, including additional details about some of the formats, see
[Audio formats](https://cloud.ibm.com/docs/services/text-to-speech/audio-formats.html).
### Warning messages
If a request includes invalid query parameters, the service returns a `Warnings` response header that provides
messages about the invalid parameters. The warning includes a descriptive message and a list of invalid argument
strings. For example, a message such as `\"Unknown arguments:\"` or `\"Unknown url query arguments:\"` followed by
a list of the form `\"{invalid_arg_1}, {invalid_arg_2}.\"` The request succeeds despite the warnings.
@param synthesizeOptions the {@link SynthesizeOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link InputStream} | [
"Synthesize",
"audio",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java#L266-L287 | train |
watson-developer-cloud/java-sdk | text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java | TextToSpeech.getPronunciation | public ServiceCall<Pronunciation> getPronunciation(GetPronunciationOptions getPronunciationOptions) {
Validator.notNull(getPronunciationOptions, "getPronunciationOptions cannot be null");
String[] pathSegments = { "v1/pronunciation" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getPronunciation");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("text", getPronunciationOptions.text());
if (getPronunciationOptions.voice() != null) {
builder.query("voice", getPronunciationOptions.voice());
}
if (getPronunciationOptions.format() != null) {
builder.query("format", getPronunciationOptions.format());
}
if (getPronunciationOptions.customizationId() != null) {
builder.query("customization_id", getPronunciationOptions.customizationId());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Pronunciation.class));
} | java | public ServiceCall<Pronunciation> getPronunciation(GetPronunciationOptions getPronunciationOptions) {
Validator.notNull(getPronunciationOptions, "getPronunciationOptions cannot be null");
String[] pathSegments = { "v1/pronunciation" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getPronunciation");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("text", getPronunciationOptions.text());
if (getPronunciationOptions.voice() != null) {
builder.query("voice", getPronunciationOptions.voice());
}
if (getPronunciationOptions.format() != null) {
builder.query("format", getPronunciationOptions.format());
}
if (getPronunciationOptions.customizationId() != null) {
builder.query("customization_id", getPronunciationOptions.customizationId());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Pronunciation.class));
} | [
"public",
"ServiceCall",
"<",
"Pronunciation",
">",
"getPronunciation",
"(",
"GetPronunciationOptions",
"getPronunciationOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"getPronunciationOptions",
",",
"\"getPronunciationOptions cannot be null\"",
")",
";",
"String",
"... | Get pronunciation.
Gets the phonetic pronunciation for the specified word. You can request the pronunciation for a specific format.
You can also request the pronunciation for a specific voice to see the default translation for the language of that
voice or for a specific custom voice model to see the translation for that voice model.
**Note:** This method is currently a beta release.
**See also:** [Querying a word from a
language](https://cloud.ibm.com/docs/services/text-to-speech/custom-entries.html#cuWordsQueryLanguage).
@param getPronunciationOptions the {@link GetPronunciationOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Pronunciation} | [
"Get",
"pronunciation",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java#L327-L347 | train |
watson-developer-cloud/java-sdk | text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java | TextToSpeech.createVoiceModel | public ServiceCall<VoiceModel> createVoiceModel(CreateVoiceModelOptions createVoiceModelOptions) {
Validator.notNull(createVoiceModelOptions, "createVoiceModelOptions cannot be null");
String[] pathSegments = { "v1/customizations" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "createVoiceModel");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("name", createVoiceModelOptions.name());
if (createVoiceModelOptions.language() != null) {
contentJson.addProperty("language", createVoiceModelOptions.language());
}
if (createVoiceModelOptions.description() != null) {
contentJson.addProperty("description", createVoiceModelOptions.description());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(VoiceModel.class));
} | java | public ServiceCall<VoiceModel> createVoiceModel(CreateVoiceModelOptions createVoiceModelOptions) {
Validator.notNull(createVoiceModelOptions, "createVoiceModelOptions cannot be null");
String[] pathSegments = { "v1/customizations" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "createVoiceModel");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("name", createVoiceModelOptions.name());
if (createVoiceModelOptions.language() != null) {
contentJson.addProperty("language", createVoiceModelOptions.language());
}
if (createVoiceModelOptions.description() != null) {
contentJson.addProperty("description", createVoiceModelOptions.description());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(VoiceModel.class));
} | [
"public",
"ServiceCall",
"<",
"VoiceModel",
">",
"createVoiceModel",
"(",
"CreateVoiceModelOptions",
"createVoiceModelOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"createVoiceModelOptions",
",",
"\"createVoiceModelOptions cannot be null\"",
")",
";",
"String",
"[",... | Create a custom model.
Creates a new empty custom voice model. You must specify a name for the new custom model. You can optionally
specify the language and a description for the new model. The model is owned by the instance of the service whose
credentials are used to create it.
**Note:** This method is currently a beta release.
**See also:** [Creating a custom
model](https://cloud.ibm.com/docs/services/text-to-speech/custom-models.html#cuModelsCreate).
@param createVoiceModelOptions the {@link CreateVoiceModelOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link VoiceModel} | [
"Create",
"a",
"custom",
"model",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java#L364-L383 | train |
watson-developer-cloud/java-sdk | text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java | TextToSpeech.getVoiceModel | public ServiceCall<VoiceModel> getVoiceModel(GetVoiceModelOptions getVoiceModelOptions) {
Validator.notNull(getVoiceModelOptions, "getVoiceModelOptions cannot be null");
String[] pathSegments = { "v1/customizations" };
String[] pathParameters = { getVoiceModelOptions.customizationId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getVoiceModel");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(VoiceModel.class));
} | java | public ServiceCall<VoiceModel> getVoiceModel(GetVoiceModelOptions getVoiceModelOptions) {
Validator.notNull(getVoiceModelOptions, "getVoiceModelOptions cannot be null");
String[] pathSegments = { "v1/customizations" };
String[] pathParameters = { getVoiceModelOptions.customizationId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getVoiceModel");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(VoiceModel.class));
} | [
"public",
"ServiceCall",
"<",
"VoiceModel",
">",
"getVoiceModel",
"(",
"GetVoiceModelOptions",
"getVoiceModelOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"getVoiceModelOptions",
",",
"\"getVoiceModelOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"path... | Get a custom model.
Gets all information about a specified custom voice model. In addition to metadata such as the name and description
of the voice model, the output includes the words and their translations as defined in the model. To see just the
metadata for a voice model, use the **List custom models** method.
**Note:** This method is currently a beta release.
**See also:** [Querying a custom
model](https://cloud.ibm.com/docs/services/text-to-speech/custom-models.html#cuModelsQuery).
@param getVoiceModelOptions the {@link GetVoiceModelOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link VoiceModel} | [
"Get",
"a",
"custom",
"model",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java#L427-L439 | train |
watson-developer-cloud/java-sdk | text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java | TextToSpeech.listVoiceModels | public ServiceCall<VoiceModels> listVoiceModels(ListVoiceModelsOptions listVoiceModelsOptions) {
String[] pathSegments = { "v1/customizations" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "listVoiceModels");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listVoiceModelsOptions != null) {
if (listVoiceModelsOptions.language() != null) {
builder.query("language", listVoiceModelsOptions.language());
}
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(VoiceModels.class));
} | java | public ServiceCall<VoiceModels> listVoiceModels(ListVoiceModelsOptions listVoiceModelsOptions) {
String[] pathSegments = { "v1/customizations" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "listVoiceModels");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listVoiceModelsOptions != null) {
if (listVoiceModelsOptions.language() != null) {
builder.query("language", listVoiceModelsOptions.language());
}
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(VoiceModels.class));
} | [
"public",
"ServiceCall",
"<",
"VoiceModels",
">",
"listVoiceModels",
"(",
"ListVoiceModelsOptions",
"listVoiceModelsOptions",
")",
"{",
"String",
"[",
"]",
"pathSegments",
"=",
"{",
"\"v1/customizations\"",
"}",
";",
"RequestBuilder",
"builder",
"=",
"RequestBuilder",
... | List custom models.
Lists metadata such as the name and description for all custom voice models that are owned by an instance of the
service. Specify a language to list the voice models for that language only. To see the words in addition to the
metadata for a specific voice model, use the **List a custom model** method. You must use credentials for the
instance of the service that owns a model to list information about it.
**Note:** This method is currently a beta release.
**See also:** [Querying all custom
models](https://cloud.ibm.com/docs/services/text-to-speech/custom-models.html#cuModelsQueryAll).
@param listVoiceModelsOptions the {@link ListVoiceModelsOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link VoiceModels} | [
"List",
"custom",
"models",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java#L457-L471 | train |
watson-developer-cloud/java-sdk | text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java | TextToSpeech.updateVoiceModel | public ServiceCall<Void> updateVoiceModel(UpdateVoiceModelOptions updateVoiceModelOptions) {
Validator.notNull(updateVoiceModelOptions, "updateVoiceModelOptions cannot be null");
String[] pathSegments = { "v1/customizations" };
String[] pathParameters = { updateVoiceModelOptions.customizationId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "updateVoiceModel");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (updateVoiceModelOptions.name() != null) {
contentJson.addProperty("name", updateVoiceModelOptions.name());
}
if (updateVoiceModelOptions.description() != null) {
contentJson.addProperty("description", updateVoiceModelOptions.description());
}
if (updateVoiceModelOptions.words() != null) {
contentJson.add("words", GsonSingleton.getGson().toJsonTree(updateVoiceModelOptions.words()));
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | java | public ServiceCall<Void> updateVoiceModel(UpdateVoiceModelOptions updateVoiceModelOptions) {
Validator.notNull(updateVoiceModelOptions, "updateVoiceModelOptions cannot be null");
String[] pathSegments = { "v1/customizations" };
String[] pathParameters = { updateVoiceModelOptions.customizationId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "updateVoiceModel");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (updateVoiceModelOptions.name() != null) {
contentJson.addProperty("name", updateVoiceModelOptions.name());
}
if (updateVoiceModelOptions.description() != null) {
contentJson.addProperty("description", updateVoiceModelOptions.description());
}
if (updateVoiceModelOptions.words() != null) {
contentJson.add("words", GsonSingleton.getGson().toJsonTree(updateVoiceModelOptions.words()));
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | [
"public",
"ServiceCall",
"<",
"Void",
">",
"updateVoiceModel",
"(",
"UpdateVoiceModelOptions",
"updateVoiceModelOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"updateVoiceModelOptions",
",",
"\"updateVoiceModelOptions cannot be null\"",
")",
";",
"String",
"[",
"]"... | Update a custom model.
Updates information for the specified custom voice model. You can update metadata such as the name and description
of the voice model. You can also update the words in the model and their translations. Adding a new translation for
a word that already exists in a custom model overwrites the word's existing translation. A custom model can contain
no more than 20,000 entries. You must use credentials for the instance of the service that owns a model to update
it.
You can define sounds-like or phonetic translations for words. A sounds-like translation consists of one or more
words that, when combined, sound like the word. Phonetic translations are based on the SSML phoneme format for
representing a word. You can specify them in standard International Phonetic Alphabet (IPA) representation
<code><phoneme alphabet=\"ipa\" ph=\"təmˈɑto\"></phoneme></code>
or in the proprietary IBM Symbolic Phonetic Representation (SPR)
<code><phoneme alphabet=\"ibm\" ph=\"1gAstroEntxrYFXs\"></phoneme></code>
**Note:** This method is currently a beta release.
**See also:**
* [Updating a custom model](https://cloud.ibm.com/docs/services/text-to-speech/custom-models.html#cuModelsUpdate)
* [Adding words to a Japanese custom
model](https://cloud.ibm.com/docs/services/text-to-speech/custom-entries.html#cuJapaneseAdd)
* [Understanding customization](https://cloud.ibm.com/docs/services/text-to-speech/custom-intro.html).
@param updateVoiceModelOptions the {@link UpdateVoiceModelOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of Void | [
"Update",
"a",
"custom",
"model",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java#L522-L545 | train |
watson-developer-cloud/java-sdk | text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java | TextToSpeech.addWords | public ServiceCall<Void> addWords(AddWordsOptions addWordsOptions) {
Validator.notNull(addWordsOptions, "addWordsOptions cannot be null");
String[] pathSegments = { "v1/customizations", "words" };
String[] pathParameters = { addWordsOptions.customizationId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "addWords");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.add("words", GsonSingleton.getGson().toJsonTree(addWordsOptions.words()));
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | java | public ServiceCall<Void> addWords(AddWordsOptions addWordsOptions) {
Validator.notNull(addWordsOptions, "addWordsOptions cannot be null");
String[] pathSegments = { "v1/customizations", "words" };
String[] pathParameters = { addWordsOptions.customizationId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "addWords");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.add("words", GsonSingleton.getGson().toJsonTree(addWordsOptions.words()));
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | [
"public",
"ServiceCall",
"<",
"Void",
">",
"addWords",
"(",
"AddWordsOptions",
"addWordsOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"addWordsOptions",
",",
"\"addWordsOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegments",
"=",
"{",
"\"v... | Add custom words.
Adds one or more words and their translations to the specified custom voice model. Adding a new translation for a
word that already exists in a custom model overwrites the word's existing translation. A custom model can contain
no more than 20,000 entries. You must use credentials for the instance of the service that owns a model to add
words to it.
You can define sounds-like or phonetic translations for words. A sounds-like translation consists of one or more
words that, when combined, sound like the word. Phonetic translations are based on the SSML phoneme format for
representing a word. You can specify them in standard International Phonetic Alphabet (IPA) representation
<code><phoneme alphabet=\"ipa\" ph=\"təmˈɑto\"></phoneme></code>
or in the proprietary IBM Symbolic Phonetic Representation (SPR)
<code><phoneme alphabet=\"ibm\" ph=\"1gAstroEntxrYFXs\"></phoneme></code>
**Note:** This method is currently a beta release.
**See also:**
* [Adding multiple words to a custom
model](https://cloud.ibm.com/docs/services/text-to-speech/custom-entries.html#cuWordsAdd)
* [Adding words to a Japanese custom
model](https://cloud.ibm.com/docs/services/text-to-speech/custom-entries.html#cuJapaneseAdd)
* [Understanding customization](https://cloud.ibm.com/docs/services/text-to-speech/custom-intro.html).
@param addWordsOptions the {@link AddWordsOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of Void | [
"Add",
"custom",
"words",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java#L626-L641 | train |
watson-developer-cloud/java-sdk | text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java | TextToSpeech.deleteWord | public ServiceCall<Void> deleteWord(DeleteWordOptions deleteWordOptions) {
Validator.notNull(deleteWordOptions, "deleteWordOptions cannot be null");
String[] pathSegments = { "v1/customizations", "words" };
String[] pathParameters = { deleteWordOptions.customizationId(), deleteWordOptions.word() };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "deleteWord");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | java | public ServiceCall<Void> deleteWord(DeleteWordOptions deleteWordOptions) {
Validator.notNull(deleteWordOptions, "deleteWordOptions cannot be null");
String[] pathSegments = { "v1/customizations", "words" };
String[] pathParameters = { deleteWordOptions.customizationId(), deleteWordOptions.word() };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "deleteWord");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | [
"public",
"ServiceCall",
"<",
"Void",
">",
"deleteWord",
"(",
"DeleteWordOptions",
"deleteWordOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"deleteWordOptions",
",",
"\"deleteWordOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegments",
"=",
"... | Delete a custom word.
Deletes a single word from the specified custom voice model. You must use credentials for the instance of the
service that owns a model to delete its words.
**Note:** This method is currently a beta release.
**See also:** [Deleting a word from a custom
model](https://cloud.ibm.com/docs/services/text-to-speech/custom-entries.html#cuWordDelete).
@param deleteWordOptions the {@link DeleteWordOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of Void | [
"Delete",
"a",
"custom",
"word",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java#L657-L668 | train |
watson-developer-cloud/java-sdk | text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java | TextToSpeech.getWord | public ServiceCall<Translation> getWord(GetWordOptions getWordOptions) {
Validator.notNull(getWordOptions, "getWordOptions cannot be null");
String[] pathSegments = { "v1/customizations", "words" };
String[] pathParameters = { getWordOptions.customizationId(), getWordOptions.word() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getWord");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Translation.class));
} | java | public ServiceCall<Translation> getWord(GetWordOptions getWordOptions) {
Validator.notNull(getWordOptions, "getWordOptions cannot be null");
String[] pathSegments = { "v1/customizations", "words" };
String[] pathParameters = { getWordOptions.customizationId(), getWordOptions.word() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "getWord");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Translation.class));
} | [
"public",
"ServiceCall",
"<",
"Translation",
">",
"getWord",
"(",
"GetWordOptions",
"getWordOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"getWordOptions",
",",
"\"getWordOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegments",
"=",
"{",
"\... | Get a custom word.
Gets the translation for a single word from the specified custom model. The output shows the translation as it is
defined in the model. You must use credentials for the instance of the service that owns a model to list its words.
**Note:** This method is currently a beta release.
**See also:** [Querying a single word from a custom
model](https://cloud.ibm.com/docs/services/text-to-speech/custom-entries.html#cuWordQueryModel).
@param getWordOptions the {@link GetWordOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Translation} | [
"Get",
"a",
"custom",
"word",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java#L685-L697 | train |
watson-developer-cloud/java-sdk | text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java | TextToSpeech.listWords | public ServiceCall<Words> listWords(ListWordsOptions listWordsOptions) {
Validator.notNull(listWordsOptions, "listWordsOptions cannot be null");
String[] pathSegments = { "v1/customizations", "words" };
String[] pathParameters = { listWordsOptions.customizationId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "listWords");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Words.class));
} | java | public ServiceCall<Words> listWords(ListWordsOptions listWordsOptions) {
Validator.notNull(listWordsOptions, "listWordsOptions cannot be null");
String[] pathSegments = { "v1/customizations", "words" };
String[] pathParameters = { listWordsOptions.customizationId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("text_to_speech", "v1", "listWords");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Words.class));
} | [
"public",
"ServiceCall",
"<",
"Words",
">",
"listWords",
"(",
"ListWordsOptions",
"listWordsOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"listWordsOptions",
",",
"\"listWordsOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegments",
"=",
"{",
... | List custom words.
Lists all of the words and their translations for the specified custom voice model. The output shows the
translations as they are defined in the model. You must use credentials for the instance of the service that owns a
model to list its words.
**Note:** This method is currently a beta release.
**See also:** [Querying all words from a custom
model](https://cloud.ibm.com/docs/services/text-to-speech/custom-entries.html#cuWordsQueryModel).
@param listWordsOptions the {@link ListWordsOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Words} | [
"List",
"custom",
"words",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java#L714-L726 | train |
watson-developer-cloud/java-sdk | natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifier.java | NaturalLanguageClassifier.classify | public ServiceCall<Classification> classify(ClassifyOptions classifyOptions) {
Validator.notNull(classifyOptions, "classifyOptions cannot be null");
String[] pathSegments = { "v1/classifiers", "classify" };
String[] pathParameters = { classifyOptions.classifierId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "classify");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("text", classifyOptions.text());
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classification.class));
} | java | public ServiceCall<Classification> classify(ClassifyOptions classifyOptions) {
Validator.notNull(classifyOptions, "classifyOptions cannot be null");
String[] pathSegments = { "v1/classifiers", "classify" };
String[] pathParameters = { classifyOptions.classifierId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "classify");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("text", classifyOptions.text());
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classification.class));
} | [
"public",
"ServiceCall",
"<",
"Classification",
">",
"classify",
"(",
"ClassifyOptions",
"classifyOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"classifyOptions",
",",
"\"classifyOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegments",
"=",
"... | Classify a phrase.
Returns label information for the input. The status must be `Available` before you can use the classifier to
classify text.
@param classifyOptions the {@link ClassifyOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Classification} | [
"Classify",
"a",
"phrase",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifier.java#L99-L114 | train |
watson-developer-cloud/java-sdk | natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifier.java | NaturalLanguageClassifier.classifyCollection | public ServiceCall<ClassificationCollection> classifyCollection(ClassifyCollectionOptions classifyCollectionOptions) {
Validator.notNull(classifyCollectionOptions, "classifyCollectionOptions cannot be null");
String[] pathSegments = { "v1/classifiers", "classify_collection" };
String[] pathParameters = { classifyCollectionOptions.classifierId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "classifyCollection");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.add("collection", GsonSingleton.getGson().toJsonTree(classifyCollectionOptions.collection()));
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ClassificationCollection.class));
} | java | public ServiceCall<ClassificationCollection> classifyCollection(ClassifyCollectionOptions classifyCollectionOptions) {
Validator.notNull(classifyCollectionOptions, "classifyCollectionOptions cannot be null");
String[] pathSegments = { "v1/classifiers", "classify_collection" };
String[] pathParameters = { classifyCollectionOptions.classifierId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "classifyCollection");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.add("collection", GsonSingleton.getGson().toJsonTree(classifyCollectionOptions.collection()));
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ClassificationCollection.class));
} | [
"public",
"ServiceCall",
"<",
"ClassificationCollection",
">",
"classifyCollection",
"(",
"ClassifyCollectionOptions",
"classifyCollectionOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"classifyCollectionOptions",
",",
"\"classifyCollectionOptions cannot be null\"",
")",
... | Classify multiple phrases.
Returns label information for multiple phrases. The status must be `Available` before you can use the classifier to
classify text.
Note that classifying Japanese texts is a beta feature.
@param classifyCollectionOptions the {@link ClassifyCollectionOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link ClassificationCollection} | [
"Classify",
"multiple",
"phrases",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifier.java#L127-L142 | train |
watson-developer-cloud/java-sdk | natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifier.java | NaturalLanguageClassifier.createClassifier | public ServiceCall<Classifier> createClassifier(CreateClassifierOptions createClassifierOptions) {
Validator.notNull(createClassifierOptions, "createClassifierOptions cannot be null");
String[] pathSegments = { "v1/classifiers" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "createClassifier");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
RequestBody trainingMetadataBody = RequestUtils.inputStreamBody(createClassifierOptions.metadata(),
"application/json");
multipartBuilder.addFormDataPart("training_metadata", "filename", trainingMetadataBody);
RequestBody trainingDataBody = RequestUtils.inputStreamBody(createClassifierOptions.trainingData(), "text/csv");
multipartBuilder.addFormDataPart("training_data", "filename", trainingDataBody);
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifier.class));
} | java | public ServiceCall<Classifier> createClassifier(CreateClassifierOptions createClassifierOptions) {
Validator.notNull(createClassifierOptions, "createClassifierOptions cannot be null");
String[] pathSegments = { "v1/classifiers" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("natural_language_classifier", "v1", "createClassifier");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
RequestBody trainingMetadataBody = RequestUtils.inputStreamBody(createClassifierOptions.metadata(),
"application/json");
multipartBuilder.addFormDataPart("training_metadata", "filename", trainingMetadataBody);
RequestBody trainingDataBody = RequestUtils.inputStreamBody(createClassifierOptions.trainingData(), "text/csv");
multipartBuilder.addFormDataPart("training_data", "filename", trainingDataBody);
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifier.class));
} | [
"public",
"ServiceCall",
"<",
"Classifier",
">",
"createClassifier",
"(",
"CreateClassifierOptions",
"createClassifierOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"createClassifierOptions",
",",
"\"createClassifierOptions cannot be null\"",
")",
";",
"String",
"[",... | Create classifier.
Sends data to create and train a classifier and returns information about the new classifier.
@param createClassifierOptions the {@link CreateClassifierOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Classifier} | [
"Create",
"classifier",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/natural-language-classifier/src/main/java/com/ibm/watson/natural_language_classifier/v1/NaturalLanguageClassifier.java#L152-L170 | train |
watson-developer-cloud/java-sdk | text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/WaveUtils.java | WaveUtils.writeInt | private static void writeInt(int value, byte[] array, int offset) {
for (int i = 0; i < 4; i++) {
array[offset + i] = (byte) (value >>> (8 * i));
}
} | java | private static void writeInt(int value, byte[] array, int offset) {
for (int i = 0; i < 4; i++) {
array[offset + i] = (byte) (value >>> (8 * i));
}
} | [
"private",
"static",
"void",
"writeInt",
"(",
"int",
"value",
",",
"byte",
"[",
"]",
"array",
",",
"int",
"offset",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"4",
";",
"i",
"++",
")",
"{",
"array",
"[",
"offset",
"+",
"i",
"]... | Writes an number into an array using 4 bytes.
@param value the number to write
@param array the byte array
@param offset the offset | [
"Writes",
"an",
"number",
"into",
"an",
"array",
"using",
"4",
"bytes",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/WaveUtils.java#L46-L50 | train |
watson-developer-cloud/java-sdk | speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/MediaTypeUtils.java | MediaTypeUtils.getMediaTypeFromFile | public static String getMediaTypeFromFile(final File file) {
if (file == null) {
return null;
}
final String fileName = file.getName();
final int i = fileName.lastIndexOf('.');
if (i == -1) {
return null;
}
return MEDIA_TYPES.get(fileName.substring(i).toLowerCase());
} | java | public static String getMediaTypeFromFile(final File file) {
if (file == null) {
return null;
}
final String fileName = file.getName();
final int i = fileName.lastIndexOf('.');
if (i == -1) {
return null;
}
return MEDIA_TYPES.get(fileName.substring(i).toLowerCase());
} | [
"public",
"static",
"String",
"getMediaTypeFromFile",
"(",
"final",
"File",
"file",
")",
"{",
"if",
"(",
"file",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"String",
"fileName",
"=",
"file",
".",
"getName",
"(",
")",
";",
"final",
"in... | Returns the media type for a given file.
@param file the file object for which media type needs to be provided
@return Internet media type for the file, or null if none found | [
"Returns",
"the",
"media",
"type",
"for",
"a",
"given",
"file",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/MediaTypeUtils.java#L54-L67 | train |
watson-developer-cloud/java-sdk | speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/MediaTypeUtils.java | MediaTypeUtils.isValidMediaType | public static boolean isValidMediaType(final String mediaType) {
return (mediaType != null) && MEDIA_TYPES.values().contains(mediaType.toLowerCase());
} | java | public static boolean isValidMediaType(final String mediaType) {
return (mediaType != null) && MEDIA_TYPES.values().contains(mediaType.toLowerCase());
} | [
"public",
"static",
"boolean",
"isValidMediaType",
"(",
"final",
"String",
"mediaType",
")",
"{",
"return",
"(",
"mediaType",
"!=",
"null",
")",
"&&",
"MEDIA_TYPES",
".",
"values",
"(",
")",
".",
"contains",
"(",
"mediaType",
".",
"toLowerCase",
"(",
")",
... | Checks if the media type is supported by the service.
@param mediaType Internet media type for the file
@return true if it is supported, false if not. | [
"Checks",
"if",
"the",
"media",
"type",
"is",
"supported",
"by",
"the",
"service",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/MediaTypeUtils.java#L75-L77 | train |
watson-developer-cloud/java-sdk | examples/src/main/java/com/ibm/watson/assistant/v1/tone_analyzer_integration/ToneDetection.java | ToneDetection.updateEmotionTone | @SuppressWarnings("unchecked")
private static void updateEmotionTone(Map<String, Object> user, List<ToneScore> emotionTone,
boolean maintainHistory) {
Double maxScore = 0.0;
String primaryEmotion = null;
Double primaryEmotionScore = null;
for (ToneScore tone : emotionTone) {
if (tone.getScore() > maxScore) {
maxScore = tone.getScore();
primaryEmotion = tone.getToneName().toLowerCase();
primaryEmotionScore = tone.getScore();
}
}
if (maxScore <= PRIMARY_EMOTION_SCORE_THRESHOLD) {
primaryEmotion = "neutral";
primaryEmotionScore = null;
}
// update user emotion tone
Map<String, Object> emotion = (Map<String, Object>) ((Map<String, Object>) (user.get("tone"))).get("emotion");
emotion.put("current", primaryEmotion);
if (maintainHistory) {
List<Map<String, Object>> history = new ArrayList<Map<String, Object>>();
if (emotion.get("history") != null) {
history = (List<Map<String, Object>>) emotion.get("history");
}
Map<String, Object> emotionHistoryObject = new HashMap<String, Object>();
emotionHistoryObject.put("tone_name", primaryEmotion);
emotionHistoryObject.put("score", primaryEmotionScore);
history.add(emotionHistoryObject);
emotion.put("history", history);
}
} | java | @SuppressWarnings("unchecked")
private static void updateEmotionTone(Map<String, Object> user, List<ToneScore> emotionTone,
boolean maintainHistory) {
Double maxScore = 0.0;
String primaryEmotion = null;
Double primaryEmotionScore = null;
for (ToneScore tone : emotionTone) {
if (tone.getScore() > maxScore) {
maxScore = tone.getScore();
primaryEmotion = tone.getToneName().toLowerCase();
primaryEmotionScore = tone.getScore();
}
}
if (maxScore <= PRIMARY_EMOTION_SCORE_THRESHOLD) {
primaryEmotion = "neutral";
primaryEmotionScore = null;
}
// update user emotion tone
Map<String, Object> emotion = (Map<String, Object>) ((Map<String, Object>) (user.get("tone"))).get("emotion");
emotion.put("current", primaryEmotion);
if (maintainHistory) {
List<Map<String, Object>> history = new ArrayList<Map<String, Object>>();
if (emotion.get("history") != null) {
history = (List<Map<String, Object>>) emotion.get("history");
}
Map<String, Object> emotionHistoryObject = new HashMap<String, Object>();
emotionHistoryObject.put("tone_name", primaryEmotion);
emotionHistoryObject.put("score", primaryEmotionScore);
history.add(emotionHistoryObject);
emotion.put("history", history);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"static",
"void",
"updateEmotionTone",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"user",
",",
"List",
"<",
"ToneScore",
">",
"emotionTone",
",",
"boolean",
"maintainHistory",
")",
"{",
"Double... | updateEmotionTone updates the user emotion tone with the primary emotion - the emotion tone that has a score
greater than or equal to the EMOTION_SCORE_THRESHOLD; otherwise primary emotion will be 'neutral'.
@param user a json object representing user information (tone) to be used in conversing with the Assistant
Service
@param emotionTone a json object containing the emotion tones in the payload returned by the Tone Analyzer | [
"updateEmotionTone",
"updates",
"the",
"user",
"emotion",
"tone",
"with",
"the",
"primary",
"emotion",
"-",
"the",
"emotion",
"tone",
"that",
"has",
"a",
"score",
"greater",
"than",
"or",
"equal",
"to",
"the",
"EMOTION_SCORE_THRESHOLD",
";",
"otherwise",
"primar... | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/examples/src/main/java/com/ibm/watson/assistant/v1/tone_analyzer_integration/ToneDetection.java#L144-L182 | train |
watson-developer-cloud/java-sdk | examples/src/main/java/com/ibm/watson/assistant/v1/tone_analyzer_integration/ToneDetection.java | ToneDetection.updateLanguageTone | @SuppressWarnings("unchecked")
private static void updateLanguageTone(Map<String, Object> user, List<ToneScore> languageTone,
boolean maintainHistory) {
List<String> currentLanguage = new ArrayList<String>();
Map<String, Object> currentLanguageObject = new HashMap<String, Object>();
// Process each language tone and determine if it is high or low
for (ToneScore tone : languageTone) {
if (tone.getScore() >= LANGUAGE_HIGH_SCORE_THRESHOLD) {
currentLanguage.add(tone.getToneName().toLowerCase() + "_high");
currentLanguageObject.put("tone_name", tone.getToneName().toLowerCase());
currentLanguageObject.put("score", tone.getScore());
currentLanguageObject.put("interpretation", "likely high");
} else if (tone.getScore() <= LANGUAGE_NO_SCORE_THRESHOLD) {
currentLanguageObject.put("tone_name", tone.getToneName().toLowerCase());
currentLanguageObject.put("score", tone.getScore());
currentLanguageObject.put("interpretation", "no evidence");
} else {
currentLanguageObject.put("tone_name", tone.getToneName().toLowerCase());
currentLanguageObject.put("score", tone.getScore());
currentLanguageObject.put("interpretation", "likely medium");
}
}
// update user language tone
Map<String, Object> language = (Map<String, Object>) ((Map<String, Object>) user.get("tone")).get("language");
// the current language pulled from tone
language.put("current", currentLanguage);
// if history needs to be maintained
if (maintainHistory) {
List<Map<String, Object>> history = new ArrayList<Map<String, Object>>();
if (language.get("history") != null) {
history = (List<Map<String, Object>>) language.get("history");
}
history.add(currentLanguageObject);
language.put("history", history);
}
} | java | @SuppressWarnings("unchecked")
private static void updateLanguageTone(Map<String, Object> user, List<ToneScore> languageTone,
boolean maintainHistory) {
List<String> currentLanguage = new ArrayList<String>();
Map<String, Object> currentLanguageObject = new HashMap<String, Object>();
// Process each language tone and determine if it is high or low
for (ToneScore tone : languageTone) {
if (tone.getScore() >= LANGUAGE_HIGH_SCORE_THRESHOLD) {
currentLanguage.add(tone.getToneName().toLowerCase() + "_high");
currentLanguageObject.put("tone_name", tone.getToneName().toLowerCase());
currentLanguageObject.put("score", tone.getScore());
currentLanguageObject.put("interpretation", "likely high");
} else if (tone.getScore() <= LANGUAGE_NO_SCORE_THRESHOLD) {
currentLanguageObject.put("tone_name", tone.getToneName().toLowerCase());
currentLanguageObject.put("score", tone.getScore());
currentLanguageObject.put("interpretation", "no evidence");
} else {
currentLanguageObject.put("tone_name", tone.getToneName().toLowerCase());
currentLanguageObject.put("score", tone.getScore());
currentLanguageObject.put("interpretation", "likely medium");
}
}
// update user language tone
Map<String, Object> language = (Map<String, Object>) ((Map<String, Object>) user.get("tone")).get("language");
// the current language pulled from tone
language.put("current", currentLanguage);
// if history needs to be maintained
if (maintainHistory) {
List<Map<String, Object>> history = new ArrayList<Map<String, Object>>();
if (language.get("history") != null) {
history = (List<Map<String, Object>>) language.get("history");
}
history.add(currentLanguageObject);
language.put("history", history);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"static",
"void",
"updateLanguageTone",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"user",
",",
"List",
"<",
"ToneScore",
">",
"languageTone",
",",
"boolean",
"maintainHistory",
")",
"{",
"List... | updateLanguageTone updates the user with the language tones interpreted based on the specified thresholds.
@param user a json object representing user information (tone) to be used in conversing with the Assistant
Service
@param languageTone a json object containing the language tones in the payload returned by the Tone Analyzer | [
"updateLanguageTone",
"updates",
"the",
"user",
"with",
"the",
"language",
"tones",
"interpreted",
"based",
"on",
"the",
"specified",
"thresholds",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/examples/src/main/java/com/ibm/watson/assistant/v1/tone_analyzer_integration/ToneDetection.java#L191-L231 | train |
watson-developer-cloud/java-sdk | examples/src/main/java/com/ibm/watson/assistant/v1/tone_analyzer_integration/ToneDetection.java | ToneDetection.updateSocialTone | @SuppressWarnings("unchecked")
public static void updateSocialTone(Map<String, Object> user, List<ToneScore> socialTone, boolean maintainHistory) {
List<String> currentSocial = new ArrayList<String>();
Map<String, Object> currentSocialObject = new HashMap<String, Object>();
for (ToneScore tone : socialTone) {
if (tone.getScore() >= SOCIAL_HIGH_SCORE_THRESHOLD) {
currentSocial.add(tone.getToneName().toLowerCase() + "_high");
currentSocialObject.put("tone_name", tone.getToneName().toLowerCase());
currentSocialObject.put("score", tone.getScore());
currentSocialObject.put("interpretation", "likely high");
} else if (tone.getScore() <= SOCIAL_LOW_SCORE_THRESHOLD) {
currentSocial.add(tone.getToneName().toLowerCase() + "_low");
currentSocialObject.put("tone_name", tone.getToneName().toLowerCase());
currentSocialObject.put("score", tone.getScore());
currentSocialObject.put("interpretation", "likely low");
} else {
currentSocialObject.put("tone_name", tone.getToneName().toLowerCase());
currentSocialObject.put("score", tone.getScore());
currentSocialObject.put("interpretation", "likely medium");
}
}
// update user language tone
Map<String, Object> social = (Map<String, Object>) ((Map<String, Object>) user.get("tone")).get("social");
social.put("current", currentSocial);
// if history needs to be maintained
if (maintainHistory) {
List<Map<String, Object>> history = new ArrayList<Map<String, Object>>();
if (social.get("history") != null) {
history = (List<Map<String, Object>>) social.get("history");
}
history.add(currentSocialObject);
social.put("history", history);
}
} | java | @SuppressWarnings("unchecked")
public static void updateSocialTone(Map<String, Object> user, List<ToneScore> socialTone, boolean maintainHistory) {
List<String> currentSocial = new ArrayList<String>();
Map<String, Object> currentSocialObject = new HashMap<String, Object>();
for (ToneScore tone : socialTone) {
if (tone.getScore() >= SOCIAL_HIGH_SCORE_THRESHOLD) {
currentSocial.add(tone.getToneName().toLowerCase() + "_high");
currentSocialObject.put("tone_name", tone.getToneName().toLowerCase());
currentSocialObject.put("score", tone.getScore());
currentSocialObject.put("interpretation", "likely high");
} else if (tone.getScore() <= SOCIAL_LOW_SCORE_THRESHOLD) {
currentSocial.add(tone.getToneName().toLowerCase() + "_low");
currentSocialObject.put("tone_name", tone.getToneName().toLowerCase());
currentSocialObject.put("score", tone.getScore());
currentSocialObject.put("interpretation", "likely low");
} else {
currentSocialObject.put("tone_name", tone.getToneName().toLowerCase());
currentSocialObject.put("score", tone.getScore());
currentSocialObject.put("interpretation", "likely medium");
}
}
// update user language tone
Map<String, Object> social = (Map<String, Object>) ((Map<String, Object>) user.get("tone")).get("social");
social.put("current", currentSocial);
// if history needs to be maintained
if (maintainHistory) {
List<Map<String, Object>> history = new ArrayList<Map<String, Object>>();
if (social.get("history") != null) {
history = (List<Map<String, Object>>) social.get("history");
}
history.add(currentSocialObject);
social.put("history", history);
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"void",
"updateSocialTone",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"user",
",",
"List",
"<",
"ToneScore",
">",
"socialTone",
",",
"boolean",
"maintainHistory",
")",
"{",
"List",
... | updateSocialTone updates the user with the social tones interpreted based on the specified thresholds.
@param user a json object representing user information (tone) to be used in conversing with the Assistant
Service
@param socialTone a json object containing the social tones in the payload returned by the Tone Analyzer
@param maintainHistory the maintain history | [
"updateSocialTone",
"updates",
"the",
"user",
"with",
"the",
"social",
"tones",
"interpreted",
"based",
"on",
"the",
"specified",
"thresholds",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/examples/src/main/java/com/ibm/watson/assistant/v1/tone_analyzer_integration/ToneDetection.java#L241-L278 | train |
watson-developer-cloud/java-sdk | visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java | VisualRecognition.classify | public ServiceCall<ClassifiedImages> classify(ClassifyOptions classifyOptions) {
Validator.notNull(classifyOptions, "classifyOptions cannot be null");
Validator.isTrue((classifyOptions.imagesFile() != null) || (classifyOptions.url() != null) || (classifyOptions
.threshold() != null) || (classifyOptions.owners() != null) || (classifyOptions.classifierIds() != null),
"At least one of imagesFile, url, threshold, owners, or classifierIds must be supplied.");
String[] pathSegments = { "v3/classify" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "classify");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (classifyOptions.acceptLanguage() != null) {
builder.header("Accept-Language", classifyOptions.acceptLanguage());
}
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
if (classifyOptions.imagesFile() != null) {
RequestBody imagesFileBody = RequestUtils.inputStreamBody(classifyOptions.imagesFile(), classifyOptions
.imagesFileContentType());
multipartBuilder.addFormDataPart("images_file", classifyOptions.imagesFilename(), imagesFileBody);
}
if (classifyOptions.url() != null) {
multipartBuilder.addFormDataPart("url", classifyOptions.url());
}
if (classifyOptions.threshold() != null) {
multipartBuilder.addFormDataPart("threshold", String.valueOf(classifyOptions.threshold()));
}
if (classifyOptions.owners() != null) {
multipartBuilder.addFormDataPart("owners", RequestUtils.join(classifyOptions.owners(), ","));
}
if (classifyOptions.classifierIds() != null) {
multipartBuilder.addFormDataPart("classifier_ids", RequestUtils.join(classifyOptions.classifierIds(), ","));
}
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ClassifiedImages.class));
} | java | public ServiceCall<ClassifiedImages> classify(ClassifyOptions classifyOptions) {
Validator.notNull(classifyOptions, "classifyOptions cannot be null");
Validator.isTrue((classifyOptions.imagesFile() != null) || (classifyOptions.url() != null) || (classifyOptions
.threshold() != null) || (classifyOptions.owners() != null) || (classifyOptions.classifierIds() != null),
"At least one of imagesFile, url, threshold, owners, or classifierIds must be supplied.");
String[] pathSegments = { "v3/classify" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "classify");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (classifyOptions.acceptLanguage() != null) {
builder.header("Accept-Language", classifyOptions.acceptLanguage());
}
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
if (classifyOptions.imagesFile() != null) {
RequestBody imagesFileBody = RequestUtils.inputStreamBody(classifyOptions.imagesFile(), classifyOptions
.imagesFileContentType());
multipartBuilder.addFormDataPart("images_file", classifyOptions.imagesFilename(), imagesFileBody);
}
if (classifyOptions.url() != null) {
multipartBuilder.addFormDataPart("url", classifyOptions.url());
}
if (classifyOptions.threshold() != null) {
multipartBuilder.addFormDataPart("threshold", String.valueOf(classifyOptions.threshold()));
}
if (classifyOptions.owners() != null) {
multipartBuilder.addFormDataPart("owners", RequestUtils.join(classifyOptions.owners(), ","));
}
if (classifyOptions.classifierIds() != null) {
multipartBuilder.addFormDataPart("classifier_ids", RequestUtils.join(classifyOptions.classifierIds(), ","));
}
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ClassifiedImages.class));
} | [
"public",
"ServiceCall",
"<",
"ClassifiedImages",
">",
"classify",
"(",
"ClassifyOptions",
"classifyOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"classifyOptions",
",",
"\"classifyOptions cannot be null\"",
")",
";",
"Validator",
".",
"isTrue",
"(",
"(",
"c... | Classify images.
Classify images with built-in or custom classifiers.
@param classifyOptions the {@link ClassifyOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link ClassifiedImages} | [
"Classify",
"images",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java#L98-L135 | train |
watson-developer-cloud/java-sdk | visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java | VisualRecognition.detectFaces | public ServiceCall<DetectedFaces> detectFaces(DetectFacesOptions detectFacesOptions) {
Validator.notNull(detectFacesOptions, "detectFacesOptions cannot be null");
Validator.isTrue((detectFacesOptions.imagesFile() != null) || (detectFacesOptions.url() != null),
"At least one of imagesFile or url must be supplied.");
String[] pathSegments = { "v3/detect_faces" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "detectFaces");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (detectFacesOptions.acceptLanguage() != null) {
builder.header("Accept-Language", detectFacesOptions.acceptLanguage());
}
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
if (detectFacesOptions.imagesFile() != null) {
RequestBody imagesFileBody = RequestUtils.inputStreamBody(detectFacesOptions.imagesFile(), detectFacesOptions
.imagesFileContentType());
multipartBuilder.addFormDataPart("images_file", detectFacesOptions.imagesFilename(), imagesFileBody);
}
if (detectFacesOptions.url() != null) {
multipartBuilder.addFormDataPart("url", detectFacesOptions.url());
}
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DetectedFaces.class));
} | java | public ServiceCall<DetectedFaces> detectFaces(DetectFacesOptions detectFacesOptions) {
Validator.notNull(detectFacesOptions, "detectFacesOptions cannot be null");
Validator.isTrue((detectFacesOptions.imagesFile() != null) || (detectFacesOptions.url() != null),
"At least one of imagesFile or url must be supplied.");
String[] pathSegments = { "v3/detect_faces" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "detectFaces");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (detectFacesOptions.acceptLanguage() != null) {
builder.header("Accept-Language", detectFacesOptions.acceptLanguage());
}
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
if (detectFacesOptions.imagesFile() != null) {
RequestBody imagesFileBody = RequestUtils.inputStreamBody(detectFacesOptions.imagesFile(), detectFacesOptions
.imagesFileContentType());
multipartBuilder.addFormDataPart("images_file", detectFacesOptions.imagesFilename(), imagesFileBody);
}
if (detectFacesOptions.url() != null) {
multipartBuilder.addFormDataPart("url", detectFacesOptions.url());
}
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DetectedFaces.class));
} | [
"public",
"ServiceCall",
"<",
"DetectedFaces",
">",
"detectFaces",
"(",
"DetectFacesOptions",
"detectFacesOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"detectFacesOptions",
",",
"\"detectFacesOptions cannot be null\"",
")",
";",
"Validator",
".",
"isTrue",
"(",... | Detect faces in images.
**Important:** On April 2, 2018, the identity information in the response to calls to the Face model was removed.
The identity information refers to the `name` of the person, `score`, and `type_hierarchy` knowledge graph. For
details about the enhanced Face model, see the [Release
notes](https://cloud.ibm.com/docs/services/visual-recognition/release-notes.html#2april2018).
Analyze and get data about faces in images. Responses can include estimated age and gender. This feature uses a
built-in model, so no training is necessary. The Detect faces method does not support general biometric facial
recognition.
Supported image formats include .gif, .jpg, .png, and .tif. The maximum image size is 10 MB. The minimum
recommended pixel density is 32X32 pixels, but the service tends to perform better with images that are at least
224 x 224 pixels.
@param detectFacesOptions the {@link DetectFacesOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link DetectedFaces} | [
"Detect",
"faces",
"in",
"images",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java#L167-L194 | train |
watson-developer-cloud/java-sdk | visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java | VisualRecognition.deleteClassifier | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "deleteClassifier");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | java | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "deleteClassifier");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | [
"public",
"ServiceCall",
"<",
"Void",
">",
"deleteClassifier",
"(",
"DeleteClassifierOptions",
"deleteClassifierOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"deleteClassifierOptions",
",",
"\"deleteClassifierOptions cannot be null\"",
")",
";",
"String",
"[",
"]"... | Delete a classifier.
@param deleteClassifierOptions the {@link DeleteClassifierOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of Void | [
"Delete",
"a",
"classifier",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java#L265-L278 | train |
watson-developer-cloud/java-sdk | visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java | VisualRecognition.getClassifier | public ServiceCall<Classifier> getClassifier(GetClassifierOptions getClassifierOptions) {
Validator.notNull(getClassifierOptions, "getClassifierOptions cannot be null");
String[] pathSegments = { "v3/classifiers" };
String[] pathParameters = { getClassifierOptions.classifierId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "getClassifier");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifier.class));
} | java | public ServiceCall<Classifier> getClassifier(GetClassifierOptions getClassifierOptions) {
Validator.notNull(getClassifierOptions, "getClassifierOptions cannot be null");
String[] pathSegments = { "v3/classifiers" };
String[] pathParameters = { getClassifierOptions.classifierId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "getClassifier");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifier.class));
} | [
"public",
"ServiceCall",
"<",
"Classifier",
">",
"getClassifier",
"(",
"GetClassifierOptions",
"getClassifierOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"getClassifierOptions",
",",
"\"getClassifierOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"path... | Retrieve classifier details.
Retrieve information about a custom classifier.
@param getClassifierOptions the {@link GetClassifierOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Classifier} | [
"Retrieve",
"classifier",
"details",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java#L288-L301 | train |
watson-developer-cloud/java-sdk | visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java | VisualRecognition.listClassifiers | public ServiceCall<Classifiers> listClassifiers(ListClassifiersOptions listClassifiersOptions) {
String[] pathSegments = { "v3/classifiers" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "listClassifiers");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listClassifiersOptions != null) {
if (listClassifiersOptions.verbose() != null) {
builder.query("verbose", String.valueOf(listClassifiersOptions.verbose()));
}
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifiers.class));
} | java | public ServiceCall<Classifiers> listClassifiers(ListClassifiersOptions listClassifiersOptions) {
String[] pathSegments = { "v3/classifiers" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "listClassifiers");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listClassifiersOptions != null) {
if (listClassifiersOptions.verbose() != null) {
builder.query("verbose", String.valueOf(listClassifiersOptions.verbose()));
}
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifiers.class));
} | [
"public",
"ServiceCall",
"<",
"Classifiers",
">",
"listClassifiers",
"(",
"ListClassifiersOptions",
"listClassifiersOptions",
")",
"{",
"String",
"[",
"]",
"pathSegments",
"=",
"{",
"\"v3/classifiers\"",
"}",
";",
"RequestBuilder",
"builder",
"=",
"RequestBuilder",
".... | Retrieve a list of classifiers.
@param listClassifiersOptions the {@link ListClassifiersOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Classifiers} | [
"Retrieve",
"a",
"list",
"of",
"classifiers",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java#L309-L324 | train |
watson-developer-cloud/java-sdk | visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java | VisualRecognition.updateClassifier | public ServiceCall<Classifier> updateClassifier(UpdateClassifierOptions updateClassifierOptions) {
Validator.notNull(updateClassifierOptions, "updateClassifierOptions cannot be null");
Validator.isTrue((updateClassifierOptions.positiveExamples() != null) || (updateClassifierOptions
.negativeExamples() != null), "At least one of positiveExamples or negativeExamples must be supplied.");
String[] pathSegments = { "v3/classifiers" };
String[] pathParameters = { updateClassifierOptions.classifierId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "updateClassifier");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
if (updateClassifierOptions.positiveExamples() != null) {
for (Map.Entry<String, InputStream> entry : updateClassifierOptions.positiveExamples().entrySet()) {
String partName = String.format("%s_positive_examples", entry.getKey());
RequestBody part = RequestUtils.inputStreamBody(entry.getValue(), "application/octet-stream");
multipartBuilder.addFormDataPart(partName, entry.getKey(), part);
}
}
if (updateClassifierOptions.negativeExamples() != null) {
RequestBody negativeExamplesBody = RequestUtils.inputStreamBody(updateClassifierOptions.negativeExamples(),
"application/octet-stream");
multipartBuilder.addFormDataPart("negative_examples", updateClassifierOptions.negativeExamplesFilename(),
negativeExamplesBody);
}
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifier.class));
} | java | public ServiceCall<Classifier> updateClassifier(UpdateClassifierOptions updateClassifierOptions) {
Validator.notNull(updateClassifierOptions, "updateClassifierOptions cannot be null");
Validator.isTrue((updateClassifierOptions.positiveExamples() != null) || (updateClassifierOptions
.negativeExamples() != null), "At least one of positiveExamples or negativeExamples must be supplied.");
String[] pathSegments = { "v3/classifiers" };
String[] pathParameters = { updateClassifierOptions.classifierId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "updateClassifier");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
if (updateClassifierOptions.positiveExamples() != null) {
for (Map.Entry<String, InputStream> entry : updateClassifierOptions.positiveExamples().entrySet()) {
String partName = String.format("%s_positive_examples", entry.getKey());
RequestBody part = RequestUtils.inputStreamBody(entry.getValue(), "application/octet-stream");
multipartBuilder.addFormDataPart(partName, entry.getKey(), part);
}
}
if (updateClassifierOptions.negativeExamples() != null) {
RequestBody negativeExamplesBody = RequestUtils.inputStreamBody(updateClassifierOptions.negativeExamples(),
"application/octet-stream");
multipartBuilder.addFormDataPart("negative_examples", updateClassifierOptions.negativeExamplesFilename(),
negativeExamplesBody);
}
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifier.class));
} | [
"public",
"ServiceCall",
"<",
"Classifier",
">",
"updateClassifier",
"(",
"UpdateClassifierOptions",
"updateClassifierOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"updateClassifierOptions",
",",
"\"updateClassifierOptions cannot be null\"",
")",
";",
"Validator",
"... | Update a classifier.
Update a custom classifier by adding new positive or negative classes or by adding new images to existing classes.
You must supply at least one set of positive or negative examples. For details, see [Updating custom
classifiers](https://cloud.ibm.com/docs/services/visual-recognition/customizing.html#updating-custom-classifiers).
Encode all names in UTF-8 if they contain non-ASCII characters (.zip and image file names, and classifier and class
names). The service assumes UTF-8 encoding if it encounters non-ASCII characters.
**Tip:** Don't make retraining calls on a classifier until the status is ready. When you submit retraining requests
in parallel, the last request overwrites the previous requests. The retrained property shows the last time the
classifier retraining finished.
@param updateClassifierOptions the {@link UpdateClassifierOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Classifier} | [
"Update",
"a",
"classifier",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java#L352-L383 | train |
watson-developer-cloud/java-sdk | visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java | VisualRecognition.getCoreMlModel | public ServiceCall<InputStream> getCoreMlModel(GetCoreMlModelOptions getCoreMlModelOptions) {
Validator.notNull(getCoreMlModelOptions, "getCoreMlModelOptions cannot be null");
String[] pathSegments = { "v3/classifiers", "core_ml_model" };
String[] pathParameters = { getCoreMlModelOptions.classifierId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "getCoreMlModel");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/octet-stream");
return createServiceCall(builder.build(), ResponseConverterUtils.getInputStream());
} | java | public ServiceCall<InputStream> getCoreMlModel(GetCoreMlModelOptions getCoreMlModelOptions) {
Validator.notNull(getCoreMlModelOptions, "getCoreMlModelOptions cannot be null");
String[] pathSegments = { "v3/classifiers", "core_ml_model" };
String[] pathParameters = { getCoreMlModelOptions.classifierId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "getCoreMlModel");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/octet-stream");
return createServiceCall(builder.build(), ResponseConverterUtils.getInputStream());
} | [
"public",
"ServiceCall",
"<",
"InputStream",
">",
"getCoreMlModel",
"(",
"GetCoreMlModelOptions",
"getCoreMlModelOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"getCoreMlModelOptions",
",",
"\"getCoreMlModelOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
... | Retrieve a Core ML model of a classifier.
Download a Core ML model file (.mlmodel) of a custom classifier that returns <tt>\"core_ml_enabled\": true</tt> in
the classifier details.
@param getCoreMlModelOptions the {@link GetCoreMlModelOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link InputStream} | [
"Retrieve",
"a",
"Core",
"ML",
"model",
"of",
"a",
"classifier",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java#L394-L407 | train |
watson-developer-cloud/java-sdk | visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java | VisualRecognition.deleteUserData | public ServiceCall<Void> deleteUserData(DeleteUserDataOptions deleteUserDataOptions) {
Validator.notNull(deleteUserDataOptions, "deleteUserDataOptions cannot be null");
String[] pathSegments = { "v3/user_data" };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "deleteUserData");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("customer_id", deleteUserDataOptions.customerId());
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | java | public ServiceCall<Void> deleteUserData(DeleteUserDataOptions deleteUserDataOptions) {
Validator.notNull(deleteUserDataOptions, "deleteUserDataOptions cannot be null");
String[] pathSegments = { "v3/user_data" };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("watson_vision_combined", "v3", "deleteUserData");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("customer_id", deleteUserDataOptions.customerId());
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | [
"public",
"ServiceCall",
"<",
"Void",
">",
"deleteUserData",
"(",
"DeleteUserDataOptions",
"deleteUserDataOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"deleteUserDataOptions",
",",
"\"deleteUserDataOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathS... | Delete labeled data.
Deletes all data associated with a specified customer ID. The method has no effect if no data is associated with
the customer ID.
You associate a customer ID with data by passing the `X-Watson-Metadata` header with a request that passes data.
For more information about personal data and customer IDs, see [Information
security](https://cloud.ibm.com/docs/services/visual-recognition/information-security.html).
@param deleteUserDataOptions the {@link DeleteUserDataOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of Void | [
"Delete",
"labeled",
"data",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/visual-recognition/src/main/java/com/ibm/watson/visual_recognition/v3/VisualRecognition.java#L422-L434 | train |
watson-developer-cloud/java-sdk | examples/src/main/java/com/ibm/watson/text_to_speech/v1/TranslateAndSynthesizeExample.java | TranslateAndSynthesizeExample.writeToFile | private static void writeToFile(InputStream in, File file) {
try {
OutputStream out = new FileOutputStream(file);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.close();
in.close();
} catch (Exception e) {
e.printStackTrace();
}
} | java | private static void writeToFile(InputStream in, File file) {
try {
OutputStream out = new FileOutputStream(file);
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.close();
in.close();
} catch (Exception e) {
e.printStackTrace();
}
} | [
"private",
"static",
"void",
"writeToFile",
"(",
"InputStream",
"in",
",",
"File",
"file",
")",
"{",
"try",
"{",
"OutputStream",
"out",
"=",
"new",
"FileOutputStream",
"(",
"file",
")",
";",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"1024",
"]"... | Write the input stream to a file. | [
"Write",
"the",
"input",
"stream",
"to",
"a",
"file",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/examples/src/main/java/com/ibm/watson/text_to_speech/v1/TranslateAndSynthesizeExample.java#L71-L84 | train |
watson-developer-cloud/java-sdk | natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstanding.java | NaturalLanguageUnderstanding.analyze | public ServiceCall<AnalysisResults> analyze(AnalyzeOptions analyzeOptions) {
Validator.notNull(analyzeOptions, "analyzeOptions cannot be null");
String[] pathSegments = { "v1/analyze" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "analyze");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.add("features", GsonSingleton.getGson().toJsonTree(analyzeOptions.features()));
if (analyzeOptions.text() != null) {
contentJson.addProperty("text", analyzeOptions.text());
}
if (analyzeOptions.html() != null) {
contentJson.addProperty("html", analyzeOptions.html());
}
if (analyzeOptions.url() != null) {
contentJson.addProperty("url", analyzeOptions.url());
}
if (analyzeOptions.clean() != null) {
contentJson.addProperty("clean", analyzeOptions.clean());
}
if (analyzeOptions.xpath() != null) {
contentJson.addProperty("xpath", analyzeOptions.xpath());
}
if (analyzeOptions.fallbackToRaw() != null) {
contentJson.addProperty("fallback_to_raw", analyzeOptions.fallbackToRaw());
}
if (analyzeOptions.returnAnalyzedText() != null) {
contentJson.addProperty("return_analyzed_text", analyzeOptions.returnAnalyzedText());
}
if (analyzeOptions.language() != null) {
contentJson.addProperty("language", analyzeOptions.language());
}
if (analyzeOptions.limitTextCharacters() != null) {
contentJson.addProperty("limit_text_characters", analyzeOptions.limitTextCharacters());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(AnalysisResults.class));
} | java | public ServiceCall<AnalysisResults> analyze(AnalyzeOptions analyzeOptions) {
Validator.notNull(analyzeOptions, "analyzeOptions cannot be null");
String[] pathSegments = { "v1/analyze" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("natural-language-understanding", "v1", "analyze");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.add("features", GsonSingleton.getGson().toJsonTree(analyzeOptions.features()));
if (analyzeOptions.text() != null) {
contentJson.addProperty("text", analyzeOptions.text());
}
if (analyzeOptions.html() != null) {
contentJson.addProperty("html", analyzeOptions.html());
}
if (analyzeOptions.url() != null) {
contentJson.addProperty("url", analyzeOptions.url());
}
if (analyzeOptions.clean() != null) {
contentJson.addProperty("clean", analyzeOptions.clean());
}
if (analyzeOptions.xpath() != null) {
contentJson.addProperty("xpath", analyzeOptions.xpath());
}
if (analyzeOptions.fallbackToRaw() != null) {
contentJson.addProperty("fallback_to_raw", analyzeOptions.fallbackToRaw());
}
if (analyzeOptions.returnAnalyzedText() != null) {
contentJson.addProperty("return_analyzed_text", analyzeOptions.returnAnalyzedText());
}
if (analyzeOptions.language() != null) {
contentJson.addProperty("language", analyzeOptions.language());
}
if (analyzeOptions.limitTextCharacters() != null) {
contentJson.addProperty("limit_text_characters", analyzeOptions.limitTextCharacters());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(AnalysisResults.class));
} | [
"public",
"ServiceCall",
"<",
"AnalysisResults",
">",
"analyze",
"(",
"AnalyzeOptions",
"analyzeOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"analyzeOptions",
",",
"\"analyzeOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegments",
"=",
"{",
... | Analyze text.
Analyzes text, HTML, or a public webpage for the following features:
- Categories
- Concepts
- Emotion
- Entities
- Keywords
- Metadata
- Relations
- Semantic roles
- Sentiment
- Syntax (Experimental).
@param analyzeOptions the {@link AnalyzeOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link AnalysisResults} | [
"Analyze",
"text",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstanding.java#L115-L156 | train |
watson-developer-cloud/java-sdk | text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/TextToSpeechWebSocketListener.java | TextToSpeechWebSocketListener.buildStopMessage | private String buildStopMessage() {
JsonObject stopMessage = new JsonObject();
stopMessage.addProperty(ACTION, STOP);
return stopMessage.toString();
} | java | private String buildStopMessage() {
JsonObject stopMessage = new JsonObject();
stopMessage.addProperty(ACTION, STOP);
return stopMessage.toString();
} | [
"private",
"String",
"buildStopMessage",
"(",
")",
"{",
"JsonObject",
"stopMessage",
"=",
"new",
"JsonObject",
"(",
")",
";",
"stopMessage",
".",
"addProperty",
"(",
"ACTION",
",",
"STOP",
")",
";",
"return",
"stopMessage",
".",
"toString",
"(",
")",
";",
... | Builds the stop message.
@return the string | [
"Builds",
"the",
"stop",
"message",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/TextToSpeechWebSocketListener.java#L170-L174 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/query/AggregationDeserializer.java | AggregationDeserializer.parseArray | private void parseArray(JsonReader in, HashMap<String, Object> objMap, String name) throws IOException {
List<HashMap<String, Object>> array = new ArrayList<>();
in.beginArray();
while (in.peek() != JsonToken.END_ARRAY) {
HashMap<String, Object> arrayItem = new HashMap<>();
parseNext(in, arrayItem);
array.add(arrayItem);
}
in.endArray();
objMap.put(name, array);
} | java | private void parseArray(JsonReader in, HashMap<String, Object> objMap, String name) throws IOException {
List<HashMap<String, Object>> array = new ArrayList<>();
in.beginArray();
while (in.peek() != JsonToken.END_ARRAY) {
HashMap<String, Object> arrayItem = new HashMap<>();
parseNext(in, arrayItem);
array.add(arrayItem);
}
in.endArray();
objMap.put(name, array);
} | [
"private",
"void",
"parseArray",
"(",
"JsonReader",
"in",
",",
"HashMap",
"<",
"String",
",",
"Object",
">",
"objMap",
",",
"String",
"name",
")",
"throws",
"IOException",
"{",
"List",
"<",
"HashMap",
"<",
"String",
",",
"Object",
">",
">",
"array",
"=",... | Parses a JSON array and adds it to the main object map.
@param in {@link JsonReader} object used for parsing
@param objMap Map used to build the structure for the resulting {@link QueryAggregation} object
@param name key value to go with the resulting value of this method pass
@throws IOException signals that there has been an IO exception | [
"Parses",
"a",
"JSON",
"array",
"and",
"adds",
"it",
"to",
"the",
"main",
"object",
"map",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/query/AggregationDeserializer.java#L157-L169 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/query/AggregationDeserializer.java | AggregationDeserializer.parseObject | private void parseObject(JsonReader in, HashMap<String, Object> objMap, String name) throws IOException {
HashMap<String, Object> innerObject = new HashMap<>();
in.beginObject();
while (in.peek() != JsonToken.END_OBJECT) {
parseNext(in, innerObject);
}
in.endObject();
objMap.put(name, innerObject);
} | java | private void parseObject(JsonReader in, HashMap<String, Object> objMap, String name) throws IOException {
HashMap<String, Object> innerObject = new HashMap<>();
in.beginObject();
while (in.peek() != JsonToken.END_OBJECT) {
parseNext(in, innerObject);
}
in.endObject();
objMap.put(name, innerObject);
} | [
"private",
"void",
"parseObject",
"(",
"JsonReader",
"in",
",",
"HashMap",
"<",
"String",
",",
"Object",
">",
"objMap",
",",
"String",
"name",
")",
"throws",
"IOException",
"{",
"HashMap",
"<",
"String",
",",
"Object",
">",
"innerObject",
"=",
"new",
"Hash... | Parses a JSON object and adds it to the main object map.
@param in {@link JsonReader} object used for parsing
@param objMap Map used to build the structure for the resulting {@link QueryAggregation} object
@param name key value to go with the resulting value of this method pass
@throws IOException signals that there has been an IO exception | [
"Parses",
"a",
"JSON",
"object",
"and",
"adds",
"it",
"to",
"the",
"main",
"object",
"map",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/query/AggregationDeserializer.java#L179-L189 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/query/AggregationDeserializer.java | AggregationDeserializer.collapseMap | private void collapseMap(HashMap<String, Object> objMap) {
while (objMap.keySet().size() == 1 && objMap.keySet().contains("")) {
HashMap<String, Object> innerMap = (HashMap<String, Object>) objMap.get("");
objMap.clear();
objMap.putAll(innerMap);
}
} | java | private void collapseMap(HashMap<String, Object> objMap) {
while (objMap.keySet().size() == 1 && objMap.keySet().contains("")) {
HashMap<String, Object> innerMap = (HashMap<String, Object>) objMap.get("");
objMap.clear();
objMap.putAll(innerMap);
}
} | [
"private",
"void",
"collapseMap",
"(",
"HashMap",
"<",
"String",
",",
"Object",
">",
"objMap",
")",
"{",
"while",
"(",
"objMap",
".",
"keySet",
"(",
")",
".",
"size",
"(",
")",
"==",
"1",
"&&",
"objMap",
".",
"keySet",
"(",
")",
".",
"contains",
"(... | Condenses the main object map to eliminate unnecessary nesting and allow for proper type conversion when the map
is complete.
@param objMap Map used to build the structure for the resulting {@link QueryAggregation} object | [
"Condenses",
"the",
"main",
"object",
"map",
"to",
"eliminate",
"unnecessary",
"nesting",
"and",
"allow",
"for",
"proper",
"type",
"conversion",
"when",
"the",
"map",
"is",
"complete",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/query/AggregationDeserializer.java#L197-L203 | train |
watson-developer-cloud/java-sdk | personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/PersonalityInsights.java | PersonalityInsights.profile | public ServiceCall<Profile> profile(ProfileOptions profileOptions) {
Validator.notNull(profileOptions, "profileOptions cannot be null");
String[] pathSegments = { "v3/profile" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("personality_insights", "v3", "profile");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (profileOptions.contentLanguage() != null) {
builder.header("Content-Language", profileOptions.contentLanguage());
}
if (profileOptions.acceptLanguage() != null) {
builder.header("Accept-Language", profileOptions.acceptLanguage());
}
if (profileOptions.contentType() != null) {
builder.header("Content-Type", profileOptions.contentType());
}
if (profileOptions.rawScores() != null) {
builder.query("raw_scores", String.valueOf(profileOptions.rawScores()));
}
if (profileOptions.csvHeaders() != null) {
builder.query("csv_headers", String.valueOf(profileOptions.csvHeaders()));
}
if (profileOptions.consumptionPreferences() != null) {
builder.query("consumption_preferences", String.valueOf(profileOptions.consumptionPreferences()));
}
builder.bodyContent(profileOptions.contentType(), profileOptions.content(), null, profileOptions.body());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Profile.class));
} | java | public ServiceCall<Profile> profile(ProfileOptions profileOptions) {
Validator.notNull(profileOptions, "profileOptions cannot be null");
String[] pathSegments = { "v3/profile" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("personality_insights", "v3", "profile");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (profileOptions.contentLanguage() != null) {
builder.header("Content-Language", profileOptions.contentLanguage());
}
if (profileOptions.acceptLanguage() != null) {
builder.header("Accept-Language", profileOptions.acceptLanguage());
}
if (profileOptions.contentType() != null) {
builder.header("Content-Type", profileOptions.contentType());
}
if (profileOptions.rawScores() != null) {
builder.query("raw_scores", String.valueOf(profileOptions.rawScores()));
}
if (profileOptions.csvHeaders() != null) {
builder.query("csv_headers", String.valueOf(profileOptions.csvHeaders()));
}
if (profileOptions.consumptionPreferences() != null) {
builder.query("consumption_preferences", String.valueOf(profileOptions.consumptionPreferences()));
}
builder.bodyContent(profileOptions.contentType(), profileOptions.content(), null, profileOptions.body());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Profile.class));
} | [
"public",
"ServiceCall",
"<",
"Profile",
">",
"profile",
"(",
"ProfileOptions",
"profileOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"profileOptions",
",",
"\"profileOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"pathSegments",
"=",
"{",
"\"v3/... | Get profile.
Generates a personality profile for the author of the input text. The service accepts a maximum of 20 MB of input
content, but it requires much less text to produce an accurate profile. The service can analyze text in Arabic,
English, Japanese, Korean, or Spanish. It can return its results in a variety of languages.
**See also:**
* [Requesting a profile](https://cloud.ibm.com/docs/services/personality-insights/input.html)
* [Providing sufficient input](https://cloud.ibm.com/docs/services/personality-insights/input.html#sufficient)
### Content types
You can provide input content as plain text (`text/plain`), HTML (`text/html`), or JSON (`application/json`) by
specifying the **Content-Type** parameter. The default is `text/plain`.
* Per the JSON specification, the default character encoding for JSON content is effectively always UTF-8.
* Per the HTTP specification, the default encoding for plain text and HTML is ISO-8859-1 (effectively, the ASCII
character set).
When specifying a content type of plain text or HTML, include the `charset` parameter to indicate the character
encoding of the input text; for example, `Content-Type: text/plain;charset=utf-8`.
**See also:** [Specifying request and response
formats](https://cloud.ibm.com/docs/services/personality-insights/input.html#formats)
### Accept types
You must request a response as JSON (`application/json`) or comma-separated values (`text/csv`) by specifying the
**Accept** parameter. CSV output includes a fixed number of columns. Set the **csv_headers** parameter to `true` to
request optional column headers for CSV output.
**See also:**
* [Understanding a JSON profile](https://cloud.ibm.com/docs/services/personality-insights/output.html)
* [Understanding a CSV profile](https://cloud.ibm.com/docs/services/personality-insights/output-csv.html).
@param profileOptions the {@link ProfileOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Profile} | [
"Get",
"profile",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/personality-insights/src/main/java/com/ibm/watson/personality_insights/v3/PersonalityInsights.java#L140-L170 | train |
watson-developer-cloud/java-sdk | speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/SpeechToTextWebSocketListener.java | SpeechToTextWebSocketListener.sendInputStream | private void sendInputStream(InputStream inputStream) {
byte[] buffer = new byte[ONE_KB];
int read;
try {
// This method uses a blocking while loop to receive all contents of the underlying input stream.
// AudioInputStreams, typically used for streaming microphone inputs return 0 only when the stream has been
// closed. Elsewise AudioInputStream.read() blocks until enough audio frames are read.
while (((read = inputStream.read(buffer)) > 0) && socketOpen) {
// If OkHttp's WebSocket queue gets overwhelmed, it'll abruptly close the connection
// (see: https://github.com/square/okhttp/issues/3317). This will ensure we wait until the coast is clear.
while (socket.queueSize() > QUEUE_SIZE_LIMIT) {
Thread.sleep(QUEUE_WAIT_MILLIS);
}
if (read == ONE_KB) {
socket.send(ByteString.of(buffer));
} else {
socket.send(ByteString.of(Arrays.copyOfRange(buffer, 0, read)));
}
}
} catch (IOException | InterruptedException e) {
LOG.log(Level.SEVERE, e.getMessage(), e);
} finally {
try {
inputStream.close();
} catch (IOException e) {
// do nothing - the InputStream may have already been closed externally.
}
}
} | java | private void sendInputStream(InputStream inputStream) {
byte[] buffer = new byte[ONE_KB];
int read;
try {
// This method uses a blocking while loop to receive all contents of the underlying input stream.
// AudioInputStreams, typically used for streaming microphone inputs return 0 only when the stream has been
// closed. Elsewise AudioInputStream.read() blocks until enough audio frames are read.
while (((read = inputStream.read(buffer)) > 0) && socketOpen) {
// If OkHttp's WebSocket queue gets overwhelmed, it'll abruptly close the connection
// (see: https://github.com/square/okhttp/issues/3317). This will ensure we wait until the coast is clear.
while (socket.queueSize() > QUEUE_SIZE_LIMIT) {
Thread.sleep(QUEUE_WAIT_MILLIS);
}
if (read == ONE_KB) {
socket.send(ByteString.of(buffer));
} else {
socket.send(ByteString.of(Arrays.copyOfRange(buffer, 0, read)));
}
}
} catch (IOException | InterruptedException e) {
LOG.log(Level.SEVERE, e.getMessage(), e);
} finally {
try {
inputStream.close();
} catch (IOException e) {
// do nothing - the InputStream may have already been closed externally.
}
}
} | [
"private",
"void",
"sendInputStream",
"(",
"InputStream",
"inputStream",
")",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"ONE_KB",
"]",
";",
"int",
"read",
";",
"try",
"{",
"// This method uses a blocking while loop to receive all contents of the underl... | Send input stream.
@param inputStream the input stream | [
"Send",
"input",
"stream",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/SpeechToTextWebSocketListener.java#L187-L217 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.createEnvironment | public ServiceCall<Environment> createEnvironment(CreateEnvironmentOptions createEnvironmentOptions) {
Validator.notNull(createEnvironmentOptions, "createEnvironmentOptions cannot be null");
String[] pathSegments = { "v1/environments" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createEnvironment");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("name", createEnvironmentOptions.name());
if (createEnvironmentOptions.description() != null) {
contentJson.addProperty("description", createEnvironmentOptions.description());
}
if (createEnvironmentOptions.size() != null) {
contentJson.addProperty("size", createEnvironmentOptions.size());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Environment.class));
} | java | public ServiceCall<Environment> createEnvironment(CreateEnvironmentOptions createEnvironmentOptions) {
Validator.notNull(createEnvironmentOptions, "createEnvironmentOptions cannot be null");
String[] pathSegments = { "v1/environments" };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createEnvironment");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("name", createEnvironmentOptions.name());
if (createEnvironmentOptions.description() != null) {
contentJson.addProperty("description", createEnvironmentOptions.description());
}
if (createEnvironmentOptions.size() != null) {
contentJson.addProperty("size", createEnvironmentOptions.size());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Environment.class));
} | [
"public",
"ServiceCall",
"<",
"Environment",
">",
"createEnvironment",
"(",
"CreateEnvironmentOptions",
"createEnvironmentOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"createEnvironmentOptions",
",",
"\"createEnvironmentOptions cannot be null\"",
")",
";",
"String",
... | Create an environment.
Creates a new environment for private data. An environment must be created before collections can be created.
**Note**: You can create only one environment for private data per service instance. An attempt to create another
environment results in an error.
@param createEnvironmentOptions the {@link CreateEnvironmentOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Environment} | [
"Create",
"an",
"environment",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L195-L215 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.getEnvironment | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getEnvironment");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Environment.class));
} | java | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getEnvironment");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Environment.class));
} | [
"public",
"ServiceCall",
"<",
"Environment",
">",
"getEnvironment",
"(",
"GetEnvironmentOptions",
"getEnvironmentOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"getEnvironmentOptions",
",",
"\"getEnvironmentOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
... | 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} | [
"Get",
"environment",
"info",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L244-L257 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.listEnvironments | public ServiceCall<ListEnvironmentsResponse> listEnvironments(ListEnvironmentsOptions listEnvironmentsOptions) {
String[] pathSegments = { "v1/environments" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listEnvironments");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listEnvironmentsOptions != null) {
if (listEnvironmentsOptions.name() != null) {
builder.query("name", listEnvironmentsOptions.name());
}
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListEnvironmentsResponse.class));
} | java | public ServiceCall<ListEnvironmentsResponse> listEnvironments(ListEnvironmentsOptions listEnvironmentsOptions) {
String[] pathSegments = { "v1/environments" };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listEnvironments");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listEnvironmentsOptions != null) {
if (listEnvironmentsOptions.name() != null) {
builder.query("name", listEnvironmentsOptions.name());
}
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListEnvironmentsResponse.class));
} | [
"public",
"ServiceCall",
"<",
"ListEnvironmentsResponse",
">",
"listEnvironments",
"(",
"ListEnvironmentsOptions",
"listEnvironmentsOptions",
")",
"{",
"String",
"[",
"]",
"pathSegments",
"=",
"{",
"\"v1/environments\"",
"}",
";",
"RequestBuilder",
"builder",
"=",
"Requ... | List environments.
List existing environments for the service instance.
@param listEnvironmentsOptions the {@link ListEnvironmentsOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link ListEnvironmentsResponse} | [
"List",
"environments",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L267-L282 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.listFields | public ServiceCall<ListCollectionFieldsResponse> listFields(ListFieldsOptions listFieldsOptions) {
Validator.notNull(listFieldsOptions, "listFieldsOptions cannot be null");
String[] pathSegments = { "v1/environments", "fields" };
String[] pathParameters = { listFieldsOptions.environmentId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listFields");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("collection_ids", RequestUtils.join(listFieldsOptions.collectionIds(), ","));
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListCollectionFieldsResponse.class));
} | java | public ServiceCall<ListCollectionFieldsResponse> listFields(ListFieldsOptions listFieldsOptions) {
Validator.notNull(listFieldsOptions, "listFieldsOptions cannot be null");
String[] pathSegments = { "v1/environments", "fields" };
String[] pathParameters = { listFieldsOptions.environmentId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listFields");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
builder.query("collection_ids", RequestUtils.join(listFieldsOptions.collectionIds(), ","));
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListCollectionFieldsResponse.class));
} | [
"public",
"ServiceCall",
"<",
"ListCollectionFieldsResponse",
">",
"listFields",
"(",
"ListFieldsOptions",
"listFieldsOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"listFieldsOptions",
",",
"\"listFieldsOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"p... | List fields across collections.
Gets a list of the unique fields (and their types) stored in the indexes of the specified collections.
@param listFieldsOptions the {@link ListFieldsOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link ListCollectionFieldsResponse} | [
"List",
"fields",
"across",
"collections",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L303-L317 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.getConfiguration | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getConfiguration");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Configuration.class));
} | java | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getConfiguration");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Configuration.class));
} | [
"public",
"ServiceCall",
"<",
"Configuration",
">",
"getConfiguration",
"(",
"GetConfigurationOptions",
"getConfigurationOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"getConfigurationOptions",
",",
"\"getConfigurationOptions cannot be null\"",
")",
";",
"String",
"... | 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} | [
"Get",
"configuration",
"details",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L437-L450 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.listConfigurations | public ServiceCall<ListConfigurationsResponse> listConfigurations(
ListConfigurationsOptions listConfigurationsOptions) {
Validator.notNull(listConfigurationsOptions, "listConfigurationsOptions cannot be null");
String[] pathSegments = { "v1/environments", "configurations" };
String[] pathParameters = { listConfigurationsOptions.environmentId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listConfigurations");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listConfigurationsOptions.name() != null) {
builder.query("name", listConfigurationsOptions.name());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListConfigurationsResponse.class));
} | java | public ServiceCall<ListConfigurationsResponse> listConfigurations(
ListConfigurationsOptions listConfigurationsOptions) {
Validator.notNull(listConfigurationsOptions, "listConfigurationsOptions cannot be null");
String[] pathSegments = { "v1/environments", "configurations" };
String[] pathParameters = { listConfigurationsOptions.environmentId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listConfigurations");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listConfigurationsOptions.name() != null) {
builder.query("name", listConfigurationsOptions.name());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListConfigurationsResponse.class));
} | [
"public",
"ServiceCall",
"<",
"ListConfigurationsResponse",
">",
"listConfigurations",
"(",
"ListConfigurationsOptions",
"listConfigurationsOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"listConfigurationsOptions",
",",
"\"listConfigurationsOptions cannot be null\"",
")",... | List configurations.
Lists existing configurations for the service instance.
@param listConfigurationsOptions the {@link ListConfigurationsOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link ListConfigurationsResponse} | [
"List",
"configurations",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L460-L477 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.updateConfiguration | public ServiceCall<Configuration> updateConfiguration(UpdateConfigurationOptions updateConfigurationOptions) {
Validator.notNull(updateConfigurationOptions, "updateConfigurationOptions cannot be null");
String[] pathSegments = { "v1/environments", "configurations" };
String[] pathParameters = { updateConfigurationOptions.environmentId(), updateConfigurationOptions
.configurationId() };
RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateConfiguration");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("name", updateConfigurationOptions.name());
if (updateConfigurationOptions.description() != null) {
contentJson.addProperty("description", updateConfigurationOptions.description());
}
if (updateConfigurationOptions.conversions() != null) {
contentJson.add("conversions", GsonSingleton.getGson().toJsonTree(updateConfigurationOptions.conversions()));
}
if (updateConfigurationOptions.enrichments() != null) {
contentJson.add("enrichments", GsonSingleton.getGson().toJsonTree(updateConfigurationOptions.enrichments()));
}
if (updateConfigurationOptions.normalizations() != null) {
contentJson.add("normalizations", GsonSingleton.getGson().toJsonTree(updateConfigurationOptions
.normalizations()));
}
if (updateConfigurationOptions.source() != null) {
contentJson.add("source", GsonSingleton.getGson().toJsonTree(updateConfigurationOptions.source()));
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Configuration.class));
} | java | public ServiceCall<Configuration> updateConfiguration(UpdateConfigurationOptions updateConfigurationOptions) {
Validator.notNull(updateConfigurationOptions, "updateConfigurationOptions cannot be null");
String[] pathSegments = { "v1/environments", "configurations" };
String[] pathParameters = { updateConfigurationOptions.environmentId(), updateConfigurationOptions
.configurationId() };
RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateConfiguration");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("name", updateConfigurationOptions.name());
if (updateConfigurationOptions.description() != null) {
contentJson.addProperty("description", updateConfigurationOptions.description());
}
if (updateConfigurationOptions.conversions() != null) {
contentJson.add("conversions", GsonSingleton.getGson().toJsonTree(updateConfigurationOptions.conversions()));
}
if (updateConfigurationOptions.enrichments() != null) {
contentJson.add("enrichments", GsonSingleton.getGson().toJsonTree(updateConfigurationOptions.enrichments()));
}
if (updateConfigurationOptions.normalizations() != null) {
contentJson.add("normalizations", GsonSingleton.getGson().toJsonTree(updateConfigurationOptions
.normalizations()));
}
if (updateConfigurationOptions.source() != null) {
contentJson.add("source", GsonSingleton.getGson().toJsonTree(updateConfigurationOptions.source()));
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Configuration.class));
} | [
"public",
"ServiceCall",
"<",
"Configuration",
">",
"updateConfiguration",
"(",
"UpdateConfigurationOptions",
"updateConfigurationOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"updateConfigurationOptions",
",",
"\"updateConfigurationOptions cannot be null\"",
")",
";",
... | Update a configuration.
Replaces an existing configuration.
* Completely replaces the original configuration.
* The **configuration_id**, **updated**, and **created** fields are accepted in the request, but they are
ignored, and an error is not generated. It is also acceptable for users to submit an updated configuration with
none of the three properties.
* Documents are processed with a snapshot of the configuration as it was at the time the document was submitted
to be ingested. This means that already submitted documents will not see any updates made to the configuration.
@param updateConfigurationOptions the {@link UpdateConfigurationOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Configuration} | [
"Update",
"a",
"configuration",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L493-L526 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.createCollection | public ServiceCall<Collection> createCollection(CreateCollectionOptions createCollectionOptions) {
Validator.notNull(createCollectionOptions, "createCollectionOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections" };
String[] pathParameters = { createCollectionOptions.environmentId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createCollection");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("name", createCollectionOptions.name());
if (createCollectionOptions.description() != null) {
contentJson.addProperty("description", createCollectionOptions.description());
}
if (createCollectionOptions.configurationId() != null) {
contentJson.addProperty("configuration_id", createCollectionOptions.configurationId());
}
if (createCollectionOptions.language() != null) {
contentJson.addProperty("language", createCollectionOptions.language());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Collection.class));
} | java | public ServiceCall<Collection> createCollection(CreateCollectionOptions createCollectionOptions) {
Validator.notNull(createCollectionOptions, "createCollectionOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections" };
String[] pathParameters = { createCollectionOptions.environmentId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createCollection");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.addProperty("name", createCollectionOptions.name());
if (createCollectionOptions.description() != null) {
contentJson.addProperty("description", createCollectionOptions.description());
}
if (createCollectionOptions.configurationId() != null) {
contentJson.addProperty("configuration_id", createCollectionOptions.configurationId());
}
if (createCollectionOptions.language() != null) {
contentJson.addProperty("language", createCollectionOptions.language());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Collection.class));
} | [
"public",
"ServiceCall",
"<",
"Collection",
">",
"createCollection",
"(",
"CreateCollectionOptions",
"createCollectionOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"createCollectionOptions",
",",
"\"createCollectionOptions cannot be null\"",
")",
";",
"String",
"[",... | Create a collection.
@param createCollectionOptions the {@link CreateCollectionOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Collection} | [
"Create",
"a",
"collection",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L583-L608 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.getCollection | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getCollection");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Collection.class));
} | java | 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);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getCollection");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Collection.class));
} | [
"public",
"ServiceCall",
"<",
"Collection",
">",
"getCollection",
"(",
"GetCollectionOptions",
"getCollectionOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"getCollectionOptions",
",",
"\"getCollectionOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
"path... | 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} | [
"Get",
"collection",
"details",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L637-L650 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.listCollectionFields | public ServiceCall<ListCollectionFieldsResponse> listCollectionFields(
ListCollectionFieldsOptions listCollectionFieldsOptions) {
Validator.notNull(listCollectionFieldsOptions, "listCollectionFieldsOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "fields" };
String[] pathParameters = { listCollectionFieldsOptions.environmentId(), listCollectionFieldsOptions
.collectionId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listCollectionFields");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListCollectionFieldsResponse.class));
} | java | public ServiceCall<ListCollectionFieldsResponse> listCollectionFields(
ListCollectionFieldsOptions listCollectionFieldsOptions) {
Validator.notNull(listCollectionFieldsOptions, "listCollectionFieldsOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "fields" };
String[] pathParameters = { listCollectionFieldsOptions.environmentId(), listCollectionFieldsOptions
.collectionId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listCollectionFields");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListCollectionFieldsResponse.class));
} | [
"public",
"ServiceCall",
"<",
"ListCollectionFieldsResponse",
">",
"listCollectionFields",
"(",
"ListCollectionFieldsOptions",
"listCollectionFieldsOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"listCollectionFieldsOptions",
",",
"\"listCollectionFieldsOptions cannot be nul... | List collection fields.
Gets a list of the unique fields (and their types) stored in the index.
@param listCollectionFieldsOptions the {@link ListCollectionFieldsOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link ListCollectionFieldsResponse} | [
"List",
"collection",
"fields",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L660-L675 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.listCollections | public ServiceCall<ListCollectionsResponse> listCollections(ListCollectionsOptions listCollectionsOptions) {
Validator.notNull(listCollectionsOptions, "listCollectionsOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections" };
String[] pathParameters = { listCollectionsOptions.environmentId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listCollections");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listCollectionsOptions.name() != null) {
builder.query("name", listCollectionsOptions.name());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListCollectionsResponse.class));
} | java | public ServiceCall<ListCollectionsResponse> listCollections(ListCollectionsOptions listCollectionsOptions) {
Validator.notNull(listCollectionsOptions, "listCollectionsOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections" };
String[] pathParameters = { listCollectionsOptions.environmentId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listCollections");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
if (listCollectionsOptions.name() != null) {
builder.query("name", listCollectionsOptions.name());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListCollectionsResponse.class));
} | [
"public",
"ServiceCall",
"<",
"ListCollectionsResponse",
">",
"listCollections",
"(",
"ListCollectionsOptions",
"listCollectionsOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"listCollectionsOptions",
",",
"\"listCollectionsOptions cannot be null\"",
")",
";",
"String"... | List collections.
Lists existing collections for the service instance.
@param listCollectionsOptions the {@link ListCollectionsOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link ListCollectionsResponse} | [
"List",
"collections",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L685-L701 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.updateCollection | public ServiceCall<Collection> updateCollection(UpdateCollectionOptions updateCollectionOptions) {
Validator.notNull(updateCollectionOptions, "updateCollectionOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections" };
String[] pathParameters = { updateCollectionOptions.environmentId(), updateCollectionOptions.collectionId() };
RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateCollection");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (updateCollectionOptions.name() != null) {
contentJson.addProperty("name", updateCollectionOptions.name());
}
if (updateCollectionOptions.description() != null) {
contentJson.addProperty("description", updateCollectionOptions.description());
}
if (updateCollectionOptions.configurationId() != null) {
contentJson.addProperty("configuration_id", updateCollectionOptions.configurationId());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Collection.class));
} | java | public ServiceCall<Collection> updateCollection(UpdateCollectionOptions updateCollectionOptions) {
Validator.notNull(updateCollectionOptions, "updateCollectionOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections" };
String[] pathParameters = { updateCollectionOptions.environmentId(), updateCollectionOptions.collectionId() };
RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "updateCollection");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (updateCollectionOptions.name() != null) {
contentJson.addProperty("name", updateCollectionOptions.name());
}
if (updateCollectionOptions.description() != null) {
contentJson.addProperty("description", updateCollectionOptions.description());
}
if (updateCollectionOptions.configurationId() != null) {
contentJson.addProperty("configuration_id", updateCollectionOptions.configurationId());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Collection.class));
} | [
"public",
"ServiceCall",
"<",
"Collection",
">",
"updateCollection",
"(",
"UpdateCollectionOptions",
"updateCollectionOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"updateCollectionOptions",
",",
"\"updateCollectionOptions cannot be null\"",
")",
";",
"String",
"[",... | Update a collection.
@param updateCollectionOptions the {@link UpdateCollectionOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Collection} | [
"Update",
"a",
"collection",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L709-L733 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.createExpansions | public ServiceCall<Expansions> createExpansions(CreateExpansionsOptions createExpansionsOptions) {
Validator.notNull(createExpansionsOptions, "createExpansionsOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "expansions" };
String[] pathParameters = { createExpansionsOptions.environmentId(), createExpansionsOptions.collectionId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createExpansions");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.add("expansions", GsonSingleton.getGson().toJsonTree(createExpansionsOptions.expansions()));
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Expansions.class));
} | java | public ServiceCall<Expansions> createExpansions(CreateExpansionsOptions createExpansionsOptions) {
Validator.notNull(createExpansionsOptions, "createExpansionsOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "expansions" };
String[] pathParameters = { createExpansionsOptions.environmentId(), createExpansionsOptions.collectionId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createExpansions");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
contentJson.add("expansions", GsonSingleton.getGson().toJsonTree(createExpansionsOptions.expansions()));
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Expansions.class));
} | [
"public",
"ServiceCall",
"<",
"Expansions",
">",
"createExpansions",
"(",
"CreateExpansionsOptions",
"createExpansionsOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"createExpansionsOptions",
",",
"\"createExpansionsOptions cannot be null\"",
")",
";",
"String",
"[",... | Create or update expansion list.
Create or replace the Expansion list for this collection. The maximum number of expanded terms per collection is
`500`.
The current expansion list is replaced with the uploaded content.
@param createExpansionsOptions the {@link CreateExpansionsOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Expansions} | [
"Create",
"or",
"update",
"expansion",
"list",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L745-L761 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.createStopwordList | public ServiceCall<TokenDictStatusResponse> createStopwordList(CreateStopwordListOptions createStopwordListOptions) {
Validator.notNull(createStopwordListOptions, "createStopwordListOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "word_lists/stopwords" };
String[] pathParameters = { createStopwordListOptions.environmentId(), createStopwordListOptions.collectionId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createStopwordList");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
RequestBody stopwordFileBody = RequestUtils.inputStreamBody(createStopwordListOptions.stopwordFile(),
"application/octet-stream");
multipartBuilder.addFormDataPart("stopword_file", createStopwordListOptions.stopwordFilename(), stopwordFileBody);
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TokenDictStatusResponse.class));
} | java | public ServiceCall<TokenDictStatusResponse> createStopwordList(CreateStopwordListOptions createStopwordListOptions) {
Validator.notNull(createStopwordListOptions, "createStopwordListOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "word_lists/stopwords" };
String[] pathParameters = { createStopwordListOptions.environmentId(), createStopwordListOptions.collectionId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createStopwordList");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
MultipartBody.Builder multipartBuilder = new MultipartBody.Builder();
multipartBuilder.setType(MultipartBody.FORM);
RequestBody stopwordFileBody = RequestUtils.inputStreamBody(createStopwordListOptions.stopwordFile(),
"application/octet-stream");
multipartBuilder.addFormDataPart("stopword_file", createStopwordListOptions.stopwordFilename(), stopwordFileBody);
builder.body(multipartBuilder.build());
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TokenDictStatusResponse.class));
} | [
"public",
"ServiceCall",
"<",
"TokenDictStatusResponse",
">",
"createStopwordList",
"(",
"CreateStopwordListOptions",
"createStopwordListOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"createStopwordListOptions",
",",
"\"createStopwordListOptions cannot be null\"",
")",
... | Create stopword list.
Upload a custom stopword list to use with the specified collection.
@param createStopwordListOptions the {@link CreateStopwordListOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link TokenDictStatusResponse} | [
"Create",
"stopword",
"list",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L771-L790 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.createTokenizationDictionary | public ServiceCall<TokenDictStatusResponse> createTokenizationDictionary(
CreateTokenizationDictionaryOptions createTokenizationDictionaryOptions) {
Validator.notNull(createTokenizationDictionaryOptions, "createTokenizationDictionaryOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "word_lists/tokenization_dictionary" };
String[] pathParameters = { createTokenizationDictionaryOptions.environmentId(), createTokenizationDictionaryOptions
.collectionId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createTokenizationDictionary");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (createTokenizationDictionaryOptions.tokenizationRules() != null) {
contentJson.add("tokenization_rules", GsonSingleton.getGson().toJsonTree(createTokenizationDictionaryOptions
.tokenizationRules()));
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TokenDictStatusResponse.class));
} | java | public ServiceCall<TokenDictStatusResponse> createTokenizationDictionary(
CreateTokenizationDictionaryOptions createTokenizationDictionaryOptions) {
Validator.notNull(createTokenizationDictionaryOptions, "createTokenizationDictionaryOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "word_lists/tokenization_dictionary" };
String[] pathParameters = { createTokenizationDictionaryOptions.environmentId(), createTokenizationDictionaryOptions
.collectionId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createTokenizationDictionary");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (createTokenizationDictionaryOptions.tokenizationRules() != null) {
contentJson.add("tokenization_rules", GsonSingleton.getGson().toJsonTree(createTokenizationDictionaryOptions
.tokenizationRules()));
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TokenDictStatusResponse.class));
} | [
"public",
"ServiceCall",
"<",
"TokenDictStatusResponse",
">",
"createTokenizationDictionary",
"(",
"CreateTokenizationDictionaryOptions",
"createTokenizationDictionaryOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"createTokenizationDictionaryOptions",
",",
"\"createTokeniza... | Create tokenization dictionary.
Upload a custom tokenization dictionary to use with the specified collection.
@param createTokenizationDictionaryOptions the {@link CreateTokenizationDictionaryOptions} containing the options
for the call
@return a {@link ServiceCall} with a response type of {@link TokenDictStatusResponse} | [
"Create",
"tokenization",
"dictionary",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L801-L822 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.deleteExpansions | public ServiceCall<Void> deleteExpansions(DeleteExpansionsOptions deleteExpansionsOptions) {
Validator.notNull(deleteExpansionsOptions, "deleteExpansionsOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "expansions" };
String[] pathParameters = { deleteExpansionsOptions.environmentId(), deleteExpansionsOptions.collectionId() };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteExpansions");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | java | public ServiceCall<Void> deleteExpansions(DeleteExpansionsOptions deleteExpansionsOptions) {
Validator.notNull(deleteExpansionsOptions, "deleteExpansionsOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "expansions" };
String[] pathParameters = { deleteExpansionsOptions.environmentId(), deleteExpansionsOptions.collectionId() };
RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "deleteExpansions");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
} | [
"public",
"ServiceCall",
"<",
"Void",
">",
"deleteExpansions",
"(",
"DeleteExpansionsOptions",
"deleteExpansionsOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"deleteExpansionsOptions",
",",
"\"deleteExpansionsOptions cannot be null\"",
")",
";",
"String",
"[",
"]"... | Delete the expansion list.
Remove the expansion information for this collection. The expansion list must be deleted to disable query expansion
for a collection.
@param deleteExpansionsOptions the {@link DeleteExpansionsOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of Void | [
"Delete",
"the",
"expansion",
"list",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L833-L845 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.getTokenizationDictionaryStatus | public ServiceCall<TokenDictStatusResponse> getTokenizationDictionaryStatus(
GetTokenizationDictionaryStatusOptions getTokenizationDictionaryStatusOptions) {
Validator.notNull(getTokenizationDictionaryStatusOptions, "getTokenizationDictionaryStatusOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "word_lists/tokenization_dictionary" };
String[] pathParameters = { getTokenizationDictionaryStatusOptions.environmentId(),
getTokenizationDictionaryStatusOptions.collectionId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getTokenizationDictionaryStatus");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TokenDictStatusResponse.class));
} | java | public ServiceCall<TokenDictStatusResponse> getTokenizationDictionaryStatus(
GetTokenizationDictionaryStatusOptions getTokenizationDictionaryStatusOptions) {
Validator.notNull(getTokenizationDictionaryStatusOptions, "getTokenizationDictionaryStatusOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "word_lists/tokenization_dictionary" };
String[] pathParameters = { getTokenizationDictionaryStatusOptions.environmentId(),
getTokenizationDictionaryStatusOptions.collectionId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getTokenizationDictionaryStatus");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TokenDictStatusResponse.class));
} | [
"public",
"ServiceCall",
"<",
"TokenDictStatusResponse",
">",
"getTokenizationDictionaryStatus",
"(",
"GetTokenizationDictionaryStatusOptions",
"getTokenizationDictionaryStatusOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"getTokenizationDictionaryStatusOptions",
",",
"\"ge... | Get tokenization dictionary status.
Returns the current status of the tokenization dictionary for the specified collection.
@param getTokenizationDictionaryStatusOptions the {@link GetTokenizationDictionaryStatusOptions} containing the
options for the call
@return a {@link ServiceCall} with a response type of {@link TokenDictStatusResponse} | [
"Get",
"tokenization",
"dictionary",
"status",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L929-L944 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.listExpansions | public ServiceCall<Expansions> listExpansions(ListExpansionsOptions listExpansionsOptions) {
Validator.notNull(listExpansionsOptions, "listExpansionsOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "expansions" };
String[] pathParameters = { listExpansionsOptions.environmentId(), listExpansionsOptions.collectionId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listExpansions");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Expansions.class));
} | java | public ServiceCall<Expansions> listExpansions(ListExpansionsOptions listExpansionsOptions) {
Validator.notNull(listExpansionsOptions, "listExpansionsOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "expansions" };
String[] pathParameters = { listExpansionsOptions.environmentId(), listExpansionsOptions.collectionId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "listExpansions");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Expansions.class));
} | [
"public",
"ServiceCall",
"<",
"Expansions",
">",
"listExpansions",
"(",
"ListExpansionsOptions",
"listExpansionsOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"listExpansionsOptions",
",",
"\"listExpansionsOptions cannot be null\"",
")",
";",
"String",
"[",
"]",
... | Get the expansion list.
Returns the current expansion list for the specified collection. If an expansion list is not specified, an object
with empty expansion arrays is returned.
@param listExpansionsOptions the {@link ListExpansionsOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link Expansions} | [
"Get",
"the",
"expansion",
"list",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L955-L968 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.getDocumentStatus | public ServiceCall<DocumentStatus> getDocumentStatus(GetDocumentStatusOptions getDocumentStatusOptions) {
Validator.notNull(getDocumentStatusOptions, "getDocumentStatusOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "documents" };
String[] pathParameters = { getDocumentStatusOptions.environmentId(), getDocumentStatusOptions.collectionId(),
getDocumentStatusOptions.documentId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getDocumentStatus");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DocumentStatus.class));
} | java | public ServiceCall<DocumentStatus> getDocumentStatus(GetDocumentStatusOptions getDocumentStatusOptions) {
Validator.notNull(getDocumentStatusOptions, "getDocumentStatusOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "documents" };
String[] pathParameters = { getDocumentStatusOptions.environmentId(), getDocumentStatusOptions.collectionId(),
getDocumentStatusOptions.documentId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getDocumentStatus");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DocumentStatus.class));
} | [
"public",
"ServiceCall",
"<",
"DocumentStatus",
">",
"getDocumentStatus",
"(",
"GetDocumentStatusOptions",
"getDocumentStatusOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"getDocumentStatusOptions",
",",
"\"getDocumentStatusOptions cannot be null\"",
")",
";",
"String... | Get document details.
Fetch status details about a submitted document. **Note:** this operation does not return the document itself.
Instead, it returns only the document's processing status and any notices (warnings or errors) that were generated
when the document was ingested. Use the query API to retrieve the actual document content.
@param getDocumentStatusOptions the {@link GetDocumentStatusOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link DocumentStatus} | [
"Get",
"document",
"details",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L1062-L1076 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.queryEntities | public ServiceCall<QueryEntitiesResponse> queryEntities(QueryEntitiesOptions queryEntitiesOptions) {
Validator.notNull(queryEntitiesOptions, "queryEntitiesOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "query_entities" };
String[] pathParameters = { queryEntitiesOptions.environmentId(), queryEntitiesOptions.collectionId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "queryEntities");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (queryEntitiesOptions.feature() != null) {
contentJson.addProperty("feature", queryEntitiesOptions.feature());
}
if (queryEntitiesOptions.entity() != null) {
contentJson.add("entity", GsonSingleton.getGson().toJsonTree(queryEntitiesOptions.entity()));
}
if (queryEntitiesOptions.context() != null) {
contentJson.add("context", GsonSingleton.getGson().toJsonTree(queryEntitiesOptions.context()));
}
if (queryEntitiesOptions.count() != null) {
contentJson.addProperty("count", queryEntitiesOptions.count());
}
if (queryEntitiesOptions.evidenceCount() != null) {
contentJson.addProperty("evidence_count", queryEntitiesOptions.evidenceCount());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(QueryEntitiesResponse.class));
} | java | public ServiceCall<QueryEntitiesResponse> queryEntities(QueryEntitiesOptions queryEntitiesOptions) {
Validator.notNull(queryEntitiesOptions, "queryEntitiesOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "query_entities" };
String[] pathParameters = { queryEntitiesOptions.environmentId(), queryEntitiesOptions.collectionId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "queryEntities");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (queryEntitiesOptions.feature() != null) {
contentJson.addProperty("feature", queryEntitiesOptions.feature());
}
if (queryEntitiesOptions.entity() != null) {
contentJson.add("entity", GsonSingleton.getGson().toJsonTree(queryEntitiesOptions.entity()));
}
if (queryEntitiesOptions.context() != null) {
contentJson.add("context", GsonSingleton.getGson().toJsonTree(queryEntitiesOptions.context()));
}
if (queryEntitiesOptions.count() != null) {
contentJson.addProperty("count", queryEntitiesOptions.count());
}
if (queryEntitiesOptions.evidenceCount() != null) {
contentJson.addProperty("evidence_count", queryEntitiesOptions.evidenceCount());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(QueryEntitiesResponse.class));
} | [
"public",
"ServiceCall",
"<",
"QueryEntitiesResponse",
">",
"queryEntities",
"(",
"QueryEntitiesOptions",
"queryEntitiesOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"queryEntitiesOptions",
",",
"\"queryEntitiesOptions cannot be null\"",
")",
";",
"String",
"[",
"... | Knowledge Graph entity query.
See the [Knowledge Graph documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-kg#kg) for
more details.
@param queryEntitiesOptions the {@link QueryEntitiesOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link QueryEntitiesResponse} | [
"Knowledge",
"Graph",
"entity",
"query",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L1377-L1407 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.queryRelations | public ServiceCall<QueryRelationsResponse> queryRelations(QueryRelationsOptions queryRelationsOptions) {
Validator.notNull(queryRelationsOptions, "queryRelationsOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "query_relations" };
String[] pathParameters = { queryRelationsOptions.environmentId(), queryRelationsOptions.collectionId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "queryRelations");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (queryRelationsOptions.entities() != null) {
contentJson.add("entities", GsonSingleton.getGson().toJsonTree(queryRelationsOptions.entities()));
}
if (queryRelationsOptions.context() != null) {
contentJson.add("context", GsonSingleton.getGson().toJsonTree(queryRelationsOptions.context()));
}
if (queryRelationsOptions.sort() != null) {
contentJson.addProperty("sort", queryRelationsOptions.sort());
}
if (queryRelationsOptions.filter() != null) {
contentJson.add("filter", GsonSingleton.getGson().toJsonTree(queryRelationsOptions.filter()));
}
if (queryRelationsOptions.count() != null) {
contentJson.addProperty("count", queryRelationsOptions.count());
}
if (queryRelationsOptions.evidenceCount() != null) {
contentJson.addProperty("evidence_count", queryRelationsOptions.evidenceCount());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(QueryRelationsResponse.class));
} | java | public ServiceCall<QueryRelationsResponse> queryRelations(QueryRelationsOptions queryRelationsOptions) {
Validator.notNull(queryRelationsOptions, "queryRelationsOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "query_relations" };
String[] pathParameters = { queryRelationsOptions.environmentId(), queryRelationsOptions.collectionId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "queryRelations");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (queryRelationsOptions.entities() != null) {
contentJson.add("entities", GsonSingleton.getGson().toJsonTree(queryRelationsOptions.entities()));
}
if (queryRelationsOptions.context() != null) {
contentJson.add("context", GsonSingleton.getGson().toJsonTree(queryRelationsOptions.context()));
}
if (queryRelationsOptions.sort() != null) {
contentJson.addProperty("sort", queryRelationsOptions.sort());
}
if (queryRelationsOptions.filter() != null) {
contentJson.add("filter", GsonSingleton.getGson().toJsonTree(queryRelationsOptions.filter()));
}
if (queryRelationsOptions.count() != null) {
contentJson.addProperty("count", queryRelationsOptions.count());
}
if (queryRelationsOptions.evidenceCount() != null) {
contentJson.addProperty("evidence_count", queryRelationsOptions.evidenceCount());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(QueryRelationsResponse.class));
} | [
"public",
"ServiceCall",
"<",
"QueryRelationsResponse",
">",
"queryRelations",
"(",
"QueryRelationsOptions",
"queryRelationsOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"queryRelationsOptions",
",",
"\"queryRelationsOptions cannot be null\"",
")",
";",
"String",
"[... | Knowledge Graph relationship query.
See the [Knowledge Graph documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-kg#kg) for
more details.
@param queryRelationsOptions the {@link QueryRelationsOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link QueryRelationsResponse} | [
"Knowledge",
"Graph",
"relationship",
"query",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L1495-L1528 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.addTrainingData | public ServiceCall<TrainingQuery> addTrainingData(AddTrainingDataOptions addTrainingDataOptions) {
Validator.notNull(addTrainingDataOptions, "addTrainingDataOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "training_data" };
String[] pathParameters = { addTrainingDataOptions.environmentId(), addTrainingDataOptions.collectionId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "addTrainingData");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (addTrainingDataOptions.naturalLanguageQuery() != null) {
contentJson.addProperty("natural_language_query", addTrainingDataOptions.naturalLanguageQuery());
}
if (addTrainingDataOptions.filter() != null) {
contentJson.addProperty("filter", addTrainingDataOptions.filter());
}
if (addTrainingDataOptions.examples() != null) {
contentJson.add("examples", GsonSingleton.getGson().toJsonTree(addTrainingDataOptions.examples()));
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingQuery.class));
} | java | public ServiceCall<TrainingQuery> addTrainingData(AddTrainingDataOptions addTrainingDataOptions) {
Validator.notNull(addTrainingDataOptions, "addTrainingDataOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "training_data" };
String[] pathParameters = { addTrainingDataOptions.environmentId(), addTrainingDataOptions.collectionId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "addTrainingData");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (addTrainingDataOptions.naturalLanguageQuery() != null) {
contentJson.addProperty("natural_language_query", addTrainingDataOptions.naturalLanguageQuery());
}
if (addTrainingDataOptions.filter() != null) {
contentJson.addProperty("filter", addTrainingDataOptions.filter());
}
if (addTrainingDataOptions.examples() != null) {
contentJson.add("examples", GsonSingleton.getGson().toJsonTree(addTrainingDataOptions.examples()));
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingQuery.class));
} | [
"public",
"ServiceCall",
"<",
"TrainingQuery",
">",
"addTrainingData",
"(",
"AddTrainingDataOptions",
"addTrainingDataOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"addTrainingDataOptions",
",",
"\"addTrainingDataOptions cannot be null\"",
")",
";",
"String",
"[",
... | Add query to training data.
Adds a query to the training data for this collection. The query can contain a filter and natural language query.
@param addTrainingDataOptions the {@link AddTrainingDataOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link TrainingQuery} | [
"Add",
"query",
"to",
"training",
"data",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L1538-L1562 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.createTrainingExample | public ServiceCall<TrainingExample> createTrainingExample(CreateTrainingExampleOptions createTrainingExampleOptions) {
Validator.notNull(createTrainingExampleOptions, "createTrainingExampleOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "training_data", "examples" };
String[] pathParameters = { createTrainingExampleOptions.environmentId(), createTrainingExampleOptions
.collectionId(), createTrainingExampleOptions.queryId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createTrainingExample");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (createTrainingExampleOptions.documentId() != null) {
contentJson.addProperty("document_id", createTrainingExampleOptions.documentId());
}
if (createTrainingExampleOptions.crossReference() != null) {
contentJson.addProperty("cross_reference", createTrainingExampleOptions.crossReference());
}
if (createTrainingExampleOptions.relevance() != null) {
contentJson.addProperty("relevance", createTrainingExampleOptions.relevance());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingExample.class));
} | java | public ServiceCall<TrainingExample> createTrainingExample(CreateTrainingExampleOptions createTrainingExampleOptions) {
Validator.notNull(createTrainingExampleOptions, "createTrainingExampleOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "training_data", "examples" };
String[] pathParameters = { createTrainingExampleOptions.environmentId(), createTrainingExampleOptions
.collectionId(), createTrainingExampleOptions.queryId() };
RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "createTrainingExample");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (createTrainingExampleOptions.documentId() != null) {
contentJson.addProperty("document_id", createTrainingExampleOptions.documentId());
}
if (createTrainingExampleOptions.crossReference() != null) {
contentJson.addProperty("cross_reference", createTrainingExampleOptions.crossReference());
}
if (createTrainingExampleOptions.relevance() != null) {
contentJson.addProperty("relevance", createTrainingExampleOptions.relevance());
}
builder.bodyJson(contentJson);
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingExample.class));
} | [
"public",
"ServiceCall",
"<",
"TrainingExample",
">",
"createTrainingExample",
"(",
"CreateTrainingExampleOptions",
"createTrainingExampleOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"createTrainingExampleOptions",
",",
"\"createTrainingExampleOptions cannot be null\"",
... | Add example to training data query.
Adds a example to this training data query.
@param createTrainingExampleOptions the {@link CreateTrainingExampleOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link TrainingExample} | [
"Add",
"example",
"to",
"training",
"data",
"query",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L1572-L1597 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.getTrainingData | public ServiceCall<TrainingQuery> getTrainingData(GetTrainingDataOptions getTrainingDataOptions) {
Validator.notNull(getTrainingDataOptions, "getTrainingDataOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "training_data" };
String[] pathParameters = { getTrainingDataOptions.environmentId(), getTrainingDataOptions.collectionId(),
getTrainingDataOptions.queryId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getTrainingData");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingQuery.class));
} | java | public ServiceCall<TrainingQuery> getTrainingData(GetTrainingDataOptions getTrainingDataOptions) {
Validator.notNull(getTrainingDataOptions, "getTrainingDataOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "training_data" };
String[] pathParameters = { getTrainingDataOptions.environmentId(), getTrainingDataOptions.collectionId(),
getTrainingDataOptions.queryId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getTrainingData");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingQuery.class));
} | [
"public",
"ServiceCall",
"<",
"TrainingQuery",
">",
"getTrainingData",
"(",
"GetTrainingDataOptions",
"getTrainingDataOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"getTrainingDataOptions",
",",
"\"getTrainingDataOptions cannot be null\"",
")",
";",
"String",
"[",
... | Get details about a query.
Gets details for a specific training data query, including the query string and all examples.
@param getTrainingDataOptions the {@link GetTrainingDataOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link TrainingQuery} | [
"Get",
"details",
"about",
"a",
"query",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L1676-L1690 | train |
watson-developer-cloud/java-sdk | discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java | Discovery.getTrainingExample | public ServiceCall<TrainingExample> getTrainingExample(GetTrainingExampleOptions getTrainingExampleOptions) {
Validator.notNull(getTrainingExampleOptions, "getTrainingExampleOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "training_data", "examples" };
String[] pathParameters = { getTrainingExampleOptions.environmentId(), getTrainingExampleOptions.collectionId(),
getTrainingExampleOptions.queryId(), getTrainingExampleOptions.exampleId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getTrainingExample");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingExample.class));
} | java | public ServiceCall<TrainingExample> getTrainingExample(GetTrainingExampleOptions getTrainingExampleOptions) {
Validator.notNull(getTrainingExampleOptions, "getTrainingExampleOptions cannot be null");
String[] pathSegments = { "v1/environments", "collections", "training_data", "examples" };
String[] pathParameters = { getTrainingExampleOptions.environmentId(), getTrainingExampleOptions.collectionId(),
getTrainingExampleOptions.queryId(), getTrainingExampleOptions.exampleId() };
RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
pathParameters));
builder.query("version", versionDate);
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getTrainingExample");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingExample.class));
} | [
"public",
"ServiceCall",
"<",
"TrainingExample",
">",
"getTrainingExample",
"(",
"GetTrainingExampleOptions",
"getTrainingExampleOptions",
")",
"{",
"Validator",
".",
"notNull",
"(",
"getTrainingExampleOptions",
",",
"\"getTrainingExampleOptions cannot be null\"",
")",
";",
"... | Get details for training data example.
Gets the details for this training example.
@param getTrainingExampleOptions the {@link GetTrainingExampleOptions} containing the options for the call
@return a {@link ServiceCall} with a response type of {@link TrainingExample} | [
"Get",
"details",
"for",
"training",
"data",
"example",
"."
] | c926117afd20e2002b69942537720ab733a914f3 | https://github.com/watson-developer-cloud/java-sdk/blob/c926117afd20e2002b69942537720ab733a914f3/discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java#L1700-L1714 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.