# coding: utf-8

"""
    IoT服务

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)  # noqa: E501

    The version of the OpenAPI document: 1.0.0
    Generated by: https://openapi-generator.tech
"""


from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from dhicn_iot_service.api_client import ApiClient
from dhicn_iot_service.exceptions import (  # noqa: F401
    ApiTypeError,
    ApiValueError
)


class TelemetryApi(object):
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, api_client=None):
        if api_client is None:
            api_client = ApiClient()
        self.api_client = api_client

    def api_v1_iot_latest_timeseries_by_time_post(self, **kwargs):  # noqa: E501
        """根据设备编码和指标名获取离指定时间点最近的实测数据  # noqa: E501

        关键词：设备、设备指标、时间点、实测数据、获取、查询  使用场景：  该接口一般用于基于某个时间点创建的预案中，如果需要查询该预案时刻下的最近实测数据，则使用该接口，若要查询实时数据，请用/api/v3/iot/latest-timeseries接口  输入：设备编码、指标名称、时间点  输出：设备编码、指标的时间序列数据  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_v1_iot_latest_timeseries_by_time_post(async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param LatestTimeSeriesByTimeInput latest_time_series_by_time_input:
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: list[LatestTimeSeriesOutputV3]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.api_v1_iot_latest_timeseries_by_time_post_with_http_info(**kwargs)  # noqa: E501

    def api_v1_iot_latest_timeseries_by_time_post_with_http_info(self, **kwargs):  # noqa: E501
        """根据设备编码和指标名获取离指定时间点最近的实测数据  # noqa: E501

        关键词：设备、设备指标、时间点、实测数据、获取、查询  使用场景：  该接口一般用于基于某个时间点创建的预案中，如果需要查询该预案时刻下的最近实测数据，则使用该接口，若要查询实时数据，请用/api/v3/iot/latest-timeseries接口  输入：设备编码、指标名称、时间点  输出：设备编码、指标的时间序列数据  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_v1_iot_latest_timeseries_by_time_post_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param LatestTimeSeriesByTimeInput latest_time_series_by_time_input:
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(list[LatestTimeSeriesOutputV3], status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'latest_time_series_by_time_input'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout'
            ]
        )

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method api_v1_iot_latest_timeseries_by_time_post" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'latest_time_series_by_time_input' in local_var_params:
            body_params = local_var_params['latest_time_series_by_time_input']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['text/plain'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['bearer']  # noqa: E501

        return self.api_client.call_api(
            '/api/v1/iot/latest-timeseries-by-time', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[LatestTimeSeriesOutputV3]',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def api_v1_iot_query_online_processed_timeseries_get(self, device_id, keys, start_ts, end_ts, **kwargs):  # noqa: E501
        """查询设备指标在指定时间段内的时间序列数据,按时间倒序排序  # noqa: E501

        关键词：设备、设备指标、设备指标时间序列数据、查询  使用场景：查询设备多个指标在某个时间段内的时间序列数据,和接口/api/v1/iot/timeseries的区别在于此接口不指定时间排序方式，只能倒序查询数据  输入：设备、指标、时间区间  输出：指标与时间序列数据的键值对  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_v1_iot_query_online_processed_timeseries_get(device_id, keys, start_ts, end_ts, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str device_id: 设备ID，如：065cd960-67d4-11ee-a501-41ab9ac02e38 (required)
        :param list[str] keys: 指标列表，如：ceshi_1_shuichang_flow、ceshi_1_shuichang_waterlevel (required)
        :param datetime start_ts: 查询开始时间 (required)
        :param datetime end_ts: 查询结束时间 (required)
        :param str order_by: 排序方式，ASC (升序)，DESC (降序) sort order, ASC (ASCENDING) or DESC (DESCENDING);默认是降序DESC
        :param int interval: 时间间隔，默认是1分钟
        :param str agg: 用于指定聚合函数，如AVG（平均值）、SUM（总和）、MIN（最小值）、MAX（最大值）等
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: dict(str, list[object])
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.api_v1_iot_query_online_processed_timeseries_get_with_http_info(device_id, keys, start_ts, end_ts, **kwargs)  # noqa: E501

    def api_v1_iot_query_online_processed_timeseries_get_with_http_info(self, device_id, keys, start_ts, end_ts, **kwargs):  # noqa: E501
        """查询设备指标在指定时间段内的时间序列数据,按时间倒序排序  # noqa: E501

        关键词：设备、设备指标、设备指标时间序列数据、查询  使用场景：查询设备多个指标在某个时间段内的时间序列数据,和接口/api/v1/iot/timeseries的区别在于此接口不指定时间排序方式，只能倒序查询数据  输入：设备、指标、时间区间  输出：指标与时间序列数据的键值对  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_v1_iot_query_online_processed_timeseries_get_with_http_info(device_id, keys, start_ts, end_ts, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str device_id: 设备ID，如：065cd960-67d4-11ee-a501-41ab9ac02e38 (required)
        :param list[str] keys: 指标列表，如：ceshi_1_shuichang_flow、ceshi_1_shuichang_waterlevel (required)
        :param datetime start_ts: 查询开始时间 (required)
        :param datetime end_ts: 查询结束时间 (required)
        :param str order_by: 排序方式，ASC (升序)，DESC (降序) sort order, ASC (ASCENDING) or DESC (DESCENDING);默认是降序DESC
        :param int interval: 时间间隔，默认是1分钟
        :param str agg: 用于指定聚合函数，如AVG（平均值）、SUM（总和）、MIN（最小值）、MAX（最大值）等
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(dict(str, list[object]), status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'device_id',
            'keys',
            'start_ts',
            'end_ts',
            'order_by',
            'interval',
            'agg'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout'
            ]
        )

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method api_v1_iot_query_online_processed_timeseries_get" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'device_id' is set
        if self.api_client.client_side_validation and ('device_id' not in local_var_params or  # noqa: E501
                                                        local_var_params['device_id'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `device_id` when calling `api_v1_iot_query_online_processed_timeseries_get`")  # noqa: E501
        # verify the required parameter 'keys' is set
        if self.api_client.client_side_validation and ('keys' not in local_var_params or  # noqa: E501
                                                        local_var_params['keys'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `keys` when calling `api_v1_iot_query_online_processed_timeseries_get`")  # noqa: E501
        # verify the required parameter 'start_ts' is set
        if self.api_client.client_side_validation and ('start_ts' not in local_var_params or  # noqa: E501
                                                        local_var_params['start_ts'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `start_ts` when calling `api_v1_iot_query_online_processed_timeseries_get`")  # noqa: E501
        # verify the required parameter 'end_ts' is set
        if self.api_client.client_side_validation and ('end_ts' not in local_var_params or  # noqa: E501
                                                        local_var_params['end_ts'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `end_ts` when calling `api_v1_iot_query_online_processed_timeseries_get`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'device_id' in local_var_params and local_var_params['device_id'] is not None:  # noqa: E501
            query_params.append(('DeviceId', local_var_params['device_id']))  # noqa: E501
        if 'keys' in local_var_params and local_var_params['keys'] is not None:  # noqa: E501
            query_params.append(('Keys', local_var_params['keys']))  # noqa: E501
            collection_formats['Keys'] = 'multi'  # noqa: E501
        if 'start_ts' in local_var_params and local_var_params['start_ts'] is not None:  # noqa: E501
            query_params.append(('StartTs', local_var_params['start_ts']))  # noqa: E501
        if 'end_ts' in local_var_params and local_var_params['end_ts'] is not None:  # noqa: E501
            query_params.append(('EndTs', local_var_params['end_ts']))  # noqa: E501
        if 'order_by' in local_var_params and local_var_params['order_by'] is not None:  # noqa: E501
            query_params.append(('OrderBy', local_var_params['order_by']))  # noqa: E501
        if 'interval' in local_var_params and local_var_params['interval'] is not None:  # noqa: E501
            query_params.append(('Interval', local_var_params['interval']))  # noqa: E501
        if 'agg' in local_var_params and local_var_params['agg'] is not None:  # noqa: E501
            query_params.append(('Agg', local_var_params['agg']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['text/plain'])  # noqa: E501

        # Authentication setting
        auth_settings = ['bearer']  # noqa: E501

        return self.api_client.call_api(
            '/api/v1/iot/query-online-processed-timeseries', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='dict(str, list[object])',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def api_v1_iot_timeseries_get(self, device_id, keys, start_ts, end_ts, **kwargs):  # noqa: E501
        """查询设备指标在指定时间段内的时间序列数据，可根据排序方式OrderBy按时间排序  # noqa: E501

        关键词：设备、设备指标、设备指标时间序列数据、时间、排序、查询  使用场景：查询设备多个指标在某个时间段内的时间序列数据，可按时间排序，该数据来自系统接入的实测数据，可用于展示到前端界面  输入：设备、指标、时间区间  输出：指标与时间序列数据的键值对  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_v1_iot_timeseries_get(device_id, keys, start_ts, end_ts, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str device_id: 设备ID，如：065cd960-67d4-11ee-a501-41ab9ac02e38 (required)
        :param list[str] keys: 指标列表，如：ceshi_1_shuichang_flow、ceshi_1_shuichang_waterlevel (required)
        :param datetime start_ts: 查询开始时间 (required)
        :param datetime end_ts: 查询结束时间 (required)
        :param str order_by: 排序方式，ASC (升序)，DESC (降序) sort order, ASC (ASCENDING) or DESC (DESCENDING);默认是降序DESC
        :param int interval: 时间间隔，默认是1分钟
        :param str agg: 用于指定聚合函数，如AVG（平均值）、SUM（总和）、MIN（最小值）、MAX（最大值）等
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: dict(str, list[object])
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.api_v1_iot_timeseries_get_with_http_info(device_id, keys, start_ts, end_ts, **kwargs)  # noqa: E501

    def api_v1_iot_timeseries_get_with_http_info(self, device_id, keys, start_ts, end_ts, **kwargs):  # noqa: E501
        """查询设备指标在指定时间段内的时间序列数据，可根据排序方式OrderBy按时间排序  # noqa: E501

        关键词：设备、设备指标、设备指标时间序列数据、时间、排序、查询  使用场景：查询设备多个指标在某个时间段内的时间序列数据，可按时间排序，该数据来自系统接入的实测数据，可用于展示到前端界面  输入：设备、指标、时间区间  输出：指标与时间序列数据的键值对  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_v1_iot_timeseries_get_with_http_info(device_id, keys, start_ts, end_ts, async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param str device_id: 设备ID，如：065cd960-67d4-11ee-a501-41ab9ac02e38 (required)
        :param list[str] keys: 指标列表，如：ceshi_1_shuichang_flow、ceshi_1_shuichang_waterlevel (required)
        :param datetime start_ts: 查询开始时间 (required)
        :param datetime end_ts: 查询结束时间 (required)
        :param str order_by: 排序方式，ASC (升序)，DESC (降序) sort order, ASC (ASCENDING) or DESC (DESCENDING);默认是降序DESC
        :param int interval: 时间间隔，默认是1分钟
        :param str agg: 用于指定聚合函数，如AVG（平均值）、SUM（总和）、MIN（最小值）、MAX（最大值）等
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(dict(str, list[object]), status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'device_id',
            'keys',
            'start_ts',
            'end_ts',
            'order_by',
            'interval',
            'agg'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout'
            ]
        )

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method api_v1_iot_timeseries_get" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'device_id' is set
        if self.api_client.client_side_validation and ('device_id' not in local_var_params or  # noqa: E501
                                                        local_var_params['device_id'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `device_id` when calling `api_v1_iot_timeseries_get`")  # noqa: E501
        # verify the required parameter 'keys' is set
        if self.api_client.client_side_validation and ('keys' not in local_var_params or  # noqa: E501
                                                        local_var_params['keys'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `keys` when calling `api_v1_iot_timeseries_get`")  # noqa: E501
        # verify the required parameter 'start_ts' is set
        if self.api_client.client_side_validation and ('start_ts' not in local_var_params or  # noqa: E501
                                                        local_var_params['start_ts'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `start_ts` when calling `api_v1_iot_timeseries_get`")  # noqa: E501
        # verify the required parameter 'end_ts' is set
        if self.api_client.client_side_validation and ('end_ts' not in local_var_params or  # noqa: E501
                                                        local_var_params['end_ts'] is None):  # noqa: E501
            raise ApiValueError("Missing the required parameter `end_ts` when calling `api_v1_iot_timeseries_get`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'device_id' in local_var_params and local_var_params['device_id'] is not None:  # noqa: E501
            query_params.append(('DeviceId', local_var_params['device_id']))  # noqa: E501
        if 'keys' in local_var_params and local_var_params['keys'] is not None:  # noqa: E501
            query_params.append(('Keys', local_var_params['keys']))  # noqa: E501
            collection_formats['Keys'] = 'multi'  # noqa: E501
        if 'start_ts' in local_var_params and local_var_params['start_ts'] is not None:  # noqa: E501
            query_params.append(('StartTs', local_var_params['start_ts']))  # noqa: E501
        if 'end_ts' in local_var_params and local_var_params['end_ts'] is not None:  # noqa: E501
            query_params.append(('EndTs', local_var_params['end_ts']))  # noqa: E501
        if 'order_by' in local_var_params and local_var_params['order_by'] is not None:  # noqa: E501
            query_params.append(('OrderBy', local_var_params['order_by']))  # noqa: E501
        if 'interval' in local_var_params and local_var_params['interval'] is not None:  # noqa: E501
            query_params.append(('Interval', local_var_params['interval']))  # noqa: E501
        if 'agg' in local_var_params and local_var_params['agg'] is not None:  # noqa: E501
            query_params.append(('Agg', local_var_params['agg']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['text/plain'])  # noqa: E501

        # Authentication setting
        auth_settings = ['bearer']  # noqa: E501

        return self.api_client.call_api(
            '/api/v1/iot/timeseries', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='dict(str, list[object])',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def api_v3_iot_latest_timeseries_from_db_post(self, **kwargs):  # noqa: E501
        """根据设备编码和指标名获取最新实测数据,只从数据库中读取，不读缓存数据  # noqa: E501

        关键词：设备、设备指标、最新、实测数据、获取、查询  使用场景：批量查询多个设备指标最新的实测数据，根据TimeRange控制是否有最新数据的时间范围（分钟），若TimeRange=5则查询距离当前时刻5分钟内的最新实测数据，用于多个设备指标只展示最新实测数据的情景  与接口/api/v3/iot/latest-timeseries优先读取缓存中的数据不同，该接口始终从数据库中读取最新一条实测数据，这些数据的入库时间通常经过了对齐处理，  在接口/api/v1/historical-data/search-latest中会调用该接口获取最新一条实测数据，并返回相同时间的模拟数据  输入：设备编码、指标名称、离当前时刻最近的数据范围  输出：设备编码、指标的时间序列数据  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_v3_iot_latest_timeseries_from_db_post(async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param list[LatestTimeSeriesInputV3] latest_time_series_input_v3:
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: list[LatestTimeSeriesOutputV3]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.api_v3_iot_latest_timeseries_from_db_post_with_http_info(**kwargs)  # noqa: E501

    def api_v3_iot_latest_timeseries_from_db_post_with_http_info(self, **kwargs):  # noqa: E501
        """根据设备编码和指标名获取最新实测数据,只从数据库中读取，不读缓存数据  # noqa: E501

        关键词：设备、设备指标、最新、实测数据、获取、查询  使用场景：批量查询多个设备指标最新的实测数据，根据TimeRange控制是否有最新数据的时间范围（分钟），若TimeRange=5则查询距离当前时刻5分钟内的最新实测数据，用于多个设备指标只展示最新实测数据的情景  与接口/api/v3/iot/latest-timeseries优先读取缓存中的数据不同，该接口始终从数据库中读取最新一条实测数据，这些数据的入库时间通常经过了对齐处理，  在接口/api/v1/historical-data/search-latest中会调用该接口获取最新一条实测数据，并返回相同时间的模拟数据  输入：设备编码、指标名称、离当前时刻最近的数据范围  输出：设备编码、指标的时间序列数据  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_v3_iot_latest_timeseries_from_db_post_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param list[LatestTimeSeriesInputV3] latest_time_series_input_v3:
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(list[LatestTimeSeriesOutputV3], status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'latest_time_series_input_v3'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout'
            ]
        )

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method api_v3_iot_latest_timeseries_from_db_post" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'latest_time_series_input_v3' in local_var_params:
            body_params = local_var_params['latest_time_series_input_v3']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['text/plain'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['bearer']  # noqa: E501

        return self.api_client.call_api(
            '/api/v3/iot/latest-timeseries-from-db', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[LatestTimeSeriesOutputV3]',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def api_v3_iot_latest_timeseries_post(self, **kwargs):  # noqa: E501
        """根据设备编码和指标名获取最新实测数据  # noqa: E501

        关键词：设备、设备指标、最新、实测数据、获取、查询  使用场景：批量查询多个设备指标最新的实测数据，根据TimeRange控制是否有最新数据的时间范围（分钟），若TimeRange=5则查询距离当前时刻5分钟内的最新实测数据，用于多个设备指标只展示最新实测数据的情景  输入：设备编码、指标名称、离当前时刻最近的数据范围  输出：设备编码、指标的时间序列数据  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_v3_iot_latest_timeseries_post(async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param list[LatestTimeSeriesInputV3] latest_time_series_input_v3:
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: list[LatestTimeSeriesOutputV3]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.api_v3_iot_latest_timeseries_post_with_http_info(**kwargs)  # noqa: E501

    def api_v3_iot_latest_timeseries_post_with_http_info(self, **kwargs):  # noqa: E501
        """根据设备编码和指标名获取最新实测数据  # noqa: E501

        关键词：设备、设备指标、最新、实测数据、获取、查询  使用场景：批量查询多个设备指标最新的实测数据，根据TimeRange控制是否有最新数据的时间范围（分钟），若TimeRange=5则查询距离当前时刻5分钟内的最新实测数据，用于多个设备指标只展示最新实测数据的情景  输入：设备编码、指标名称、离当前时刻最近的数据范围  输出：设备编码、指标的时间序列数据  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_v3_iot_latest_timeseries_post_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param list[LatestTimeSeriesInputV3] latest_time_series_input_v3:
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(list[LatestTimeSeriesOutputV3], status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'latest_time_series_input_v3'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout'
            ]
        )

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method api_v3_iot_latest_timeseries_post" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'latest_time_series_input_v3' in local_var_params:
            body_params = local_var_params['latest_time_series_input_v3']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['text/plain'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['bearer']  # noqa: E501

        return self.api_client.call_api(
            '/api/v3/iot/latest-timeseries', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[LatestTimeSeriesOutputV3]',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def api_v3_iot_save_telemetry_data_batch_post(self, **kwargs):  # noqa: E501
        """以结构化的数据格式通过消息队列批量保存或更新实测数据  # noqa: E501

        关键词：时间戳、设备、设备指标、实测数据、消息队列、更新  使用场景：批量保存或更新多个设备指标实测数据，更新到缓存中并推送到消息队列做数据存储，保存的数据可通过查询接口/api/v3/iot/timeseries-batch查询做进一步数据处理或展示  输入：时间戳、设备编码、指标名称、数值  输出：无  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_v3_iot_save_telemetry_data_batch_post(async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param list[SaveTelemetryStructDataBatchInput] save_telemetry_struct_data_batch_input:
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.api_v3_iot_save_telemetry_data_batch_post_with_http_info(**kwargs)  # noqa: E501

    def api_v3_iot_save_telemetry_data_batch_post_with_http_info(self, **kwargs):  # noqa: E501
        """以结构化的数据格式通过消息队列批量保存或更新实测数据  # noqa: E501

        关键词：时间戳、设备、设备指标、实测数据、消息队列、更新  使用场景：批量保存或更新多个设备指标实测数据，更新到缓存中并推送到消息队列做数据存储，保存的数据可通过查询接口/api/v3/iot/timeseries-batch查询做进一步数据处理或展示  输入：时间戳、设备编码、指标名称、数值  输出：无  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_v3_iot_save_telemetry_data_batch_post_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param list[SaveTelemetryStructDataBatchInput] save_telemetry_struct_data_batch_input:
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'save_telemetry_struct_data_batch_input'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout'
            ]
        )

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method api_v3_iot_save_telemetry_data_batch_post" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'save_telemetry_struct_data_batch_input' in local_var_params:
            body_params = local_var_params['save_telemetry_struct_data_batch_input']
        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['bearer']  # noqa: E501

        return self.api_client.call_api(
            '/api/v3/iot/save-telemetry-data-batch', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)

    def api_v3_iot_timeseries_batch_post(self, **kwargs):  # noqa: E501
        """批量查询多个设备指标的时间序列数据  # noqa: E501

        关键词：设备、设备指标、设备指标时间序列数据、时间、排序、批量查询、抽样  使用场景：批量查询多个设备指标在某个时间段内的时间序列数据，可抽样查询，并按时间排序，默认按照时间从大到小排序；如:sample=minutes,interval=5,表示按照5分钟进行抽样，用于多个设备指标同时展示实测数据的情景  输入：设备、指标、时间区间、抽样类型、抽样频率  输出：多个设备、指标的时间序列数据  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_v3_iot_timeseries_batch_post(async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param list[TimeseriesBatchForV3Input] timeseries_batch_for_v3_input:
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: list[TimeseriesBatchForV3Output]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.api_v3_iot_timeseries_batch_post_with_http_info(**kwargs)  # noqa: E501

    def api_v3_iot_timeseries_batch_post_with_http_info(self, **kwargs):  # noqa: E501
        """批量查询多个设备指标的时间序列数据  # noqa: E501

        关键词：设备、设备指标、设备指标时间序列数据、时间、排序、批量查询、抽样  使用场景：批量查询多个设备指标在某个时间段内的时间序列数据，可抽样查询，并按时间排序，默认按照时间从大到小排序；如:sample=minutes,interval=5,表示按照5分钟进行抽样，用于多个设备指标同时展示实测数据的情景  输入：设备、指标、时间区间、抽样类型、抽样频率  输出：多个设备、指标的时间序列数据  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.api_v3_iot_timeseries_batch_post_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool: execute request asynchronously
        :param list[TimeseriesBatchForV3Input] timeseries_batch_for_v3_input:
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(list[TimeseriesBatchForV3Output], status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = [
            'timeseries_batch_for_v3_input'
        ]
        all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout'
            ]
        )

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method api_v3_iot_timeseries_batch_post" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'timeseries_batch_for_v3_input' in local_var_params:
            body_params = local_var_params['timeseries_batch_for_v3_input']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['text/plain'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['application/json'])  # noqa: E501

        # Authentication setting
        auth_settings = ['bearer']  # noqa: E501

        return self.api_client.call_api(
            '/api/v3/iot/timeseries-batch', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='list[TimeseriesBatchForV3Output]',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)
