# coding: utf-8

"""
    Mentortools Notifications Server

    Mentortools service for Notifications

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

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


import re  # noqa: F401
import io
import warnings

from pydantic import validate_arguments, ValidationError
from typing import overload, Optional, Union, Awaitable

from typing_extensions import Annotated
from pydantic import Field, StrictBool, StrictInt, StrictStr

from typing import Any, Optional

from notifications_server_connector.models.contact_footer_request import ContactFooterRequest
from notifications_server_connector.models.template_override_batch_request import TemplateOverrideBatchRequest
from notifications_server_connector.models.template_override_request import TemplateOverrideRequest
from notifications_server_connector.models.wrapped_response_bool import WrappedResponseBool
from notifications_server_connector.models.wrapped_response_contact_footer_response import WrappedResponseContactFooterResponse
from notifications_server_connector.models.wrapped_response_dict_str_str import WrappedResponseDictStrStr
from notifications_server_connector.models.wrapped_response_int import WrappedResponseInt
from notifications_server_connector.models.wrapped_response_list_int import WrappedResponseListInt
from notifications_server_connector.models.wrapped_response_list_overridable_source_type_response import WrappedResponseListOverridableSourceTypeResponse
from notifications_server_connector.models.wrapped_response_list_portal_template_override_response import WrappedResponseListPortalTemplateOverrideResponse
from notifications_server_connector.models.wrapped_response_portal_template_override_response import WrappedResponsePortalTemplateOverrideResponse

from notifications_server_connector.api_client import ApiClient
from notifications_server_connector.api_response import ApiResponse
from notifications_server_connector.exceptions import (  # noqa: F401
    ApiTypeError,
    ApiValueError
)


class TemplatesApi:
    """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
    async def templates_delete_portal_override(self, source_type_id : Annotated[StrictInt, Field(..., description="Source type ID")], token : Optional[StrictStr] = None, **kwargs) -> WrappedResponseBool:  # noqa: E501
        """Delete override  # noqa: E501

        Delete a template override for the authenticated user's portal. Reverts to Weblate default.  # noqa: E501

        :param source_type_id: Source type ID (required)
        :type source_type_id: int
        :param token:
        :type token: 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.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseBool
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the templates_delete_portal_override_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.templates_delete_portal_override_with_http_info(source_type_id, token, **kwargs)  # noqa: E501

    @validate_arguments
    async def templates_delete_portal_override_with_http_info(self, source_type_id : Annotated[StrictInt, Field(..., description="Source type ID")], token : Optional[StrictStr] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Delete override  # noqa: E501

        Delete a template override for the authenticated user's portal. Reverts to Weblate default.  # noqa: E501

        :param source_type_id: Source type ID (required)
        :type source_type_id: int
        :param token:
        :type token: str
        :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_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.
        :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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseBool, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'source_type_id',
            'token'
        ]
        _all_params.extend(
            [
                '_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 templates_delete_portal_override" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['source_type_id'] is not None:
            _path_params['source_type_id'] = _params['source_type_id']


        # process the query parameters
        _query_params = []
        if _params.get('token') is not None:  # noqa: E501
            _query_params.append(('token', _params['token']))

        # 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'])  # noqa: E501

        # authentication setting
        _auth_settings = ['APIKeyHeader', 'HTTPBearer']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseBool",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/templates/{source_type_id}', 'DELETE',
            _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,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _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
    async def templates_get_contact_footer(self, token : Optional[StrictStr] = None, **kwargs) -> WrappedResponseContactFooterResponse:  # noqa: E501
        """Get contact info footer  # noqa: E501

        Get the contact info footer template for the authenticated user's portal. Returns override if available, otherwise Weblate default.  # noqa: E501

        :param token:
        :type token: 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.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseContactFooterResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the templates_get_contact_footer_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.templates_get_contact_footer_with_http_info(token, **kwargs)  # noqa: E501

    @validate_arguments
    async def templates_get_contact_footer_with_http_info(self, token : Optional[StrictStr] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Get contact info footer  # noqa: E501

        Get the contact info footer template for the authenticated user's portal. Returns override if available, otherwise Weblate default.  # noqa: E501

        :param token:
        :type token: str
        :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_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.
        :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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseContactFooterResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'token'
        ]
        _all_params.extend(
            [
                '_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 templates_get_contact_footer" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get('token') is not None:  # noqa: E501
            _query_params.append(('token', _params['token']))

        # 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'])  # noqa: E501

        # authentication setting
        _auth_settings = ['APIKeyHeader', 'HTTPBearer']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseContactFooterResponse",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/templates/contact_footer', '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,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _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
    async def templates_get_overridable_source_types(self, token : Optional[StrictStr] = None, **kwargs) -> WrappedResponseListOverridableSourceTypeResponse:  # noqa: E501
        """Get all overridable source types  # noqa: E501

        Get all source types that support template overrides with their allowed variables.  # noqa: E501

        :param token:
        :type token: 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.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseListOverridableSourceTypeResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the templates_get_overridable_source_types_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.templates_get_overridable_source_types_with_http_info(token, **kwargs)  # noqa: E501

    @validate_arguments
    async def templates_get_overridable_source_types_with_http_info(self, token : Optional[StrictStr] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Get all overridable source types  # noqa: E501

        Get all source types that support template overrides with their allowed variables.  # noqa: E501

        :param token:
        :type token: str
        :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_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.
        :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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseListOverridableSourceTypeResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'token'
        ]
        _all_params.extend(
            [
                '_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 templates_get_overridable_source_types" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get('token') is not None:  # noqa: E501
            _query_params.append(('token', _params['token']))

        # 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'])  # noqa: E501

        # authentication setting
        _auth_settings = ['APIKeyHeader', 'HTTPBearer']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseListOverridableSourceTypeResponse",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/templates/source_types', '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,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _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
    async def templates_get_portal_template(self, source_type_id : Annotated[StrictInt, Field(..., description="Source type ID")], token : Optional[StrictStr] = None, **kwargs) -> WrappedResponsePortalTemplateOverrideResponse:  # noqa: E501
        """Get specific template for portal  # noqa: E501

        Get a specific template for the authenticated user's portal by source type ID.  # noqa: E501

        :param source_type_id: Source type ID (required)
        :type source_type_id: int
        :param token:
        :type token: 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.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponsePortalTemplateOverrideResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the templates_get_portal_template_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.templates_get_portal_template_with_http_info(source_type_id, token, **kwargs)  # noqa: E501

    @validate_arguments
    async def templates_get_portal_template_with_http_info(self, source_type_id : Annotated[StrictInt, Field(..., description="Source type ID")], token : Optional[StrictStr] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Get specific template for portal  # noqa: E501

        Get a specific template for the authenticated user's portal by source type ID.  # noqa: E501

        :param source_type_id: Source type ID (required)
        :type source_type_id: int
        :param token:
        :type token: str
        :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_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.
        :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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponsePortalTemplateOverrideResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'source_type_id',
            'token'
        ]
        _all_params.extend(
            [
                '_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 templates_get_portal_template" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['source_type_id'] is not None:
            _path_params['source_type_id'] = _params['source_type_id']


        # process the query parameters
        _query_params = []
        if _params.get('token') is not None:  # noqa: E501
            _query_params.append(('token', _params['token']))

        # 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'])  # noqa: E501

        # authentication setting
        _auth_settings = ['APIKeyHeader', 'HTTPBearer']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponsePortalTemplateOverrideResponse",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/templates/{source_type_id}', '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,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _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
    async def templates_get_portal_templates(self, token : Optional[StrictStr] = None, **kwargs) -> WrappedResponseListPortalTemplateOverrideResponse:  # noqa: E501
        """Get all templates for portal  # noqa: E501

        Get all templates for the authenticated user's portal. Returns overrides if available, otherwise Weblate defaults.  # noqa: E501

        :param token:
        :type token: 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.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseListPortalTemplateOverrideResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the templates_get_portal_templates_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.templates_get_portal_templates_with_http_info(token, **kwargs)  # noqa: E501

    @validate_arguments
    async def templates_get_portal_templates_with_http_info(self, token : Optional[StrictStr] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Get all templates for portal  # noqa: E501

        Get all templates for the authenticated user's portal. Returns overrides if available, otherwise Weblate defaults.  # noqa: E501

        :param token:
        :type token: str
        :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_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.
        :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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseListPortalTemplateOverrideResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'token'
        ]
        _all_params.extend(
            [
                '_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 templates_get_portal_templates" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get('token') is not None:  # noqa: E501
            _query_params.append(('token', _params['token']))

        # 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'])  # noqa: E501

        # authentication setting
        _auth_settings = ['APIKeyHeader', 'HTTPBearer']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseListPortalTemplateOverrideResponse",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/templates', '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,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _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
    async def templates_get_templates(self, component_name : Annotated[StrictStr, Field(..., description="Weblate component name")], template_code : Annotated[StrictStr, Field(..., description="Comma-separated template codes")], language : Annotated[Any, Field(..., description="Language code")], allow_not_found : Annotated[Optional[StrictBool], Field(description="Allow missing templates")] = None, **kwargs) -> WrappedResponseDictStrStr:  # noqa: E501
        """Get raw templates  # noqa: E501

        Get raw Weblate templates by component name and template codes.  # noqa: E501

        :param component_name: Weblate component name (required)
        :type component_name: str
        :param template_code: Comma-separated template codes (required)
        :type template_code: str
        :param language: Language code (required)
        :type language: Language
        :param allow_not_found: Allow missing templates
        :type allow_not_found: bool
        :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.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseDictStrStr
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the templates_get_templates_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.templates_get_templates_with_http_info(component_name, template_code, language, allow_not_found, **kwargs)  # noqa: E501

    @validate_arguments
    async def templates_get_templates_with_http_info(self, component_name : Annotated[StrictStr, Field(..., description="Weblate component name")], template_code : Annotated[StrictStr, Field(..., description="Comma-separated template codes")], language : Annotated[Any, Field(..., description="Language code")], allow_not_found : Annotated[Optional[StrictBool], Field(description="Allow missing templates")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Get raw templates  # noqa: E501

        Get raw Weblate templates by component name and template codes.  # noqa: E501

        :param component_name: Weblate component name (required)
        :type component_name: str
        :param template_code: Comma-separated template codes (required)
        :type template_code: str
        :param language: Language code (required)
        :type language: Language
        :param allow_not_found: Allow missing templates
        :type allow_not_found: bool
        :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_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.
        :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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseDictStrStr, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'component_name',
            'template_code',
            'language',
            'allow_not_found'
        ]
        _all_params.extend(
            [
                '_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 templates_get_templates" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get('component_name') is not None:  # noqa: E501
            _query_params.append(('component_name', _params['component_name']))

        if _params.get('template_code') is not None:  # noqa: E501
            _query_params.append(('template_code', _params['template_code']))

        if _params.get('language') is not None:  # noqa: E501
            _query_params.append(('language', _params['language'].value))

        if _params.get('allow_not_found') is not None:  # noqa: E501
            _query_params.append(('allow_not_found', _params['allow_not_found']))

        # 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'])  # noqa: E501

        # authentication setting
        _auth_settings = ['APIKeyHeader']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseDictStrStr",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/template/get', '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,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _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
    async def templates_reset_contact_footer(self, token : Optional[StrictStr] = None, **kwargs) -> WrappedResponseBool:  # noqa: E501
        """Reset contact info footer  # noqa: E501

        Reset the contact info footer to Weblate default by removing the portal's custom override.  # noqa: E501

        :param token:
        :type token: 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.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseBool
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the templates_reset_contact_footer_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.templates_reset_contact_footer_with_http_info(token, **kwargs)  # noqa: E501

    @validate_arguments
    async def templates_reset_contact_footer_with_http_info(self, token : Optional[StrictStr] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Reset contact info footer  # noqa: E501

        Reset the contact info footer to Weblate default by removing the portal's custom override.  # noqa: E501

        :param token:
        :type token: str
        :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_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.
        :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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseBool, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'token'
        ]
        _all_params.extend(
            [
                '_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 templates_reset_contact_footer" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get('token') is not None:  # noqa: E501
            _query_params.append(('token', _params['token']))

        # 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'])  # noqa: E501

        # authentication setting
        _auth_settings = ['APIKeyHeader', 'HTTPBearer']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseBool",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/templates/contact_footer/reset', '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,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _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
    async def templates_upsert_contact_footer(self, contact_footer_request : ContactFooterRequest, token : Optional[StrictStr] = None, **kwargs) -> WrappedResponseInt:  # noqa: E501
        """Set contact info footer  # noqa: E501

        Create or update the contact info footer template for the authenticated user's portal.  # noqa: E501

        :param contact_footer_request: (required)
        :type contact_footer_request: ContactFooterRequest
        :param token:
        :type token: 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.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseInt
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the templates_upsert_contact_footer_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.templates_upsert_contact_footer_with_http_info(contact_footer_request, token, **kwargs)  # noqa: E501

    @validate_arguments
    async def templates_upsert_contact_footer_with_http_info(self, contact_footer_request : ContactFooterRequest, token : Optional[StrictStr] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Set contact info footer  # noqa: E501

        Create or update the contact info footer template for the authenticated user's portal.  # noqa: E501

        :param contact_footer_request: (required)
        :type contact_footer_request: ContactFooterRequest
        :param token:
        :type token: str
        :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_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.
        :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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseInt, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'contact_footer_request',
            'token'
        ]
        _all_params.extend(
            [
                '_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 templates_upsert_contact_footer" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get('token') is not None:  # noqa: E501
            _query_params.append(('token', _params['token']))

        # 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['contact_footer_request'] is not None:
            _body_params = _params['contact_footer_request']

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

        # 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 = ['APIKeyHeader', 'HTTPBearer']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseInt",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/templates/contact_footer', 'PUT',
            _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,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _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
    async def templates_upsert_portal_override(self, source_type_id : Annotated[StrictInt, Field(..., description="Source type ID")], template_override_request : TemplateOverrideRequest, token : Optional[StrictStr] = None, **kwargs) -> WrappedResponseInt:  # noqa: E501
        """Create or update override  # noqa: E501

        Create or update a template override for the authenticated user's portal. Validates template before saving.  # noqa: E501

        :param source_type_id: Source type ID (required)
        :type source_type_id: int
        :param template_override_request: (required)
        :type template_override_request: TemplateOverrideRequest
        :param token:
        :type token: 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.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseInt
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the templates_upsert_portal_override_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.templates_upsert_portal_override_with_http_info(source_type_id, template_override_request, token, **kwargs)  # noqa: E501

    @validate_arguments
    async def templates_upsert_portal_override_with_http_info(self, source_type_id : Annotated[StrictInt, Field(..., description="Source type ID")], template_override_request : TemplateOverrideRequest, token : Optional[StrictStr] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Create or update override  # noqa: E501

        Create or update a template override for the authenticated user's portal. Validates template before saving.  # noqa: E501

        :param source_type_id: Source type ID (required)
        :type source_type_id: int
        :param template_override_request: (required)
        :type template_override_request: TemplateOverrideRequest
        :param token:
        :type token: str
        :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_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.
        :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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseInt, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'source_type_id',
            'template_override_request',
            'token'
        ]
        _all_params.extend(
            [
                '_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 templates_upsert_portal_override" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['source_type_id'] is not None:
            _path_params['source_type_id'] = _params['source_type_id']


        # process the query parameters
        _query_params = []
        if _params.get('token') is not None:  # noqa: E501
            _query_params.append(('token', _params['token']))

        # 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['template_override_request'] is not None:
            _body_params = _params['template_override_request']

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

        # 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 = ['APIKeyHeader', 'HTTPBearer']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseInt",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/templates/{source_type_id}', 'PUT',
            _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,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _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
    async def templates_upsert_portal_overrides_batch(self, template_override_batch_request : TemplateOverrideBatchRequest, token : Optional[StrictStr] = None, **kwargs) -> WrappedResponseListInt:  # noqa: E501
        """Batch create or update overrides  # noqa: E501

        Create or update multiple template overrides for the authenticated user's portal. Only updates the mentioned templates. Validates all templates before saving.  # noqa: E501

        :param template_override_batch_request: (required)
        :type template_override_batch_request: TemplateOverrideBatchRequest
        :param token:
        :type token: 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.
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: WrappedResponseListInt
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the templates_upsert_portal_overrides_batch_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        return await self.templates_upsert_portal_overrides_batch_with_http_info(template_override_batch_request, token, **kwargs)  # noqa: E501

    @validate_arguments
    async def templates_upsert_portal_overrides_batch_with_http_info(self, template_override_batch_request : TemplateOverrideBatchRequest, token : Optional[StrictStr] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """Batch create or update overrides  # noqa: E501

        Create or update multiple template overrides for the authenticated user's portal. Only updates the mentioned templates. Validates all templates before saving.  # noqa: E501

        :param template_override_batch_request: (required)
        :type template_override_batch_request: TemplateOverrideBatchRequest
        :param token:
        :type token: str
        :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_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.
        :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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(WrappedResponseListInt, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'template_override_batch_request',
            'token'
        ]
        _all_params.extend(
            [
                '_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 templates_upsert_portal_overrides_batch" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get('token') is not None:  # noqa: E501
            _query_params.append(('token', _params['token']))

        # 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['template_override_batch_request'] is not None:
            _body_params = _params['template_override_batch_request']

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

        # 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 = ['APIKeyHeader', 'HTTPBearer']  # noqa: E501

        _response_types_map = {
            '200': "WrappedResponseListInt",
            '422': "HTTPValidationError",
        }

        return await self.api_client.call_api(
            '/v1/templates', 'PATCH',
            _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,
            _return_http_data_only=_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))
