# coding: utf-8

"""
Earnix Elevate Umon API

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

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

Do not edit the class manually.
"""


from datetime import datetime
from typing import List, Optional

from pydantic.v1 import Field, validate_arguments
from typing_extensions import Annotated

from earnix_elevate.clients.umon.api_client import ApiClient
from earnix_elevate.clients.umon.api_response import ApiResponse
from earnix_elevate.clients.umon.exceptions import ApiTypeError
from earnix_elevate.clients.umon.models.create_quota_request import CreateQuotaRequest
from earnix_elevate.clients.umon.models.quota_contract_response import (
    QuotaContractResponse,
)
from earnix_elevate.clients.umon.models.quota_overage_allowed_request import (
    QuotaOverageAllowedRequest,
)


class QuotaServiceApi:
    """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_arguments
    def create_quota(
        self,
        create_quota_request: Annotated[
            CreateQuotaRequest,
            Field(..., description="Request to create a new quota contract"),
        ],
        **kwargs,
    ) -> QuotaContractResponse:
        """Create new quota contract

        Create new quota contract (insert-only, immutable)

        :param create_quota_request: Request to create a new quota contract (required)
        :type create_quota_request: CreateQuotaRequest
        :return: Returns the result object.
        :rtype: QuotaContractResponse
        """
        kwargs["_return_http_data_only"] = True
        if "_preload_content" in kwargs:
            message = "Error! Please call the create_quota_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"
            raise ValueError(message)
        return self.create_quota_with_http_info(create_quota_request, **kwargs)

    @validate_arguments
    def create_quota_with_http_info(
        self,
        create_quota_request: Annotated[
            CreateQuotaRequest,
            Field(..., description="Request to create a new quota contract"),
        ],
        **kwargs,
    ) -> ApiResponse:
        """Create new quota contract

        Create new quota contract (insert-only, immutable)

        :param create_quota_request: Request to create a new quota contract (required)
        :type create_quota_request: CreateQuotaRequest
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, 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
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
        :rtype: tuple(QuotaContractResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = ["create_quota_request"]
        _all_params.extend(
            [
                "async_req",
                "_return_http_data_only",
                "_preload_content",
                "_request_timeout",
                "_request_auth",
                "_content_type",
                "_headers",
            ]
        )

        # validate the arguments
        for _key, _val in _params["kwargs"].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method create_quota" % _key
                )
            _params[_key] = _val
        del _params["kwargs"]

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get("_headers", {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        if _params["create_quota_request"] is not None:
            _body_params = _params["create_quota_request"]

        # set the HTTP header `Accept`
        _header_params["Accept"] = self.api_client.select_header_accept(
            ["application/json", "application/problem+json"]
        )

        # set the HTTP header `Content-Type`
        _content_types_list = _params.get(
            "_content_type",
            self.api_client.select_header_content_type(["application/json"]),
        )
        if _content_types_list:
            _header_params["Content-Type"] = _content_types_list

        # authentication setting
        _auth_settings = ["BearerAuth"]

        _response_types_map = {
            "201": "QuotaContractResponse",
        }

        return self.api_client.call_api(
            "/v1/quota",
            "POST",
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            async_req=_params.get("async_req"),
            _return_http_data_only=_params.get("_return_http_data_only"),
            _preload_content=_params.get("_preload_content", True),
            _request_timeout=_params.get("_request_timeout"),
            collection_formats=_collection_formats,
            _request_auth=_params.get("_request_auth"),
        )

    @validate_arguments
    def get_quotas(
        self,
        start_date: Annotated[
            Optional[datetime], Field(description="Start of date range")
        ] = None,
        end_date: Annotated[
            Optional[datetime], Field(description="End of date range")
        ] = None,
        **kwargs,
    ) -> List[QuotaContractResponse]:
        """Get quota contracts

        Retrieve current quota or quotas for a date range. if only one date is provided, we assume that the date that isn't provided is the current date.

        :param start_date: Start of date range
        :type start_date: datetime
        :param end_date: End of date range
        :type end_date: datetime
        :return: Returns the result object.
        :rtype: List[QuotaContractResponse]
        """
        kwargs["_return_http_data_only"] = True
        if "_preload_content" in kwargs:
            message = "Error! Please call the get_quotas_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"
            raise ValueError(message)
        return self.get_quotas_with_http_info(start_date, end_date, **kwargs)

    @validate_arguments
    def get_quotas_with_http_info(
        self,
        start_date: Annotated[
            Optional[datetime], Field(description="Start of date range")
        ] = None,
        end_date: Annotated[
            Optional[datetime], Field(description="End of date range")
        ] = None,
        **kwargs,
    ) -> ApiResponse:
        """Get quota contracts

        Retrieve current quota or quotas for a date range. if only one date is provided, we assume that the date that isn't provided is the current date.

        :param start_date: Start of date range
        :type start_date: datetime
        :param end_date: End of date range
        :type end_date: datetime
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, 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
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
        :rtype: tuple(List[QuotaContractResponse], status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = ["start_date", "end_date"]
        _all_params.extend(
            [
                "async_req",
                "_return_http_data_only",
                "_preload_content",
                "_request_timeout",
                "_request_auth",
                "_content_type",
                "_headers",
            ]
        )

        # validate the arguments
        for _key, _val in _params["kwargs"].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method get_quotas" % _key
                )
            _params[_key] = _val
        del _params["kwargs"]

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get("start_date") is not None:
            if isinstance(_params["start_date"], datetime):
                _query_params.append(
                    (
                        "startDate",
                        _params["start_date"].strftime(
                            self.api_client.configuration.datetime_format
                        ),
                    )
                )
            else:
                _query_params.append(("startDate", _params["start_date"]))

        if _params.get("end_date") is not None:
            if isinstance(_params["end_date"], datetime):
                _query_params.append(
                    (
                        "endDate",
                        _params["end_date"].strftime(
                            self.api_client.configuration.datetime_format
                        ),
                    )
                )
            else:
                _query_params.append(("endDate", _params["end_date"]))

        # process the header parameters
        _header_params = dict(_params.get("_headers", {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        # set the HTTP header `Accept`
        _header_params["Accept"] = self.api_client.select_header_accept(
            ["application/json", "application/problem+json"]
        )

        # authentication setting
        _auth_settings = ["BearerAuth"]

        _response_types_map = {
            "200": "List[QuotaContractResponse]",
        }

        return self.api_client.call_api(
            "/v1/quota",
            "GET",
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            async_req=_params.get("async_req"),
            _return_http_data_only=_params.get("_return_http_data_only"),
            _preload_content=_params.get("_preload_content", True),
            _request_timeout=_params.get("_request_timeout"),
            collection_formats=_collection_formats,
            _request_auth=_params.get("_request_auth"),
        )

    @validate_arguments
    def modify_overage_allowed(
        self,
        quota_overage_allowed_request: Annotated[
            QuotaOverageAllowedRequest,
            Field(
                ...,
                description="Request to modify overage allowed on the current quota contract",
            ),
        ],
        **kwargs,
    ) -> QuotaContractResponse:
        """Modify overage allowed

        Modify overage allowed on the current quota contract

        :param quota_overage_allowed_request: Request to modify overage allowed on the current quota contract (required)
        :type quota_overage_allowed_request: QuotaOverageAllowedRequest
        :return: Returns the result object.
        :rtype: QuotaContractResponse
        """
        kwargs["_return_http_data_only"] = True
        if "_preload_content" in kwargs:
            message = "Error! Please call the modify_overage_allowed_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"
            raise ValueError(message)
        return self.modify_overage_allowed_with_http_info(
            quota_overage_allowed_request, **kwargs
        )

    @validate_arguments
    def modify_overage_allowed_with_http_info(
        self,
        quota_overage_allowed_request: Annotated[
            QuotaOverageAllowedRequest,
            Field(
                ...,
                description="Request to modify overage allowed on the current quota contract",
            ),
        ],
        **kwargs,
    ) -> ApiResponse:
        """Modify overage allowed

        Modify overage allowed on the current quota contract

        :param quota_overage_allowed_request: Request to modify overage allowed on the current quota contract (required)
        :type quota_overage_allowed_request: QuotaOverageAllowedRequest
        :param _preload_content: if False, the ApiResponse.data will
                                 be set to none and raw_data will store the
                                 HTTP response body without reading/decoding.
                                 Default is True.
        :type _preload_content: bool, optional
        :param _return_http_data_only: response data instead of ApiResponse
                                       object with status code, headers, etc
        :type _return_http_data_only: bool, 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
        :type _content_type: string, optional: force content-type for the request
        :return: Returns the result object.
        :rtype: tuple(QuotaContractResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = ["quota_overage_allowed_request"]
        _all_params.extend(
            [
                "async_req",
                "_return_http_data_only",
                "_preload_content",
                "_request_timeout",
                "_request_auth",
                "_content_type",
                "_headers",
            ]
        )

        # validate the arguments
        for _key, _val in _params["kwargs"].items():
            if _key not in _all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method modify_overage_allowed" % _key
                )
            _params[_key] = _val
        del _params["kwargs"]

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        # process the header parameters
        _header_params = dict(_params.get("_headers", {}))
        # process the form parameters
        _form_params = []
        _files = {}
        # process the body parameter
        _body_params = None
        if _params["quota_overage_allowed_request"] is not None:
            _body_params = _params["quota_overage_allowed_request"]

        # set the HTTP header `Accept`
        _header_params["Accept"] = self.api_client.select_header_accept(
            ["application/json", "application/problem+json"]
        )

        # set the HTTP header `Content-Type`
        _content_types_list = _params.get(
            "_content_type",
            self.api_client.select_header_content_type(["application/json"]),
        )
        if _content_types_list:
            _header_params["Content-Type"] = _content_types_list

        # authentication setting
        _auth_settings = ["BearerAuth"]

        _response_types_map = {
            "200": "QuotaContractResponse",
        }

        return self.api_client.call_api(
            "/v1/quota/overage-allowed",
            "POST",
            _path_params,
            _query_params,
            _header_params,
            body=_body_params,
            post_params=_form_params,
            files=_files,
            response_types_map=_response_types_map,
            auth_settings=_auth_settings,
            async_req=_params.get("async_req"),
            _return_http_data_only=_params.get("_return_http_data_only"),
            _preload_content=_params.get("_preload_content", True),
            _request_timeout=_params.get("_request_timeout"),
            collection_formats=_collection_formats,
            _request_auth=_params.get("_request_auth"),
        )
