# coding: utf-8

"""
    AssistedInstall

    Assisted installation  # noqa: E501

    OpenAPI spec version: 1.0.0
    
    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 assisted_service_client.api_client import ApiClient


class EventsApi(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 v2_list_events(self, **kwargs):  # noqa: E501
        """v2_list_events  # noqa: E501

        Lists events for a cluster.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.v2_list_events(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str cluster_id: The cluster to return events for.
        :param str host_id: A host in the specified cluster to return events for (DEPRECATED. Use `host_ids` instead).
        :param list[str] host_ids: Hosts in the specified cluster to return events for.
        :param str infra_env_id: The infra-env to return events for.
        :param int limit: The maximum number of records to retrieve.
        :param int offset: Number of records to skip before starting to return the records.
        :param str order: Order by event_time of events retrieved.
        :param list[str] severities: Retrieved events severities.
        :param str message: Retrieved events message pattern.
        :param bool deleted_hosts: Deleted hosts flag.
        :param bool cluster_level: Cluster level events flag.
        :param list[str] categories: A comma-separated list of event categories.
        :return: EventList
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.v2_list_events_with_http_info(**kwargs)  # noqa: E501
        else:
            (data) = self.v2_list_events_with_http_info(**kwargs)  # noqa: E501
            return data

    def v2_list_events_with_http_info(self, **kwargs):  # noqa: E501
        """v2_list_events  # noqa: E501

        Lists events for a cluster.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.v2_list_events_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str cluster_id: The cluster to return events for.
        :param str host_id: A host in the specified cluster to return events for (DEPRECATED. Use `host_ids` instead).
        :param list[str] host_ids: Hosts in the specified cluster to return events for.
        :param str infra_env_id: The infra-env to return events for.
        :param int limit: The maximum number of records to retrieve.
        :param int offset: Number of records to skip before starting to return the records.
        :param str order: Order by event_time of events retrieved.
        :param list[str] severities: Retrieved events severities.
        :param str message: Retrieved events message pattern.
        :param bool deleted_hosts: Deleted hosts flag.
        :param bool cluster_level: Cluster level events flag.
        :param list[str] categories: A comma-separated list of event categories.
        :return: EventList
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['cluster_id', 'host_id', 'host_ids', 'infra_env_id', 'limit', 'offset', 'order', 'severities', 'message', 'deleted_hosts', 'cluster_level', 'categories']  # 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 v2_list_events" % key
                )
            params[key] = val
        del params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'cluster_id' in params:
            query_params.append(('cluster_id', params['cluster_id']))  # noqa: E501
        if 'host_id' in params:
            query_params.append(('host_id', params['host_id']))  # noqa: E501
        if 'host_ids' in params:
            query_params.append(('host_ids', params['host_ids']))  # noqa: E501
            collection_formats['host_ids'] = 'csv'  # noqa: E501
        if 'infra_env_id' in params:
            query_params.append(('infra_env_id', params['infra_env_id']))  # noqa: E501
        if 'limit' in params:
            query_params.append(('limit', params['limit']))  # noqa: E501
        if 'offset' in params:
            query_params.append(('offset', params['offset']))  # noqa: E501
        if 'order' in params:
            query_params.append(('order', params['order']))  # noqa: E501
        if 'severities' in params:
            query_params.append(('severities', params['severities']))  # noqa: E501
            collection_formats['severities'] = 'csv'  # noqa: E501
        if 'message' in params:
            query_params.append(('message', params['message']))  # noqa: E501
        if 'deleted_hosts' in params:
            query_params.append(('deleted_hosts', params['deleted_hosts']))  # noqa: E501
        if 'cluster_level' in params:
            query_params.append(('cluster_level', params['cluster_level']))  # noqa: E501
        if 'categories' in params:
            query_params.append(('categories', params['categories']))  # noqa: E501
            collection_formats['categories'] = 'csv'  # 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

        # 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 = ['urlAuth', 'userAuth']  # noqa: E501

        return self.api_client.call_api(
            '/v2/events', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='EventList',  # 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 v2_trigger_event(self, trigger_event_params, **kwargs):  # noqa: E501
        """v2_trigger_event  # noqa: E501

        Add new assisted installer event.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.v2_trigger_event(trigger_event_params, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param Event trigger_event_params: The event to be created. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('async_req'):
            return self.v2_trigger_event_with_http_info(trigger_event_params, **kwargs)  # noqa: E501
        else:
            (data) = self.v2_trigger_event_with_http_info(trigger_event_params, **kwargs)  # noqa: E501
            return data

    def v2_trigger_event_with_http_info(self, trigger_event_params, **kwargs):  # noqa: E501
        """v2_trigger_event  # noqa: E501

        Add new assisted installer event.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.v2_trigger_event_with_http_info(trigger_event_params, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param Event trigger_event_params: The event to be created. (required)
        :return: None
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['trigger_event_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 v2_trigger_event" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'trigger_event_params' is set
        if ('trigger_event_params' not in params or
                params['trigger_event_params'] is None):
            raise ValueError("Missing the required parameter `trigger_event_params` when calling `v2_trigger_event`")  # noqa: E501

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if 'trigger_event_params' in params:
            body_params = params['trigger_event_params']
        # 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 = ['agentAuth']  # noqa: E501

        return self.api_client.call_api(
            '/v2/events', '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=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)
