co.uk.crowdemotion.MetricApi.java Source code

Java tutorial

Introduction

Here is the source code for co.uk.crowdemotion.MetricApi.java

Source

/**
 * CloudEmotion API v1
 * CrowdEmotion API
 *
 * OpenAPI spec version: 1.1.0
 * 
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 *
 * 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 co.uk.crowdemotion;

import co.uk.crowdemotion.ApiCallback;
import co.uk.crowdemotion.ApiClient;
import co.uk.crowdemotion.ApiException;
import co.uk.crowdemotion.ApiResponse;
import co.uk.crowdemotion.Configuration;
import co.uk.crowdemotion.Pair;
import co.uk.crowdemotion.ProgressRequestBody;
import co.uk.crowdemotion.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;

import io.swagger.client.model.Metric;
import io.swagger.client.model.MetricCreation;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MetricApi {
    private ApiClient apiClient;

    public MetricApi() {
        this(Configuration.getDefaultApiClient());
    }

    public MetricApi(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    public ApiClient getApiClient() {
        return apiClient;
    }

    public void setApiClient(ApiClient apiClient) {
        this.apiClient = apiClient;
    }

    /* Build call for metricGet */
    private com.squareup.okhttp.Call metricGetCall(Integer skip, Integer limit, String where, String sort,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // create path and map variables
        String localVarPath = "/metric".replaceAll("\\{format\\}", "json");

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        if (skip != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "skip", skip));
        if (limit != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "limit", limit));
        if (where != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "where", where));
        if (sort != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "sort", sort));

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = { "application/json" };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null)
            localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = { "application/json" };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if (progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
                @Override
                public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain)
                        throws IOException {
                    com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                            .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build();
                }
            });
        }

        String[] localVarAuthNames = new String[] { "api_key" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * List all registered metrics
     * &lt;p&gt;Metrics are linked to time-series and define their meaning.&lt;/p&gt; &lt;p&gt;Common metric ID are listed below:&lt;/p&gt; &lt;table&gt;   &lt;tr&gt;&lt;td&gt;id&lt;/td&gt;&lt;td&gt;Value&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Timestamp&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;Neutral&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;Happiness&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;Surprise&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;Puzzlement&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;Disgust&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;Fear&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;Sadness&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;p&gt;&lt;strong&gt;Permissions:&lt;/strong&gt;  Respondent  Customer  Manager&lt;/p&gt;
     * @param skip The number of results to skip. (optional)
     * @param limit The maximum number of results to return. (optional)
     * @param where JSON formatted string condition. (optional)
     * @param sort Attribute used to sort results. (optional)
     * @return List&lt;Metric&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public List<Metric> metricGet(Integer skip, Integer limit, String where, String sort) throws ApiException {
        ApiResponse<List<Metric>> resp = metricGetWithHttpInfo(skip, limit, where, sort);
        return resp.getData();
    }

    /**
     * List all registered metrics
     * &lt;p&gt;Metrics are linked to time-series and define their meaning.&lt;/p&gt; &lt;p&gt;Common metric ID are listed below:&lt;/p&gt; &lt;table&gt;   &lt;tr&gt;&lt;td&gt;id&lt;/td&gt;&lt;td&gt;Value&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Timestamp&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;Neutral&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;Happiness&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;Surprise&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;Puzzlement&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;Disgust&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;Fear&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;Sadness&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;p&gt;&lt;strong&gt;Permissions:&lt;/strong&gt;  Respondent  Customer  Manager&lt;/p&gt;
     * @param skip The number of results to skip. (optional)
     * @param limit The maximum number of results to return. (optional)
     * @param where JSON formatted string condition. (optional)
     * @param sort Attribute used to sort results. (optional)
     * @return ApiResponse&lt;List&lt;Metric&gt;&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<List<Metric>> metricGetWithHttpInfo(Integer skip, Integer limit, String where, String sort)
            throws ApiException {
        com.squareup.okhttp.Call call = metricGetCall(skip, limit, where, sort, null, null);
        Type localVarReturnType = new TypeToken<List<Metric>>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * List all registered metrics (asynchronously)
     * &lt;p&gt;Metrics are linked to time-series and define their meaning.&lt;/p&gt; &lt;p&gt;Common metric ID are listed below:&lt;/p&gt; &lt;table&gt;   &lt;tr&gt;&lt;td&gt;id&lt;/td&gt;&lt;td&gt;Value&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Timestamp&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;Neutral&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;Happiness&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;Surprise&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;Puzzlement&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;Disgust&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;Fear&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;Sadness&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;p&gt;&lt;strong&gt;Permissions:&lt;/strong&gt;  Respondent  Customer  Manager&lt;/p&gt;
     * @param skip The number of results to skip. (optional)
     * @param limit The maximum number of results to return. (optional)
     * @param where JSON formatted string condition. (optional)
     * @param sort Attribute used to sort results. (optional)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call metricGetAsync(Integer skip, Integer limit, String where, String sort,
            final ApiCallback<List<Metric>> callback) throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = metricGetCall(skip, limit, where, sort, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<List<Metric>>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for metricMetricIdDelete */
    private com.squareup.okhttp.Call metricMetricIdDeleteCall(Integer metricId,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // verify the required parameter 'metricId' is set
        if (metricId == null) {
            throw new ApiException(
                    "Missing the required parameter 'metricId' when calling metricMetricIdDelete(Async)");
        }

        // create path and map variables
        String localVarPath = "/metric/{metric_id}".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "metric_id" + "\\}", apiClient.escapeString(metricId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = { "application/json" };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null)
            localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = { "application/json" };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if (progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
                @Override
                public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain)
                        throws IOException {
                    com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                            .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build();
                }
            });
        }

        String[] localVarAuthNames = new String[] { "api_key" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarPostBody,
                localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Delete a Metric
     * &lt;p&gt;&lt;strong&gt;Permissions:&lt;/strong&gt;  Respondent  Customer  Manager&lt;/p&gt;
     * @param metricId ID of Metric to be deleted. (required)
     * @return Metric
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public Metric metricMetricIdDelete(Integer metricId) throws ApiException {
        ApiResponse<Metric> resp = metricMetricIdDeleteWithHttpInfo(metricId);
        return resp.getData();
    }

    /**
     * Delete a Metric
     * &lt;p&gt;&lt;strong&gt;Permissions:&lt;/strong&gt;  Respondent  Customer  Manager&lt;/p&gt;
     * @param metricId ID of Metric to be deleted. (required)
     * @return ApiResponse&lt;Metric&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<Metric> metricMetricIdDeleteWithHttpInfo(Integer metricId) throws ApiException {
        com.squareup.okhttp.Call call = metricMetricIdDeleteCall(metricId, null, null);
        Type localVarReturnType = new TypeToken<Metric>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Delete a Metric (asynchronously)
     * &lt;p&gt;&lt;strong&gt;Permissions:&lt;/strong&gt;  Respondent  Customer  Manager&lt;/p&gt;
     * @param metricId ID of Metric to be deleted. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call metricMetricIdDeleteAsync(Integer metricId, final ApiCallback<Metric> callback)
            throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = metricMetricIdDeleteCall(metricId, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<Metric>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for metricMetricIdGet */
    private com.squareup.okhttp.Call metricMetricIdGetCall(Integer metricId,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

        // verify the required parameter 'metricId' is set
        if (metricId == null) {
            throw new ApiException(
                    "Missing the required parameter 'metricId' when calling metricMetricIdGet(Async)");
        }

        // create path and map variables
        String localVarPath = "/metric/{metric_id}".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "metric_id" + "\\}", apiClient.escapeString(metricId.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = { "application/json" };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null)
            localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = { "application/json" };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if (progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
                @Override
                public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain)
                        throws IOException {
                    com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                            .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build();
                }
            });
        }

        String[] localVarAuthNames = new String[] { "api_key" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Find a Metric
     * &lt;p&gt;Metrics are linked to time-series and define their meaning.&lt;/p&gt; &lt;p&gt;Common metric ID are listed below:&lt;/p&gt; &lt;table&gt;   &lt;tr&gt;&lt;td&gt;id&lt;/td&gt;&lt;td&gt;Value&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Timestamp&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;Neutral&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;Happiness&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;Surprise&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;Puzzlement&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;Disgust&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;Fear&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;Sadness&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;p&gt;&lt;strong&gt;Permissions:&lt;/strong&gt;  Respondent  Customer  Manager&lt;/p&gt;
     * @param metricId ID of Metric to find. (required)
     * @return Metric
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public Metric metricMetricIdGet(Integer metricId) throws ApiException {
        ApiResponse<Metric> resp = metricMetricIdGetWithHttpInfo(metricId);
        return resp.getData();
    }

    /**
     * Find a Metric
     * &lt;p&gt;Metrics are linked to time-series and define their meaning.&lt;/p&gt; &lt;p&gt;Common metric ID are listed below:&lt;/p&gt; &lt;table&gt;   &lt;tr&gt;&lt;td&gt;id&lt;/td&gt;&lt;td&gt;Value&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Timestamp&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;Neutral&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;Happiness&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;Surprise&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;Puzzlement&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;Disgust&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;Fear&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;Sadness&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;p&gt;&lt;strong&gt;Permissions:&lt;/strong&gt;  Respondent  Customer  Manager&lt;/p&gt;
     * @param metricId ID of Metric to find. (required)
     * @return ApiResponse&lt;Metric&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<Metric> metricMetricIdGetWithHttpInfo(Integer metricId) throws ApiException {
        com.squareup.okhttp.Call call = metricMetricIdGetCall(metricId, null, null);
        Type localVarReturnType = new TypeToken<Metric>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Find a Metric (asynchronously)
     * &lt;p&gt;Metrics are linked to time-series and define their meaning.&lt;/p&gt; &lt;p&gt;Common metric ID are listed below:&lt;/p&gt; &lt;table&gt;   &lt;tr&gt;&lt;td&gt;id&lt;/td&gt;&lt;td&gt;Value&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;Timestamp&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;Neutral&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;Happiness&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;Surprise&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;5&lt;/td&gt;&lt;td&gt;Puzzlement&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;6&lt;/td&gt;&lt;td&gt;Disgust&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;7&lt;/td&gt;&lt;td&gt;Fear&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;td&gt;8&lt;/td&gt;&lt;td&gt;Sadness&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;p&gt;&lt;strong&gt;Permissions:&lt;/strong&gt;  Respondent  Customer  Manager&lt;/p&gt;
     * @param metricId ID of Metric to find. (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call metricMetricIdGetAsync(Integer metricId, final ApiCallback<Metric> callback)
            throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = metricMetricIdGetCall(metricId, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<Metric>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for metricPost */
    private com.squareup.okhttp.Call metricPostCall(MetricCreation body,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = body;

        // verify the required parameter 'body' is set
        if (body == null) {
            throw new ApiException("Missing the required parameter 'body' when calling metricPost(Async)");
        }

        // create path and map variables
        String localVarPath = "/metric".replaceAll("\\{format\\}", "json");

        List<Pair> localVarQueryParams = new ArrayList<Pair>();

        Map<String, String> localVarHeaderParams = new HashMap<String, String>();

        Map<String, Object> localVarFormParams = new HashMap<String, Object>();

        final String[] localVarAccepts = { "application/json" };
        final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
        if (localVarAccept != null)
            localVarHeaderParams.put("Accept", localVarAccept);

        final String[] localVarContentTypes = { "application/json" };
        final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
        localVarHeaderParams.put("Content-Type", localVarContentType);

        if (progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
                @Override
                public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain)
                        throws IOException {
                    com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                            .body(new ProgressResponseBody(originalResponse.body(), progressListener)).build();
                }
            });
        }

        String[] localVarAuthNames = new String[] { "api_key" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody,
                localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Create Metric
     * &lt;p&gt;&lt;strong&gt;Permissions:&lt;/strong&gt;  Respondent  Customer  Manager&lt;/p&gt;
     * @param body Request body (required)
     * @return Metric
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public Metric metricPost(MetricCreation body) throws ApiException {
        ApiResponse<Metric> resp = metricPostWithHttpInfo(body);
        return resp.getData();
    }

    /**
     * Create Metric
     * &lt;p&gt;&lt;strong&gt;Permissions:&lt;/strong&gt;  Respondent  Customer  Manager&lt;/p&gt;
     * @param body Request body (required)
     * @return ApiResponse&lt;Metric&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<Metric> metricPostWithHttpInfo(MetricCreation body) throws ApiException {
        com.squareup.okhttp.Call call = metricPostCall(body, null, null);
        Type localVarReturnType = new TypeToken<Metric>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Create Metric (asynchronously)
     * &lt;p&gt;&lt;strong&gt;Permissions:&lt;/strong&gt;  Respondent  Customer  Manager&lt;/p&gt;
     * @param body Request body (required)
     * @param callback The callback to be executed when the API call finishes
     * @return The request call
     * @throws ApiException If fail to process the API call, e.g. serializing the request body object
     */
    public com.squareup.okhttp.Call metricPostAsync(MetricCreation body, final ApiCallback<Metric> callback)
            throws ApiException {

        ProgressResponseBody.ProgressListener progressListener = null;
        ProgressRequestBody.ProgressRequestListener progressRequestListener = null;

        if (callback != null) {
            progressListener = new ProgressResponseBody.ProgressListener() {
                @Override
                public void update(long bytesRead, long contentLength, boolean done) {
                    callback.onDownloadProgress(bytesRead, contentLength, done);
                }
            };

            progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {
                @Override
                public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                    callback.onUploadProgress(bytesWritten, contentLength, done);
                }
            };
        }

        com.squareup.okhttp.Call call = metricPostCall(body, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<Metric>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}