# coding: utf-8

"""
    STACKIT Audit Log API

    API Endpoints to retrieve recorded actions and resulting changes in the system.  ### Documentation The user documentation with explanations how to use the api can be found  [here](https://docs.stackit.cloud/stackit/en/retrieve-audit-log-per-api-request-134415907.html).  ### Audit Logging Changes on organizations, folders and projects and respective cloud resources are logged and collected in the audit  log.  ### API Constraints The audit log API allows to download messages from the last 90 days. The maximum duration that can be queried at  once is 24 hours. Requests are rate limited - the current maximum is 60 requests per minute.

    The version of the OpenAPI document: 2.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

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

from datetime import datetime
from typing import Any, Dict, List, Optional, Tuple, Union
from uuid import UUID

from pydantic import Field, StrictFloat, StrictInt, StrictStr, validate_call
from stackit.core.configuration import Configuration
from typing_extensions import Annotated

from stackit.auditlog.api_client import ApiClient, RequestSerialized
from stackit.auditlog.api_response import ApiResponse
from stackit.auditlog.models.list_audit_log_entries_response import (
    ListAuditLogEntriesResponse,
)
from stackit.auditlog.rest import RESTResponseType


class DefaultApi:
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    def __init__(self, configuration: Configuration = None) -> None:
        if configuration is None:
            configuration = Configuration()
        self.configuration = configuration
        self.api_client = ApiClient(self.configuration)

    @validate_call
    def list_folder_audit_log_entries(
        self,
        folder_id: Annotated[UUID, Field(description="ID of the folder for which entries should be returned.")],
        start_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time."
            ),
        ],
        end_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received."
            ),
        ],
        limit: Annotated[
            Optional[
                Union[
                    Annotated[float, Field(le=100, strict=True, ge=1)], Annotated[int, Field(le=100, strict=True, ge=1)]
                ]
            ],
            Field(
                description="The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead."
            ),
        ] = None,
        cursor: Annotated[
            Optional[StrictStr],
            Field(
                description="A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API."
            ),
        ] = 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,
    ) -> ListAuditLogEntriesResponse:
        """Folder - Download audit log entries

        Returns all audit log entries of the folder for the specified period. \\ Period must not be longer than 24 hours within the last 90 days.

        :param folder_id: ID of the folder for which entries should be returned. (required)
        :type folder_id: UUID
        :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required)
        :type start_time_range: datetime
        :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required)
        :type end_time_range: datetime
        :param limit: The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead.
        :type limit: float
        :param cursor: A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API.
        :type cursor: 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._list_folder_audit_log_entries_serialize(
            folder_id=folder_id,
            start_time_range=start_time_range,
            end_time_range=end_time_range,
            limit=limit,
            cursor=cursor,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "ListAuditLogEntriesResponse",
            "400": "ErrorResponse",
            "401": "ErrorResponse",
            "404": "ErrorResponse",
            "429": "GatewayErrorResponse",
        }
        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 list_folder_audit_log_entries_with_http_info(
        self,
        folder_id: Annotated[UUID, Field(description="ID of the folder for which entries should be returned.")],
        start_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time."
            ),
        ],
        end_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received."
            ),
        ],
        limit: Annotated[
            Optional[
                Union[
                    Annotated[float, Field(le=100, strict=True, ge=1)], Annotated[int, Field(le=100, strict=True, ge=1)]
                ]
            ],
            Field(
                description="The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead."
            ),
        ] = None,
        cursor: Annotated[
            Optional[StrictStr],
            Field(
                description="A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API."
            ),
        ] = 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[ListAuditLogEntriesResponse]:
        """Folder - Download audit log entries

        Returns all audit log entries of the folder for the specified period. \\ Period must not be longer than 24 hours within the last 90 days.

        :param folder_id: ID of the folder for which entries should be returned. (required)
        :type folder_id: UUID
        :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required)
        :type start_time_range: datetime
        :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required)
        :type end_time_range: datetime
        :param limit: The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead.
        :type limit: float
        :param cursor: A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API.
        :type cursor: 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._list_folder_audit_log_entries_serialize(
            folder_id=folder_id,
            start_time_range=start_time_range,
            end_time_range=end_time_range,
            limit=limit,
            cursor=cursor,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "ListAuditLogEntriesResponse",
            "400": "ErrorResponse",
            "401": "ErrorResponse",
            "404": "ErrorResponse",
            "429": "GatewayErrorResponse",
        }
        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 list_folder_audit_log_entries_without_preload_content(
        self,
        folder_id: Annotated[UUID, Field(description="ID of the folder for which entries should be returned.")],
        start_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time."
            ),
        ],
        end_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received."
            ),
        ],
        limit: Annotated[
            Optional[
                Union[
                    Annotated[float, Field(le=100, strict=True, ge=1)], Annotated[int, Field(le=100, strict=True, ge=1)]
                ]
            ],
            Field(
                description="The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead."
            ),
        ] = None,
        cursor: Annotated[
            Optional[StrictStr],
            Field(
                description="A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API."
            ),
        ] = 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:
        """Folder - Download audit log entries

        Returns all audit log entries of the folder for the specified period. \\ Period must not be longer than 24 hours within the last 90 days.

        :param folder_id: ID of the folder for which entries should be returned. (required)
        :type folder_id: UUID
        :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required)
        :type start_time_range: datetime
        :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required)
        :type end_time_range: datetime
        :param limit: The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead.
        :type limit: float
        :param cursor: A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API.
        :type cursor: 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._list_folder_audit_log_entries_serialize(
            folder_id=folder_id,
            start_time_range=start_time_range,
            end_time_range=end_time_range,
            limit=limit,
            cursor=cursor,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

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

    def _list_folder_audit_log_entries_serialize(
        self,
        folder_id,
        start_time_range,
        end_time_range,
        limit,
        cursor,
        _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 folder_id is not None:
            _path_params["folderId"] = folder_id
        # process the query parameters
        if start_time_range is not None:
            if isinstance(start_time_range, datetime):
                _query_params.append(
                    ("start-time-range", start_time_range.strftime(self.api_client.configuration.datetime_format))
                )
            else:
                _query_params.append(("start-time-range", start_time_range))

        if end_time_range is not None:
            if isinstance(end_time_range, datetime):
                _query_params.append(
                    ("end-time-range", end_time_range.strftime(self.api_client.configuration.datetime_format))
                )
            else:
                _query_params.append(("end-time-range", end_time_range))

        if limit is not None:

            _query_params.append(("limit", limit))

        if cursor is not None:

            _query_params.append(("cursor", cursor))

        # 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] = []

        return self.api_client.param_serialize(
            method="GET",
            resource_path="/v2/folders/{folderId}",
            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 list_organization_audit_log_entries(
        self,
        organization_id: Annotated[
            UUID, Field(description="ID of the organization for which entries should be returned.")
        ],
        start_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time."
            ),
        ],
        end_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received."
            ),
        ],
        limit: Annotated[
            Optional[
                Union[
                    Annotated[float, Field(le=100, strict=True, ge=1)], Annotated[int, Field(le=100, strict=True, ge=1)]
                ]
            ],
            Field(
                description="The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead."
            ),
        ] = None,
        cursor: Annotated[
            Optional[StrictStr],
            Field(
                description="A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API."
            ),
        ] = 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,
    ) -> ListAuditLogEntriesResponse:
        """Organization - Download audit log entries

        Returns all audit log entries of the organization for the specified period. \\ Period must not be longer than 24 hours within the last 90 days.

        :param organization_id: ID of the organization for which entries should be returned. (required)
        :type organization_id: UUID
        :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required)
        :type start_time_range: datetime
        :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required)
        :type end_time_range: datetime
        :param limit: The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead.
        :type limit: float
        :param cursor: A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API.
        :type cursor: 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._list_organization_audit_log_entries_serialize(
            organization_id=organization_id,
            start_time_range=start_time_range,
            end_time_range=end_time_range,
            limit=limit,
            cursor=cursor,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "ListAuditLogEntriesResponse",
            "400": "ErrorResponse",
            "401": "ErrorResponse",
            "404": "ErrorResponse",
            "429": "GatewayErrorResponse",
        }
        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 list_organization_audit_log_entries_with_http_info(
        self,
        organization_id: Annotated[
            UUID, Field(description="ID of the organization for which entries should be returned.")
        ],
        start_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time."
            ),
        ],
        end_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received."
            ),
        ],
        limit: Annotated[
            Optional[
                Union[
                    Annotated[float, Field(le=100, strict=True, ge=1)], Annotated[int, Field(le=100, strict=True, ge=1)]
                ]
            ],
            Field(
                description="The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead."
            ),
        ] = None,
        cursor: Annotated[
            Optional[StrictStr],
            Field(
                description="A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API."
            ),
        ] = 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[ListAuditLogEntriesResponse]:
        """Organization - Download audit log entries

        Returns all audit log entries of the organization for the specified period. \\ Period must not be longer than 24 hours within the last 90 days.

        :param organization_id: ID of the organization for which entries should be returned. (required)
        :type organization_id: UUID
        :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required)
        :type start_time_range: datetime
        :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required)
        :type end_time_range: datetime
        :param limit: The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead.
        :type limit: float
        :param cursor: A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API.
        :type cursor: 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._list_organization_audit_log_entries_serialize(
            organization_id=organization_id,
            start_time_range=start_time_range,
            end_time_range=end_time_range,
            limit=limit,
            cursor=cursor,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "ListAuditLogEntriesResponse",
            "400": "ErrorResponse",
            "401": "ErrorResponse",
            "404": "ErrorResponse",
            "429": "GatewayErrorResponse",
        }
        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 list_organization_audit_log_entries_without_preload_content(
        self,
        organization_id: Annotated[
            UUID, Field(description="ID of the organization for which entries should be returned.")
        ],
        start_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time."
            ),
        ],
        end_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received."
            ),
        ],
        limit: Annotated[
            Optional[
                Union[
                    Annotated[float, Field(le=100, strict=True, ge=1)], Annotated[int, Field(le=100, strict=True, ge=1)]
                ]
            ],
            Field(
                description="The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead."
            ),
        ] = None,
        cursor: Annotated[
            Optional[StrictStr],
            Field(
                description="A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API."
            ),
        ] = 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:
        """Organization - Download audit log entries

        Returns all audit log entries of the organization for the specified period. \\ Period must not be longer than 24 hours within the last 90 days.

        :param organization_id: ID of the organization for which entries should be returned. (required)
        :type organization_id: UUID
        :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required)
        :type start_time_range: datetime
        :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required)
        :type end_time_range: datetime
        :param limit: The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead.
        :type limit: float
        :param cursor: A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API.
        :type cursor: 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._list_organization_audit_log_entries_serialize(
            organization_id=organization_id,
            start_time_range=start_time_range,
            end_time_range=end_time_range,
            limit=limit,
            cursor=cursor,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

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

    def _list_organization_audit_log_entries_serialize(
        self,
        organization_id,
        start_time_range,
        end_time_range,
        limit,
        cursor,
        _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 organization_id is not None:
            _path_params["organizationId"] = organization_id
        # process the query parameters
        if start_time_range is not None:
            if isinstance(start_time_range, datetime):
                _query_params.append(
                    ("start-time-range", start_time_range.strftime(self.api_client.configuration.datetime_format))
                )
            else:
                _query_params.append(("start-time-range", start_time_range))

        if end_time_range is not None:
            if isinstance(end_time_range, datetime):
                _query_params.append(
                    ("end-time-range", end_time_range.strftime(self.api_client.configuration.datetime_format))
                )
            else:
                _query_params.append(("end-time-range", end_time_range))

        if limit is not None:

            _query_params.append(("limit", limit))

        if cursor is not None:

            _query_params.append(("cursor", cursor))

        # 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] = []

        return self.api_client.param_serialize(
            method="GET",
            resource_path="/v2/organizations/{organizationId}",
            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 list_project_audit_log_entries(
        self,
        project_id: Annotated[UUID, Field(description="ID of the project for which entries should be returned.")],
        start_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time."
            ),
        ],
        end_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received."
            ),
        ],
        limit: Annotated[
            Optional[
                Union[
                    Annotated[float, Field(le=100, strict=True, ge=1)], Annotated[int, Field(le=100, strict=True, ge=1)]
                ]
            ],
            Field(
                description="The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead."
            ),
        ] = None,
        cursor: Annotated[
            Optional[StrictStr],
            Field(
                description="A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API."
            ),
        ] = 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,
    ) -> ListAuditLogEntriesResponse:
        """Project - Download audit log entries

        Returns all audit log entries of the project for the specified period. \\ Period must not be longer than 24 hours within the last 90 days.

        :param project_id: ID of the project for which entries should be returned. (required)
        :type project_id: UUID
        :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required)
        :type start_time_range: datetime
        :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required)
        :type end_time_range: datetime
        :param limit: The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead.
        :type limit: float
        :param cursor: A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API.
        :type cursor: 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._list_project_audit_log_entries_serialize(
            project_id=project_id,
            start_time_range=start_time_range,
            end_time_range=end_time_range,
            limit=limit,
            cursor=cursor,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "ListAuditLogEntriesResponse",
            "400": "ErrorResponse",
            "401": "ErrorResponse",
            "404": "ErrorResponse",
            "429": "GatewayErrorResponse",
        }
        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 list_project_audit_log_entries_with_http_info(
        self,
        project_id: Annotated[UUID, Field(description="ID of the project for which entries should be returned.")],
        start_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time."
            ),
        ],
        end_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received."
            ),
        ],
        limit: Annotated[
            Optional[
                Union[
                    Annotated[float, Field(le=100, strict=True, ge=1)], Annotated[int, Field(le=100, strict=True, ge=1)]
                ]
            ],
            Field(
                description="The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead."
            ),
        ] = None,
        cursor: Annotated[
            Optional[StrictStr],
            Field(
                description="A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API."
            ),
        ] = 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[ListAuditLogEntriesResponse]:
        """Project - Download audit log entries

        Returns all audit log entries of the project for the specified period. \\ Period must not be longer than 24 hours within the last 90 days.

        :param project_id: ID of the project for which entries should be returned. (required)
        :type project_id: UUID
        :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required)
        :type start_time_range: datetime
        :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required)
        :type end_time_range: datetime
        :param limit: The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead.
        :type limit: float
        :param cursor: A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API.
        :type cursor: 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._list_project_audit_log_entries_serialize(
            project_id=project_id,
            start_time_range=start_time_range,
            end_time_range=end_time_range,
            limit=limit,
            cursor=cursor,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

        _response_types_map: Dict[str, Optional[str]] = {
            "200": "ListAuditLogEntriesResponse",
            "400": "ErrorResponse",
            "401": "ErrorResponse",
            "404": "ErrorResponse",
            "429": "GatewayErrorResponse",
        }
        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 list_project_audit_log_entries_without_preload_content(
        self,
        project_id: Annotated[UUID, Field(description="ID of the project for which entries should be returned.")],
        start_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time."
            ),
        ],
        end_time_range: Annotated[
            datetime,
            Field(
                description="An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received."
            ),
        ],
        limit: Annotated[
            Optional[
                Union[
                    Annotated[float, Field(le=100, strict=True, ge=1)], Annotated[int, Field(le=100, strict=True, ge=1)]
                ]
            ],
            Field(
                description="The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead."
            ),
        ] = None,
        cursor: Annotated[
            Optional[StrictStr],
            Field(
                description="A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API."
            ),
        ] = 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:
        """Project - Download audit log entries

        Returns all audit log entries of the project for the specified period. \\ Period must not be longer than 24 hours within the last 90 days.

        :param project_id: ID of the project for which entries should be returned. (required)
        :type project_id: UUID
        :param start_time_range: An ISO timestamp to specify the beginning of the time range from which entries should be returned, based on the eventTimeStamp. If not given, defaults to the beginning of time. (required)
        :type start_time_range: datetime
        :param end_time_range: An ISO timestamp to specify the end of the time range up until which entries should be returned, based on the eventTimeStamp. If not given, defaults to the time this request was received. (required)
        :type end_time_range: datetime
        :param limit: The maximum number of entries to return. If the value exceeds the allowed maximum, the maximum value will be used instead.
        :type limit: float
        :param cursor: A pagination cursor to load further audit log entries for. May be included in the response of previous calls of the API.
        :type cursor: 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._list_project_audit_log_entries_serialize(
            project_id=project_id,
            start_time_range=start_time_range,
            end_time_range=end_time_range,
            limit=limit,
            cursor=cursor,
            _request_auth=_request_auth,
            _content_type=_content_type,
            _headers=_headers,
            _host_index=_host_index,
        )

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

    def _list_project_audit_log_entries_serialize(
        self,
        project_id,
        start_time_range,
        end_time_range,
        limit,
        cursor,
        _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 project_id is not None:
            _path_params["projectId"] = project_id
        # process the query parameters
        if start_time_range is not None:
            if isinstance(start_time_range, datetime):
                _query_params.append(
                    ("start-time-range", start_time_range.strftime(self.api_client.configuration.datetime_format))
                )
            else:
                _query_params.append(("start-time-range", start_time_range))

        if end_time_range is not None:
            if isinstance(end_time_range, datetime):
                _query_params.append(
                    ("end-time-range", end_time_range.strftime(self.api_client.configuration.datetime_format))
                )
            else:
                _query_params.append(("end-time-range", end_time_range))

        if limit is not None:

            _query_params.append(("limit", limit))

        if cursor is not None:

            _query_params.append(("cursor", cursor))

        # 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] = []

        return self.api_client.param_serialize(
            method="GET",
            resource_path="/v2/projects/{projectId}",
            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,
        )
