# coding: utf-8

"""
    FINBOURNE Access Management API

    FINBOURNE Technology  # noqa: E501

    Contact: info@finbourne.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


import re  # noqa: F401
import io
import warnings

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

from typing_extensions import Annotated
from datetime import datetime

from pydantic.v1 import Field, StrictInt, constr, validator

from typing import Optional

from finbourne_access.models.generate_policy_from_template_request import GeneratePolicyFromTemplateRequest
from finbourne_access.models.generated_policy_components import GeneratedPolicyComponents
from finbourne_access.models.policy_template_creation_request import PolicyTemplateCreationRequest
from finbourne_access.models.policy_template_response import PolicyTemplateResponse
from finbourne_access.models.policy_template_update_request import PolicyTemplateUpdateRequest
from finbourne_access.models.resource_list_of_policy_template_response import ResourceListOfPolicyTemplateResponse

from finbourne_access.api_client import ApiClient
from finbourne_access.api_response import ApiResponse
from finbourne_access.exceptions import (  # noqa: F401
    ApiTypeError,
    ApiValueError
)
from finbourne_access.extensions.configuration_options import ConfigurationOptions


class PolicyTemplatesApi:
    """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

    @overload
    async def create_policy_template(self, policy_template_creation_request : Annotated[PolicyTemplateCreationRequest, Field(..., description="The definition of the policy template")], **kwargs) -> PolicyTemplateResponse:  # noqa: E501
        ...

    @overload
    def create_policy_template(self, policy_template_creation_request : Annotated[PolicyTemplateCreationRequest, Field(..., description="The definition of the policy template")], async_req: Optional[bool]=True, **kwargs) -> PolicyTemplateResponse:  # noqa: E501
        ...

    @validate_arguments
    def create_policy_template(self, policy_template_creation_request : Annotated[PolicyTemplateCreationRequest, Field(..., description="The definition of the policy template")], async_req: Optional[bool]=None, **kwargs) -> Union[PolicyTemplateResponse, Awaitable[PolicyTemplateResponse]]:  # noqa: E501
        """[EXPERIMENTAL] CreatePolicyTemplate: Create a Policy Template  # noqa: E501

        Creates a Policy Template  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.create_policy_template(policy_template_creation_request, async_req=True)
        >>> result = thread.get()

        :param policy_template_creation_request: The definition of the policy template (required)
        :type policy_template_creation_request: PolicyTemplateCreationRequest
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _request_timeout: Timeout setting. Do not use - use the opts parameter instead
        :param opts: Configuration options for this request
        :type opts: ConfigurationOptions, optional
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: PolicyTemplateResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the create_policy_template_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        if async_req is not None:
            kwargs['async_req'] = async_req
        return self.create_policy_template_with_http_info(policy_template_creation_request, **kwargs)  # noqa: E501

    @validate_arguments
    def create_policy_template_with_http_info(self, policy_template_creation_request : Annotated[PolicyTemplateCreationRequest, Field(..., description="The definition of the policy template")], **kwargs) -> ApiResponse:  # noqa: E501
        """[EXPERIMENTAL] CreatePolicyTemplate: Create a Policy Template  # noqa: E501

        Creates a Policy Template  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.create_policy_template_with_http_info(policy_template_creation_request, async_req=True)
        >>> result = thread.get()

        :param policy_template_creation_request: The definition of the policy template (required)
        :type policy_template_creation_request: PolicyTemplateCreationRequest
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :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. Do not use - use the opts parameter instead
        :param opts: Configuration options for this request
        :type opts: ConfigurationOptions, 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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(PolicyTemplateResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'policy_template_creation_request'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers',
                'opts'
            ]
        )

        # 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_policy_template" % _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['policy_template_creation_request'] is not None:
            _body_params = _params['policy_template_creation_request']

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['text/plain', 'application/json', 'text/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-patch+json', 'application/json', 'text/json', 'application/*+json']))
        if _content_types_list:
                _header_params['Content-Type'] = _content_types_list

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

        _response_types_map = {
            '201': "PolicyTemplateResponse",
            '400': "LusidValidationProblemDetails",
        }

        return self.api_client.call_api(
            '/api/policytemplates', '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'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            opts=_params.get('opts'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @overload
    async def delete_policy_template(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Policy Template")], scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. Will use the default scope if not provided. The scope of the Policy Template")] = None, **kwargs) -> None:  # noqa: E501
        ...

    @overload
    def delete_policy_template(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Policy Template")], scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. Will use the default scope if not provided. The scope of the Policy Template")] = None, async_req: Optional[bool]=True, **kwargs) -> None:  # noqa: E501
        ...

    @validate_arguments
    def delete_policy_template(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Policy Template")], scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. Will use the default scope if not provided. The scope of the Policy Template")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[None, Awaitable[None]]:  # noqa: E501
        """[EXPERIMENTAL] DeletePolicyTemplate: Deleting a policy template  # noqa: E501

        Deletes an identified Policy Template  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.delete_policy_template(code, scope, async_req=True)
        >>> result = thread.get()

        :param code: The code of the Policy Template (required)
        :type code: str
        :param scope: Optional. Will use the default scope if not provided. The scope of the Policy Template
        :type scope: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _request_timeout: Timeout setting. Do not use - use the opts parameter instead
        :param opts: Configuration options for this request
        :type opts: ConfigurationOptions, optional
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: None
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the delete_policy_template_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        if async_req is not None:
            kwargs['async_req'] = async_req
        return self.delete_policy_template_with_http_info(code, scope, **kwargs)  # noqa: E501

    @validate_arguments
    def delete_policy_template_with_http_info(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Policy Template")], scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. Will use the default scope if not provided. The scope of the Policy Template")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """[EXPERIMENTAL] DeletePolicyTemplate: Deleting a policy template  # noqa: E501

        Deletes an identified Policy Template  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.delete_policy_template_with_http_info(code, scope, async_req=True)
        >>> result = thread.get()

        :param code: The code of the Policy Template (required)
        :type code: str
        :param scope: Optional. Will use the default scope if not provided. The scope of the Policy Template
        :type scope: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :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. Do not use - use the opts parameter instead
        :param opts: Configuration options for this request
        :type opts: ConfigurationOptions, 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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: None
        """

        _params = locals()

        _all_params = [
            'code',
            'scope'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers',
                'opts'
            ]
        )

        # 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 delete_policy_template" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['code']:
            _path_params['code'] = _params['code']


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

        # 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(
            ['text/plain', 'application/json', 'text/json'])  # noqa: E501

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

        _response_types_map = {}

        return self.api_client.call_api(
            '/api/policytemplates/{code}', '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,
            async_req=_params.get('async_req'),
            _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'),
            opts=_params.get('opts'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @overload
    async def generate_policy_from_template(self, generate_policy_from_template_request : Annotated[GeneratePolicyFromTemplateRequest, Field(..., description="Definition of the generate request")], as_at : Annotated[Optional[datetime], Field(description="Optional. The AsAt date time of the data")] = None, **kwargs) -> GeneratedPolicyComponents:  # noqa: E501
        ...

    @overload
    def generate_policy_from_template(self, generate_policy_from_template_request : Annotated[GeneratePolicyFromTemplateRequest, Field(..., description="Definition of the generate request")], as_at : Annotated[Optional[datetime], Field(description="Optional. The AsAt date time of the data")] = None, async_req: Optional[bool]=True, **kwargs) -> GeneratedPolicyComponents:  # noqa: E501
        ...

    @validate_arguments
    def generate_policy_from_template(self, generate_policy_from_template_request : Annotated[GeneratePolicyFromTemplateRequest, Field(..., description="Definition of the generate request")], as_at : Annotated[Optional[datetime], Field(description="Optional. The AsAt date time of the data")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[GeneratedPolicyComponents, Awaitable[GeneratedPolicyComponents]]:  # noqa: E501
        """[EXPERIMENTAL] GeneratePolicyFromTemplate: Generate policy from template  # noqa: E501

        Generates policies from templates  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.generate_policy_from_template(generate_policy_from_template_request, as_at, async_req=True)
        >>> result = thread.get()

        :param generate_policy_from_template_request: Definition of the generate request (required)
        :type generate_policy_from_template_request: GeneratePolicyFromTemplateRequest
        :param as_at: Optional. The AsAt date time of the data
        :type as_at: datetime
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _request_timeout: Timeout setting. Do not use - use the opts parameter instead
        :param opts: Configuration options for this request
        :type opts: ConfigurationOptions, optional
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: GeneratedPolicyComponents
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the generate_policy_from_template_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        if async_req is not None:
            kwargs['async_req'] = async_req
        return self.generate_policy_from_template_with_http_info(generate_policy_from_template_request, as_at, **kwargs)  # noqa: E501

    @validate_arguments
    def generate_policy_from_template_with_http_info(self, generate_policy_from_template_request : Annotated[GeneratePolicyFromTemplateRequest, Field(..., description="Definition of the generate request")], as_at : Annotated[Optional[datetime], Field(description="Optional. The AsAt date time of the data")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """[EXPERIMENTAL] GeneratePolicyFromTemplate: Generate policy from template  # noqa: E501

        Generates policies from templates  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.generate_policy_from_template_with_http_info(generate_policy_from_template_request, as_at, async_req=True)
        >>> result = thread.get()

        :param generate_policy_from_template_request: Definition of the generate request (required)
        :type generate_policy_from_template_request: GeneratePolicyFromTemplateRequest
        :param as_at: Optional. The AsAt date time of the data
        :type as_at: datetime
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :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. Do not use - use the opts parameter instead
        :param opts: Configuration options for this request
        :type opts: ConfigurationOptions, 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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(GeneratedPolicyComponents, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'generate_policy_from_template_request',
            'as_at'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers',
                'opts'
            ]
        )

        # 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 generate_policy_from_template" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # process the query parameters
        _query_params = []
        if _params.get('as_at') is not None:  # noqa: E501
            if isinstance(_params['as_at'], datetime):
                _query_params.append(('asAt', _params['as_at'].strftime(self.api_client.configuration.datetime_format)))
            else:
                _query_params.append(('asAt', _params['as_at']))

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

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['text/plain', 'application/json', 'text/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-patch+json', 'application/json', 'text/json', 'application/*+json']))
        if _content_types_list:
                _header_params['Content-Type'] = _content_types_list

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

        _response_types_map = {
            '200': "GeneratedPolicyComponents",
            '400': "LusidValidationProblemDetails",
        }

        return self.api_client.call_api(
            '/api/policytemplates/$generatepolicy', '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'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            opts=_params.get('opts'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @overload
    async def get_policy_template(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Policy Template")], as_at : Annotated[Optional[datetime], Field(description="Optional. The AsAt date time of the data. If not specified defaults to current time")] = None, scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. Will use the default scope if not provided. The scope of the Policy Template")] = None, **kwargs) -> PolicyTemplateResponse:  # noqa: E501
        ...

    @overload
    def get_policy_template(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Policy Template")], as_at : Annotated[Optional[datetime], Field(description="Optional. The AsAt date time of the data. If not specified defaults to current time")] = None, scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. Will use the default scope if not provided. The scope of the Policy Template")] = None, async_req: Optional[bool]=True, **kwargs) -> PolicyTemplateResponse:  # noqa: E501
        ...

    @validate_arguments
    def get_policy_template(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Policy Template")], as_at : Annotated[Optional[datetime], Field(description="Optional. The AsAt date time of the data. If not specified defaults to current time")] = None, scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. Will use the default scope if not provided. The scope of the Policy Template")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[PolicyTemplateResponse, Awaitable[PolicyTemplateResponse]]:  # noqa: E501
        """[EXPERIMENTAL] GetPolicyTemplate: Retrieving one Policy Template  # noqa: E501

        Gets an identified Policy Template  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.get_policy_template(code, as_at, scope, async_req=True)
        >>> result = thread.get()

        :param code: The code of the Policy Template (required)
        :type code: str
        :param as_at: Optional. The AsAt date time of the data. If not specified defaults to current time
        :type as_at: datetime
        :param scope: Optional. Will use the default scope if not provided. The scope of the Policy Template
        :type scope: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _request_timeout: Timeout setting. Do not use - use the opts parameter instead
        :param opts: Configuration options for this request
        :type opts: ConfigurationOptions, optional
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: PolicyTemplateResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the get_policy_template_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        if async_req is not None:
            kwargs['async_req'] = async_req
        return self.get_policy_template_with_http_info(code, as_at, scope, **kwargs)  # noqa: E501

    @validate_arguments
    def get_policy_template_with_http_info(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Policy Template")], as_at : Annotated[Optional[datetime], Field(description="Optional. The AsAt date time of the data. If not specified defaults to current time")] = None, scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. Will use the default scope if not provided. The scope of the Policy Template")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """[EXPERIMENTAL] GetPolicyTemplate: Retrieving one Policy Template  # noqa: E501

        Gets an identified Policy Template  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.get_policy_template_with_http_info(code, as_at, scope, async_req=True)
        >>> result = thread.get()

        :param code: The code of the Policy Template (required)
        :type code: str
        :param as_at: Optional. The AsAt date time of the data. If not specified defaults to current time
        :type as_at: datetime
        :param scope: Optional. Will use the default scope if not provided. The scope of the Policy Template
        :type scope: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :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. Do not use - use the opts parameter instead
        :param opts: Configuration options for this request
        :type opts: ConfigurationOptions, 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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(PolicyTemplateResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'code',
            'as_at',
            'scope'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers',
                'opts'
            ]
        )

        # 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_policy_template" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['code']:
            _path_params['code'] = _params['code']


        # process the query parameters
        _query_params = []
        if _params.get('as_at') is not None:  # noqa: E501
            if isinstance(_params['as_at'], datetime):
                _query_params.append(('asAt', _params['as_at'].strftime(self.api_client.configuration.datetime_format)))
            else:
                _query_params.append(('asAt', _params['as_at']))

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

        # 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(
            ['text/plain', 'application/json', 'text/json'])  # noqa: E501

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

        _response_types_map = {
            '200': "PolicyTemplateResponse",
            '400': "LusidValidationProblemDetails",
        }

        return self.api_client.call_api(
            '/api/policytemplates/{code}', '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'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            opts=_params.get('opts'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @overload
    async def list_policy_templates(self, as_at : Annotated[Optional[datetime], Field(description="Optional. The AsAt date time of the data")] = None, sort_by : Annotated[Optional[constr(strict=True, max_length=16384, min_length=1)], Field(description="Optional. Order the results by these fields. Use use the '-' sign to denote descending order e.g. -MyFieldName")] = None, limit : Annotated[Optional[StrictInt], Field(description="Optional. When paginating, limit the number of returned results to this many.")] = None, filter : Annotated[Optional[constr(strict=True, max_length=16384, min_length=0)], Field(description="Optional. Expression to filter the result set")] = None, page : Annotated[Optional[constr(strict=True, max_length=500, min_length=1)], Field(description="Optional. Paging token returned from a previous result")] = None, **kwargs) -> ResourceListOfPolicyTemplateResponse:  # noqa: E501
        ...

    @overload
    def list_policy_templates(self, as_at : Annotated[Optional[datetime], Field(description="Optional. The AsAt date time of the data")] = None, sort_by : Annotated[Optional[constr(strict=True, max_length=16384, min_length=1)], Field(description="Optional. Order the results by these fields. Use use the '-' sign to denote descending order e.g. -MyFieldName")] = None, limit : Annotated[Optional[StrictInt], Field(description="Optional. When paginating, limit the number of returned results to this many.")] = None, filter : Annotated[Optional[constr(strict=True, max_length=16384, min_length=0)], Field(description="Optional. Expression to filter the result set")] = None, page : Annotated[Optional[constr(strict=True, max_length=500, min_length=1)], Field(description="Optional. Paging token returned from a previous result")] = None, async_req: Optional[bool]=True, **kwargs) -> ResourceListOfPolicyTemplateResponse:  # noqa: E501
        ...

    @validate_arguments
    def list_policy_templates(self, as_at : Annotated[Optional[datetime], Field(description="Optional. The AsAt date time of the data")] = None, sort_by : Annotated[Optional[constr(strict=True, max_length=16384, min_length=1)], Field(description="Optional. Order the results by these fields. Use use the '-' sign to denote descending order e.g. -MyFieldName")] = None, limit : Annotated[Optional[StrictInt], Field(description="Optional. When paginating, limit the number of returned results to this many.")] = None, filter : Annotated[Optional[constr(strict=True, max_length=16384, min_length=0)], Field(description="Optional. Expression to filter the result set")] = None, page : Annotated[Optional[constr(strict=True, max_length=500, min_length=1)], Field(description="Optional. Paging token returned from a previous result")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[ResourceListOfPolicyTemplateResponse, Awaitable[ResourceListOfPolicyTemplateResponse]]:  # noqa: E501
        """[EXPERIMENTAL] ListPolicyTemplates: List Policy Templates  # noqa: E501

        Gets all Policy Templates with pagination support.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.list_policy_templates(as_at, sort_by, limit, filter, page, async_req=True)
        >>> result = thread.get()

        :param as_at: Optional. The AsAt date time of the data
        :type as_at: datetime
        :param sort_by: Optional. Order the results by these fields. Use use the '-' sign to denote descending order e.g. -MyFieldName
        :type sort_by: str
        :param limit: Optional. When paginating, limit the number of returned results to this many.
        :type limit: int
        :param filter: Optional. Expression to filter the result set
        :type filter: str
        :param page: Optional. Paging token returned from a previous result
        :type page: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _request_timeout: Timeout setting. Do not use - use the opts parameter instead
        :param opts: Configuration options for this request
        :type opts: ConfigurationOptions, optional
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: ResourceListOfPolicyTemplateResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the list_policy_templates_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        if async_req is not None:
            kwargs['async_req'] = async_req
        return self.list_policy_templates_with_http_info(as_at, sort_by, limit, filter, page, **kwargs)  # noqa: E501

    @validate_arguments
    def list_policy_templates_with_http_info(self, as_at : Annotated[Optional[datetime], Field(description="Optional. The AsAt date time of the data")] = None, sort_by : Annotated[Optional[constr(strict=True, max_length=16384, min_length=1)], Field(description="Optional. Order the results by these fields. Use use the '-' sign to denote descending order e.g. -MyFieldName")] = None, limit : Annotated[Optional[StrictInt], Field(description="Optional. When paginating, limit the number of returned results to this many.")] = None, filter : Annotated[Optional[constr(strict=True, max_length=16384, min_length=0)], Field(description="Optional. Expression to filter the result set")] = None, page : Annotated[Optional[constr(strict=True, max_length=500, min_length=1)], Field(description="Optional. Paging token returned from a previous result")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """[EXPERIMENTAL] ListPolicyTemplates: List Policy Templates  # noqa: E501

        Gets all Policy Templates with pagination support.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.list_policy_templates_with_http_info(as_at, sort_by, limit, filter, page, async_req=True)
        >>> result = thread.get()

        :param as_at: Optional. The AsAt date time of the data
        :type as_at: datetime
        :param sort_by: Optional. Order the results by these fields. Use use the '-' sign to denote descending order e.g. -MyFieldName
        :type sort_by: str
        :param limit: Optional. When paginating, limit the number of returned results to this many.
        :type limit: int
        :param filter: Optional. Expression to filter the result set
        :type filter: str
        :param page: Optional. Paging token returned from a previous result
        :type page: str
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :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. Do not use - use the opts parameter instead
        :param opts: Configuration options for this request
        :type opts: ConfigurationOptions, 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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(ResourceListOfPolicyTemplateResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'as_at',
            'sort_by',
            'limit',
            'filter',
            'page'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers',
                'opts'
            ]
        )

        # 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 list_policy_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('as_at') is not None:  # noqa: E501
            if isinstance(_params['as_at'], datetime):
                _query_params.append(('asAt', _params['as_at'].strftime(self.api_client.configuration.datetime_format)))
            else:
                _query_params.append(('asAt', _params['as_at']))

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

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

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

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

        # 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(
            ['text/plain', 'application/json', 'text/json'])  # noqa: E501

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

        _response_types_map = {
            '200': "ResourceListOfPolicyTemplateResponse",
            '400': "LusidValidationProblemDetails",
        }

        return self.api_client.call_api(
            '/api/policytemplates', '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'),  # noqa: E501
            _preload_content=_params.get('_preload_content', True),
            _request_timeout=_params.get('_request_timeout'),
            opts=_params.get('opts'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))

    @overload
    async def update_policy_template(self, code : Annotated[constr(strict=True), Field(..., description="Code of the policy template to update")], policy_template_update_request : Annotated[Optional[PolicyTemplateUpdateRequest], Field(description="Definition of the updated policy template")] = None, **kwargs) -> PolicyTemplateResponse:  # noqa: E501
        ...

    @overload
    def update_policy_template(self, code : Annotated[constr(strict=True), Field(..., description="Code of the policy template to update")], policy_template_update_request : Annotated[Optional[PolicyTemplateUpdateRequest], Field(description="Definition of the updated policy template")] = None, async_req: Optional[bool]=True, **kwargs) -> PolicyTemplateResponse:  # noqa: E501
        ...

    @validate_arguments
    def update_policy_template(self, code : Annotated[constr(strict=True), Field(..., description="Code of the policy template to update")], policy_template_update_request : Annotated[Optional[PolicyTemplateUpdateRequest], Field(description="Definition of the updated policy template")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[PolicyTemplateResponse, Awaitable[PolicyTemplateResponse]]:  # noqa: E501
        """[EXPERIMENTAL] UpdatePolicyTemplate: Update a Policy Template  # noqa: E501

        Updates an identified Policy Template  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.update_policy_template(code, policy_template_update_request, async_req=True)
        >>> result = thread.get()

        :param code: Code of the policy template to update (required)
        :type code: str
        :param policy_template_update_request: Definition of the updated policy template
        :type policy_template_update_request: PolicyTemplateUpdateRequest
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :param _request_timeout: Timeout setting. Do not use - use the opts parameter instead
        :param opts: Configuration options for this request
        :type opts: ConfigurationOptions, optional
        :return: Returns the result object.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: PolicyTemplateResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the update_policy_template_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data"  # noqa: E501
            raise ValueError(message)
        if async_req is not None:
            kwargs['async_req'] = async_req
        return self.update_policy_template_with_http_info(code, policy_template_update_request, **kwargs)  # noqa: E501

    @validate_arguments
    def update_policy_template_with_http_info(self, code : Annotated[constr(strict=True), Field(..., description="Code of the policy template to update")], policy_template_update_request : Annotated[Optional[PolicyTemplateUpdateRequest], Field(description="Definition of the updated policy template")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """[EXPERIMENTAL] UpdatePolicyTemplate: Update a Policy Template  # noqa: E501

        Updates an identified Policy Template  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.update_policy_template_with_http_info(code, policy_template_update_request, async_req=True)
        >>> result = thread.get()

        :param code: Code of the policy template to update (required)
        :type code: str
        :param policy_template_update_request: Definition of the updated policy template
        :type policy_template_update_request: PolicyTemplateUpdateRequest
        :param async_req: Whether to execute the request asynchronously.
        :type async_req: bool, optional
        :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. Do not use - use the opts parameter instead
        :param opts: Configuration options for this request
        :type opts: ConfigurationOptions, 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.
                 If the method is called asynchronously,
                 returns the request thread.
        :rtype: tuple(PolicyTemplateResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'code',
            'policy_template_update_request'
        ]
        _all_params.extend(
            [
                'async_req',
                '_return_http_data_only',
                '_preload_content',
                '_request_timeout',
                '_request_auth',
                '_content_type',
                '_headers',
                'opts'
            ]
        )

        # 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 update_policy_template" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

        # process the path parameters
        _path_params = {}
        if _params['code']:
            _path_params['code'] = _params['code']


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

        # set the HTTP header `Accept`
        _header_params['Accept'] = self.api_client.select_header_accept(
            ['text/plain', 'application/json', 'text/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-patch+json', 'application/json', 'text/json', 'application/*+json']))
        if _content_types_list:
                _header_params['Content-Type'] = _content_types_list

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

        _response_types_map = {
            '200': "PolicyTemplateResponse",
            '400': "LusidValidationProblemDetails",
        }

        return self.api_client.call_api(
            '/api/policytemplates/{code}', '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,
            async_req=_params.get('async_req'),
            _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'),
            opts=_params.get('opts'),
            collection_formats=_collection_formats,
            _request_auth=_params.get('_request_auth'))
