# coding: utf-8

"""
    Layered Insight Assessment, Compliance, Witness & Control

    LI Assessment & Compliance performs static vulnerability analysis, license and package compliance. LI Witness provides deep insight and analytics into containerized applications. Control provides dynamic runtime security and analytics for containerized applications. You can find out more about the Layered Insight Suite at [http://layeredinsight.com](http://layeredinsight.com).

    OpenAPI spec version: 0.10
    Contact: help@layeredinsight.com
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""


from __future__ import absolute_import

import sys
import os
import re

# python 2 and python 3 compatibility library
from six import iteritems

from ..configuration import Configuration
from ..api_client import ApiClient


class LogApi(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):
        config = Configuration()
        if api_client:
            self.api_client = api_client
        else:
            if not config.api_client:
                config.api_client = ApiClient()
            self.api_client = config.api_client

    def array_of_dropped_logs(self, starting_time, ending_time, seconds_per_interval, **kwargs):
        """
        Get histograph of policy hits
        Get array with the amount of policy hits within a timeframe
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.array_of_dropped_logs(starting_time, ending_time, seconds_per_interval, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str starting_time: Time from when histograph should start (required)
        :param str ending_time: Time from when histograph should end (required)
        :param str seconds_per_interval: Histograph resolution (required)
        :return: LevelSyscallMetrics
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.array_of_dropped_logs_with_http_info(starting_time, ending_time, seconds_per_interval, **kwargs)
        else:
            (data) = self.array_of_dropped_logs_with_http_info(starting_time, ending_time, seconds_per_interval, **kwargs)
            return data

    def array_of_dropped_logs_with_http_info(self, starting_time, ending_time, seconds_per_interval, **kwargs):
        """
        Get histograph of policy hits
        Get array with the amount of policy hits within a timeframe
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.array_of_dropped_logs_with_http_info(starting_time, ending_time, seconds_per_interval, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str starting_time: Time from when histograph should start (required)
        :param str ending_time: Time from when histograph should end (required)
        :param str seconds_per_interval: Histograph resolution (required)
        :return: LevelSyscallMetrics
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['starting_time', 'ending_time', 'seconds_per_interval']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method array_of_dropped_logs" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'starting_time' is set
        if ('starting_time' not in params) or (params['starting_time'] is None):
            raise ValueError("Missing the required parameter `starting_time` when calling `array_of_dropped_logs`")
        # verify the required parameter 'ending_time' is set
        if ('ending_time' not in params) or (params['ending_time'] is None):
            raise ValueError("Missing the required parameter `ending_time` when calling `array_of_dropped_logs`")
        # verify the required parameter 'seconds_per_interval' is set
        if ('seconds_per_interval' not in params) or (params['seconds_per_interval'] is None):
            raise ValueError("Missing the required parameter `seconds_per_interval` when calling `array_of_dropped_logs`")


        collection_formats = {}

        path_params = {}

        query_params = []
        if 'starting_time' in params:
            query_params.append(('StartingTime', params['starting_time']))
        if 'ending_time' in params:
            query_params.append(('EndingTime', params['ending_time']))
        if 'seconds_per_interval' in params:
            query_params.append(('SecondsPerInterval', params['seconds_per_interval']))

        header_params = {}

        form_params = []
        local_var_files = {}

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

        # Authentication setting
        auth_settings = ['ApiKey']

        return self.api_client.call_api('/LogsDropped', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='LevelSyscallMetrics',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _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 show_logs(self, **kwargs):
        """
        Get all logs
        Get all logs for a user
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.show_logs(callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :return: ContainerLogs
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.show_logs_with_http_info(**kwargs)
        else:
            (data) = self.show_logs_with_http_info(**kwargs)
            return data

    def show_logs_with_http_info(self, **kwargs):
        """
        Get all logs
        Get all logs for a user
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.show_logs_with_http_info(callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :return: ContainerLogs
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = []
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method show_logs" % 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'])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api('/Logs', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='ContainerLogs',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _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 show_logs_for_container(self, container_id, **kwargs):
        """
        Get container logs
        Get all logs belonging to a container
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.show_logs_for_container(container_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str container_id: hexadecimal ID of container to get logs from (required)
        :return: ContainerLogs
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        if kwargs.get('callback'):
            return self.show_logs_for_container_with_http_info(container_id, **kwargs)
        else:
            (data) = self.show_logs_for_container_with_http_info(container_id, **kwargs)
            return data

    def show_logs_for_container_with_http_info(self, container_id, **kwargs):
        """
        Get container logs
        Get all logs belonging to a container
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please define a `callback` function
        to be invoked when receiving the response.
        >>> def callback_function(response):
        >>>     pprint(response)
        >>>
        >>> thread = api.show_logs_for_container_with_http_info(container_id, callback=callback_function)

        :param callback function: The callback function
            for asynchronous request. (optional)
        :param str container_id: hexadecimal ID of container to get logs from (required)
        :return: ContainerLogs
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ['container_id']
        all_params.append('callback')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        params = locals()
        for key, val in iteritems(params['kwargs']):
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method show_logs_for_container" % key
                )
            params[key] = val
        del params['kwargs']
        # verify the required parameter 'container_id' is set
        if ('container_id' not in params) or (params['container_id'] is None):
            raise ValueError("Missing the required parameter `container_id` when calling `show_logs_for_container`")


        collection_formats = {}

        path_params = {}
        if 'container_id' in params:
            path_params['ContainerId'] = params['container_id']

        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'])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api('/Logs/{ContainerId}', 'GET',
                                        path_params,
                                        query_params,
                                        header_params,
                                        body=body_params,
                                        post_params=form_params,
                                        files=local_var_files,
                                        response_type='ContainerLogs',
                                        auth_settings=auth_settings,
                                        callback=params.get('callback'),
                                        _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)
