# coding: utf-8

"""
    Cloudera Manager API

    <h1>Cloudera Manager API v57</h1>       <p>Introduced in Cloudera Manager 7.13.1</p>       <p><a href=\"http://www.cloudera.com/documentation.html\">Cloudera Product Documentation</a></p>  # noqa: E501

    OpenAPI spec version: 7.13.1
    
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""

from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from cm_client.api_client import ApiClient


class TimeSeriesResourceApi(object):
    """NOTE: This class is auto generated by the swagger code generator program.

    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

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

    def get_entity_type_attributes(self, **kwargs):  # noqa: E501
        """Retrieve all metric entity type attributes monitored by Cloudera Manager.  # noqa: E501

        Retrieve all metric entity type attributes monitored by Cloudera Manager. <p/> Available since API v11.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_entity_type_attributes(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: ApiTimeSeriesEntityAttributeList
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_entity_type_attributes_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.get_entity_type_attributes_with_http_info(**kwargs)  # noqa: E501
            return data

    def get_entity_type_attributes_with_http_info(self, **kwargs):  # noqa: E501
        """Retrieve all metric entity type attributes monitored by Cloudera Manager.  # noqa: E501

        Retrieve all metric entity type attributes monitored by Cloudera Manager. <p/> Available since API v11.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_entity_type_attributes_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: ApiTimeSeriesEntityAttributeList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = []  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

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

        return self.api_client.call_api(
            '/timeseries/entityTypeAttributes', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ApiTimeSeriesEntityAttributeList',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_entity_types(self, **kwargs):  # noqa: E501
        """Retrieve all metric entity types monitored by Cloudera Manager.  # noqa: E501

        Retrieve all metric entity types monitored by Cloudera Manager. It is guaranteed that parent types appear before their children. <p/> Available since API v11.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_entity_types(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: ApiTimeSeriesEntityTypeList
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_entity_types_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.get_entity_types_with_http_info(**kwargs)  # noqa: E501
            return data

    def get_entity_types_with_http_info(self, **kwargs):  # noqa: E501
        """Retrieve all metric entity types monitored by Cloudera Manager.  # noqa: E501

        Retrieve all metric entity types monitored by Cloudera Manager. It is guaranteed that parent types appear before their children. <p/> Available since API v11.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_entity_types_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: ApiTimeSeriesEntityTypeList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = []  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

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

        return self.api_client.call_api(
            '/timeseries/entityTypes', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ApiTimeSeriesEntityTypeList',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def get_metric_schema(self, **kwargs):  # noqa: E501
        """Retrieve schema for all metrics.  # noqa: E501

        Retrieve schema for all metrics <p/> The schema is fixed for a product version. The schema may change for an API versions <p/> Available since API v4.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_metric_schema(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: ApiMetricSchemaList
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.get_metric_schema_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.get_metric_schema_with_http_info(**kwargs)  # noqa: E501
            return data

    def get_metric_schema_with_http_info(self, **kwargs):  # noqa: E501
        """Retrieve schema for all metrics.  # noqa: E501

        Retrieve schema for all metrics <p/> The schema is fixed for a product version. The schema may change for an API versions <p/> Available since API v4.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.get_metric_schema_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :return: ApiMetricSchemaList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = []  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

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

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

        return self.api_client.call_api(
            '/timeseries/schema', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ApiMetricSchemaList',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def query_time_series(self, **kwargs):  # noqa: E501
        """Retrieve time-series data from the Cloudera Manager (CM) time-series data store using a tsquery.  # noqa: E501

        Retrieve time-series data from the Cloudera Manager (CM) time-series data store using a tsquery.  Please see the <a href=\"https://docs.cloudera.com/r/cm_tsquery\"> tsquery language documentation</a>. <p/> Available since API v6.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.query_time_series(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str content_type: to return the response in. The content types \"application/json\" and \"text/csv\" are supported. This defaults to \"application/json\". If \"text/csv\" is specified then we return one row per time series data point, and we don't return any of the metadata.
        :param str desired_rollup: Aggregate rollup level desired for the response data. Valid values are RAW, TEN_MINUTELY, HOURLY, SIX_HOURLY, DAILY, and WEEKLY. Note that if the mustUseDesiredRollup parameter is not set, then the monitoring server can decide to return a different rollup level.
        :param str _from: Start of the period to query in ISO 8601 format (defaults to 5 minutes before the end of the period).
        :param bool must_use_desired_rollup: If set then the tsquery will return data with the desired aggregate rollup level.
        :param str query: Tsquery to run against the CM time-series data store.
        :param str to: End of the period to query in ISO 8601 format (defaults to current time).
        :return: ApiTimeSeriesResponseList
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.query_time_series_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.query_time_series_with_http_info(**kwargs)  # noqa: E501
            return data

    def query_time_series_with_http_info(self, **kwargs):  # noqa: E501
        """Retrieve time-series data from the Cloudera Manager (CM) time-series data store using a tsquery.  # noqa: E501

        Retrieve time-series data from the Cloudera Manager (CM) time-series data store using a tsquery.  Please see the <a href=\"https://docs.cloudera.com/r/cm_tsquery\"> tsquery language documentation</a>. <p/> Available since API v6.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.query_time_series_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str content_type: to return the response in. The content types \"application/json\" and \"text/csv\" are supported. This defaults to \"application/json\". If \"text/csv\" is specified then we return one row per time series data point, and we don't return any of the metadata.
        :param str desired_rollup: Aggregate rollup level desired for the response data. Valid values are RAW, TEN_MINUTELY, HOURLY, SIX_HOURLY, DAILY, and WEEKLY. Note that if the mustUseDesiredRollup parameter is not set, then the monitoring server can decide to return a different rollup level.
        :param str _from: Start of the period to query in ISO 8601 format (defaults to 5 minutes before the end of the period).
        :param bool must_use_desired_rollup: If set then the tsquery will return data with the desired aggregate rollup level.
        :param str query: Tsquery to run against the CM time-series data store.
        :param str to: End of the period to query in ISO 8601 format (defaults to current time).
        :return: ApiTimeSeriesResponseList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['content_type', 'desired_rollup', '_from', 'must_use_desired_rollup', 'query', 'to']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'content_type' in params:
            query_params.append(('contentType', params['content_type']))  # noqa: E501
        if 'desired_rollup' in params:
            query_params.append(('desiredRollup', params['desired_rollup']))  # noqa: E501
        if '_from' in params:
            query_params.append(('from', params['_from']))  # noqa: E501
        if 'must_use_desired_rollup' in params:
            query_params.append(('mustUseDesiredRollup', params['must_use_desired_rollup']))  # noqa: E501
        if 'query' in params:
            query_params.append(('query', params['query']))  # noqa: E501
        if 'to' in params:
            query_params.append(('to', params['to']))  # noqa: E501

        header_params = {}

        form_params = []
        local_var_files = {}

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

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

        return self.api_client.call_api(
            '/timeseries', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ApiTimeSeriesResponseList',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)

    def query_time_series_0(self, **kwargs):  # noqa: E501
        """Retrieve time-series data from the Cloudera Manager (CM) time-series data store accepting HTTP POST request.  # noqa: E501

        Retrieve time-series data from the Cloudera Manager (CM) time-series data store accepting HTTP POST request. This method differs from queryTimeSeries() in v6 that this could accept query strings that are longer than HTTP GET request limit.  Available since API v11.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.query_time_series_0(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param ApiTimeSeriesRequest body: Request object containing information used when
retrieving timeseries data.
        :return: ApiTimeSeriesResponseList
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.query_time_series_0_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.query_time_series_0_with_http_info(**kwargs)  # noqa: E501
            return data

    def query_time_series_0_with_http_info(self, **kwargs):  # noqa: E501
        """Retrieve time-series data from the Cloudera Manager (CM) time-series data store accepting HTTP POST request.  # noqa: E501

        Retrieve time-series data from the Cloudera Manager (CM) time-series data store accepting HTTP POST request. This method differs from queryTimeSeries() in v6 that this could accept query strings that are longer than HTTP GET request limit.  Available since API v11.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.query_time_series_0_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param ApiTimeSeriesRequest body: Request object containing information used when
retrieving timeseries data.
        :return: ApiTimeSeriesResponseList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['body']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

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

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'body' in params:
            body_params = params['body']
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # 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 = ['basic']  # noqa: E501

        return self.api_client.call_api(
            '/timeseries', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ApiTimeSeriesResponseList',  # noqa: E501
            auth_settings=auth_settings,
            async_req=params.get('async_req'),
            _return_http_data_only=params.get('_return_http_data_only'),
            _preload_content=params.get('_preload_content', True),
            _request_timeout=params.get('_request_timeout'),
            collection_formats=collection_formats)
