Search in sources :

Example 16 with MetricResponse

use of com.ibm.watson.discovery.v1.model.MetricResponse in project java-sdk by watson-developer-cloud.

the class Discovery method getMetricsQueryNoResults.

/**
 * Number of queries with no search results over time.
 *
 * <p>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 result of type {@link MetricResponse}
 */
public ServiceCall<MetricResponse> getMetricsQueryNoResults(GetMetricsQueryNoResultsOptions getMetricsQueryNoResultsOptions) {
    if (getMetricsQueryNoResultsOptions == null) {
        getMetricsQueryNoResultsOptions = new GetMetricsQueryNoResultsOptions.Builder().build();
    }
    RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/metrics/number_of_queries_with_no_search_results"));
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("discovery", "v1", "getMetricsQueryNoResults");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
        builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    builder.query("version", String.valueOf(this.version));
    if (getMetricsQueryNoResultsOptions.startTime() != null) {
        builder.query("start_time", DateUtils.formatAsDateTime(getMetricsQueryNoResultsOptions.startTime()));
    }
    if (getMetricsQueryNoResultsOptions.endTime() != null) {
        builder.query("end_time", DateUtils.formatAsDateTime(getMetricsQueryNoResultsOptions.endTime()));
    }
    if (getMetricsQueryNoResultsOptions.resultType() != null) {
        builder.query("result_type", String.valueOf(getMetricsQueryNoResultsOptions.resultType()));
    }
    ResponseConverter<MetricResponse> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<MetricResponse>() {
    }.getType());
    return createServiceCall(builder.build(), responseConverter);
}
Also used : RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder) MetricResponse(com.ibm.watson.discovery.v1.model.MetricResponse) RequestBuilder(com.ibm.cloud.sdk.core.http.RequestBuilder)

Aggregations

MetricResponse (com.ibm.watson.discovery.v1.model.MetricResponse)16 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)12 WatsonServiceUnitTest (com.ibm.watson.common.WatsonServiceUnitTest)8 RequestBuilder (com.ibm.cloud.sdk.core.http.RequestBuilder)4 MockResponse (okhttp3.mockwebserver.MockResponse)4 Test (org.testng.annotations.Test)4 GetMetricsEventRateOptions (com.ibm.watson.discovery.v1.model.GetMetricsEventRateOptions)2 GetMetricsQueryEventOptions (com.ibm.watson.discovery.v1.model.GetMetricsQueryEventOptions)2 GetMetricsQueryNoResultsOptions (com.ibm.watson.discovery.v1.model.GetMetricsQueryNoResultsOptions)2 GetMetricsQueryOptions (com.ibm.watson.discovery.v1.model.GetMetricsQueryOptions)2