# coding: utf-8

"""
    Vidispine API

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

    The version of the OpenAPI document: 5.x
    Contact: info@vidispine.com
    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 vidispine.models import *
from vidispine.api_client import ApiClient
from vidispine.exceptions import (
    ApiTypeError,
    ApiValueError
)


class AuditLogApi(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 get_full_logs(self, **kwargs):  # noqa: E501
        """Retrieve the entire audit log  # noqa: E501

        Is very similar to the method above, but instead of delivering the entire document at once it is streamed. Therefore there is no restriction on the maximum number of rows that can be retrieved.  # 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_full_logs(async_req=True)
        >>> result = thread.get()

        :key bool async_req: execute request asynchronously
        :key str method: Only return rows with the specified method, e. g.  `GET`.  Default is all rows.
        :key str endtime: ISO 8601 time, for upper limit of rows to return.
        :key int first: Number of first row to return.
        :key bool wildcard: - `true` (default) - Treat end of path to have a `*` wildcard.  - `false` - Do truncation at end of path.
        :key int rows: Number of rows to return.
        :key str starttime: ISO 8601 time, for lower limit of rows to return.
        :key str username: Only return rows that the specified user invoked.  Default is all rows.
        :key str sort: - `asc` - Order by timestamp ascending.  - `desc` (default) - Order by timestamp descending.
        :key str path: Matches path in log lines.
        :key _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :key _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: AuditLogType.
                 If the method is called asynchronously, returns the request thread.
        :rtype: AuditLogType or multiprocessing.pool.AsyncResult
        """
        kwargs['_return_http_data_only'] = True
        return self.get_full_logs_with_http_info(**kwargs)  # noqa: E501

    def get_full_logs_with_http_info(self, **kwargs):  # noqa: E501
        """Retrieve the entire audit log  # noqa: E501

        Is very similar to the method above, but instead of delivering the entire document at once it is streamed. Therefore there is no restriction on the maximum number of rows that can be retrieved.  # 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_full_logs_with_http_info(async_req=True)
        >>> result = thread.get()

        :key bool async_req: execute request asynchronously
        :key str method: Only return rows with the specified method, e. g.  `GET`.  Default is all rows.
        :key str endtime: ISO 8601 time, for upper limit of rows to return.
        :key int first: Number of first row to return.
        :key bool wildcard: - `true` (default) - Treat end of path to have a `*` wildcard.  - `false` - Do truncation at end of path.
        :key int rows: Number of rows to return.
        :key str starttime: ISO 8601 time, for lower limit of rows to return.
        :key str username: Only return rows that the specified user invoked.  Default is all rows.
        :key str sort: - `asc` - Order by timestamp ascending.  - `desc` (default) - Order by timestamp descending.
        :key str path: Matches path in log lines.
        :key _return_http_data_only: response data without head status code
                                       and headers
        :key _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :key _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(AuditLogType, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['method', 'endtime', 'first', 'wildcard', 'rows', 'starttime', 'username', 'sort', 'path']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_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 get_full_logs" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'method' in local_var_params:
            query_params.append(('method', local_var_params['method']))  # noqa: E501
        if 'endtime' in local_var_params:
            query_params.append(('endtime', local_var_params['endtime']))  # noqa: E501
        if 'first' in local_var_params:
            query_params.append(('first', local_var_params['first']))  # noqa: E501
        if 'wildcard' in local_var_params:
            query_params.append(('wildcard', local_var_params['wildcard']))  # noqa: E501
        if 'rows' in local_var_params:
            query_params.append(('rows', local_var_params['rows']))  # noqa: E501
        if 'starttime' in local_var_params:
            query_params.append(('starttime', local_var_params['starttime']))  # noqa: E501
        if 'username' in local_var_params:
            query_params.append(('username', local_var_params['username']))  # noqa: E501
        if 'sort' in local_var_params:
            query_params.append(('sort', local_var_params['sort']))  # noqa: E501
        if 'path' in local_var_params:
            query_params.append(('path', local_var_params['path']))  # 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/xml'])  # noqa: E501

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

        return self.api_client.call_api(
            '/log/export', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='AuditLogType',  # 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 get_logs(self, **kwargs):  # noqa: E501
        """List all audit log entries  # noqa: E501

        Retrieves log entries according to the specified filtering criteria. The path can be seen as having an implicit wildcard in the end, unless it is disabled with the `wildcard` parameter. For example `/item/VX-123` will match `/item/VX-123/shape` but not `/item/VX-124`.  # 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_logs(async_req=True)
        >>> result = thread.get()

        :key bool async_req: execute request asynchronously
        :key str method: Only return rows with the specified method, e. g.  `GET`.  Default is all rows.
        :key str endtime: ISO 8601 time, for upper limit of rows to return.
        :key int first: Number of first row to return.
        :key bool wildcard: - `true` (default) - Treat end of path to have a `*` wildcard.  - `false` - Do truncation at end of path.
        :key int rows: Number of rows to return.  Cannot be greater than 1000.
        :key str starttime: ISO 8601 time, for lower limit of rows to return.
        :key bool perform_count: - `true` - Return a total number of rows matching criteria (except first and count).  - `false` (default) - Do not return a total number of rows matching criteria.
        :key str username: Only return rows that the specified user invoked.  Default is all rows.
        :key str sort: - `asc` - Order by timestamp ascending.  - `desc` (default) - Order by timestamp descending.
        :key str path: Matches path in log lines.
        :key _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :key _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: AuditLogType.
                 If the method is called asynchronously, returns the request thread.
        :rtype: AuditLogType or multiprocessing.pool.AsyncResult
        """
        kwargs['_return_http_data_only'] = True
        return self.get_logs_with_http_info(**kwargs)  # noqa: E501

    def get_logs_with_http_info(self, **kwargs):  # noqa: E501
        """List all audit log entries  # noqa: E501

        Retrieves log entries according to the specified filtering criteria. The path can be seen as having an implicit wildcard in the end, unless it is disabled with the `wildcard` parameter. For example `/item/VX-123` will match `/item/VX-123/shape` but not `/item/VX-124`.  # 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_logs_with_http_info(async_req=True)
        >>> result = thread.get()

        :key bool async_req: execute request asynchronously
        :key str method: Only return rows with the specified method, e. g.  `GET`.  Default is all rows.
        :key str endtime: ISO 8601 time, for upper limit of rows to return.
        :key int first: Number of first row to return.
        :key bool wildcard: - `true` (default) - Treat end of path to have a `*` wildcard.  - `false` - Do truncation at end of path.
        :key int rows: Number of rows to return.  Cannot be greater than 1000.
        :key str starttime: ISO 8601 time, for lower limit of rows to return.
        :key bool perform_count: - `true` - Return a total number of rows matching criteria (except first and count).  - `false` (default) - Do not return a total number of rows matching criteria.
        :key str username: Only return rows that the specified user invoked.  Default is all rows.
        :key str sort: - `asc` - Order by timestamp ascending.  - `desc` (default) - Order by timestamp descending.
        :key str path: Matches path in log lines.
        :key _return_http_data_only: response data without head status code
                                       and headers
        :key _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :key _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(AuditLogType, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['method', 'endtime', 'first', 'wildcard', 'rows', 'starttime', 'perform_count', 'username', 'sort', 'path']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_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 get_logs" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']

        collection_formats = {}

        path_params = {}

        query_params = []
        if 'method' in local_var_params:
            query_params.append(('method', local_var_params['method']))  # noqa: E501
        if 'endtime' in local_var_params:
            query_params.append(('endtime', local_var_params['endtime']))  # noqa: E501
        if 'first' in local_var_params:
            query_params.append(('first', local_var_params['first']))  # noqa: E501
        if 'wildcard' in local_var_params:
            query_params.append(('wildcard', local_var_params['wildcard']))  # noqa: E501
        if 'rows' in local_var_params:
            query_params.append(('rows', local_var_params['rows']))  # noqa: E501
        if 'starttime' in local_var_params:
            query_params.append(('starttime', local_var_params['starttime']))  # noqa: E501
        if 'perform_count' in local_var_params:
            query_params.append(('performCount', local_var_params['perform_count']))  # noqa: E501
        if 'username' in local_var_params:
            query_params.append(('username', local_var_params['username']))  # noqa: E501
        if 'sort' in local_var_params:
            query_params.append(('sort', local_var_params['sort']))  # noqa: E501
        if 'path' in local_var_params:
            query_params.append(('path', local_var_params['path']))  # 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', 'application/xml'])  # noqa: E501

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

        return self.api_client.call_api(
            '/log', 'GET',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='AuditLogType',  # 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)
