# coding: utf-8

"""
    Platform API

    _OpenAPI specification for the **Platform API** of **Helix**, the nomination platform of ElecLink_  ---  Additional documentation available in the API's [GitHub repository](https://github.com/eleclink-helix/platform-api) 

    The version of the OpenAPI document: 1.1.0
    Contact: team.eleclink@eleclink.co.uk
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501

import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Any, Dict, List, Optional, Tuple, Union
from typing_extensions import Annotated

from datetime import datetime
from pydantic import Field, StrictStr
from typing import List, Optional
from typing_extensions import Annotated
from helix_platform_api_public_client.models.audit_log_batch import AuditLogBatch
from helix_platform_api_public_client.models.audit_log_domain import AuditLogDomain
from helix_platform_api_public_client.models.audit_log_payload import AuditLogPayload
from helix_platform_api_public_client.models.audit_log_sort_by import AuditLogSortBy
from helix_platform_api_public_client.models.audit_log_status import AuditLogStatus

from helix_platform_api_public_client.api_client import ApiClient, RequestSerialized
from helix_platform_api_public_client.api_response import ApiResponse
from helix_platform_api_public_client.rest import RESTResponseType


class AuditLogApi:
    """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) -> None:
        if api_client is None:
            api_client = ApiClient.get_default()
        self.api_client = api_client


    @validate_call
    def get_audit_log_payload(
        self,
        id: Annotated[StrictStr, Field(description="Internal unique ID of an entity")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> AuditLogPayload:
        """get_audit_log_payload

        Fetch payload for an existing Audit Log entry by its identifier  ---  __Requires Permission:__ (at least one)   * `VIEW_OWN_AUDIT_LOGS`   * `VIEW_ANY_AUDIT_LOGS`

        :param id: Internal unique ID of an entity (required)
        :type id: str
        :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.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_audit_log_payload_serialize(
            id=id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "AuditLogPayload",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def get_audit_log_payload_with_http_info(
        self,
        id: Annotated[StrictStr, Field(description="Internal unique ID of an entity")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[AuditLogPayload]:
        """get_audit_log_payload

        Fetch payload for an existing Audit Log entry by its identifier  ---  __Requires Permission:__ (at least one)   * `VIEW_OWN_AUDIT_LOGS`   * `VIEW_ANY_AUDIT_LOGS`

        :param id: Internal unique ID of an entity (required)
        :type id: str
        :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.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_audit_log_payload_serialize(
            id=id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "AuditLogPayload",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def get_audit_log_payload_without_preload_content(
        self,
        id: Annotated[StrictStr, Field(description="Internal unique ID of an entity")],
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """get_audit_log_payload

        Fetch payload for an existing Audit Log entry by its identifier  ---  __Requires Permission:__ (at least one)   * `VIEW_OWN_AUDIT_LOGS`   * `VIEW_ANY_AUDIT_LOGS`

        :param id: Internal unique ID of an entity (required)
        :type id: str
        :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.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_audit_log_payload_serialize(
            id=id,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "AuditLogPayload",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '404': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _get_audit_log_payload_serialize(
        self,
        id,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        if id is not None:
            _path_params['id'] = id
        # process the query parameters
        # process the header parameters
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'ApiKey'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/v1/audit-logs/{id}/payload',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )




    @validate_call
    def get_audit_logs(
        self,
        limit: Annotated[int, Field(le=100, strict=True, ge=1, description="Number of records to return on a page")],
        sort_by: AuditLogSortBy,
        offset: Annotated[Optional[Annotated[int, Field(strict=True, ge=0)]], Field(description="Offset in the list of records to return")] = None,
        id_offset: Annotated[Optional[StrictStr], Field(description="Offset by ID in the list of records to return")] = None,
        domains: Optional[List[AuditLogDomain]] = None,
        x_organisation_id: Annotated[Optional[StrictStr], Field(description="Internal ID of an Organisation (optional)")] = None,
        creation_period_start: Optional[datetime] = None,
        creation_period_end: Optional[datetime] = None,
        query: Optional[StrictStr] = None,
        status: Optional[List[AuditLogStatus]] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> AuditLogBatch:
        """get_audit_logs

        Fetch a list of Audit Logs optionally filtered for an Organisation  ---  __Requires Permission:__ (at least one)   * `VIEW_OWN_AUDIT_LOGS`   * `VIEW_ANY_AUDIT_LOGS`

        :param limit: Number of records to return on a page (required)
        :type limit: int
        :param sort_by: (required)
        :type sort_by: AuditLogSortBy
        :param offset: Offset in the list of records to return
        :type offset: int
        :param id_offset: Offset by ID in the list of records to return
        :type id_offset: str
        :param domains:
        :type domains: List[AuditLogDomain]
        :param x_organisation_id: Internal ID of an Organisation (optional)
        :type x_organisation_id: str
        :param creation_period_start:
        :type creation_period_start: datetime
        :param creation_period_end:
        :type creation_period_end: datetime
        :param query:
        :type query: str
        :param status:
        :type status: List[AuditLogStatus]
        :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.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_audit_logs_serialize(
            limit=limit,
            sort_by=sort_by,
            offset=offset,
            id_offset=id_offset,
            domains=domains,
            x_organisation_id=x_organisation_id,
            creation_period_start=creation_period_start,
            creation_period_end=creation_period_end,
            query=query,
            status=status,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "AuditLogBatch",
            '400': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '422': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        ).data


    @validate_call
    def get_audit_logs_with_http_info(
        self,
        limit: Annotated[int, Field(le=100, strict=True, ge=1, description="Number of records to return on a page")],
        sort_by: AuditLogSortBy,
        offset: Annotated[Optional[Annotated[int, Field(strict=True, ge=0)]], Field(description="Offset in the list of records to return")] = None,
        id_offset: Annotated[Optional[StrictStr], Field(description="Offset by ID in the list of records to return")] = None,
        domains: Optional[List[AuditLogDomain]] = None,
        x_organisation_id: Annotated[Optional[StrictStr], Field(description="Internal ID of an Organisation (optional)")] = None,
        creation_period_start: Optional[datetime] = None,
        creation_period_end: Optional[datetime] = None,
        query: Optional[StrictStr] = None,
        status: Optional[List[AuditLogStatus]] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> ApiResponse[AuditLogBatch]:
        """get_audit_logs

        Fetch a list of Audit Logs optionally filtered for an Organisation  ---  __Requires Permission:__ (at least one)   * `VIEW_OWN_AUDIT_LOGS`   * `VIEW_ANY_AUDIT_LOGS`

        :param limit: Number of records to return on a page (required)
        :type limit: int
        :param sort_by: (required)
        :type sort_by: AuditLogSortBy
        :param offset: Offset in the list of records to return
        :type offset: int
        :param id_offset: Offset by ID in the list of records to return
        :type id_offset: str
        :param domains:
        :type domains: List[AuditLogDomain]
        :param x_organisation_id: Internal ID of an Organisation (optional)
        :type x_organisation_id: str
        :param creation_period_start:
        :type creation_period_start: datetime
        :param creation_period_end:
        :type creation_period_end: datetime
        :param query:
        :type query: str
        :param status:
        :type status: List[AuditLogStatus]
        :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.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_audit_logs_serialize(
            limit=limit,
            sort_by=sort_by,
            offset=offset,
            id_offset=id_offset,
            domains=domains,
            x_organisation_id=x_organisation_id,
            creation_period_start=creation_period_start,
            creation_period_end=creation_period_end,
            query=query,
            status=status,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "AuditLogBatch",
            '400': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '422': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        response_data.read()
        return self.api_client.response_deserialize(
            response_data=response_data,
            response_types_map=_response_types_map,
        )


    @validate_call
    def get_audit_logs_without_preload_content(
        self,
        limit: Annotated[int, Field(le=100, strict=True, ge=1, description="Number of records to return on a page")],
        sort_by: AuditLogSortBy,
        offset: Annotated[Optional[Annotated[int, Field(strict=True, ge=0)]], Field(description="Offset in the list of records to return")] = None,
        id_offset: Annotated[Optional[StrictStr], Field(description="Offset by ID in the list of records to return")] = None,
        domains: Optional[List[AuditLogDomain]] = None,
        x_organisation_id: Annotated[Optional[StrictStr], Field(description="Internal ID of an Organisation (optional)")] = None,
        creation_period_start: Optional[datetime] = None,
        creation_period_end: Optional[datetime] = None,
        query: Optional[StrictStr] = None,
        status: Optional[List[AuditLogStatus]] = None,
        _request_timeout: Union[
            None,
            Annotated[StrictFloat, Field(gt=0)],
            Tuple[
                Annotated[StrictFloat, Field(gt=0)],
                Annotated[StrictFloat, Field(gt=0)]
            ]
        ] = None,
        _request_auth: Optional[Dict[StrictStr, Any]] = None,
        _content_type: Optional[StrictStr] = None,
        _headers: Optional[Dict[StrictStr, Any]] = None,
        _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
    ) -> RESTResponseType:
        """get_audit_logs

        Fetch a list of Audit Logs optionally filtered for an Organisation  ---  __Requires Permission:__ (at least one)   * `VIEW_OWN_AUDIT_LOGS`   * `VIEW_ANY_AUDIT_LOGS`

        :param limit: Number of records to return on a page (required)
        :type limit: int
        :param sort_by: (required)
        :type sort_by: AuditLogSortBy
        :param offset: Offset in the list of records to return
        :type offset: int
        :param id_offset: Offset by ID in the list of records to return
        :type id_offset: str
        :param domains:
        :type domains: List[AuditLogDomain]
        :param x_organisation_id: Internal ID of an Organisation (optional)
        :type x_organisation_id: str
        :param creation_period_start:
        :type creation_period_start: datetime
        :param creation_period_end:
        :type creation_period_end: datetime
        :param query:
        :type query: str
        :param status:
        :type status: List[AuditLogStatus]
        :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.
        :type _request_timeout: int, tuple(int, int), optional
        :param _request_auth: set to override the auth_settings for an a single
                              request; this effectively ignores the
                              authentication in the spec for a single request.
        :type _request_auth: dict, optional
        :param _content_type: force content-type for the request.
        :type _content_type: str, Optional
        :param _headers: set to override the headers for a single
                         request; this effectively ignores the headers
                         in the spec for a single request.
        :type _headers: dict, optional
        :param _host_index: set to override the host_index for a single
                            request; this effectively ignores the host_index
                            in the spec for a single request.
        :type _host_index: int, optional
        :return: Returns the result object.
        """ # noqa: E501

        _param = self._get_audit_logs_serialize(
            limit=limit,
            sort_by=sort_by,
            offset=offset,
            id_offset=id_offset,
            domains=domains,
            x_organisation_id=x_organisation_id,
            creation_period_start=creation_period_start,
            creation_period_end=creation_period_end,
            query=query,
            status=status,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index
        )

        _response_types_map: Dict[str, Optional[str]] = {
            '200': "AuditLogBatch",
            '400': "ErrorResponse",
            '401': "ErrorResponse",
            '403': "ErrorResponse",
            '422': "ErrorResponse",
        }
        response_data = self.api_client.call_api(
            *_param,
            _request_timeout=_request_timeout
        )
        return response_data.response


    def _get_audit_logs_serialize(
        self,
        limit,
        sort_by,
        offset,
        id_offset,
        domains,
        x_organisation_id,
        creation_period_start,
        creation_period_end,
        query,
        status,
        _request_auth,
        _content_type,
        _headers,
        _host_index,
    ) -> RequestSerialized:

        _host = None

        _collection_formats: Dict[str, str] = {
            'domains': 'multi',
            'status': 'multi',
        }

        _path_params: Dict[str, str] = {}
        _query_params: List[Tuple[str, str]] = []
        _header_params: Dict[str, Optional[str]] = _headers or {}
        _form_params: List[Tuple[str, str]] = []
        _files: Dict[
            str, Union[str, bytes, List[str], List[bytes], List[Tuple[str, bytes]]]
        ] = {}
        _body_params: Optional[bytes] = None

        # process the path parameters
        # process the query parameters
        if limit is not None:
            
            _query_params.append(('limit', limit))
            
        if offset is not None:
            
            _query_params.append(('offset', offset))
            
        if id_offset is not None:
            
            _query_params.append(('idOffset', id_offset))
            
        if sort_by is not None:
            
            _query_params.append(('sortBy', sort_by.value))
            
        if domains is not None:
            
            _query_params.append(('domains', domains))
            
        if creation_period_start is not None:
            if isinstance(creation_period_start, datetime):
                _query_params.append(
                    (
                        'creationPeriodStart',
                        creation_period_start.isoformat()
                    )
                )
            else:
                _query_params.append(('creationPeriodStart', creation_period_start))
            
        if creation_period_end is not None:
            if isinstance(creation_period_end, datetime):
                _query_params.append(
                    (
                        'creationPeriodEnd',
                        creation_period_end.isoformat()
                    )
                )
            else:
                _query_params.append(('creationPeriodEnd', creation_period_end))
            
        if query is not None:
            
            _query_params.append(('query', query))
            
        if status is not None:
            
            _query_params.append(('status', status))
            
        # process the header parameters
        if x_organisation_id is not None:
            _header_params['X-Organisation-Id'] = x_organisation_id
        # process the form parameters
        # process the body parameter


        # set the HTTP header `Accept`
        if 'Accept' not in _header_params:
            _header_params['Accept'] = self.api_client.select_header_accept(
                [
                    'application/json'
                ]
            )


        # authentication setting
        _auth_settings: List[str] = [
            'ApiKey'
        ]

        return self.api_client.param_serialize(
            method='GET',
            resource_path='/v1/audit-logs',
            path_params=_path_params,
            query_params=_query_params,
            header_params=_header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            auth_settings=_auth_settings,
            collection_formats=_collection_formats,
            _host=_host,
            _request_auth=_request_auth
        )


