diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 96d7e3df6d1..3cd4acb7d21 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,6 +1,7 @@ [bumpversion] -current_version = 6.3.0 +current_version = 6.4.0 commit = True +message = docs: Update version numbers from {current_version} -> {new_version} [bumpversion:file:README.md] diff --git a/README.md b/README.md index a61735dfc6e..91ebaea4501 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ All the services: com.ibm.watson.developer_cloud java-sdk - 6.3.1 + 6.4.0 ``` @@ -70,7 +70,7 @@ Only Discovery: com.ibm.watson.developer_cloud discovery - 6.3.1 + 6.4.0 ``` @@ -79,13 +79,13 @@ Only Discovery: All the services: ```gradle -'com.ibm.watson.developer_cloud:java-sdk:6.3.1' +'com.ibm.watson.developer_cloud:java-sdk:6.4.0' ``` Only Assistant: ```gradle -'com.ibm.watson.developer_cloud:assistant:6.3.1' +'com.ibm.watson.developer_cloud:assistant:6.4.0' ``` ##### Development snapshots @@ -108,7 +108,7 @@ And then reference the snapshot version on your app module gradle Only Speech to Text: ```gradle -'com.ibm.watson.developer_cloud:speech-to-text:6.3.1-SNAPSHOT' +'com.ibm.watson.developer_cloud:speech-to-text:6.4.1-SNAPSHOT' ``` ##### JAR @@ -143,10 +143,9 @@ Watson services are migrating to token-based Identity and Access Management (IAM ### Getting credentials To find out which authentication to use, view the service credentials. You find the service credentials for authentication the same way for all Watson services: -1. Go to the IBM Cloud **[Dashboard][watson-dashboard]** page. -1. Either click an existing Watson service instance or click **Create**. -1. Click **Show** to view your service credentials. -1. Copy the `url` and either `apikey` or `username` and `password`. +1. Go to the IBM Cloud [Dashboard](https://console.bluemix.net/dashboard/apps?category=ai) page. +1. Either click an existing Watson service instance or click [**Create resource > AI**](https://console.bluemix.net/catalog/?category=ai) and create a service instance. +1. Copy the `url` and either `apikey` or `username` and `password`. Click **Show** if the credentials are masked. In your code, you can use these values in the service constructor or with a method call after instantiating your service. @@ -376,7 +375,7 @@ Gradle: ```sh cd java-sdk -gradle jar # build jar file (build/libs/watson-developer-cloud-6.3.1.jar) +gradle jar # build jar file (build/libs/watson-developer-cloud-6.4.0.jar) gradle test # run tests gradle check # performs quality checks on source files and generates reports gradle testReport # run tests and generate the aggregated test report (build/reports/allTests) @@ -420,7 +419,6 @@ or [Stack Overflow](http://stackoverflow.com/questions/ask?tags=ibm-watson). [wdc]: https://www.ibm.com/watson/developer/ [ibm_cloud]: https://console.bluemix.net -[watson-dashboard]: https://console.bluemix.net/dashboard/apps?category=watson [Gradle]: http://www.gradle.org/ [OkHttp]: http://square.github.io/okhttp/ [gson]: https://github.com/google/gson @@ -430,4 +428,4 @@ or [Stack Overflow](http://stackoverflow.com/questions/ask?tags=ibm-watson). [ibm-cloud-onboarding]: http://console.bluemix.net/registration?target=/developer/watson&cm_sp=WatsonPlatform-WatsonServices-_-OnPageNavLink-IBMWatson_SDKs-_-Java -[jar]: https://github.com/watson-developer-cloud/java-sdk/releases/download/java-sdk-6.3.0/java-sdk-6.3.1-jar-with-dependencies.jar +[jar]: https://github.com/watson-developer-cloud/java-sdk/releases/download/java-sdk-6.4.0/java-sdk-6.4.0-jar-with-dependencies.jar diff --git a/assistant/README.md b/assistant/README.md index 284b7f3f88f..ee1a96372f0 100644 --- a/assistant/README.md +++ b/assistant/README.md @@ -7,13 +7,13 @@ com.ibm.watson.developer_cloud assistant - 6.3.0 + 6.4.0 ``` ##### Gradle ```gradle -'com.ibm.watson.developer_cloud:assistant:6.3.0' +'com.ibm.watson.developer_cloud:assistant:6.4.0' ``` ## Usage diff --git a/conversation/README.md b/conversation/README.md index c9b5a19a8e2..296832ef02e 100644 --- a/conversation/README.md +++ b/conversation/README.md @@ -7,13 +7,13 @@ com.ibm.watson.developer_cloud conversation - 6.3.0 + 6.4.0 ``` ##### Gradle ```gradle -'com.ibm.watson.developer_cloud:conversation:6.3.0' +'com.ibm.watson.developer_cloud:conversation:6.4.0' ``` ## Usage diff --git a/discovery/README.md b/discovery/README.md index 645451af297..5b9c4eed06f 100644 --- a/discovery/README.md +++ b/discovery/README.md @@ -7,13 +7,13 @@ com.ibm.watson.developer_cloud discovery - 6.3.0 + 6.4.0 ``` ##### Gradle ```gradle -'com.ibm.watson.developer_cloud:discovery:6.3.0' +'com.ibm.watson.developer_cloud:discovery:6.4.0' ``` ## Usage diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/Discovery.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/Discovery.java index 669ba9813c8..de83fcdb951 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/Discovery.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/Discovery.java @@ -21,6 +21,8 @@ import com.ibm.watson.developer_cloud.discovery.v1.model.CreateConfigurationOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.CreateCredentialsOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEnvironmentOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEventOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEventResponse; import com.ibm.watson.developer_cloud.discovery.v1.model.CreateExpansionsOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.CreateTrainingExampleOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.Credentials; @@ -46,6 +48,11 @@ import com.ibm.watson.developer_cloud.discovery.v1.model.GetCredentialsOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.GetDocumentStatusOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.GetEnvironmentOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.GetMetricsEventRateOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.GetMetricsQueryEventOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.GetMetricsQueryNoResultsOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.GetMetricsQueryOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.GetMetricsQueryTokenEventOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.GetTrainingDataOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.GetTrainingExampleOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsOptions; @@ -61,8 +68,12 @@ import com.ibm.watson.developer_cloud.discovery.v1.model.ListFieldsOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingDataOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingExamplesOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.LogQueryResponse; +import com.ibm.watson.developer_cloud.discovery.v1.model.MetricResponse; +import com.ibm.watson.developer_cloud.discovery.v1.model.MetricTokenResponse; import com.ibm.watson.developer_cloud.discovery.v1.model.QueryEntitiesOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.QueryEntitiesResponse; +import com.ibm.watson.developer_cloud.discovery.v1.model.QueryLogOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse; import com.ibm.watson.developer_cloud.discovery.v1.model.QueryOptions; @@ -1402,6 +1413,269 @@ public ServiceCall deleteUserData(DeleteUserDataOptions deleteUserDataOpti return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); } + /** + * Create event. + * + * The **Events** API can be used to create log entries that are associated with specific queries. For example, you + * can record which documents in the results set were \"clicked\" by a user and when that click occured. + * + * @param createEventOptions the {@link CreateEventOptions} containing the options for the call + * @return a {@link ServiceCall} with a response type of {@link CreateEventResponse} + */ + public ServiceCall createEvent(CreateEventOptions createEventOptions) { + Validator.notNull(createEventOptions, "createEventOptions cannot be null"); + String[] pathSegments = { "v1/events" }; + RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); + builder.query(VERSION, versionDate); + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("type", createEventOptions.type()); + contentJson.add("data", GsonSingleton.getGson().toJsonTree(createEventOptions.data())); + builder.bodyJson(contentJson); + return createServiceCall(builder.build(), ResponseConverterUtils.getObject(CreateEventResponse.class)); + } + + /** + * Percentage of queries with an associated event. + * + * The percentage of queries using the **natural_language_query** parameter that have a corresponding \"click\" event + * over a specified time window. This metric requires having integrated event tracking in your application using the + * **Events** API. + * + * @param getMetricsEventRateOptions the {@link GetMetricsEventRateOptions} containing the options for the call + * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + */ + public ServiceCall getMetricsEventRate(GetMetricsEventRateOptions getMetricsEventRateOptions) { + String[] pathSegments = { "v1/metrics/event_rate" }; + RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); + builder.query(VERSION, versionDate); + if (getMetricsEventRateOptions != null) { + if (getMetricsEventRateOptions.startTime() != null) { + builder.query("start_time", String.valueOf(getMetricsEventRateOptions.startTime())); + } + if (getMetricsEventRateOptions.endTime() != null) { + builder.query("end_time", String.valueOf(getMetricsEventRateOptions.endTime())); + } + if (getMetricsEventRateOptions.resultType() != null) { + builder.query("result_type", getMetricsEventRateOptions.resultType()); + } + } + return createServiceCall(builder.build(), ResponseConverterUtils.getObject(MetricResponse.class)); + } + + /** + * Percentage of queries with an associated event. + * + * The percentage of queries using the **natural_language_query** parameter that have a corresponding \"click\" event + * over a specified time window. This metric requires having integrated event tracking in your application using the + * **Events** API. + * + * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + */ + public ServiceCall getMetricsEventRate() { + return getMetricsEventRate(null); + } + + /** + * Number of queries over time. + * + * Total number of queries using the **natural_language_query** parameter over a specific time window. + * + * @param getMetricsQueryOptions the {@link GetMetricsQueryOptions} containing the options for the call + * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + */ + public ServiceCall getMetricsQuery(GetMetricsQueryOptions getMetricsQueryOptions) { + String[] pathSegments = { "v1/metrics/number_of_queries" }; + RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); + builder.query(VERSION, versionDate); + if (getMetricsQueryOptions != null) { + if (getMetricsQueryOptions.startTime() != null) { + builder.query("start_time", String.valueOf(getMetricsQueryOptions.startTime())); + } + if (getMetricsQueryOptions.endTime() != null) { + builder.query("end_time", String.valueOf(getMetricsQueryOptions.endTime())); + } + if (getMetricsQueryOptions.resultType() != null) { + builder.query("result_type", getMetricsQueryOptions.resultType()); + } + } + return createServiceCall(builder.build(), ResponseConverterUtils.getObject(MetricResponse.class)); + } + + /** + * Number of queries over time. + * + * Total number of queries using the **natural_language_query** parameter over a specific time window. + * + * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + */ + public ServiceCall getMetricsQuery() { + return getMetricsQuery(null); + } + + /** + * Number of queries with an event over time. + * + * Total number of queries using the **natural_language_query** parameter that have a corresponding \"click\" event + * over a specified time window. This metric requires having integrated event tracking in your application using the + * **Events** API. + * + * @param getMetricsQueryEventOptions the {@link GetMetricsQueryEventOptions} containing the options for the call + * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + */ + public ServiceCall getMetricsQueryEvent(GetMetricsQueryEventOptions getMetricsQueryEventOptions) { + String[] pathSegments = { "v1/metrics/number_of_queries_with_event" }; + RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); + builder.query(VERSION, versionDate); + if (getMetricsQueryEventOptions != null) { + if (getMetricsQueryEventOptions.startTime() != null) { + builder.query("start_time", String.valueOf(getMetricsQueryEventOptions.startTime())); + } + if (getMetricsQueryEventOptions.endTime() != null) { + builder.query("end_time", String.valueOf(getMetricsQueryEventOptions.endTime())); + } + if (getMetricsQueryEventOptions.resultType() != null) { + builder.query("result_type", getMetricsQueryEventOptions.resultType()); + } + } + return createServiceCall(builder.build(), ResponseConverterUtils.getObject(MetricResponse.class)); + } + + /** + * Number of queries with an event over time. + * + * Total number of queries using the **natural_language_query** parameter that have a corresponding \"click\" event + * over a specified time window. This metric requires having integrated event tracking in your application using the + * **Events** API. + * + * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + */ + public ServiceCall getMetricsQueryEvent() { + return getMetricsQueryEvent(null); + } + + /** + * Number of queries with no search results over time. + * + * Total number of queries using the **natural_language_query** parameter that have no results returned over a + * specified time window. + * + * @param getMetricsQueryNoResultsOptions the {@link GetMetricsQueryNoResultsOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + */ + public ServiceCall getMetricsQueryNoResults( + GetMetricsQueryNoResultsOptions getMetricsQueryNoResultsOptions) { + String[] pathSegments = { "v1/metrics/number_of_queries_with_no_search_results" }; + RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); + builder.query(VERSION, versionDate); + if (getMetricsQueryNoResultsOptions != null) { + if (getMetricsQueryNoResultsOptions.startTime() != null) { + builder.query("start_time", String.valueOf(getMetricsQueryNoResultsOptions.startTime())); + } + if (getMetricsQueryNoResultsOptions.endTime() != null) { + builder.query("end_time", String.valueOf(getMetricsQueryNoResultsOptions.endTime())); + } + if (getMetricsQueryNoResultsOptions.resultType() != null) { + builder.query("result_type", getMetricsQueryNoResultsOptions.resultType()); + } + } + return createServiceCall(builder.build(), ResponseConverterUtils.getObject(MetricResponse.class)); + } + + /** + * Number of queries with no search results over time. + * + * Total number of queries using the **natural_language_query** parameter that have no results returned over a + * specified time window. + * + * @return a {@link ServiceCall} with a response type of {@link MetricResponse} + */ + public ServiceCall getMetricsQueryNoResults() { + return getMetricsQueryNoResults(null); + } + + /** + * Most frequent query tokens with an event. + * + * The most frequent query tokens parsed from the **natural_language_query** parameter and their corresponding + * \"click\" event rate within the recording period (queries and events are stored for 30 days). A query token is an + * individual word or unigram within the query string. + * + * @param getMetricsQueryTokenEventOptions the {@link GetMetricsQueryTokenEventOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a response type of {@link MetricTokenResponse} + */ + public ServiceCall getMetricsQueryTokenEvent( + GetMetricsQueryTokenEventOptions getMetricsQueryTokenEventOptions) { + String[] pathSegments = { "v1/metrics/top_query_tokens_with_event_rate" }; + RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); + builder.query(VERSION, versionDate); + if (getMetricsQueryTokenEventOptions != null) { + if (getMetricsQueryTokenEventOptions.count() != null) { + builder.query("count", String.valueOf(getMetricsQueryTokenEventOptions.count())); + } + } + return createServiceCall(builder.build(), ResponseConverterUtils.getObject(MetricTokenResponse.class)); + } + + /** + * Most frequent query tokens with an event. + * + * The most frequent query tokens parsed from the **natural_language_query** parameter and their corresponding + * \"click\" event rate within the recording period (queries and events are stored for 30 days). A query token is an + * individual word or unigram within the query string. + * + * @return a {@link ServiceCall} with a response type of {@link MetricTokenResponse} + */ + public ServiceCall getMetricsQueryTokenEvent() { + return getMetricsQueryTokenEvent(null); + } + + /** + * Search the query and event log. + * + * Searches the query and event log to find query sessions that match the specified criteria. Searching the **logs** + * endpoint uses the standard Discovery query syntax for the parameters that are supported. + * + * @param queryLogOptions the {@link QueryLogOptions} containing the options for the call + * @return a {@link ServiceCall} with a response type of {@link LogQueryResponse} + */ + public ServiceCall queryLog(QueryLogOptions queryLogOptions) { + String[] pathSegments = { "v1/logs" }; + RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); + builder.query(VERSION, versionDate); + if (queryLogOptions != null) { + if (queryLogOptions.filter() != null) { + builder.query("filter", queryLogOptions.filter()); + } + if (queryLogOptions.query() != null) { + builder.query("query", queryLogOptions.query()); + } + if (queryLogOptions.count() != null) { + builder.query("count", String.valueOf(queryLogOptions.count())); + } + if (queryLogOptions.offset() != null) { + builder.query("offset", String.valueOf(queryLogOptions.offset())); + } + if (queryLogOptions.sort() != null) { + builder.query("sort", RequestUtils.join(queryLogOptions.sort(), ",")); + } + } + return createServiceCall(builder.build(), ResponseConverterUtils.getObject(LogQueryResponse.class)); + } + + /** + * Search the query and event log. + * + * Searches the query and event log to find query sessions that match the specified criteria. Searching the **logs** + * endpoint uses the standard Discovery query syntax for the parameters that are supported. + * + * @return a {@link ServiceCall} with a response type of {@link LogQueryResponse} + */ + public ServiceCall queryLog() { + return queryLog(null); + } + /** * Create credentials. * diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateEnvironmentOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateEnvironmentOptions.java index 451699dee03..35afcee8cd0 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateEnvironmentOptions.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateEnvironmentOptions.java @@ -20,9 +20,33 @@ */ public class CreateEnvironmentOptions extends GenericModel { + /** + * Size of the environment. + */ + public interface Size { + /** XS. */ + String XS = "XS"; + /** S. */ + String S = "S"; + /** MS. */ + String MS = "MS"; + /** M. */ + String M = "M"; + /** ML. */ + String ML = "ML"; + /** L. */ + String L = "L"; + /** XL. */ + String XL = "XL"; + /** XXL. */ + String XXL = "XXL"; + /** XXXL. */ + String XXXL = "XXXL"; + } + private String name; private String description; - private Long size; + private String size; /** * Builder. @@ -30,7 +54,7 @@ public class CreateEnvironmentOptions extends GenericModel { public static class Builder { private String name; private String description; - private Long size; + private String size; private Builder(CreateEnvironmentOptions createEnvironmentOptions) { name = createEnvironmentOptions.name; @@ -90,10 +114,17 @@ public Builder description(String description) { * @param size the size * @return the CreateEnvironmentOptions builder */ - public Builder size(long size) { + public Builder size(String size) { this.size = size; return this; } + + /** + * @deprecated This method no longer has an effect on the created environment. Please use the String method. + */ + public Builder size(Long size) { + return this; + } } private CreateEnvironmentOptions(Builder builder) { @@ -137,11 +168,11 @@ public String description() { /** * Gets the size. * - * **Deprecated**: Size of the environment. + * Size of the environment. * * @return the size */ - public Long size() { + public String size() { return size; } } diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateEventOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateEventOptions.java new file mode 100644 index 00000000000..ed228f071f5 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateEventOptions.java @@ -0,0 +1,132 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; +import com.ibm.watson.developer_cloud.util.Validator; + +/** + * The createEvent options. + */ +public class CreateEventOptions extends GenericModel { + + /** + * The event type to be created. + */ + public interface Type { + /** click. */ + String CLICK = "click"; + } + + private String type; + private EventData data; + + /** + * Builder. + */ + public static class Builder { + private String type; + private EventData data; + + private Builder(CreateEventOptions createEventOptions) { + type = createEventOptions.type; + data = createEventOptions.data; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Instantiates a new builder with required properties. + * + * @param type the type + * @param data the data + */ + public Builder(String type, EventData data) { + this.type = type; + this.data = data; + } + + /** + * Builds a CreateEventOptions. + * + * @return the createEventOptions + */ + public CreateEventOptions build() { + return new CreateEventOptions(this); + } + + /** + * Set the type. + * + * @param type the type + * @return the CreateEventOptions builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the data. + * + * @param data the data + * @return the CreateEventOptions builder + */ + public Builder data(EventData data) { + this.data = data; + return this; + } + } + + private CreateEventOptions(Builder builder) { + Validator.notNull(builder.type, "type cannot be null"); + Validator.notNull(builder.data, "data cannot be null"); + type = builder.type; + data = builder.data; + } + + /** + * New builder. + * + * @return a CreateEventOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the type. + * + * The event type to be created. + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the data. + * + * Data object used to create a query event. + * + * @return the data + */ + public EventData data() { + return data; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateEventResponse.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateEventResponse.java new file mode 100644 index 00000000000..1c8f507bad5 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateEventResponse.java @@ -0,0 +1,54 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * An object defining the event being created. + */ +public class CreateEventResponse extends GenericModel { + + /** + * The event type that was created. + */ + public interface Type { + /** click. */ + String CLICK = "click"; + } + + private String type; + private EventData data; + + /** + * Gets the type. + * + * The event type that was created. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the data. + * + * Query event data object. + * + * @return the data + */ + public EventData getData() { + return data; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Environment.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Environment.java index 16b592c0030..c13d96c8944 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Environment.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Environment.java @@ -34,6 +34,30 @@ public interface Status { String MAINTENANCE = "maintenance"; } + /** + * Size of the environment. + */ + public interface Size { + /** XS. */ + String XS = "XS"; + /** S. */ + String S = "S"; + /** MS. */ + String MS = "MS"; + /** M. */ + String M = "M"; + /** ML. */ + String ML = "ML"; + /** L. */ + String L = "L"; + /** XL. */ + String XL = "XL"; + /** XXL. */ + String XXL = "XXL"; + /** XXXL. */ + String XXXL = "XXXL"; + } + @SerializedName("environment_id") private String environmentId; private String name; @@ -43,7 +67,7 @@ public interface Status { private String status; @SerializedName("read_only") private Boolean readOnly; - private Long size; + private String size; @SerializedName("index_capacity") private IndexCapacity indexCapacity; @@ -127,11 +151,11 @@ public Boolean isReadOnly() { /** * Gets the size. * - * **Deprecated**: Size of the environment. + * Size of the environment. * * @return the size */ - public Long getSize() { + public String getSize() { return size; } diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EventData.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EventData.java new file mode 100644 index 00000000000..e632c2761aa --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EventData.java @@ -0,0 +1,172 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import java.util.Date; + +import com.google.gson.annotations.SerializedName; +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * Query event data object. + */ +public class EventData extends GenericModel { + + @SerializedName("environment_id") + private String environmentId; + @SerializedName("session_token") + private String sessionToken; + @SerializedName("client_timestamp") + private Date clientTimestamp; + @SerializedName("display_rank") + private Long displayRank; + @SerializedName("collection_id") + private String collectionId; + @SerializedName("document_id") + private String documentId; + @SerializedName("query_id") + private String queryId; + + /** + * Gets the environmentId. + * + * The **environment_id** associated with the query that the event is associated with. + * + * @return the environmentId + */ + public String getEnvironmentId() { + return environmentId; + } + + /** + * Gets the sessionToken. + * + * The session token that was returned as part of the query results that this event is associated with. + * + * @return the sessionToken + */ + public String getSessionToken() { + return sessionToken; + } + + /** + * Gets the clientTimestamp. + * + * The optional timestamp for the event that was created. If not provided, the time that the event was created in the + * log was used. + * + * @return the clientTimestamp + */ + public Date getClientTimestamp() { + return clientTimestamp; + } + + /** + * Gets the displayRank. + * + * The rank of the result item which the event is associated with. + * + * @return the displayRank + */ + public Long getDisplayRank() { + return displayRank; + } + + /** + * Gets the collectionId. + * + * The **collection_id** of the document that this event is associated with. + * + * @return the collectionId + */ + public String getCollectionId() { + return collectionId; + } + + /** + * Gets the documentId. + * + * The **document_id** of the document that this event is associated with. + * + * @return the documentId + */ + public String getDocumentId() { + return documentId; + } + + /** + * Gets the queryId. + * + * The query identifier stored in the log. The query and any events associated with that query are stored with the + * same **query_id**. + * + * @return the queryId + */ + public String getQueryId() { + return queryId; + } + + /** + * Sets the environmentId. + * + * @param environmentId the new environmentId + */ + public void setEnvironmentId(final String environmentId) { + this.environmentId = environmentId; + } + + /** + * Sets the sessionToken. + * + * @param sessionToken the new sessionToken + */ + public void setSessionToken(final String sessionToken) { + this.sessionToken = sessionToken; + } + + /** + * Sets the clientTimestamp. + * + * @param clientTimestamp the new clientTimestamp + */ + public void setClientTimestamp(final Date clientTimestamp) { + this.clientTimestamp = clientTimestamp; + } + + /** + * Sets the displayRank. + * + * @param displayRank the new displayRank + */ + public void setDisplayRank(final long displayRank) { + this.displayRank = displayRank; + } + + /** + * Sets the collectionId. + * + * @param collectionId the new collectionId + */ + public void setCollectionId(final String collectionId) { + this.collectionId = collectionId; + } + + /** + * Sets the documentId. + * + * @param documentId the new documentId + */ + public void setDocumentId(final String documentId) { + this.documentId = documentId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/FederatedQueryNoticesOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/FederatedQueryNoticesOptions.java index 487d0ab1b0f..4e8c25dbe69 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/FederatedQueryNoticesOptions.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/FederatedQueryNoticesOptions.java @@ -454,7 +454,7 @@ public String aggregation() { /** * Gets the count. * - * Number of documents to return. + * Number of results to return. * * @return the count */ diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/FederatedQueryOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/FederatedQueryOptions.java index b735375250b..1ad3f86ca9e 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/FederatedQueryOptions.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/FederatedQueryOptions.java @@ -545,7 +545,7 @@ public String aggregation() { /** * Gets the count. * - * Number of documents to return. + * Number of results to return. * * @return the count */ diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetMetricsEventRateOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetMetricsEventRateOptions.java new file mode 100644 index 00000000000..43fd7b56cd7 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetMetricsEventRateOptions.java @@ -0,0 +1,146 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import java.util.Date; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * The getMetricsEventRate options. + */ +public class GetMetricsEventRateOptions extends GenericModel { + + /** + * The type of result to consider when calculating the metric. + */ + public interface ResultType { + /** document. */ + String DOCUMENT = "document"; + } + + private Date startTime; + private Date endTime; + private String resultType; + + /** + * Builder. + */ + public static class Builder { + private Date startTime; + private Date endTime; + private String resultType; + + private Builder(GetMetricsEventRateOptions getMetricsEventRateOptions) { + startTime = getMetricsEventRateOptions.startTime; + endTime = getMetricsEventRateOptions.endTime; + resultType = getMetricsEventRateOptions.resultType; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a GetMetricsEventRateOptions. + * + * @return the getMetricsEventRateOptions + */ + public GetMetricsEventRateOptions build() { + return new GetMetricsEventRateOptions(this); + } + + /** + * Set the startTime. + * + * @param startTime the startTime + * @return the GetMetricsEventRateOptions builder + */ + public Builder startTime(Date startTime) { + this.startTime = startTime; + return this; + } + + /** + * Set the endTime. + * + * @param endTime the endTime + * @return the GetMetricsEventRateOptions builder + */ + public Builder endTime(Date endTime) { + this.endTime = endTime; + return this; + } + + /** + * Set the resultType. + * + * @param resultType the resultType + * @return the GetMetricsEventRateOptions builder + */ + public Builder resultType(String resultType) { + this.resultType = resultType; + return this; + } + } + + private GetMetricsEventRateOptions(Builder builder) { + startTime = builder.startTime; + endTime = builder.endTime; + resultType = builder.resultType; + } + + /** + * New builder. + * + * @return a GetMetricsEventRateOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the startTime. + * + * Metric is computed from data recorded after this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. + * + * @return the startTime + */ + public Date startTime() { + return startTime; + } + + /** + * Gets the endTime. + * + * Metric is computed from data recorded before this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. + * + * @return the endTime + */ + public Date endTime() { + return endTime; + } + + /** + * Gets the resultType. + * + * The type of result to consider when calculating the metric. + * + * @return the resultType + */ + public String resultType() { + return resultType; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetMetricsQueryEventOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetMetricsQueryEventOptions.java new file mode 100644 index 00000000000..85c9bafda55 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetMetricsQueryEventOptions.java @@ -0,0 +1,146 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import java.util.Date; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * The getMetricsQueryEvent options. + */ +public class GetMetricsQueryEventOptions extends GenericModel { + + /** + * The type of result to consider when calculating the metric. + */ + public interface ResultType { + /** document. */ + String DOCUMENT = "document"; + } + + private Date startTime; + private Date endTime; + private String resultType; + + /** + * Builder. + */ + public static class Builder { + private Date startTime; + private Date endTime; + private String resultType; + + private Builder(GetMetricsQueryEventOptions getMetricsQueryEventOptions) { + startTime = getMetricsQueryEventOptions.startTime; + endTime = getMetricsQueryEventOptions.endTime; + resultType = getMetricsQueryEventOptions.resultType; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a GetMetricsQueryEventOptions. + * + * @return the getMetricsQueryEventOptions + */ + public GetMetricsQueryEventOptions build() { + return new GetMetricsQueryEventOptions(this); + } + + /** + * Set the startTime. + * + * @param startTime the startTime + * @return the GetMetricsQueryEventOptions builder + */ + public Builder startTime(Date startTime) { + this.startTime = startTime; + return this; + } + + /** + * Set the endTime. + * + * @param endTime the endTime + * @return the GetMetricsQueryEventOptions builder + */ + public Builder endTime(Date endTime) { + this.endTime = endTime; + return this; + } + + /** + * Set the resultType. + * + * @param resultType the resultType + * @return the GetMetricsQueryEventOptions builder + */ + public Builder resultType(String resultType) { + this.resultType = resultType; + return this; + } + } + + private GetMetricsQueryEventOptions(Builder builder) { + startTime = builder.startTime; + endTime = builder.endTime; + resultType = builder.resultType; + } + + /** + * New builder. + * + * @return a GetMetricsQueryEventOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the startTime. + * + * Metric is computed from data recorded after this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. + * + * @return the startTime + */ + public Date startTime() { + return startTime; + } + + /** + * Gets the endTime. + * + * Metric is computed from data recorded before this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. + * + * @return the endTime + */ + public Date endTime() { + return endTime; + } + + /** + * Gets the resultType. + * + * The type of result to consider when calculating the metric. + * + * @return the resultType + */ + public String resultType() { + return resultType; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetMetricsQueryNoResultsOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetMetricsQueryNoResultsOptions.java new file mode 100644 index 00000000000..c637eacded5 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetMetricsQueryNoResultsOptions.java @@ -0,0 +1,146 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import java.util.Date; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * The getMetricsQueryNoResults options. + */ +public class GetMetricsQueryNoResultsOptions extends GenericModel { + + /** + * The type of result to consider when calculating the metric. + */ + public interface ResultType { + /** document. */ + String DOCUMENT = "document"; + } + + private Date startTime; + private Date endTime; + private String resultType; + + /** + * Builder. + */ + public static class Builder { + private Date startTime; + private Date endTime; + private String resultType; + + private Builder(GetMetricsQueryNoResultsOptions getMetricsQueryNoResultsOptions) { + startTime = getMetricsQueryNoResultsOptions.startTime; + endTime = getMetricsQueryNoResultsOptions.endTime; + resultType = getMetricsQueryNoResultsOptions.resultType; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a GetMetricsQueryNoResultsOptions. + * + * @return the getMetricsQueryNoResultsOptions + */ + public GetMetricsQueryNoResultsOptions build() { + return new GetMetricsQueryNoResultsOptions(this); + } + + /** + * Set the startTime. + * + * @param startTime the startTime + * @return the GetMetricsQueryNoResultsOptions builder + */ + public Builder startTime(Date startTime) { + this.startTime = startTime; + return this; + } + + /** + * Set the endTime. + * + * @param endTime the endTime + * @return the GetMetricsQueryNoResultsOptions builder + */ + public Builder endTime(Date endTime) { + this.endTime = endTime; + return this; + } + + /** + * Set the resultType. + * + * @param resultType the resultType + * @return the GetMetricsQueryNoResultsOptions builder + */ + public Builder resultType(String resultType) { + this.resultType = resultType; + return this; + } + } + + private GetMetricsQueryNoResultsOptions(Builder builder) { + startTime = builder.startTime; + endTime = builder.endTime; + resultType = builder.resultType; + } + + /** + * New builder. + * + * @return a GetMetricsQueryNoResultsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the startTime. + * + * Metric is computed from data recorded after this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. + * + * @return the startTime + */ + public Date startTime() { + return startTime; + } + + /** + * Gets the endTime. + * + * Metric is computed from data recorded before this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. + * + * @return the endTime + */ + public Date endTime() { + return endTime; + } + + /** + * Gets the resultType. + * + * The type of result to consider when calculating the metric. + * + * @return the resultType + */ + public String resultType() { + return resultType; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetMetricsQueryOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetMetricsQueryOptions.java new file mode 100644 index 00000000000..1c45397b31f --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetMetricsQueryOptions.java @@ -0,0 +1,146 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import java.util.Date; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * The getMetricsQuery options. + */ +public class GetMetricsQueryOptions extends GenericModel { + + /** + * The type of result to consider when calculating the metric. + */ + public interface ResultType { + /** document. */ + String DOCUMENT = "document"; + } + + private Date startTime; + private Date endTime; + private String resultType; + + /** + * Builder. + */ + public static class Builder { + private Date startTime; + private Date endTime; + private String resultType; + + private Builder(GetMetricsQueryOptions getMetricsQueryOptions) { + startTime = getMetricsQueryOptions.startTime; + endTime = getMetricsQueryOptions.endTime; + resultType = getMetricsQueryOptions.resultType; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a GetMetricsQueryOptions. + * + * @return the getMetricsQueryOptions + */ + public GetMetricsQueryOptions build() { + return new GetMetricsQueryOptions(this); + } + + /** + * Set the startTime. + * + * @param startTime the startTime + * @return the GetMetricsQueryOptions builder + */ + public Builder startTime(Date startTime) { + this.startTime = startTime; + return this; + } + + /** + * Set the endTime. + * + * @param endTime the endTime + * @return the GetMetricsQueryOptions builder + */ + public Builder endTime(Date endTime) { + this.endTime = endTime; + return this; + } + + /** + * Set the resultType. + * + * @param resultType the resultType + * @return the GetMetricsQueryOptions builder + */ + public Builder resultType(String resultType) { + this.resultType = resultType; + return this; + } + } + + private GetMetricsQueryOptions(Builder builder) { + startTime = builder.startTime; + endTime = builder.endTime; + resultType = builder.resultType; + } + + /** + * New builder. + * + * @return a GetMetricsQueryOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the startTime. + * + * Metric is computed from data recorded after this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. + * + * @return the startTime + */ + public Date startTime() { + return startTime; + } + + /** + * Gets the endTime. + * + * Metric is computed from data recorded before this timestamp; must be in `YYYY-MM-DDThh:mm:ssZ` format. + * + * @return the endTime + */ + public Date endTime() { + return endTime; + } + + /** + * Gets the resultType. + * + * The type of result to consider when calculating the metric. + * + * @return the resultType + */ + public String resultType() { + return resultType; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetMetricsQueryTokenEventOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetMetricsQueryTokenEventOptions.java new file mode 100644 index 00000000000..1d44365842c --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetMetricsQueryTokenEventOptions.java @@ -0,0 +1,84 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * The getMetricsQueryTokenEvent options. + */ +public class GetMetricsQueryTokenEventOptions extends GenericModel { + + private Long count; + + /** + * Builder. + */ + public static class Builder { + private Long count; + + private Builder(GetMetricsQueryTokenEventOptions getMetricsQueryTokenEventOptions) { + count = getMetricsQueryTokenEventOptions.count; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a GetMetricsQueryTokenEventOptions. + * + * @return the getMetricsQueryTokenEventOptions + */ + public GetMetricsQueryTokenEventOptions build() { + return new GetMetricsQueryTokenEventOptions(this); + } + + /** + * Set the count. + * + * @param count the count + * @return the GetMetricsQueryTokenEventOptions builder + */ + public Builder count(long count) { + this.count = count; + return this; + } + } + + private GetMetricsQueryTokenEventOptions(Builder builder) { + count = builder.count; + } + + /** + * New builder. + * + * @return a GetMetricsQueryTokenEventOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the count. + * + * Number of results to return. + * + * @return the count + */ + public Long count() { + return count; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/LogQueryResponse.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/LogQueryResponse.java new file mode 100644 index 00000000000..79920a12c9e --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/LogQueryResponse.java @@ -0,0 +1,48 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * Object containing results that match the requested **logs** query. + */ +public class LogQueryResponse extends GenericModel { + + @SerializedName("matching_results") + private Long matchingResults; + private List results; + + /** + * Gets the matchingResults. + * + * Number of matching results. + * + * @return the matchingResults + */ + public Long getMatchingResults() { + return matchingResults; + } + + /** + * Gets the results. + * + * @return the results + */ + public List getResults() { + return results; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/LogQueryResponseResult.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/LogQueryResponseResult.java new file mode 100644 index 00000000000..7a0d27abfbf --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/LogQueryResponseResult.java @@ -0,0 +1,269 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import java.util.Date; + +import com.google.gson.annotations.SerializedName; +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * Individual result object for a **logs** query. Each object represents either a query to a Discovery collection or an + * event that is associated with a query. + */ +public class LogQueryResponseResult extends GenericModel { + + /** + * The type of log entry returned. + * + * **query** indicates that the log represents the results of a call to the single collection **query** method. + * + * **event** indicates that the log represents a call to the **events** API. + */ + public interface DocumentType { + /** query. */ + String QUERY = "query"; + /** event. */ + String EVENT = "event"; + } + + /** + * The type of event that this object respresents. Possible values are + * + * - `query` the log of a query to a collection + * + * - `click` the result of a call to the **events** endpoint. + */ + public interface EventType { + /** click. */ + String CLICK = "click"; + /** query. */ + String QUERY = "query"; + } + + /** + * The type of result that this **event** is associated with. Only returned with logs of type `event`. + */ + public interface ResultType { + /** document. */ + String DOCUMENT = "document"; + } + + @SerializedName("environment_id") + private String environmentId; + @SerializedName("customer_id") + private String customerId; + @SerializedName("document_type") + private String documentType; + @SerializedName("natural_language_query") + private String naturalLanguageQuery; + @SerializedName("document_results") + private LogQueryResponseResultDocuments documentResults; + @SerializedName("created_timestamp") + private Date createdTimestamp; + @SerializedName("client_timestamp") + private Date clientTimestamp; + @SerializedName("query_id") + private String queryId; + @SerializedName("session_token") + private String sessionToken; + @SerializedName("collection_id") + private String collectionId; + @SerializedName("display_rank") + private Long displayRank; + @SerializedName("document_id") + private String documentId; + @SerializedName("event_type") + private String eventType; + @SerializedName("result_type") + private String resultType; + + /** + * Gets the environmentId. + * + * The environment ID that is associated with this log entry. + * + * @return the environmentId + */ + public String getEnvironmentId() { + return environmentId; + } + + /** + * Gets the customerId. + * + * The **customer_id** label that was specified in the header of the query or event API call that corresponds to this + * log entry. + * + * @return the customerId + */ + public String getCustomerId() { + return customerId; + } + + /** + * Gets the documentType. + * + * The type of log entry returned. + * + * **query** indicates that the log represents the results of a call to the single collection **query** method. + * + * **event** indicates that the log represents a call to the **events** API. + * + * @return the documentType + */ + public String getDocumentType() { + return documentType; + } + + /** + * Gets the naturalLanguageQuery. + * + * The value of the **natural_language_query** query parameter that was used to create these results. Only returned + * with logs of type **query**. + * + * **Note:** Other query parameters (such as **filter** or **deduplicate**) might have been used with this query, but + * are not recorded. + * + * @return the naturalLanguageQuery + */ + public String getNaturalLanguageQuery() { + return naturalLanguageQuery; + } + + /** + * Gets the documentResults. + * + * Object containing result information that was returned by the query used to create this log entry. Only returned + * with logs of type `query`. + * + * @return the documentResults + */ + public LogQueryResponseResultDocuments getDocumentResults() { + return documentResults; + } + + /** + * Gets the createdTimestamp. + * + * Date that the log result was created. Returned in `YYYY-MM-DDThh:mm:ssZ` format. + * + * @return the createdTimestamp + */ + public Date getCreatedTimestamp() { + return createdTimestamp; + } + + /** + * Gets the clientTimestamp. + * + * Date specified by the user when recording an event. Returned in `YYYY-MM-DDThh:mm:ssZ` format. Only returned with + * logs of type **event**. + * + * @return the clientTimestamp + */ + public Date getClientTimestamp() { + return clientTimestamp; + } + + /** + * Gets the queryId. + * + * Identifier that corresponds to the **natural_language_query** string used in the original or associated query. All + * **event** and **query** log entries that have the same original **natural_language_query** string also have them + * same **query_id**. This field can be used to recall all **event** and **query** log results that have the same + * original query (**event** logs do not contain the original **natural_language_query** field). + * + * @return the queryId + */ + public String getQueryId() { + return queryId; + } + + /** + * Gets the sessionToken. + * + * Unique identifier (within a 24-hour period) that identifies a single `query` log and any `event` logs that were + * created for it. + * + * **Note:** If the exact same query is run at the exact same time on different days, the **session_token** for those + * queries might be identical. However, the **created_timestamp** differs. + * + * **Note:** Session tokens are case sensitive. To avoid matching on session tokens that are identical except for + * case, use the exact match operator (`::`) when you query for a specific session token. + * + * @return the sessionToken + */ + public String getSessionToken() { + return sessionToken; + } + + /** + * Gets the collectionId. + * + * The collection ID of the document associated with this event. Only returned with logs of type `event`. + * + * @return the collectionId + */ + public String getCollectionId() { + return collectionId; + } + + /** + * Gets the displayRank. + * + * The original display rank of the document associated with this event. Only returned with logs of type `event`. + * + * @return the displayRank + */ + public Long getDisplayRank() { + return displayRank; + } + + /** + * Gets the documentId. + * + * The document ID of the document associated with this event. Only returned with logs of type `event`. + * + * @return the documentId + */ + public String getDocumentId() { + return documentId; + } + + /** + * Gets the eventType. + * + * The type of event that this object respresents. Possible values are + * + * - `query` the log of a query to a collection + * + * - `click` the result of a call to the **events** endpoint. + * + * @return the eventType + */ + public String getEventType() { + return eventType; + } + + /** + * Gets the resultType. + * + * The type of result that this **event** is associated with. Only returned with logs of type `event`. + * + * @return the resultType + */ + public String getResultType() { + return resultType; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/LogQueryResponseResultDocuments.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/LogQueryResponseResultDocuments.java new file mode 100644 index 00000000000..d70d58d9b93 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/LogQueryResponseResultDocuments.java @@ -0,0 +1,47 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import java.util.List; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * Object containing result information that was returned by the query used to create this log entry. Only returned with + * logs of type `query`. + */ +public class LogQueryResponseResultDocuments extends GenericModel { + + private List results; + private Long count; + + /** + * Gets the results. + * + * @return the results + */ + public List getResults() { + return results; + } + + /** + * Gets the count. + * + * The number of results returned in the query associate with this log. + * + * @return the count + */ + public Long getCount() { + return count; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/LogQueryResponseResultDocumentsResult.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/LogQueryResponseResultDocumentsResult.java new file mode 100644 index 00000000000..cc82f24d77a --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/LogQueryResponseResultDocumentsResult.java @@ -0,0 +1,85 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * Each object in the **results** array corresponds to an individual document returned by the original query. + */ +public class LogQueryResponseResultDocumentsResult extends GenericModel { + + private Long position; + @SerializedName("document_id") + private String documentId; + private Double score; + private Double confidence; + @SerializedName("collection_id") + private String collectionId; + + /** + * Gets the position. + * + * The result rank of this document. A position of `1` indicates that it was the first returned result. + * + * @return the position + */ + public Long getPosition() { + return position; + } + + /** + * Gets the documentId. + * + * The **document_id** of the document that this result represents. + * + * @return the documentId + */ + public String getDocumentId() { + return documentId; + } + + /** + * Gets the score. + * + * The raw score of this result. A higher score indicates a greater match to the query parameters. + * + * @return the score + */ + public Double getScore() { + return score; + } + + /** + * Gets the confidence. + * + * The confidence score of the result's analysis. A higher score indicating greater confidence. + * + * @return the confidence + */ + public Double getConfidence() { + return confidence; + } + + /** + * Gets the collectionId. + * + * The **collection_id** of the document represented by this result. + * + * @return the collectionId + */ + public String getCollectionId() { + return collectionId; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricAggregation.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricAggregation.java new file mode 100644 index 00000000000..3515b93f427 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricAggregation.java @@ -0,0 +1,60 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * An aggregation analyzing log information for queries and events. + */ +public class MetricAggregation extends GenericModel { + + private String interval; + @SerializedName("event_type") + private String eventType; + private List results; + + /** + * Gets the interval. + * + * The measurement interval for this metric. Metric intervals are always 1 day (`1d`). + * + * @return the interval + */ + public String getInterval() { + return interval; + } + + /** + * Gets the eventType. + * + * The event type associated with this metric result. This field, when present, will always be `click`. + * + * @return the eventType + */ + public String getEventType() { + return eventType; + } + + /** + * Gets the results. + * + * @return the results + */ + public List getResults() { + return results; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricAggregationResult.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricAggregationResult.java new file mode 100644 index 00000000000..78eedbb3bd0 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricAggregationResult.java @@ -0,0 +1,77 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import java.util.Date; + +import com.google.gson.annotations.SerializedName; +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * Aggregation result data for the requested metric. + */ +public class MetricAggregationResult extends GenericModel { + + @SerializedName("key_as_string") + private Date keyAsString; + private Long key; + @SerializedName("matching_results") + private Long matchingResults; + @SerializedName("event_rate") + private Double eventRate; + + /** + * Gets the keyAsString. + * + * Date in string form representing the start of this interval. + * + * @return the keyAsString + */ + public Date getKeyAsString() { + return keyAsString; + } + + /** + * Gets the key. + * + * Unix epoch time equivalent of the **key_as_string**, that represents the start of this interval. + * + * @return the key + */ + public Long getKey() { + return key; + } + + /** + * Gets the matchingResults. + * + * Number of matching results. + * + * @return the matchingResults + */ + public Long getMatchingResults() { + return matchingResults; + } + + /** + * Gets the eventRate. + * + * The number of queries with associated events divided by the total number of queries for the interval. Only returned + * with **event_rate** metrics. + * + * @return the eventRate + */ + public Double getEventRate() { + return eventRate; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricResponse.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricResponse.java new file mode 100644 index 00000000000..80ef08bbe5c --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import java.util.List; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * The response generated from a call to a **metrics** method. + */ +public class MetricResponse extends GenericModel { + + private List aggregations; + + /** + * Gets the aggregations. + * + * @return the aggregations + */ + public List getAggregations() { + return aggregations; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricTokenAggregation.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricTokenAggregation.java new file mode 100644 index 00000000000..37b16751cae --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricTokenAggregation.java @@ -0,0 +1,48 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * An aggregation analyzing log information for queries and events. + */ +public class MetricTokenAggregation extends GenericModel { + + @SerializedName("event_type") + private String eventType; + private List results; + + /** + * Gets the eventType. + * + * The event type associated with this metric result. This field, when present, will always be `click`. + * + * @return the eventType + */ + public String getEventType() { + return eventType; + } + + /** + * Gets the results. + * + * @return the results + */ + public List getResults() { + return results; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricTokenAggregationResult.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricTokenAggregationResult.java new file mode 100644 index 00000000000..9ba02e0e672 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricTokenAggregationResult.java @@ -0,0 +1,62 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * Aggregation result data for the requested metric. + */ +public class MetricTokenAggregationResult extends GenericModel { + + private String key; + @SerializedName("matching_results") + private Long matchingResults; + @SerializedName("event_rate") + private Double eventRate; + + /** + * Gets the key. + * + * The content of the **natural_language_query** parameter used in the query that this result represents. + * + * @return the key + */ + public String getKey() { + return key; + } + + /** + * Gets the matchingResults. + * + * Number of matching results. + * + * @return the matchingResults + */ + public Long getMatchingResults() { + return matchingResults; + } + + /** + * Gets the eventRate. + * + * The number of queries with associated events divided by the total number of queries currently stored (queries and + * events are stored in the log for 30 days). + * + * @return the eventRate + */ + public Double getEventRate() { + return eventRate; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricTokenResponse.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricTokenResponse.java new file mode 100644 index 00000000000..6a03ac40cf0 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MetricTokenResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import java.util.List; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; + +/** + * The response generated from a call to a **metrics** method that evaluates tokens. + */ +public class MetricTokenResponse extends GenericModel { + + private List aggregations; + + /** + * Gets the aggregations. + * + * @return the aggregations + */ + public List getAggregations() { + return aggregations; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryAggregation.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryAggregation.java index a3f0f1f1f81..ab40cc85239 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryAggregation.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryAggregation.java @@ -14,12 +14,15 @@ import java.util.List; +import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; +import com.ibm.watson.developer_cloud.discovery.v1.query.AggregationDeserializer; import com.ibm.watson.developer_cloud.service.model.GenericModel; /** * An aggregation produced by the Discovery service to analyze the input provided. */ +@JsonAdapter(AggregationDeserializer.class) public class QueryAggregation extends GenericModel { private String type; diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryLogOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryLogOptions.java new file mode 100644 index 00000000000..a0123037b8b --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryLogOptions.java @@ -0,0 +1,215 @@ +/* + * Copyright 2018 IBM Corp. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.ibm.watson.developer_cloud.discovery.v1.model; + +import java.util.ArrayList; +import java.util.List; + +import com.ibm.watson.developer_cloud.service.model.GenericModel; +import com.ibm.watson.developer_cloud.util.Validator; + +/** + * The queryLog options. + */ +public class QueryLogOptions extends GenericModel { + + private String filter; + private String query; + private Long count; + private Long offset; + private List sort; + + /** + * Builder. + */ + public static class Builder { + private String filter; + private String query; + private Long count; + private Long offset; + private List sort; + + private Builder(QueryLogOptions queryLogOptions) { + filter = queryLogOptions.filter; + query = queryLogOptions.query; + count = queryLogOptions.count; + offset = queryLogOptions.offset; + sort = queryLogOptions.sort; + } + + /** + * Instantiates a new builder. + */ + public Builder() { + } + + /** + * Builds a QueryLogOptions. + * + * @return the queryLogOptions + */ + public QueryLogOptions build() { + return new QueryLogOptions(this); + } + + /** + * Adds an sort to sort. + * + * @param sort the new sort + * @return the QueryLogOptions builder + */ + public Builder addSort(String sort) { + Validator.notNull(sort, "sort cannot be null"); + if (this.sort == null) { + this.sort = new ArrayList(); + } + this.sort.add(sort); + return this; + } + + /** + * Set the filter. + * + * @param filter the filter + * @return the QueryLogOptions builder + */ + public Builder filter(String filter) { + this.filter = filter; + return this; + } + + /** + * Set the query. + * + * @param query the query + * @return the QueryLogOptions builder + */ + public Builder query(String query) { + this.query = query; + return this; + } + + /** + * Set the count. + * + * @param count the count + * @return the QueryLogOptions builder + */ + public Builder count(long count) { + this.count = count; + return this; + } + + /** + * Set the offset. + * + * @param offset the offset + * @return the QueryLogOptions builder + */ + public Builder offset(long offset) { + this.offset = offset; + return this; + } + + /** + * Set the sort. + * Existing sort will be replaced. + * + * @param sort the sort + * @return the QueryLogOptions builder + */ + public Builder sort(List sort) { + this.sort = sort; + return this; + } + } + + private QueryLogOptions(Builder builder) { + filter = builder.filter; + query = builder.query; + count = builder.count; + offset = builder.offset; + sort = builder.sort; + } + + /** + * New builder. + * + * @return a QueryLogOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the filter. + * + * A cacheable query that limits the documents returned to exclude any documents that don't mention the query content. + * Filter searches are better for metadata type searches and when you are trying to get a sense of concepts in the + * data set. + * + * @return the filter + */ + public String filter() { + return filter; + } + + /** + * Gets the query. + * + * A query search returns all documents in your data set with full enrichments and full text, but with the most + * relevant documents listed first. Use a query search when you want to find the most relevant search results. You + * cannot use **natural_language_query** and **query** at the same time. + * + * @return the query + */ + public String query() { + return query; + } + + /** + * Gets the count. + * + * Number of results to return. + * + * @return the count + */ + public Long count() { + return count; + } + + /** + * Gets the offset. + * + * The number of query results to skip at the beginning. For example, if the total number of results that are returned + * is 10, and the offset is 8, it returns the last two results. + * + * @return the offset + */ + public Long offset() { + return offset; + } + + /** + * Gets the sort. + * + * A comma separated list of fields in the document to sort on. You can optionally specify a sort direction by + * prefixing the field with `-` for descending or `+` for ascending. Ascending is the default sort direction if no + * prefix is specified. + * + * @return the sort + */ + public List sort() { + return sort; + } +} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryNoticesOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryNoticesOptions.java index 5263fbe5b44..04df0965387 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryNoticesOptions.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryNoticesOptions.java @@ -525,7 +525,7 @@ public String aggregation() { /** * Gets the count. * - * Number of documents to return. + * Number of results to return. * * @return the count */ diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryOptions.java index b634a30976e..7cd06058da8 100644 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryOptions.java +++ b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryOptions.java @@ -555,7 +555,7 @@ public String aggregation() { /** * Gets the count. * - * Number of documents to return. + * Number of results to return. * * @return the count */ diff --git a/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java b/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java index 652391922a6..8d526685a67 100644 --- a/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java +++ b/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java @@ -26,6 +26,8 @@ import com.ibm.watson.developer_cloud.discovery.v1.model.CreateConfigurationOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.CreateCredentialsOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEnvironmentOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEventOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEventResponse; import com.ibm.watson.developer_cloud.discovery.v1.model.CreateExpansionsOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.CreateTrainingExampleOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.CredentialDetails; @@ -46,6 +48,7 @@ import com.ibm.watson.developer_cloud.discovery.v1.model.Enrichment; import com.ibm.watson.developer_cloud.discovery.v1.model.EnrichmentOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.Environment; +import com.ibm.watson.developer_cloud.discovery.v1.model.EventData; import com.ibm.watson.developer_cloud.discovery.v1.model.Expansion; import com.ibm.watson.developer_cloud.discovery.v1.model.Expansions; import com.ibm.watson.developer_cloud.discovery.v1.model.Filter; @@ -69,6 +72,9 @@ import com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsResponse; import com.ibm.watson.developer_cloud.discovery.v1.model.ListExpansionsOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingDataOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.LogQueryResponse; +import com.ibm.watson.developer_cloud.discovery.v1.model.MetricResponse; +import com.ibm.watson.developer_cloud.discovery.v1.model.MetricTokenResponse; import com.ibm.watson.developer_cloud.discovery.v1.model.Nested; import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentEmotion; import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentEntities; @@ -143,9 +149,6 @@ @RunWith(RetryRunner.class) public class DiscoveryServiceIT extends WatsonServiceTest { - // Constants for enum fields - private static final Long FREE = 0L; - private static final String DISCOVERY_TEST_CONFIG_FILE = "src/test/resources/discovery/test-config.json"; private static final String DISCOVERY1_TEST_CONFIG_FILE = "src/test/resources/discovery/issue517.json"; private static final String DISCOVERY2_TEST_CONFIG_FILE = "src/test/resources/discovery/issue518.json"; @@ -186,7 +189,7 @@ public static void setupClass() throws Exception { // no environment found, create a new one (assuming we are a FREE plan) String environmentName = "watson_developer_cloud_test_environment"; CreateEnvironmentOptions createOptions = new CreateEnvironmentOptions.Builder() - .name(environmentName).size(FREE).build(); + .name(environmentName).build(); Environment createResponse = dummyTest.discovery.createEnvironment(createOptions).execute(); environmentId = createResponse.getEnvironmentId(); WaitFor.Condition environmentReady = new EnvironmentReady(dummyTest.discovery, environmentId); @@ -207,7 +210,7 @@ public void setup() throws Exception { String username = getProperty("discovery.username"); String password = getProperty("discovery.password"); String url = getProperty("discovery.url"); - discovery = new Discovery("2017-11-07"); + discovery = new Discovery("2018-05-23"); discovery.setEndPoint(url); discovery.setUsernameAndPassword(username, password); @@ -274,7 +277,6 @@ public void exampleIsSuccessful() { String environmentName = "watson_developer_cloud_test_environment"; CreateEnvironmentOptions createOptions = new CreateEnvironmentOptions.Builder() .name(environmentName) - .size(0L) /* FREE */ .build(); Environment createResponse = discovery.createEnvironment(createOptions).execute(); environmentId = createResponse.getEnvironmentId(); @@ -449,8 +451,7 @@ public void listEnvironmentsByNameIsSuccessful() { @Ignore("Only 1 BYOD environment allowed per service instance, so we cannot create more") public void createEnvironmentIsSuccessful() { String environmentName = uniqueName + "-environment"; - CreateEnvironmentOptions createOptions = new CreateEnvironmentOptions.Builder().name(environmentName).size(FREE) - .build(); + CreateEnvironmentOptions createOptions = new CreateEnvironmentOptions.Builder().name(environmentName).build(); Environment createResponse = createEnvironment(createOptions); assertEquals(environmentName, createResponse.getName()); @@ -460,8 +461,7 @@ public void createEnvironmentIsSuccessful() { @Ignore("Only 1 BYOD environment allowed per service instance, so do not delete it") public void deleteEnvironmentIsSuccessful() { String environmentName = uniqueName + "-environment"; - CreateEnvironmentOptions createOptions = new CreateEnvironmentOptions.Builder().name(environmentName).size(FREE) - .build(); + CreateEnvironmentOptions createOptions = new CreateEnvironmentOptions.Builder().name(environmentName).build(); Environment createResponse = createEnvironment(createOptions); DeleteEnvironmentOptions deleteOptions = new DeleteEnvironmentOptions.Builder(createResponse.getEnvironmentId()) @@ -473,8 +473,7 @@ public void deleteEnvironmentIsSuccessful() { @Ignore("Only 1 BYOD environment allowed per service instance, so we cannot create more") public void updateEnvironmentIsSuccessful() { String environmentName = uniqueName + "-environment"; - CreateEnvironmentOptions createOptions = new CreateEnvironmentOptions.Builder().name(environmentName).size(FREE) - .build(); + CreateEnvironmentOptions createOptions = new CreateEnvironmentOptions.Builder().name(environmentName).build(); Environment createResponse = createEnvironment(createOptions); String randomDescription = UUID.randomUUID().toString() + " appbuilder tests"; @@ -1825,6 +1824,71 @@ public void credentialsOperationsAreSuccessful() { } } + @Test + public void createEventIsSuccessful() { + // create test document + DocumentAccepted accepted = createTestDocument("event_file", collectionId); + + // make query to get session_token + QueryOptions queryOptions = new QueryOptions.Builder() + .environmentId(environmentId) + .collectionId(collectionId) + .naturalLanguageQuery("field number 1") + .build(); + QueryResponse queryResponse = discovery.query(queryOptions).execute(); + String sessionToken = queryResponse.getSessionToken(); + + // make createEvent call + EventData eventData = new EventData(); + eventData.setEnvironmentId(environmentId); + eventData.setCollectionId(collectionId); + eventData.setDocumentId(accepted.getDocumentId()); + eventData.setSessionToken(sessionToken); + CreateEventOptions createEventOptions = new CreateEventOptions.Builder() + .type(CreateEventOptions.Type.CLICK) + .data(eventData) + .build(); + CreateEventResponse response = discovery.createEvent(createEventOptions).execute(); + + assertNotNull(response); + } + + @Test + public void queryLogIsSuccessful() { + LogQueryResponse response = discovery.queryLog().execute(); + assertNotNull(response); + } + + @Test + public void getMetricsEventRateIsSuccessful() { + MetricResponse response = discovery.getMetricsEventRate().execute(); + assertNotNull(response); + } + + @Test + public void getMetricsQueryIsSuccessful() { + MetricResponse response = discovery.getMetricsQuery().execute(); + assertNotNull(response); + } + + @Test + public void getMetricsQueryEventIsSuccessful() { + MetricResponse response = discovery.getMetricsQueryEvent().execute(); + assertNotNull(response); + } + + @Test + public void getMetricsQueryNoResultsIsSuccessful() { + MetricResponse response = discovery.getMetricsQueryNoResults().execute(); + assertNotNull(response); + } + + @Test + public void getMetricsQueryTokenEventIsSuccessful() { + MetricTokenResponse response = discovery.getMetricsQueryTokenEvent().execute(); + assertNotNull(response); + } + private Environment createEnvironment(CreateEnvironmentOptions createOptions) { Environment createResponse = discovery.createEnvironment(createOptions).execute(); return createResponse; diff --git a/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceTest.java b/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceTest.java index e55d8096ea3..3ba362d13c9 100644 --- a/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceTest.java +++ b/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceTest.java @@ -26,6 +26,8 @@ import com.ibm.watson.developer_cloud.discovery.v1.model.CreateConfigurationOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.CreateCredentialsOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEnvironmentOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEventOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEventResponse; import com.ibm.watson.developer_cloud.discovery.v1.model.CreateExpansionsOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.CreateTrainingExampleOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.CredentialDetails; @@ -44,6 +46,7 @@ import com.ibm.watson.developer_cloud.discovery.v1.model.DocumentAccepted; import com.ibm.watson.developer_cloud.discovery.v1.model.DocumentStatus; import com.ibm.watson.developer_cloud.discovery.v1.model.Environment; +import com.ibm.watson.developer_cloud.discovery.v1.model.EventData; import com.ibm.watson.developer_cloud.discovery.v1.model.Expansion; import com.ibm.watson.developer_cloud.discovery.v1.model.Expansions; import com.ibm.watson.developer_cloud.discovery.v1.model.FederatedQueryNoticesOptions; @@ -53,6 +56,11 @@ import com.ibm.watson.developer_cloud.discovery.v1.model.GetCredentialsOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.GetDocumentStatusOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.GetEnvironmentOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.GetMetricsEventRateOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.GetMetricsQueryEventOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.GetMetricsQueryNoResultsOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.GetMetricsQueryOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.GetMetricsQueryTokenEventOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.GetTrainingDataOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.GetTrainingExampleOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsOptions; @@ -67,6 +75,10 @@ import com.ibm.watson.developer_cloud.discovery.v1.model.ListFieldsOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingDataOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingExamplesOptions; +import com.ibm.watson.developer_cloud.discovery.v1.model.LogQueryResponse; +import com.ibm.watson.developer_cloud.discovery.v1.model.MetricResponse; +import com.ibm.watson.developer_cloud.discovery.v1.model.MetricTokenResponse; +import com.ibm.watson.developer_cloud.discovery.v1.model.QueryLogOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesOptions; import com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse; import com.ibm.watson.developer_cloud.discovery.v1.model.QueryOptions; @@ -97,10 +109,12 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.List; import java.util.Map; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; /** @@ -109,8 +123,7 @@ public class DiscoveryServiceTest extends WatsonServiceUnitTest { private Discovery discoveryService; - private static final Long THREE = 3L; - private static final String VERSION = "2018-03-05"; + private static final String VERSION = "2018-05-23"; private static final String DISCOVERY_TEST_CONFIG_FILE = "src/test/resources/discovery/test-config.json"; private static final String RESOURCE = "src/test/resources/discovery/"; @@ -175,6 +188,27 @@ public class DiscoveryServiceTest extends WatsonServiceUnitTest { private static final String UPDATE_CREDENTIALS_PATH = "/v1/environments/mock_envid/credentials/new_credential_id?version=" + VERSION; + private static final String CREATE_EVENT_PATH + = "/v1/events?version=" + + VERSION; + private static final String GET_METRICS_EVENT_RATE_PATH + = "/v1/metrics/event_rate?version=" + + VERSION; + private static final String GET_METRICS_QUERY_PATH + = "/v1/metrics/number_of_queries?version=" + + VERSION; + private static final String GET_METRICS_QUERY_EVENT_PATH + = "/v1/metrics/number_of_queries_with_event?version=" + + VERSION; + private static final String GET_METRICS_QUERY_NO_RESULTS_PATH + = "/v1/metrics/number_of_queries_with_no_search_results?version=" + + VERSION; + private static final String GET_METRICS_QUERY_TOKEN_EVENT_PATH + = "/v1/metrics/top_query_tokens_with_event_rate?version=" + + VERSION; + private static final String QUERY_LOG_PATH + = "/v1/logs?version=" + + VERSION; private String environmentId; private String environmentName; @@ -185,6 +219,7 @@ public class DiscoveryServiceTest extends WatsonServiceUnitTest { private String collectionId; private String documentId; private String queryId; + private Date date; private Environment envResp; private ListEnvironmentsResponse envsResp; @@ -218,6 +253,10 @@ public class DiscoveryServiceTest extends WatsonServiceUnitTest { private Expansions expansionsResp; private Credentials credentialsResp; private CredentialsList listCredentialsResp; + private CreateEventResponse createEventResp; + private MetricResponse metricResp; + private MetricTokenResponse metricTokenResp; + private LogQueryResponse logQueryResp; @BeforeClass public static void setupClass() { @@ -226,7 +265,7 @@ public static void setupClass() { @Before public void setup() throws Exception { super.setUp(); - discoveryService = new Discovery("2018-03-05"); + discoveryService = new Discovery(VERSION); discoveryService.setUsernameAndPassword("", ""); discoveryService.setEndPoint(getMockWebServerUrl()); @@ -239,6 +278,7 @@ public void setup() throws Exception { collectionId = "mock_collid"; documentId = "mock_docid"; queryId = "mock_queryid"; + date = new Date(); envResp = loadFixture(RESOURCE + "get_env_resp.json", Environment.class); envsResp = loadFixture(RESOURCE + "get_envs_resp.json", ListEnvironmentsResponse.class); @@ -272,6 +312,10 @@ public void setup() throws Exception { expansionsResp = loadFixture(RESOURCE + "expansions_resp.json", Expansions.class); credentialsResp = loadFixture(RESOURCE + "credentials_resp.json", Credentials.class); listCredentialsResp = loadFixture(RESOURCE + "list_credentials_resp.json", CredentialsList.class); + createEventResp = loadFixture(RESOURCE + "create_event_resp.json", CreateEventResponse.class); + metricResp = loadFixture(RESOURCE + "metric_resp.json", MetricResponse.class); + metricTokenResp = loadFixture(RESOURCE + "metric_token_resp.json", MetricTokenResponse.class); + logQueryResp = loadFixture(RESOURCE + "log_query_resp.json", LogQueryResponse.class); } @After @@ -337,7 +381,7 @@ public void listEnvironmentsIsSuccessful() throws InterruptedException { public void createEnvironmentIsSuccessful() throws InterruptedException { server.enqueue(jsonResponse(createEnvResp)); CreateEnvironmentOptions.Builder createRequestBuilder = new CreateEnvironmentOptions.Builder().name(environmentName) - .size(THREE); + .size(CreateEnvironmentOptions.Size.XS); createRequestBuilder.description(environmentDesc); Environment response = discoveryService.createEnvironment(createRequestBuilder.build()).execute(); RecordedRequest request = server.takeRequest(); @@ -1096,4 +1140,351 @@ public void updateCredentialsIsSuccessful() throws InterruptedException { assertEquals(PUT, request.getMethod()); assertEquals(credentialsResp, response); } + + @Test + public void createEventIsSuccessful() throws InterruptedException { + server.enqueue(jsonResponse(createEventResp)); + + Long displayRank = 1L; + String sessionToken = "mock_session_token"; + + EventData eventData = new EventData(); + eventData.setEnvironmentId(environmentId); + eventData.setCollectionId(collectionId); + eventData.setDocumentId(documentId); + eventData.setDisplayRank(displayRank); + eventData.setSessionToken(sessionToken); + eventData.setClientTimestamp(date); + CreateEventOptions createEventOptions = new CreateEventOptions.Builder() + .type(CreateEventOptions.Type.CLICK) + .data(eventData) + .build(); + + CreateEventResponse response = discoveryService.createEvent(createEventOptions).execute(); + RecordedRequest request = server.takeRequest(); + + assertEquals(CREATE_EVENT_PATH, request.getPath()); + assertEquals(POST, request.getMethod()); + assertEquals(CreateEventOptions.Type.CLICK, response.getType()); + assertEquals(environmentId, response.getData().getEnvironmentId()); + assertEquals(collectionId, response.getData().getCollectionId()); + assertEquals(documentId, response.getData().getDocumentId()); + assertNotNull(response.getData().getClientTimestamp()); + assertEquals(displayRank, response.getData().getDisplayRank()); + assertEquals(queryId, response.getData().getQueryId()); + assertEquals(sessionToken, response.getData().getSessionToken()); + } + + @Test + public void getMetricsEventRateIsSuccessful() throws InterruptedException { + server.enqueue(jsonResponse(metricResp)); + + String interval = "1d"; + Long key = 1533513600000L; + Double eventRate = 0.0; + + GetMetricsEventRateOptions options = new GetMetricsEventRateOptions.Builder() + .startTime(date) + .endTime(date) + .resultType(GetMetricsEventRateOptions.ResultType.DOCUMENT) + .build(); + + MetricResponse response = discoveryService.getMetricsEventRate(options).execute(); + RecordedRequest request = server.takeRequest(); + + assertEquals(GET, request.getMethod()); + assertTrue(!response.getAggregations().isEmpty()); + assertEquals(interval, response.getAggregations().get(0).getInterval()); + assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); + assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); + assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); + assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); + assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); + } + + @Test + public void getMetricsEventRateNoArgsIsSuccessful() throws InterruptedException { + server.enqueue(jsonResponse(metricResp)); + + String interval = "1d"; + Long key = 1533513600000L; + Double eventRate = 0.0; + + MetricResponse response = discoveryService.getMetricsEventRate().execute(); + RecordedRequest request = server.takeRequest(); + + assertEquals(GET_METRICS_EVENT_RATE_PATH, request.getPath()); + assertEquals(GET, request.getMethod()); + assertTrue(!response.getAggregations().isEmpty()); + assertEquals(interval, response.getAggregations().get(0).getInterval()); + assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); + assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); + assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); + assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); + assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); + } + + @Test + public void getMetricsQueryIsSuccessful() throws InterruptedException { + server.enqueue(jsonResponse(metricResp)); + + String interval = "1d"; + Long key = 1533513600000L; + Double eventRate = 0.0; + + GetMetricsQueryOptions options = new GetMetricsQueryOptions.Builder() + .startTime(date) + .endTime(date) + .resultType(GetMetricsQueryOptions.ResultType.DOCUMENT) + .build(); + + MetricResponse response = discoveryService.getMetricsQuery(options).execute(); + RecordedRequest request = server.takeRequest(); + + assertEquals(GET, request.getMethod()); + assertTrue(!response.getAggregations().isEmpty()); + assertEquals(interval, response.getAggregations().get(0).getInterval()); + assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); + assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); + assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); + assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); + assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); + } + + @Test + public void getMetricsQueryNoArgsIsSuccessful() throws InterruptedException { + server.enqueue(jsonResponse(metricResp)); + + String interval = "1d"; + Long key = 1533513600000L; + Double eventRate = 0.0; + + MetricResponse response = discoveryService.getMetricsQuery().execute(); + RecordedRequest request = server.takeRequest(); + + assertEquals(GET_METRICS_QUERY_PATH, request.getPath()); + assertEquals(GET, request.getMethod()); + assertTrue(!response.getAggregations().isEmpty()); + assertEquals(interval, response.getAggregations().get(0).getInterval()); + assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); + assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); + assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); + assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); + assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); + } + + @Test + public void getMetricsQueryEventIsSuccessful() throws InterruptedException { + server.enqueue(jsonResponse(metricResp)); + + String interval = "1d"; + Long key = 1533513600000L; + Double eventRate = 0.0; + + GetMetricsQueryEventOptions options = new GetMetricsQueryEventOptions.Builder() + .startTime(date) + .endTime(date) + .resultType(GetMetricsQueryEventOptions.ResultType.DOCUMENT) + .build(); + + MetricResponse response = discoveryService.getMetricsQueryEvent(options).execute(); + RecordedRequest request = server.takeRequest(); + + assertEquals(GET, request.getMethod()); + assertTrue(!response.getAggregations().isEmpty()); + assertEquals(interval, response.getAggregations().get(0).getInterval()); + assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); + assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); + assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); + assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); + assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); + } + + @Test + public void getMetricsQueryEventNoArgsIsSuccessful() throws InterruptedException { + server.enqueue(jsonResponse(metricResp)); + + String interval = "1d"; + Long key = 1533513600000L; + Double eventRate = 0.0; + + MetricResponse response = discoveryService.getMetricsQueryEvent().execute(); + RecordedRequest request = server.takeRequest(); + + assertEquals(GET_METRICS_QUERY_EVENT_PATH, request.getPath()); + assertEquals(GET, request.getMethod()); + assertTrue(!response.getAggregations().isEmpty()); + assertEquals(interval, response.getAggregations().get(0).getInterval()); + assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); + assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); + assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); + assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); + assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); + } + + @Test + public void getMetricsQueryNoResultsIsSuccessful() throws InterruptedException { + server.enqueue(jsonResponse(metricResp)); + + String interval = "1d"; + Long key = 1533513600000L; + Double eventRate = 0.0; + + GetMetricsQueryNoResultsOptions options = new GetMetricsQueryNoResultsOptions.Builder() + .startTime(date) + .endTime(date) + .resultType(GetMetricsQueryEventOptions.ResultType.DOCUMENT) + .build(); + + MetricResponse response = discoveryService.getMetricsQueryNoResults(options).execute(); + RecordedRequest request = server.takeRequest(); + + assertEquals(GET, request.getMethod()); + assertTrue(!response.getAggregations().isEmpty()); + assertEquals(interval, response.getAggregations().get(0).getInterval()); + assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); + assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); + assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); + assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); + assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); + } + + @Test + public void getMetricsQueryNoResultsNoArgsIsSuccessful() throws InterruptedException { + server.enqueue(jsonResponse(metricResp)); + + String interval = "1d"; + Long key = 1533513600000L; + Double eventRate = 0.0; + + MetricResponse response = discoveryService.getMetricsQueryNoResults().execute(); + RecordedRequest request = server.takeRequest(); + + assertEquals(GET_METRICS_QUERY_NO_RESULTS_PATH, request.getPath()); + assertEquals(GET, request.getMethod()); + assertTrue(!response.getAggregations().isEmpty()); + assertEquals(interval, response.getAggregations().get(0).getInterval()); + assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); + assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); + assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); + assertNotNull(response.getAggregations().get(0).getResults().get(0).getKeyAsString()); + assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); + } + + @Test + public void getMetricsQueryTokenEventIsSuccessful() throws InterruptedException { + server.enqueue(jsonResponse(metricTokenResp)); + + Long count = 10L; + String key = "beat"; + Long matchingResults = 117L; + Double eventRate = 0.0; + + GetMetricsQueryTokenEventOptions options = new GetMetricsQueryTokenEventOptions.Builder() + .count(count) + .build(); + + MetricTokenResponse response = discoveryService.getMetricsQueryTokenEvent(options).execute(); + RecordedRequest request = server.takeRequest(); + + assertEquals(GET, request.getMethod()); + assertTrue(!response.getAggregations().isEmpty()); + assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); + assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); + assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); + assertEquals(matchingResults, response.getAggregations().get(0).getResults().get(0).getMatchingResults()); + assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); + } + + @Test + public void getMetricsQueryTokenEventNoArgsIsSuccessful() throws InterruptedException { + server.enqueue(jsonResponse(metricTokenResp)); + + String key = "beat"; + Long matchingResults = 117L; + Double eventRate = 0.0; + + MetricTokenResponse response = discoveryService.getMetricsQueryTokenEvent().execute(); + RecordedRequest request = server.takeRequest(); + + assertEquals(GET_METRICS_QUERY_TOKEN_EVENT_PATH, request.getPath()); + assertEquals(GET, request.getMethod()); + assertTrue(!response.getAggregations().isEmpty()); + assertEquals(CreateEventOptions.Type.CLICK, response.getAggregations().get(0).getEventType()); + assertTrue(!response.getAggregations().get(0).getResults().isEmpty()); + assertEquals(key, response.getAggregations().get(0).getResults().get(0).getKey()); + assertEquals(matchingResults, response.getAggregations().get(0).getResults().get(0).getMatchingResults()); + assertEquals(eventRate, response.getAggregations().get(0).getResults().get(0).getEventRate()); + } + + @Test + public void queryLogIsSuccessful() throws InterruptedException { + server.enqueue(jsonResponse(logQueryResp)); + + List sortList = new ArrayList<>(); + sortList.add("field_a"); + String extraSort = "field_b"; + String filter = "filter"; + String naturalLanguageQuery = "Who beat Ken Jennings in Jeopardy!"; + Long count = 5L; + Long offset = 5L; + Long matchingResults = 2L; + String customerId = ""; + String sessionToken = "mock_session_token"; + String eventType = "query"; + Long resultCount = 0L; + + QueryLogOptions options = new QueryLogOptions.Builder() + .sort(sortList) + .addSort(extraSort) + .count(count) + .filter(filter) + .offset(offset) + .query(naturalLanguageQuery) + .build(); + + LogQueryResponse response = discoveryService.queryLog(options).execute(); + RecordedRequest request = server.takeRequest(); + + assertEquals(GET, request.getMethod()); + assertEquals(matchingResults, response.getMatchingResults()); + assertTrue(!response.getResults().isEmpty()); + assertEquals(environmentId, response.getResults().get(0).getEnvironmentId()); + assertEquals(customerId, response.getResults().get(0).getCustomerId()); + assertNotNull(response.getResults().get(0).getCreatedTimestamp()); + assertEquals(queryId, response.getResults().get(0).getQueryId()); + assertEquals(sessionToken, response.getResults().get(0).getSessionToken()); + assertEquals(eventType, response.getResults().get(0).getEventType()); + assertNotNull(response.getResults().get(0).getDocumentResults().getResults()); + assertEquals(resultCount, response.getResults().get(0).getDocumentResults().getCount()); + } + + @Test + public void queryLogNoArgsIsSuccessful() throws InterruptedException { + server.enqueue(jsonResponse(logQueryResp)); + + List sortList = new ArrayList<>(); + sortList.add("field_a"); + Long matchingResults = 2L; + String customerId = ""; + String sessionToken = "mock_session_token"; + String eventType = "query"; + Long resultCount = 0L; + + LogQueryResponse response = discoveryService.queryLog().execute(); + RecordedRequest request = server.takeRequest(); + + assertEquals(QUERY_LOG_PATH, request.getPath()); + assertEquals(GET, request.getMethod()); + assertEquals(matchingResults, response.getMatchingResults()); + assertTrue(!response.getResults().isEmpty()); + assertEquals(environmentId, response.getResults().get(0).getEnvironmentId()); + assertEquals(customerId, response.getResults().get(0).getCustomerId()); + assertNotNull(response.getResults().get(0).getCreatedTimestamp()); + assertEquals(queryId, response.getResults().get(0).getQueryId()); + assertEquals(sessionToken, response.getResults().get(0).getSessionToken()); + assertEquals(eventType, response.getResults().get(0).getEventType()); + assertNotNull(response.getResults().get(0).getDocumentResults().getResults()); + assertEquals(resultCount, response.getResults().get(0).getDocumentResults().getCount()); + } } diff --git a/discovery/src/test/resources/discovery/create_event_resp.json b/discovery/src/test/resources/discovery/create_event_resp.json new file mode 100644 index 00000000000..7d5a3ef391b --- /dev/null +++ b/discovery/src/test/resources/discovery/create_event_resp.json @@ -0,0 +1,12 @@ +{ + "type": "click", + "data": { + "environment_id": "mock_envid", + "session_token": "mock_session_token", + "client_timestamp": "2016-12-14T17:32:41.593Z", + "display_rank": 1, + "collection_id": "mock_collid", + "document_id": "mock_docid", + "query_id": "mock_queryid" + } +} diff --git a/discovery/src/test/resources/discovery/log_query_resp.json b/discovery/src/test/resources/discovery/log_query_resp.json new file mode 100644 index 00000000000..8d7eb2d5f08 --- /dev/null +++ b/discovery/src/test/resources/discovery/log_query_resp.json @@ -0,0 +1,43 @@ +{ + "matching_results": 2, + "results": [ + { + "environment_id": "mock_envid", + "customer_id": "", + "natural_language_query": "Who beat Ken Jennings in Jeopardy!", + "document_results": { + "results": [], + "count": 0 + }, + "created_timestamp": "2018-07-16T18:27:26.433", + "query_id": "mock_queryid", + "session_token": "mock_session_token", + "event_type": "query" + }, + { + "environment_id": "mock_envid", + "customer_id": "", + "document_results": { + "results": [ + { + "position": 1, + "document_id": "mock_docid", + "score": 1.0, + "collection_id": "mock_collid" + }, + { + "position": 2, + "document_id": "mock_docid", + "score": 1.0, + "collection_id": "mock_collid" + } + ], + "count": 2 + }, + "created_timestamp": "2018-07-19T11:10:32.243", + "query_id": "mock_queryid", + "session_token": "mock_session_token", + "event_type": "query" + } + ] +} diff --git a/discovery/src/test/resources/discovery/metric_resp.json b/discovery/src/test/resources/discovery/metric_resp.json new file mode 100644 index 00000000000..012289e7a4c --- /dev/null +++ b/discovery/src/test/resources/discovery/metric_resp.json @@ -0,0 +1,50 @@ +{ + "aggregations": [ + { + "interval": "1d", + "event_type": "click", + "results": [ + { + "key_as_string": "2018-08-05T20:00:00.000", + "key": 1533513600000, + "event_rate": 0.0 + }, + { + "key_as_string": "2018-08-06T20:00:00.000", + "key": 1533600000000, + "event_rate": 0.0 + }, + { + "key_as_string": "2018-08-07T20:00:00.000", + "key": 1533686400000, + "event_rate": 0.0 + }, + { + "key_as_string": "2018-08-08T20:00:00.000", + "key": 1533772800000, + "event_rate": 0.0 + }, + { + "key_as_string": "2018-08-09T20:00:00.000", + "key": 1533859200000, + "event_rate": 0.0 + }, + { + "key_as_string": "2018-08-10T20:00:00.000", + "key": 1533945600000, + "event_rate": 0.0 + }, + { + "key_as_string": "2018-08-11T20:00:00.000", + "key": 1534032000000, + "event_rate": 0.0 + }, + { + "key_as_string": "2018-08-12T20:00:00.000", + "key": 1534118400000, + "event_rate": 0.09090909090909091 + } + ] + } + ] +} diff --git a/discovery/src/test/resources/discovery/metric_token_resp.json b/discovery/src/test/resources/discovery/metric_token_resp.json new file mode 100644 index 00000000000..19f33e21d81 --- /dev/null +++ b/discovery/src/test/resources/discovery/metric_token_resp.json @@ -0,0 +1,59 @@ +{ + "aggregations": [ + { + "event_type": "click", + "results": [ + { + "key": "beat", + "matching_results": 117, + "event_rate": 0.0 + }, + { + "key": "in", + "matching_results": 117, + "event_rate": 0.0 + }, + { + "key": "jennings", + "matching_results": 117, + "event_rate": 0.0 + }, + { + "key": "jeopardy", + "matching_results": 117, + "event_rate": 0.0 + }, + { + "key": "ken", + "matching_results": 117, + "event_rate": 0.0 + }, + { + "key": "who", + "matching_results": 117, + "event_rate": 0.0 + }, + { + "key": "watson", + "matching_results": 3, + "event_rate": 0.0 + }, + { + "key": "1", + "matching_results": 2, + "event_rate": 0.5 + }, + { + "key": "field", + "matching_results": 2, + "event_rate": 0.5 + }, + { + "key": "number", + "matching_results": 2, + "event_rate": 0.5 + } + ] + } + ] +} diff --git a/gradle.properties b/gradle.properties index dca2724a927..9002491691c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version=6.3.1 +version=6.4.0 group = com.ibm.watson.developer_cloud diff --git a/language-translator/README.md b/language-translator/README.md index ffbafe01fa0..cf97832df1e 100644 --- a/language-translator/README.md +++ b/language-translator/README.md @@ -10,13 +10,13 @@ Language Translator v3 is now available. The v2 Language Translator API will no com.ibm.watson.developer_cloud language-translator - 6.3.0 + 6.4.0 ``` ##### Gradle ```gradle -'com.ibm.watson.developer_cloud:language-translator:6.3.0' +'com.ibm.watson.developer_cloud:language-translator:6.4.0' ``` ## Usage diff --git a/natural-language-classifier/README.md b/natural-language-classifier/README.md index b55dd5c6a44..321194492c8 100644 --- a/natural-language-classifier/README.md +++ b/natural-language-classifier/README.md @@ -7,13 +7,13 @@ com.ibm.watson.developer_cloud natural-language-classifier - 6.3.0 + 6.4.0 ``` ##### Gradle ```gradle -'com.ibm.watson.developer_cloud:natural-language-classifier:6.3.0' +'com.ibm.watson.developer_cloud:natural-language-classifier:6.4.0' ``` ## Usage diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifyInput.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifyInput.java index 1730425994c..b90795500be 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifyInput.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifyInput.java @@ -24,7 +24,7 @@ public class ClassifyInput extends GenericModel { /** * Gets the text. * - * The submitted phrase. + * The submitted phrase. The maximum length is 2048 characters. * * @return the text */ diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifyOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifyOptions.java index adecf9bc6ed..a66eade04b0 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifyOptions.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifyOptions.java @@ -114,7 +114,7 @@ public String classifierId() { /** * Gets the text. * - * The submitted phrase. + * The submitted phrase. The maximum length is 2048 characters. * * @return the text */ diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/CollectionItem.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/CollectionItem.java index e8d1cd627e7..1615f11a159 100644 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/CollectionItem.java +++ b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/CollectionItem.java @@ -30,7 +30,7 @@ public class CollectionItem extends GenericModel { /** * Gets the text. * - * The submitted phrase. + * The submitted phrase. The maximum length is 2048 characters. * * @return the text */ diff --git a/natural-language-understanding/README.md b/natural-language-understanding/README.md index 1dc29c5f735..238e4cef9f5 100644 --- a/natural-language-understanding/README.md +++ b/natural-language-understanding/README.md @@ -7,13 +7,13 @@ com.ibm.watson.developer_cloud natural-language-understanding - 6.3.0 + 6.4.0 ``` ##### Gradle ```gradle -'com.ibm.watson.developer_cloud:natural-language-understanding:6.3.0' +'com.ibm.watson.developer_cloud:natural-language-understanding:6.4.0' ``` ## Usage diff --git a/personality-insights/README.md b/personality-insights/README.md index 09e6e0d9ab5..2c70896ec7a 100755 --- a/personality-insights/README.md +++ b/personality-insights/README.md @@ -7,13 +7,13 @@ com.ibm.watson.developer_cloud personality-insights - 6.3.0 + 6.4.0 ``` ##### Gradle ```gradle -'com.ibm.watson.developer_cloud:personality-insights:6.3.0' +'com.ibm.watson.developer_cloud:personality-insights:6.4.0' ``` ## Usage diff --git a/speech-to-text/README.md b/speech-to-text/README.md index b2075446ed1..b0619b128fc 100755 --- a/speech-to-text/README.md +++ b/speech-to-text/README.md @@ -7,13 +7,13 @@ com.ibm.watson.developer_cloud speech-to-text - 6.3.0 + 6.4.0 ``` ##### Gradle ```gradle -'com.ibm.watson.developer_cloud:speech-to-text:6.3.0' +'com.ibm.watson.developer_cloud:speech-to-text:6.4.0' ``` ## Usage diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToText.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToText.java index 8d8d8f772dd..548a10e25e5 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToText.java +++ b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToText.java @@ -102,6 +102,11 @@ * that use registered callbacks and polling for non-blocking recognition. See [The HTTP REST * interface](https://console.bluemix.net/docs/services/speech-to-text/http.html) and [The asynchronous HTTP * interface](https://console.bluemix.net/docs/services/speech-to-text/async.html). + * + * **Important:** The session-based interface is deprecated as of August 8, 2018, and will be removed from service on + * September 7, 2018. Use the sessionless, asynchronous, or WebSocket interface instead. For more information, see the + * August 8 service update in the [Release + * notes](https://console.bluemix.net/docs/services/speech-to-text/release-notes.html#August2018). * * **WebSocket interface:** The service also offers a WebSocket interface for speech recognition. The WebSocket * interface provides a full-duplex, low-latency communication channel. Clients send requests and audio to the service * and receive results over a single connection in an asynchronous fashion. See [The WebSocket diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RecognizeSessionlessOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RecognizeSessionlessOptions.java deleted file mode 100644 index 5215d600f82..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RecognizeSessionlessOptions.java +++ /dev/null @@ -1,651 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The recognizeSessionless options. - */ -public class RecognizeSessionlessOptions extends GenericModel { - - /** - * The type of the input. - */ - public interface ContentType { - /** audio/basic. */ - String AUDIO_BASIC = "audio/basic"; - /** audio/flac. */ - String AUDIO_FLAC = "audio/flac"; - /** audio/l16. */ - String AUDIO_L16 = "audio/l16"; - /** audio/mp3. */ - String AUDIO_MP3 = "audio/mp3"; - /** audio/mpeg. */ - String AUDIO_MPEG = "audio/mpeg"; - /** audio/mulaw. */ - String AUDIO_MULAW = "audio/mulaw"; - /** audio/ogg. */ - String AUDIO_OGG = "audio/ogg"; - /** audio/ogg;codecs=opus. */ - String AUDIO_OGG_CODECS_OPUS = "audio/ogg;codecs=opus"; - /** audio/ogg;codecs=vorbis. */ - String AUDIO_OGG_CODECS_VORBIS = "audio/ogg;codecs=vorbis"; - /** audio/wav. */ - String AUDIO_WAV = "audio/wav"; - /** audio/webm. */ - String AUDIO_WEBM = "audio/webm"; - /** audio/webm;codecs=opus. */ - String AUDIO_WEBM_CODECS_OPUS = "audio/webm;codecs=opus"; - /** audio/webm;codecs=vorbis. */ - String AUDIO_WEBM_CODECS_VORBIS = "audio/webm;codecs=vorbis"; - } - - /** - * The identifier of the model that is to be used for the recognition request or, for the **Create a session** method, - * with the new session. - */ - public interface Model { - /** ar-AR_BroadbandModel. */ - String AR_AR_BROADBANDMODEL = "ar-AR_BroadbandModel"; - /** en-GB_BroadbandModel. */ - String EN_GB_BROADBANDMODEL = "en-GB_BroadbandModel"; - /** en-GB_NarrowbandModel. */ - String EN_GB_NARROWBANDMODEL = "en-GB_NarrowbandModel"; - /** en-US_BroadbandModel. */ - String EN_US_BROADBANDMODEL = "en-US_BroadbandModel"; - /** en-US_NarrowbandModel. */ - String EN_US_NARROWBANDMODEL = "en-US_NarrowbandModel"; - /** es-ES_BroadbandModel. */ - String ES_ES_BROADBANDMODEL = "es-ES_BroadbandModel"; - /** es-ES_NarrowbandModel. */ - String ES_ES_NARROWBANDMODEL = "es-ES_NarrowbandModel"; - /** fr-FR_BroadbandModel. */ - String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; - /** ja-JP_BroadbandModel. */ - String JA_JP_BROADBANDMODEL = "ja-JP_BroadbandModel"; - /** ja-JP_NarrowbandModel. */ - String JA_JP_NARROWBANDMODEL = "ja-JP_NarrowbandModel"; - /** ko-KR_BroadbandModel. */ - String KO_KR_BROADBANDMODEL = "ko-KR_BroadbandModel"; - /** ko-KR_NarrowbandModel. */ - String KO_KR_NARROWBANDMODEL = "ko-KR_NarrowbandModel"; - /** pt-BR_BroadbandModel. */ - String PT_BR_BROADBANDMODEL = "pt-BR_BroadbandModel"; - /** pt-BR_NarrowbandModel. */ - String PT_BR_NARROWBANDMODEL = "pt-BR_NarrowbandModel"; - /** zh-CN_BroadbandModel. */ - String ZH_CN_BROADBANDMODEL = "zh-CN_BroadbandModel"; - /** zh-CN_NarrowbandModel. */ - String ZH_CN_NARROWBANDMODEL = "zh-CN_NarrowbandModel"; - } - - private InputStream audio; - private String contentType; - private String model; - private String customizationId; - private String acousticCustomizationId; - private String baseModelVersion; - private Double customizationWeight; - private Long inactivityTimeout; - private List keywords; - private Float keywordsThreshold; - private Long maxAlternatives; - private Float wordAlternativesThreshold; - private Boolean wordConfidence; - private Boolean timestamps; - private Boolean profanityFilter; - private Boolean smartFormatting; - private Boolean speakerLabels; - - /** - * Builder. - */ - public static class Builder { - private InputStream audio; - private String contentType; - private String model; - private String customizationId; - private String acousticCustomizationId; - private String baseModelVersion; - private Double customizationWeight; - private Long inactivityTimeout; - private List keywords; - private Float keywordsThreshold; - private Long maxAlternatives; - private Float wordAlternativesThreshold; - private Boolean wordConfidence; - private Boolean timestamps; - private Boolean profanityFilter; - private Boolean smartFormatting; - private Boolean speakerLabels; - - private Builder(RecognizeSessionlessOptions recognizeSessionlessOptions) { - audio = recognizeSessionlessOptions.audio; - contentType = recognizeSessionlessOptions.contentType; - model = recognizeSessionlessOptions.model; - customizationId = recognizeSessionlessOptions.customizationId; - acousticCustomizationId = recognizeSessionlessOptions.acousticCustomizationId; - baseModelVersion = recognizeSessionlessOptions.baseModelVersion; - customizationWeight = recognizeSessionlessOptions.customizationWeight; - inactivityTimeout = recognizeSessionlessOptions.inactivityTimeout; - keywords = recognizeSessionlessOptions.keywords; - keywordsThreshold = recognizeSessionlessOptions.keywordsThreshold; - maxAlternatives = recognizeSessionlessOptions.maxAlternatives; - wordAlternativesThreshold = recognizeSessionlessOptions.wordAlternativesThreshold; - wordConfidence = recognizeSessionlessOptions.wordConfidence; - timestamps = recognizeSessionlessOptions.timestamps; - profanityFilter = recognizeSessionlessOptions.profanityFilter; - smartFormatting = recognizeSessionlessOptions.smartFormatting; - speakerLabels = recognizeSessionlessOptions.speakerLabels; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a RecognizeSessionlessOptions. - * - * @return the recognizeSessionlessOptions - */ - public RecognizeSessionlessOptions build() { - return new RecognizeSessionlessOptions(this); - } - - /** - * Adds an keyword to keywords. - * - * @param keyword the new keyword - * @return the RecognizeSessionlessOptions builder - */ - public Builder addKeyword(String keyword) { - Validator.notNull(keyword, "keyword cannot be null"); - if (this.keywords == null) { - this.keywords = new ArrayList(); - } - this.keywords.add(keyword); - return this; - } - - /** - * Set the audio. - * - * @param audio the audio - * @return the RecognizeSessionlessOptions builder - */ - public Builder audio(InputStream audio) { - this.audio = audio; - return this; - } - - /** - * Set the contentType. - * - * @param contentType the contentType - * @return the RecognizeSessionlessOptions builder - */ - public Builder contentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * Set the model. - * - * @param model the model - * @return the RecognizeSessionlessOptions builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the RecognizeSessionlessOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the acousticCustomizationId. - * - * @param acousticCustomizationId the acousticCustomizationId - * @return the RecognizeSessionlessOptions builder - */ - public Builder acousticCustomizationId(String acousticCustomizationId) { - this.acousticCustomizationId = acousticCustomizationId; - return this; - } - - /** - * Set the baseModelVersion. - * - * @param baseModelVersion the baseModelVersion - * @return the RecognizeSessionlessOptions builder - */ - public Builder baseModelVersion(String baseModelVersion) { - this.baseModelVersion = baseModelVersion; - return this; - } - - /** - * Set the customizationWeight. - * - * @param customizationWeight the customizationWeight - * @return the RecognizeSessionlessOptions builder - */ - public Builder customizationWeight(Double customizationWeight) { - this.customizationWeight = customizationWeight; - return this; - } - - /** - * Set the inactivityTimeout. - * - * @param inactivityTimeout the inactivityTimeout - * @return the RecognizeSessionlessOptions builder - */ - public Builder inactivityTimeout(long inactivityTimeout) { - this.inactivityTimeout = inactivityTimeout; - return this; - } - - /** - * Set the keywords. - * Existing keywords will be replaced. - * - * @param keywords the keywords - * @return the RecognizeSessionlessOptions builder - */ - public Builder keywords(List keywords) { - this.keywords = keywords; - return this; - } - - /** - * Set the keywordsThreshold. - * - * @param keywordsThreshold the keywordsThreshold - * @return the RecognizeSessionlessOptions builder - */ - public Builder keywordsThreshold(Float keywordsThreshold) { - this.keywordsThreshold = keywordsThreshold; - return this; - } - - /** - * Set the maxAlternatives. - * - * @param maxAlternatives the maxAlternatives - * @return the RecognizeSessionlessOptions builder - */ - public Builder maxAlternatives(long maxAlternatives) { - this.maxAlternatives = maxAlternatives; - return this; - } - - /** - * Set the wordAlternativesThreshold. - * - * @param wordAlternativesThreshold the wordAlternativesThreshold - * @return the RecognizeSessionlessOptions builder - */ - public Builder wordAlternativesThreshold(Float wordAlternativesThreshold) { - this.wordAlternativesThreshold = wordAlternativesThreshold; - return this; - } - - /** - * Set the wordConfidence. - * - * @param wordConfidence the wordConfidence - * @return the RecognizeSessionlessOptions builder - */ - public Builder wordConfidence(Boolean wordConfidence) { - this.wordConfidence = wordConfidence; - return this; - } - - /** - * Set the timestamps. - * - * @param timestamps the timestamps - * @return the RecognizeSessionlessOptions builder - */ - public Builder timestamps(Boolean timestamps) { - this.timestamps = timestamps; - return this; - } - - /** - * Set the profanityFilter. - * - * @param profanityFilter the profanityFilter - * @return the RecognizeSessionlessOptions builder - */ - public Builder profanityFilter(Boolean profanityFilter) { - this.profanityFilter = profanityFilter; - return this; - } - - /** - * Set the smartFormatting. - * - * @param smartFormatting the smartFormatting - * @return the RecognizeSessionlessOptions builder - */ - public Builder smartFormatting(Boolean smartFormatting) { - this.smartFormatting = smartFormatting; - return this; - } - - /** - * Set the speakerLabels. - * - * @param speakerLabels the speakerLabels - * @return the RecognizeSessionlessOptions builder - */ - public Builder speakerLabels(Boolean speakerLabels) { - this.speakerLabels = speakerLabels; - return this; - } - - /** - * Set the audio. - * - * @param audio the audio - * @return the RecognizeSessionlessOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder audio(File audio) throws FileNotFoundException { - this.audio = new FileInputStream(audio); - return this; - } - } - - private RecognizeSessionlessOptions(Builder builder) { - Validator.isTrue(builder.contentType != null, "contentType cannot be null"); - audio = builder.audio; - contentType = builder.contentType; - model = builder.model; - customizationId = builder.customizationId; - acousticCustomizationId = builder.acousticCustomizationId; - baseModelVersion = builder.baseModelVersion; - customizationWeight = builder.customizationWeight; - inactivityTimeout = builder.inactivityTimeout; - keywords = builder.keywords; - keywordsThreshold = builder.keywordsThreshold; - maxAlternatives = builder.maxAlternatives; - wordAlternativesThreshold = builder.wordAlternativesThreshold; - wordConfidence = builder.wordConfidence; - timestamps = builder.timestamps; - profanityFilter = builder.profanityFilter; - smartFormatting = builder.smartFormatting; - speakerLabels = builder.speakerLabels; - } - - /** - * New builder. - * - * @return a RecognizeSessionlessOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the audio. - * - * @return the audio - */ - public InputStream audio() { - return audio; - } - - /** - * Gets the contentType. - * - * The type of the input. - * - * @return the contentType - */ - public String contentType() { - return contentType; - } - - /** - * Gets the model. - * - * The identifier of the model that is to be used for the recognition request or, for the **Create a session** method, - * with the new session. - * - * @return the model - */ - public String model() { - return model; - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of a custom language model that is to be used with the recognition request or, for the - * **Create a session** method, with the new session. The base model of the specified custom language model must match - * the model specified with the `model` parameter. You must make the request with service credentials created for the - * instance of the service that owns the custom model. By default, no custom language model is used. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the acousticCustomizationId. - * - * The customization ID (GUID) of a custom acoustic model that is to be used with the recognition request or, for the - * **Create a session** method, with the new session. The base model of the specified custom acoustic model must match - * the model specified with the `model` parameter. You must make the request with service credentials created for the - * instance of the service that owns the custom model. By default, no custom acoustic model is used. - * - * @return the acousticCustomizationId - */ - public String acousticCustomizationId() { - return acousticCustomizationId; - } - - /** - * Gets the baseModelVersion. - * - * The version of the specified base model that is to be used with recognition request or, for the **Create a - * session** method, with the new session. Multiple versions of a base model can exist when a model is updated for - * internal improvements. The parameter is intended primarily for use with custom models that have been upgraded for a - * new base model. The default value depends on whether the parameter is used with or without a custom model. For more - * information, see [Base model version](https://console.bluemix.net/docs/services/speech-to-text/input.html#version). - * - * @return the baseModelVersion - */ - public String baseModelVersion() { - return baseModelVersion; - } - - /** - * Gets the customizationWeight. - * - * If you specify the customization ID (GUID) of a custom language model with the recognition request or, for - * sessions, with the **Create a session** method, the customization weight tells the service how much weight to give - * to words from the custom language model compared to those from the base model for the current request. - * - * Specify a value between 0.0 and 1.0. Unless a different customization weight was specified for the custom model - * when it was trained, the default value is 0.3. A customization weight that you specify overrides a weight that was - * specified when the custom model was trained. - * - * The default value yields the best performance in general. Assign a higher value if your audio makes frequent use of - * OOV words from the custom model. Use caution when setting the weight: a higher value can improve the accuracy of - * phrases from the custom model's domain, but it can negatively affect performance on non-domain phrases. - * - * @return the customizationWeight - */ - public Double customizationWeight() { - return customizationWeight; - } - - /** - * Gets the inactivityTimeout. - * - * The time in seconds after which, if only silence (no speech) is detected in submitted audio, the connection is - * closed with a 400 error. The parameter is useful for stopping audio submission from a live microphone when a user - * simply walks away. Use `-1` for infinity. - * - * @return the inactivityTimeout - */ - public Long inactivityTimeout() { - return inactivityTimeout; - } - - /** - * Gets the keywords. - * - * An array of keyword strings to spot in the audio. Each keyword string can include one or more tokens. Keywords are - * spotted only in the final results, not in interim hypotheses. If you specify any keywords, you must also specify a - * keywords threshold. You can spot a maximum of 1000 keywords. Omit the parameter or specify an empty array if you do - * not need to spot keywords. - * - * @return the keywords - */ - public List keywords() { - return keywords; - } - - /** - * Gets the keywordsThreshold. - * - * A confidence value that is the lower bound for spotting a keyword. A word is considered to match a keyword if its - * confidence is greater than or equal to the threshold. Specify a probability between 0 and 1 inclusive. No keyword - * spotting is performed if you omit the parameter. If you specify a threshold, you must also specify one or more - * keywords. - * - * @return the keywordsThreshold - */ - public Float keywordsThreshold() { - return keywordsThreshold; - } - - /** - * Gets the maxAlternatives. - * - * The maximum number of alternative transcripts to be returned. By default, a single transcription is returned. - * - * @return the maxAlternatives - */ - public Long maxAlternatives() { - return maxAlternatives; - } - - /** - * Gets the wordAlternativesThreshold. - * - * A confidence value that is the lower bound for identifying a hypothesis as a possible word alternative (also known - * as "Confusion Networks"). An alternative word is considered if its confidence is greater than or equal to the - * threshold. Specify a probability between 0 and 1 inclusive. No alternative words are computed if you omit the - * parameter. - * - * @return the wordAlternativesThreshold - */ - public Float wordAlternativesThreshold() { - return wordAlternativesThreshold; - } - - /** - * Gets the wordConfidence. - * - * If `true`, a confidence measure in the range of 0 to 1 is returned for each word. By default, no word confidence - * measures are returned. - * - * @return the wordConfidence - */ - public Boolean wordConfidence() { - return wordConfidence; - } - - /** - * Gets the timestamps. - * - * If `true`, time alignment is returned for each word. By default, no timestamps are returned. - * - * @return the timestamps - */ - public Boolean timestamps() { - return timestamps; - } - - /** - * Gets the profanityFilter. - * - * If `true` (the default), filters profanity from all output except for keyword results by replacing inappropriate - * words with a series of asterisks. Set the parameter to `false` to return results with no censoring. Applies to US - * English transcription only. - * - * @return the profanityFilter - */ - public Boolean profanityFilter() { - return profanityFilter; - } - - /** - * Gets the smartFormatting. - * - * If `true`, converts dates, times, series of digits and numbers, phone numbers, currency values, and internet - * addresses into more readable, conventional representations in the final transcript of a recognition request. For US - * English, also converts certain keyword strings to punctuation symbols. By default, no smart formatting is - * performed. Applies to US English and Spanish transcription only. - * - * @return the smartFormatting - */ - public Boolean smartFormatting() { - return smartFormatting; - } - - /** - * Gets the speakerLabels. - * - * If `true`, the response includes labels that identify which words were spoken by which participants in a - * multi-person exchange. By default, no speaker labels are returned. Setting `speaker_labels` to `true` forces the - * `timestamps` parameter to be `true`, regardless of whether you specify `false` for the parameter. - * - * To determine whether a language model supports speaker labels, use the **Get models** method and check that the - * attribute `speaker_labels` is set to `true`. You can also refer to [Speaker - * labels](https://console.bluemix.net/docs/services/speech-to-text/output.html#speaker_labels). - * - * @return the speakerLabels - */ - public Boolean speakerLabels() { - return speakerLabels; - } -} diff --git a/text-to-speech/README.md b/text-to-speech/README.md index 258d6e552a3..eefca4f9795 100755 --- a/text-to-speech/README.md +++ b/text-to-speech/README.md @@ -7,13 +7,13 @@ com.ibm.watson.developer_cloud text-to-speech - 6.3.0 + 6.4.0 ``` ##### Gradle ```gradle -'com.ibm.watson.developer_cloud:text-to-speech:6.3.0' +'com.ibm.watson.developer_cloud:text-to-speech:6.4.0' ``` ## Usage diff --git a/tone-analyzer/README.md b/tone-analyzer/README.md index 64f07d3ba7a..2d14eaeb6d5 100755 --- a/tone-analyzer/README.md +++ b/tone-analyzer/README.md @@ -7,13 +7,13 @@ com.ibm.watson.developer_cloud tone-analyzer - 6.3.0 + 6.4.0 ``` ##### Gradle ```gradle -'com.ibm.watson.developer_cloud:tone-analyzer:6.3.0' +'com.ibm.watson.developer_cloud:tone-analyzer:6.4.0' ``` ## Usage diff --git a/visual-recognition/README.md b/visual-recognition/README.md index ed62c645e51..83ef9cc0f05 100644 --- a/visual-recognition/README.md +++ b/visual-recognition/README.md @@ -7,13 +7,13 @@ com.ibm.watson.developer_cloud visual-recognition - 6.3.0 + 6.4.0 ``` ##### Gradle ```gradle -'com.ibm.watson.developer_cloud:visual-recognition:6.3.0' +'com.ibm.watson.developer_cloud:visual-recognition:6.4.0' ``` ## Usage diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifyOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifyOptions.java index e24446c7065..c1ed490c7f0 100644 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifyOptions.java +++ b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifyOptions.java @@ -372,8 +372,8 @@ public List owners() { * * The following built-in classifier IDs require no training: * - `default`: Returns classes from thousands of general tags. - * - `food`: (Beta) Enhances specificity and accuracy for images of food items. - * - `explicit`: (Beta) Evaluates whether the image might be pornographic. + * - `food`: Enhances specificity and accuracy for images of food items. + * - `explicit`: Evaluates whether the image might be pornographic. * * @return the classifierIds */