cloud.artik.api.DevicesManagementApi.java Source code

Java tutorial

Introduction

Here is the source code for cloud.artik.api.DevicesManagementApi.java

Source

/**
 * ARTIK Cloud API
 * No descripton provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
 *
 * OpenAPI spec version: 2.0.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 cloud.artik.api;

import cloud.artik.client.ApiCallback;
import cloud.artik.client.ApiClient;
import cloud.artik.client.ApiException;
import cloud.artik.client.ApiResponse;
import cloud.artik.client.Configuration;
import cloud.artik.client.Pair;
import cloud.artik.client.ProgressRequestBody;
import cloud.artik.client.ProgressResponseBody;

import com.google.gson.reflect.TypeToken;

import java.io.IOException;

import cloud.artik.model.TaskEnvelope;
import cloud.artik.model.TaskRequest;
import cloud.artik.model.MetadataEnvelope;
import cloud.artik.model.TaskByDidListEnvelope;
import cloud.artik.model.DeviceTypesInfoEnvelope;
import cloud.artik.model.MetadataPropertiesEnvelope;
import cloud.artik.model.TaskStatusesEnvelope;
import cloud.artik.model.TaskStatusesHistoryEnvelope;
import cloud.artik.model.TaskListEnvelope;
import cloud.artik.model.MetadataQueryEnvelope;
import cloud.artik.model.DeviceTypesInfo;
import cloud.artik.model.TaskUpdateRequest;
import cloud.artik.model.TaskUpdateResponse;
import cloud.artik.model.DeviceTaskUpdateRequest;
import cloud.artik.model.DeviceTaskUpdateResponse;

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

public class DevicesManagementApi {
    private ApiClient apiClient;

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

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

    public ApiClient getApiClient() {
        return apiClient;
    }

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

    /* Build call for createTasks */
    private com.squareup.okhttp.Call createTasksCall(TaskRequest taskPayload,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = taskPayload;

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

        // create path and map variables
        String localVarPath = "/devicemgmt/tasks".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 = {

        };
        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[] { "artikcloud_oauth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody,
                localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Create a new task for one or more devices
     * Create a new task for one or more devices
     * @param taskPayload Task object to be created (required)
     * @return TaskEnvelope
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TaskEnvelope createTasks(TaskRequest taskPayload) throws ApiException {
        ApiResponse<TaskEnvelope> resp = createTasksWithHttpInfo(taskPayload);
        return resp.getData();
    }

    /**
     * Create a new task for one or more devices
     * Create a new task for one or more devices
     * @param taskPayload Task object to be created (required)
     * @return ApiResponse&lt;TaskEnvelope&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TaskEnvelope> createTasksWithHttpInfo(TaskRequest taskPayload) throws ApiException {
        com.squareup.okhttp.Call call = createTasksCall(taskPayload, null, null);
        Type localVarReturnType = new TypeToken<TaskEnvelope>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Create a new task for one or more devices (asynchronously)
     * Create a new task for one or more devices
     * @param taskPayload Task object to be created (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 createTasksAsync(TaskRequest taskPayload,
            final ApiCallback<TaskEnvelope> 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 = createTasksCall(taskPayload, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<TaskEnvelope>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for deleteServerProperties */
    private com.squareup.okhttp.Call deleteServerPropertiesCall(String did,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

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

        // create path and map variables
        String localVarPath = "/devicemgmt/devices/{did}/serverproperties".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "did" + "\\}", apiClient.escapeString(did.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 = {

        };
        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[] { "artikcloud_oauth" };
        return apiClient.buildCall(localVarPath, "DELETE", localVarQueryParams, localVarPostBody,
                localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Deletes a device&#39;s properties.
     * Deletes a device&#39;s properties.
     * @param did Device ID. (required)
     * @return MetadataEnvelope
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public MetadataEnvelope deleteServerProperties(String did) throws ApiException {
        ApiResponse<MetadataEnvelope> resp = deleteServerPropertiesWithHttpInfo(did);
        return resp.getData();
    }

    /**
     * Deletes a device&#39;s properties.
     * Deletes a device&#39;s properties.
     * @param did Device ID. (required)
     * @return ApiResponse&lt;MetadataEnvelope&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<MetadataEnvelope> deleteServerPropertiesWithHttpInfo(String did) throws ApiException {
        com.squareup.okhttp.Call call = deleteServerPropertiesCall(did, null, null);
        Type localVarReturnType = new TypeToken<MetadataEnvelope>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Deletes a device&#39;s properties. (asynchronously)
     * Deletes a device&#39;s properties.
     * @param did Device ID. (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 deleteServerPropertiesAsync(String did,
            final ApiCallback<MetadataEnvelope> 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 = deleteServerPropertiesCall(did, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<MetadataEnvelope>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for getAllByDid */
    private com.squareup.okhttp.Call getAllByDidCall(String did, Integer count, Integer offset, String status,
            String order, String sort, final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

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

        // create path and map variables
        String localVarPath = "/devicemgmt/devices/{did}/tasks".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "did" + "\\}", apiClient.escapeString(did.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        if (count != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "count", count));
        if (offset != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "offset", offset));
        if (status != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "status", status));
        if (order != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "order", order));
        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 = {

        };
        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[] { "artikcloud_oauth" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Returns the list of tasks for a particular device id with optional status filter.
     * Returns the list of tasks for a particular device id with optional status filter.
     * @param did Device ID. (required)
     * @param count Max results count. (optional)
     * @param offset Result starting offset. (optional)
     * @param status Status filter. Comma-separated statuses. (optional)
     * @param order Sort results by a field. Valid fields: createdOn. (optional)
     * @param sort Sort order. Valid values: asc or desc. (optional)
     * @return TaskByDidListEnvelope
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TaskByDidListEnvelope getAllByDid(String did, Integer count, Integer offset, String status, String order,
            String sort) throws ApiException {
        ApiResponse<TaskByDidListEnvelope> resp = getAllByDidWithHttpInfo(did, count, offset, status, order, sort);
        return resp.getData();
    }

    /**
     * Returns the list of tasks for a particular device id with optional status filter.
     * Returns the list of tasks for a particular device id with optional status filter.
     * @param did Device ID. (required)
     * @param count Max results count. (optional)
     * @param offset Result starting offset. (optional)
     * @param status Status filter. Comma-separated statuses. (optional)
     * @param order Sort results by a field. Valid fields: createdOn. (optional)
     * @param sort Sort order. Valid values: asc or desc. (optional)
     * @return ApiResponse&lt;TaskByDidListEnvelope&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TaskByDidListEnvelope> getAllByDidWithHttpInfo(String did, Integer count, Integer offset,
            String status, String order, String sort) throws ApiException {
        com.squareup.okhttp.Call call = getAllByDidCall(did, count, offset, status, order, sort, null, null);
        Type localVarReturnType = new TypeToken<TaskByDidListEnvelope>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns the list of tasks for a particular device id with optional status filter. (asynchronously)
     * Returns the list of tasks for a particular device id with optional status filter.
     * @param did Device ID. (required)
     * @param count Max results count. (optional)
     * @param offset Result starting offset. (optional)
     * @param status Status filter. Comma-separated statuses. (optional)
     * @param order Sort results by a field. Valid fields: createdOn. (optional)
     * @param sort Sort order. Valid values: asc or desc. (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 getAllByDidAsync(String did, Integer count, Integer offset, String status,
            String order, String sort, final ApiCallback<TaskByDidListEnvelope> 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 = getAllByDidCall(did, count, offset, status, order, sort, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<TaskByDidListEnvelope>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for getDeviceTypesInfo */
    private com.squareup.okhttp.Call getDeviceTypesInfoCall(String dtid,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

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

        // create path and map variables
        String localVarPath = "/devicemgmt/devicetypes/{dtid}".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "dtid" + "\\}", apiClient.escapeString(dtid.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 = {

        };
        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[] { "artikcloud_oauth" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Read a device type device management information.
     * Read a device type device management information.
     * @param dtid Device type ID. (required)
     * @return DeviceTypesInfoEnvelope
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public DeviceTypesInfoEnvelope getDeviceTypesInfo(String dtid) throws ApiException {
        ApiResponse<DeviceTypesInfoEnvelope> resp = getDeviceTypesInfoWithHttpInfo(dtid);
        return resp.getData();
    }

    /**
     * Read a device type device management information.
     * Read a device type device management information.
     * @param dtid Device type ID. (required)
     * @return ApiResponse&lt;DeviceTypesInfoEnvelope&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<DeviceTypesInfoEnvelope> getDeviceTypesInfoWithHttpInfo(String dtid) throws ApiException {
        com.squareup.okhttp.Call call = getDeviceTypesInfoCall(dtid, null, null);
        Type localVarReturnType = new TypeToken<DeviceTypesInfoEnvelope>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Read a device type device management information. (asynchronously)
     * Read a device type device management information.
     * @param dtid Device type ID. (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 getDeviceTypesInfoAsync(String dtid,
            final ApiCallback<DeviceTypesInfoEnvelope> 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 = getDeviceTypesInfoCall(dtid, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<DeviceTypesInfoEnvelope>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for getManifestProperties */
    private com.squareup.okhttp.Call getManifestPropertiesCall(String dtid,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

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

        // create path and map variables
        String localVarPath = "/devicemgmt/devicetypes/{dtid}/manifest/properties"
                .replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "dtid" + "\\}", apiClient.escapeString(dtid.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 = {

        };
        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[] { "artikcloud_oauth" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Get a device type&#39;s device management manifest properties
     * Get a device type&#39;s device management manifest properties
     * @param dtid Device Type ID. (required)
     * @return MetadataPropertiesEnvelope
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public MetadataPropertiesEnvelope getManifestProperties(String dtid) throws ApiException {
        ApiResponse<MetadataPropertiesEnvelope> resp = getManifestPropertiesWithHttpInfo(dtid);
        return resp.getData();
    }

    /**
     * Get a device type&#39;s device management manifest properties
     * Get a device type&#39;s device management manifest properties
     * @param dtid Device Type ID. (required)
     * @return ApiResponse&lt;MetadataPropertiesEnvelope&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<MetadataPropertiesEnvelope> getManifestPropertiesWithHttpInfo(String dtid)
            throws ApiException {
        com.squareup.okhttp.Call call = getManifestPropertiesCall(dtid, null, null);
        Type localVarReturnType = new TypeToken<MetadataPropertiesEnvelope>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Get a device type&#39;s device management manifest properties (asynchronously)
     * Get a device type&#39;s device management manifest properties
     * @param dtid Device Type ID. (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 getManifestPropertiesAsync(String dtid,
            final ApiCallback<MetadataPropertiesEnvelope> 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 = getManifestPropertiesCall(dtid, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<MetadataPropertiesEnvelope>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for getProperties */
    private com.squareup.okhttp.Call getPropertiesCall(String did, Boolean includeTimestamp,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

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

        // create path and map variables
        String localVarPath = "/devicemgmt/devices/{did}/properties".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "did" + "\\}", apiClient.escapeString(did.toString()));

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

        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 = {

        };
        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[] { "artikcloud_oauth" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Read a device&#39;s properties.
     * Read a device&#39;s properties.
     * @param did Device ID. (required)
     * @param includeTimestamp Include timestamp. (optional)
     * @return MetadataEnvelope
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public MetadataEnvelope getProperties(String did, Boolean includeTimestamp) throws ApiException {
        ApiResponse<MetadataEnvelope> resp = getPropertiesWithHttpInfo(did, includeTimestamp);
        return resp.getData();
    }

    /**
     * Read a device&#39;s properties.
     * Read a device&#39;s properties.
     * @param did Device ID. (required)
     * @param includeTimestamp Include timestamp. (optional)
     * @return ApiResponse&lt;MetadataEnvelope&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<MetadataEnvelope> getPropertiesWithHttpInfo(String did, Boolean includeTimestamp)
            throws ApiException {
        com.squareup.okhttp.Call call = getPropertiesCall(did, includeTimestamp, null, null);
        Type localVarReturnType = new TypeToken<MetadataEnvelope>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Read a device&#39;s properties. (asynchronously)
     * Read a device&#39;s properties.
     * @param did Device ID. (required)
     * @param includeTimestamp Include timestamp. (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 getPropertiesAsync(String did, Boolean includeTimestamp,
            final ApiCallback<MetadataEnvelope> 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 = getPropertiesCall(did, includeTimestamp, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<MetadataEnvelope>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for getStatuses */
    private com.squareup.okhttp.Call getStatusesCall(String tid, Integer count, Integer offset, String status,
            String dids, final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

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

        // create path and map variables
        String localVarPath = "/devicemgmt/tasks/{tid}/statuses".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "tid" + "\\}", apiClient.escapeString(tid.toString()));

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        if (count != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "count", count));
        if (offset != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "offset", offset));
        if (status != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "status", status));
        if (dids != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "dids", dids));

        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 = {

        };
        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[] { "artikcloud_oauth" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Returns the details and status of a task id and the individual statuses of each device id in the list.
     * Returns the details and status of a task id and the individual statuses of each device id in the list.
     * @param tid Task ID. (required)
     * @param count Max results count. (optional)
     * @param offset Result starting offset. (optional)
     * @param status Status filter. Comma-separated statuses. (optional)
     * @param dids Devices filter. Comma-separated device IDs. (optional)
     * @return TaskStatusesEnvelope
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TaskStatusesEnvelope getStatuses(String tid, Integer count, Integer offset, String status, String dids)
            throws ApiException {
        ApiResponse<TaskStatusesEnvelope> resp = getStatusesWithHttpInfo(tid, count, offset, status, dids);
        return resp.getData();
    }

    /**
     * Returns the details and status of a task id and the individual statuses of each device id in the list.
     * Returns the details and status of a task id and the individual statuses of each device id in the list.
     * @param tid Task ID. (required)
     * @param count Max results count. (optional)
     * @param offset Result starting offset. (optional)
     * @param status Status filter. Comma-separated statuses. (optional)
     * @param dids Devices filter. Comma-separated device IDs. (optional)
     * @return ApiResponse&lt;TaskStatusesEnvelope&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TaskStatusesEnvelope> getStatusesWithHttpInfo(String tid, Integer count, Integer offset,
            String status, String dids) throws ApiException {
        com.squareup.okhttp.Call call = getStatusesCall(tid, count, offset, status, dids, null, null);
        Type localVarReturnType = new TypeToken<TaskStatusesEnvelope>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns the details and status of a task id and the individual statuses of each device id in the list. (asynchronously)
     * Returns the details and status of a task id and the individual statuses of each device id in the list.
     * @param tid Task ID. (required)
     * @param count Max results count. (optional)
     * @param offset Result starting offset. (optional)
     * @param status Status filter. Comma-separated statuses. (optional)
     * @param dids Devices filter. Comma-separated device IDs. (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 getStatusesAsync(String tid, Integer count, Integer offset, String status,
            String dids, final ApiCallback<TaskStatusesEnvelope> 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 = getStatusesCall(tid, count, offset, status, dids, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<TaskStatusesEnvelope>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for getStatusesHistory */
    private com.squareup.okhttp.Call getStatusesHistoryCall(String tid, String did,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

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

        // create path and map variables
        String localVarPath = "/devicemgmt/tasks/{tid}/statuses/history".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "tid" + "\\}", apiClient.escapeString(tid.toString()));

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

        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 = {

        };
        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[] { "artikcloud_oauth" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Returns the history of the status changes for a specific task id, or for a specific device id in that task.
     * Returns the history of the status changes for a specific task id, or for a specific device id in that task.
     * @param tid Task ID. (required)
     * @param did Device ID. Optional. (optional)
     * @return TaskStatusesHistoryEnvelope
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TaskStatusesHistoryEnvelope getStatusesHistory(String tid, String did) throws ApiException {
        ApiResponse<TaskStatusesHistoryEnvelope> resp = getStatusesHistoryWithHttpInfo(tid, did);
        return resp.getData();
    }

    /**
     * Returns the history of the status changes for a specific task id, or for a specific device id in that task.
     * Returns the history of the status changes for a specific task id, or for a specific device id in that task.
     * @param tid Task ID. (required)
     * @param did Device ID. Optional. (optional)
     * @return ApiResponse&lt;TaskStatusesHistoryEnvelope&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TaskStatusesHistoryEnvelope> getStatusesHistoryWithHttpInfo(String tid, String did)
            throws ApiException {
        com.squareup.okhttp.Call call = getStatusesHistoryCall(tid, did, null, null);
        Type localVarReturnType = new TypeToken<TaskStatusesHistoryEnvelope>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns the history of the status changes for a specific task id, or for a specific device id in that task. (asynchronously)
     * Returns the history of the status changes for a specific task id, or for a specific device id in that task.
     * @param tid Task ID. (required)
     * @param did Device ID. Optional. (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 getStatusesHistoryAsync(String tid, String did,
            final ApiCallback<TaskStatusesHistoryEnvelope> 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 = getStatusesHistoryCall(tid, did, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<TaskStatusesHistoryEnvelope>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for getTaskByID */
    private com.squareup.okhttp.Call getTaskByIDCall(String tid,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

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

        // create path and map variables
        String localVarPath = "/devicemgmt/tasks/{tid}".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "tid" + "\\}", apiClient.escapeString(tid.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 = {

        };
        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[] { "artikcloud_oauth" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Returns the details and global status of a specific task id.
     * Returns the details and global status of a specific task id.
     * @param tid Task ID. (required)
     * @return TaskEnvelope
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TaskEnvelope getTaskByID(String tid) throws ApiException {
        ApiResponse<TaskEnvelope> resp = getTaskByIDWithHttpInfo(tid);
        return resp.getData();
    }

    /**
     * Returns the details and global status of a specific task id.
     * Returns the details and global status of a specific task id.
     * @param tid Task ID. (required)
     * @return ApiResponse&lt;TaskEnvelope&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TaskEnvelope> getTaskByIDWithHttpInfo(String tid) throws ApiException {
        com.squareup.okhttp.Call call = getTaskByIDCall(tid, null, null);
        Type localVarReturnType = new TypeToken<TaskEnvelope>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns the details and global status of a specific task id. (asynchronously)
     * Returns the details and global status of a specific task id.
     * @param tid Task ID. (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 getTaskByIDAsync(String tid, final ApiCallback<TaskEnvelope> 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 = getTaskByIDCall(tid, progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<TaskEnvelope>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for getTasks */
    private com.squareup.okhttp.Call getTasksCall(String dtid, Integer count, Integer offset, String status,
            String order, String sort, final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

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

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

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        if (dtid != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "dtid", dtid));
        if (count != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "count", count));
        if (offset != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "offset", offset));
        if (status != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "status", status));
        if (order != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "order", order));
        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 = {

        };
        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[] { "artikcloud_oauth" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Returns the all the tasks for a device type.
     * Returns the all the tasks for a device type.
     * @param dtid Device Type ID. (required)
     * @param count Max results count. (optional)
     * @param offset Result starting offset. (optional)
     * @param status Status filter. Comma-separated statuses. (optional)
     * @param order Sort results by a field. Valid fields: createdOn. (optional)
     * @param sort Sort order. Valid values: asc or desc. (optional)
     * @return TaskListEnvelope
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TaskListEnvelope getTasks(String dtid, Integer count, Integer offset, String status, String order,
            String sort) throws ApiException {
        ApiResponse<TaskListEnvelope> resp = getTasksWithHttpInfo(dtid, count, offset, status, order, sort);
        return resp.getData();
    }

    /**
     * Returns the all the tasks for a device type.
     * Returns the all the tasks for a device type.
     * @param dtid Device Type ID. (required)
     * @param count Max results count. (optional)
     * @param offset Result starting offset. (optional)
     * @param status Status filter. Comma-separated statuses. (optional)
     * @param order Sort results by a field. Valid fields: createdOn. (optional)
     * @param sort Sort order. Valid values: asc or desc. (optional)
     * @return ApiResponse&lt;TaskListEnvelope&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TaskListEnvelope> getTasksWithHttpInfo(String dtid, Integer count, Integer offset,
            String status, String order, String sort) throws ApiException {
        com.squareup.okhttp.Call call = getTasksCall(dtid, count, offset, status, order, sort, null, null);
        Type localVarReturnType = new TypeToken<TaskListEnvelope>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Returns the all the tasks for a device type. (asynchronously)
     * Returns the all the tasks for a device type.
     * @param dtid Device Type ID. (required)
     * @param count Max results count. (optional)
     * @param offset Result starting offset. (optional)
     * @param status Status filter. Comma-separated statuses. (optional)
     * @param order Sort results by a field. Valid fields: createdOn. (optional)
     * @param sort Sort order. Valid values: asc or desc. (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 getTasksAsync(String dtid, Integer count, Integer offset, String status,
            String order, String sort, final ApiCallback<TaskListEnvelope> 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 = getTasksCall(dtid, count, offset, status, order, sort, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<TaskListEnvelope>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for queryProperties */
    private com.squareup.okhttp.Call queryPropertiesCall(String dtid, Integer count, Integer offset, String filter,
            Boolean includeTimestamp, final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = null;

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

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

        List<Pair> localVarQueryParams = new ArrayList<Pair>();
        if (dtid != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "dtid", dtid));
        if (count != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "count", count));
        if (offset != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "offset", offset));
        if (filter != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter", filter));
        if (includeTimestamp != null)
            localVarQueryParams.addAll(apiClient.parameterToPairs("", "includeTimestamp", includeTimestamp));

        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 = {

        };
        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[] { "artikcloud_oauth" };
        return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Query device properties across devices.
     * Query device properties across devices.
     * @param dtid Device Type ID. (required)
     * @param count Max results count. (optional)
     * @param offset Result starting offset. (optional)
     * @param filter Query filter. Comma-separated key&#x3D;value pairs (optional)
     * @param includeTimestamp Include timestamp. (optional)
     * @return MetadataQueryEnvelope
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public MetadataQueryEnvelope queryProperties(String dtid, Integer count, Integer offset, String filter,
            Boolean includeTimestamp) throws ApiException {
        ApiResponse<MetadataQueryEnvelope> resp = queryPropertiesWithHttpInfo(dtid, count, offset, filter,
                includeTimestamp);
        return resp.getData();
    }

    /**
     * Query device properties across devices.
     * Query device properties across devices.
     * @param dtid Device Type ID. (required)
     * @param count Max results count. (optional)
     * @param offset Result starting offset. (optional)
     * @param filter Query filter. Comma-separated key&#x3D;value pairs (optional)
     * @param includeTimestamp Include timestamp. (optional)
     * @return ApiResponse&lt;MetadataQueryEnvelope&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<MetadataQueryEnvelope> queryPropertiesWithHttpInfo(String dtid, Integer count,
            Integer offset, String filter, Boolean includeTimestamp) throws ApiException {
        com.squareup.okhttp.Call call = queryPropertiesCall(dtid, count, offset, filter, includeTimestamp, null,
                null);
        Type localVarReturnType = new TypeToken<MetadataQueryEnvelope>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Query device properties across devices. (asynchronously)
     * Query device properties across devices.
     * @param dtid Device Type ID. (required)
     * @param count Max results count. (optional)
     * @param offset Result starting offset. (optional)
     * @param filter Query filter. Comma-separated key&#x3D;value pairs (optional)
     * @param includeTimestamp Include timestamp. (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 queryPropertiesAsync(String dtid, Integer count, Integer offset, String filter,
            Boolean includeTimestamp, final ApiCallback<MetadataQueryEnvelope> 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 = queryPropertiesCall(dtid, count, offset, filter, includeTimestamp,
                progressListener, progressRequestListener);
        Type localVarReturnType = new TypeToken<MetadataQueryEnvelope>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for updateDeviceTypesInfo */
    private com.squareup.okhttp.Call updateDeviceTypesInfoCall(String dtid, DeviceTypesInfo deviceTypeInfo,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = deviceTypeInfo;

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

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

        // create path and map variables
        String localVarPath = "/devicemgmt/devicetypes/{dtid}".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "dtid" + "\\}", apiClient.escapeString(dtid.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 = {

        };
        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[] { "artikcloud_oauth" };
        return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Updates a device type information
     * Updates a device type information
     * @param dtid Device type ID. (required)
     * @param deviceTypeInfo Device type info object to be set (required)
     * @return DeviceTypesInfoEnvelope
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public DeviceTypesInfoEnvelope updateDeviceTypesInfo(String dtid, DeviceTypesInfo deviceTypeInfo)
            throws ApiException {
        ApiResponse<DeviceTypesInfoEnvelope> resp = updateDeviceTypesInfoWithHttpInfo(dtid, deviceTypeInfo);
        return resp.getData();
    }

    /**
     * Updates a device type information
     * Updates a device type information
     * @param dtid Device type ID. (required)
     * @param deviceTypeInfo Device type info object to be set (required)
     * @return ApiResponse&lt;DeviceTypesInfoEnvelope&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<DeviceTypesInfoEnvelope> updateDeviceTypesInfoWithHttpInfo(String dtid,
            DeviceTypesInfo deviceTypeInfo) throws ApiException {
        com.squareup.okhttp.Call call = updateDeviceTypesInfoCall(dtid, deviceTypeInfo, null, null);
        Type localVarReturnType = new TypeToken<DeviceTypesInfoEnvelope>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Updates a device type information (asynchronously)
     * Updates a device type information
     * @param dtid Device type ID. (required)
     * @param deviceTypeInfo Device type info object to be set (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 updateDeviceTypesInfoAsync(String dtid, DeviceTypesInfo deviceTypeInfo,
            final ApiCallback<DeviceTypesInfoEnvelope> 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 = updateDeviceTypesInfoCall(dtid, deviceTypeInfo, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<DeviceTypesInfoEnvelope>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for updateServerProperties */
    private com.squareup.okhttp.Call updateServerPropertiesCall(String did, Object deviceProperties,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = deviceProperties;

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

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

        // create path and map variables
        String localVarPath = "/devicemgmt/devices/{did}/serverproperties".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "did" + "\\}", apiClient.escapeString(did.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 = {

        };
        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[] { "artikcloud_oauth" };
        return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody,
                localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Updates a device&#39;s server properties.
     * Updates a device&#39;s server properties.
     * @param did Device ID. (required)
     * @param deviceProperties Device properties object to be set (required)
     * @return MetadataEnvelope
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public MetadataEnvelope updateServerProperties(String did, Object deviceProperties) throws ApiException {
        ApiResponse<MetadataEnvelope> resp = updateServerPropertiesWithHttpInfo(did, deviceProperties);
        return resp.getData();
    }

    /**
     * Updates a device&#39;s server properties.
     * Updates a device&#39;s server properties.
     * @param did Device ID. (required)
     * @param deviceProperties Device properties object to be set (required)
     * @return ApiResponse&lt;MetadataEnvelope&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<MetadataEnvelope> updateServerPropertiesWithHttpInfo(String did, Object deviceProperties)
            throws ApiException {
        com.squareup.okhttp.Call call = updateServerPropertiesCall(did, deviceProperties, null, null);
        Type localVarReturnType = new TypeToken<MetadataEnvelope>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Updates a device&#39;s server properties. (asynchronously)
     * Updates a device&#39;s server properties.
     * @param did Device ID. (required)
     * @param deviceProperties Device properties object to be set (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 updateServerPropertiesAsync(String did, Object deviceProperties,
            final ApiCallback<MetadataEnvelope> 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 = updateServerPropertiesCall(did, deviceProperties, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<MetadataEnvelope>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for updateTask */
    private com.squareup.okhttp.Call updateTaskCall(String tid, TaskUpdateRequest taskUpdateRequest,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = taskUpdateRequest;

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

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

        // create path and map variables
        String localVarPath = "/devicemgmt/tasks/{tid}".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "tid" + "\\}", apiClient.escapeString(tid.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 = {

        };
        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[] { "artikcloud_oauth" };
        return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Updates a task for all devices - For now just allows changing the state to cancelled.
     * Updates a task for all devices - For now just allows changing the state to cancelled.
     * @param tid Task ID. (required)
     * @param taskUpdateRequest Task update request (required)
     * @return TaskUpdateResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public TaskUpdateResponse updateTask(String tid, TaskUpdateRequest taskUpdateRequest) throws ApiException {
        ApiResponse<TaskUpdateResponse> resp = updateTaskWithHttpInfo(tid, taskUpdateRequest);
        return resp.getData();
    }

    /**
     * Updates a task for all devices - For now just allows changing the state to cancelled.
     * Updates a task for all devices - For now just allows changing the state to cancelled.
     * @param tid Task ID. (required)
     * @param taskUpdateRequest Task update request (required)
     * @return ApiResponse&lt;TaskUpdateResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<TaskUpdateResponse> updateTaskWithHttpInfo(String tid, TaskUpdateRequest taskUpdateRequest)
            throws ApiException {
        com.squareup.okhttp.Call call = updateTaskCall(tid, taskUpdateRequest, null, null);
        Type localVarReturnType = new TypeToken<TaskUpdateResponse>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Updates a task for all devices - For now just allows changing the state to cancelled. (asynchronously)
     * Updates a task for all devices - For now just allows changing the state to cancelled.
     * @param tid Task ID. (required)
     * @param taskUpdateRequest Task update request (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 updateTaskAsync(String tid, TaskUpdateRequest taskUpdateRequest,
            final ApiCallback<TaskUpdateResponse> 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 = updateTaskCall(tid, taskUpdateRequest, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<TaskUpdateResponse>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }

    /* Build call for updateTaskForDevice */
    private com.squareup.okhttp.Call updateTaskForDeviceCall(String tid, String did,
            DeviceTaskUpdateRequest deviceTaskUpdateRequest,
            final ProgressResponseBody.ProgressListener progressListener,
            final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
        Object localVarPostBody = deviceTaskUpdateRequest;

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

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

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

        // create path and map variables
        String localVarPath = "/devicemgmt/tasks/{tid}/devices/{did}".replaceAll("\\{format\\}", "json")
                .replaceAll("\\{" + "tid" + "\\}", apiClient.escapeString(tid.toString()))
                .replaceAll("\\{" + "did" + "\\}", apiClient.escapeString(did.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 = {

        };
        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[] { "artikcloud_oauth" };
        return apiClient.buildCall(localVarPath, "PUT", localVarQueryParams, localVarPostBody, localVarHeaderParams,
                localVarFormParams, localVarAuthNames, progressRequestListener);
    }

    /**
     * Updates a task for a specific device - For now just allows changing the state to cancelled.
     * Updates a task for a specific device - For now just allows changing the state to cancelled.
     * @param tid Task ID. (required)
     * @param did Device ID. (required)
     * @param deviceTaskUpdateRequest Device task update request (required)
     * @return DeviceTaskUpdateResponse
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public DeviceTaskUpdateResponse updateTaskForDevice(String tid, String did,
            DeviceTaskUpdateRequest deviceTaskUpdateRequest) throws ApiException {
        ApiResponse<DeviceTaskUpdateResponse> resp = updateTaskForDeviceWithHttpInfo(tid, did,
                deviceTaskUpdateRequest);
        return resp.getData();
    }

    /**
     * Updates a task for a specific device - For now just allows changing the state to cancelled.
     * Updates a task for a specific device - For now just allows changing the state to cancelled.
     * @param tid Task ID. (required)
     * @param did Device ID. (required)
     * @param deviceTaskUpdateRequest Device task update request (required)
     * @return ApiResponse&lt;DeviceTaskUpdateResponse&gt;
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     */
    public ApiResponse<DeviceTaskUpdateResponse> updateTaskForDeviceWithHttpInfo(String tid, String did,
            DeviceTaskUpdateRequest deviceTaskUpdateRequest) throws ApiException {
        com.squareup.okhttp.Call call = updateTaskForDeviceCall(tid, did, deviceTaskUpdateRequest, null, null);
        Type localVarReturnType = new TypeToken<DeviceTaskUpdateResponse>() {
        }.getType();
        return apiClient.execute(call, localVarReturnType);
    }

    /**
     * Updates a task for a specific device - For now just allows changing the state to cancelled. (asynchronously)
     * Updates a task for a specific device - For now just allows changing the state to cancelled.
     * @param tid Task ID. (required)
     * @param did Device ID. (required)
     * @param deviceTaskUpdateRequest Device task update request (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 updateTaskForDeviceAsync(String tid, String did,
            DeviceTaskUpdateRequest deviceTaskUpdateRequest, final ApiCallback<DeviceTaskUpdateResponse> 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 = updateTaskForDeviceCall(tid, did, deviceTaskUpdateRequest, progressListener,
                progressRequestListener);
        Type localVarReturnType = new TypeToken<DeviceTaskUpdateResponse>() {
        }.getType();
        apiClient.executeAsync(call, localVarReturnType, callback);
        return call;
    }
}