# coding: utf-8

"""
    LUSID 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 datetime import datetime
from pydantic.v1 import Field, StrictInt, StrictStr
from typing import Dict, Optional
from typing_extensions import Annotated
from lusid.models.batch_delete_relational_data_response import BatchDeleteRelationalDataResponse
from lusid.models.batch_upsert_relational_datasets_response import BatchUpsertRelationalDatasetsResponse
from lusid.models.delete_relational_data_point_request import DeleteRelationalDataPointRequest
from lusid.models.paged_resource_list_of_relational_data_point_response import PagedResourceListOfRelationalDataPointResponse
from lusid.models.query_relational_dataset_request import QueryRelationalDatasetRequest
from lusid.models.upsert_relational_data_point_request import UpsertRelationalDataPointRequest

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

# ensure templated type usages are imported
from pydantic.v1 import Field, StrictStr
from typing import Optional
from typing_extensions import Annotated

class RelationalDatasetsApi:
    """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 batch_delete_relational_data(self, relational_dataset_definition_scope : Annotated[StrictStr, Field(..., description="The Scope of the relational dataset definition.")], relational_dataset_definition_code : Annotated[StrictStr, Field(..., description="The Code of the relational dataset definition.")], request_body : Annotated[Dict[str, DeleteRelationalDataPointRequest], Field(description="The Delete Request.")], success_mode : Annotated[Optional[StrictStr], Field( description="Whether the batch request should fail Atomically or in a Partial fashion - Allowed Values: Atomic, Partial.              Note: If using partial failure modes, then it is important to check the response body for failures as any failures will still return a 200 status code.")] = None, **kwargs) -> BatchDeleteRelationalDataResponse:  # noqa: E501
        ...

    @overload
    def batch_delete_relational_data(self, relational_dataset_definition_scope : Annotated[StrictStr, Field(..., description="The Scope of the relational dataset definition.")], relational_dataset_definition_code : Annotated[StrictStr, Field(..., description="The Code of the relational dataset definition.")], request_body : Annotated[Dict[str, DeleteRelationalDataPointRequest], Field(description="The Delete Request.")], success_mode : Annotated[Optional[StrictStr], Field( description="Whether the batch request should fail Atomically or in a Partial fashion - Allowed Values: Atomic, Partial.              Note: If using partial failure modes, then it is important to check the response body for failures as any failures will still return a 200 status code.")] = None, async_req: Optional[bool]=True, **kwargs) -> BatchDeleteRelationalDataResponse:  # noqa: E501
        ...

    @validate_arguments
    def batch_delete_relational_data(self, relational_dataset_definition_scope : Annotated[StrictStr, Field(..., description="The Scope of the relational dataset definition.")], relational_dataset_definition_code : Annotated[StrictStr, Field(..., description="The Code of the relational dataset definition.")], request_body : Annotated[Dict[str, DeleteRelationalDataPointRequest], Field(description="The Delete Request.")], success_mode : Annotated[Optional[StrictStr], Field( description="Whether the batch request should fail Atomically or in a Partial fashion - Allowed Values: Atomic, Partial.              Note: If using partial failure modes, then it is important to check the response body for failures as any failures will still return a 200 status code.")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[BatchDeleteRelationalDataResponse, Awaitable[BatchDeleteRelationalDataResponse]]:  # noqa: E501
        """[EXPERIMENTAL] BatchDeleteRelationalData: Batch Delete Relational Data Points for a given Relational Dataset Definition.  # noqa: E501

        Batch Delete Relational Data Points for a given Relational Dataset Definition.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.batch_delete_relational_data(relational_dataset_definition_scope, relational_dataset_definition_code, request_body, success_mode, async_req=True)
        >>> result = thread.get()

        :param relational_dataset_definition_scope: The Scope of the relational dataset definition. (required)
        :type relational_dataset_definition_scope: str
        :param relational_dataset_definition_code: The Code of the relational dataset definition. (required)
        :type relational_dataset_definition_code: str
        :param request_body: The Delete Request. (required)
        :type request_body: Dict[str, DeleteRelationalDataPointRequest]
        :param success_mode: Whether the batch request should fail Atomically or in a Partial fashion - Allowed Values: Atomic, Partial.              Note: If using partial failure modes, then it is important to check the response body for failures as any failures will still return a 200 status code.
        :type success_mode: 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: BatchDeleteRelationalDataResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the batch_delete_relational_data_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.batch_delete_relational_data_with_http_info(relational_dataset_definition_scope, relational_dataset_definition_code, request_body, success_mode, **kwargs)  # noqa: E501

    @validate_arguments
    def batch_delete_relational_data_with_http_info(self, relational_dataset_definition_scope : Annotated[StrictStr, Field(..., description="The Scope of the relational dataset definition.")], relational_dataset_definition_code : Annotated[StrictStr, Field(..., description="The Code of the relational dataset definition.")], request_body : Annotated[Dict[str, DeleteRelationalDataPointRequest], Field(description="The Delete Request.")], success_mode : Annotated[Optional[StrictStr], Field( description="Whether the batch request should fail Atomically or in a Partial fashion - Allowed Values: Atomic, Partial.              Note: If using partial failure modes, then it is important to check the response body for failures as any failures will still return a 200 status code.")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """[EXPERIMENTAL] BatchDeleteRelationalData: Batch Delete Relational Data Points for a given Relational Dataset Definition.  # noqa: E501

        Batch Delete Relational Data Points for a given Relational Dataset Definition.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.batch_delete_relational_data_with_http_info(relational_dataset_definition_scope, relational_dataset_definition_code, request_body, success_mode, async_req=True)
        >>> result = thread.get()

        :param relational_dataset_definition_scope: The Scope of the relational dataset definition. (required)
        :type relational_dataset_definition_scope: str
        :param relational_dataset_definition_code: The Code of the relational dataset definition. (required)
        :type relational_dataset_definition_code: str
        :param request_body: The Delete Request. (required)
        :type request_body: Dict[str, DeleteRelationalDataPointRequest]
        :param success_mode: Whether the batch request should fail Atomically or in a Partial fashion - Allowed Values: Atomic, Partial.              Note: If using partial failure modes, then it is important to check the response body for failures as any failures will still return a 200 status code.
        :type success_mode: 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(BatchDeleteRelationalDataResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'relational_dataset_definition_scope',
            'relational_dataset_definition_code',
            'request_body',
            'success_mode'
        ]
        _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 batch_delete_relational_data" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

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

        if _params['relational_dataset_definition_code']:
            _path_params['relationalDatasetDefinitionCode'] = _params['relational_dataset_definition_code']


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

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

        # 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': "BatchDeleteRelationalDataResponse",
            '400': "LusidValidationProblemDetails",
        }

        return self.api_client.call_api(
            '/api/relationaldatasets/{relationalDatasetDefinitionScope}/{relationalDatasetDefinitionCode}/$batchDelete', '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 batch_upsert_relational_data(self, relational_dataset_definition_scope : Annotated[StrictStr, Field(..., description="The Scope of the relational dataset definition.")], relational_dataset_definition_code : Annotated[StrictStr, Field(..., description="The Code of the relational dataset definition.")], request_body : Annotated[Dict[str, UpsertRelationalDataPointRequest], Field(description="The DataPoints to upsert.")], success_mode : Annotated[Optional[StrictStr], Field( description="Whether the batch request should fail Atomically or in a Partial fashion - Allowed Values: Atomic, Partial.              Note: If using partial failure modes, then it is important to check the response body for failures as any failures will still return a 200 status code.")] = None, **kwargs) -> BatchUpsertRelationalDatasetsResponse:  # noqa: E501
        ...

    @overload
    def batch_upsert_relational_data(self, relational_dataset_definition_scope : Annotated[StrictStr, Field(..., description="The Scope of the relational dataset definition.")], relational_dataset_definition_code : Annotated[StrictStr, Field(..., description="The Code of the relational dataset definition.")], request_body : Annotated[Dict[str, UpsertRelationalDataPointRequest], Field(description="The DataPoints to upsert.")], success_mode : Annotated[Optional[StrictStr], Field( description="Whether the batch request should fail Atomically or in a Partial fashion - Allowed Values: Atomic, Partial.              Note: If using partial failure modes, then it is important to check the response body for failures as any failures will still return a 200 status code.")] = None, async_req: Optional[bool]=True, **kwargs) -> BatchUpsertRelationalDatasetsResponse:  # noqa: E501
        ...

    @validate_arguments
    def batch_upsert_relational_data(self, relational_dataset_definition_scope : Annotated[StrictStr, Field(..., description="The Scope of the relational dataset definition.")], relational_dataset_definition_code : Annotated[StrictStr, Field(..., description="The Code of the relational dataset definition.")], request_body : Annotated[Dict[str, UpsertRelationalDataPointRequest], Field(description="The DataPoints to upsert.")], success_mode : Annotated[Optional[StrictStr], Field( description="Whether the batch request should fail Atomically or in a Partial fashion - Allowed Values: Atomic, Partial.              Note: If using partial failure modes, then it is important to check the response body for failures as any failures will still return a 200 status code.")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[BatchUpsertRelationalDatasetsResponse, Awaitable[BatchUpsertRelationalDatasetsResponse]]:  # noqa: E501
        """[EXPERIMENTAL] BatchUpsertRelationalData: Batch Upsert Relational Data Points for a given Relational Dataset Definition.  # noqa: E501

        Batch Upsert Relational Data Points for a given Relational Dataset Definition.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.batch_upsert_relational_data(relational_dataset_definition_scope, relational_dataset_definition_code, request_body, success_mode, async_req=True)
        >>> result = thread.get()

        :param relational_dataset_definition_scope: The Scope of the relational dataset definition. (required)
        :type relational_dataset_definition_scope: str
        :param relational_dataset_definition_code: The Code of the relational dataset definition. (required)
        :type relational_dataset_definition_code: str
        :param request_body: The DataPoints to upsert. (required)
        :type request_body: Dict[str, UpsertRelationalDataPointRequest]
        :param success_mode: Whether the batch request should fail Atomically or in a Partial fashion - Allowed Values: Atomic, Partial.              Note: If using partial failure modes, then it is important to check the response body for failures as any failures will still return a 200 status code.
        :type success_mode: 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: BatchUpsertRelationalDatasetsResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the batch_upsert_relational_data_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.batch_upsert_relational_data_with_http_info(relational_dataset_definition_scope, relational_dataset_definition_code, request_body, success_mode, **kwargs)  # noqa: E501

    @validate_arguments
    def batch_upsert_relational_data_with_http_info(self, relational_dataset_definition_scope : Annotated[StrictStr, Field(..., description="The Scope of the relational dataset definition.")], relational_dataset_definition_code : Annotated[StrictStr, Field(..., description="The Code of the relational dataset definition.")], request_body : Annotated[Dict[str, UpsertRelationalDataPointRequest], Field(description="The DataPoints to upsert.")], success_mode : Annotated[Optional[StrictStr], Field( description="Whether the batch request should fail Atomically or in a Partial fashion - Allowed Values: Atomic, Partial.              Note: If using partial failure modes, then it is important to check the response body for failures as any failures will still return a 200 status code.")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """[EXPERIMENTAL] BatchUpsertRelationalData: Batch Upsert Relational Data Points for a given Relational Dataset Definition.  # noqa: E501

        Batch Upsert Relational Data Points for a given Relational Dataset Definition.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.batch_upsert_relational_data_with_http_info(relational_dataset_definition_scope, relational_dataset_definition_code, request_body, success_mode, async_req=True)
        >>> result = thread.get()

        :param relational_dataset_definition_scope: The Scope of the relational dataset definition. (required)
        :type relational_dataset_definition_scope: str
        :param relational_dataset_definition_code: The Code of the relational dataset definition. (required)
        :type relational_dataset_definition_code: str
        :param request_body: The DataPoints to upsert. (required)
        :type request_body: Dict[str, UpsertRelationalDataPointRequest]
        :param success_mode: Whether the batch request should fail Atomically or in a Partial fashion - Allowed Values: Atomic, Partial.              Note: If using partial failure modes, then it is important to check the response body for failures as any failures will still return a 200 status code.
        :type success_mode: 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(BatchUpsertRelationalDatasetsResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'relational_dataset_definition_scope',
            'relational_dataset_definition_code',
            'request_body',
            'success_mode'
        ]
        _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 batch_upsert_relational_data" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

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

        if _params['relational_dataset_definition_code']:
            _path_params['relationalDatasetDefinitionCode'] = _params['relational_dataset_definition_code']


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

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

        # 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': "BatchUpsertRelationalDatasetsResponse",
            '400': "LusidValidationProblemDetails",
        }

        return self.api_client.call_api(
            '/api/relationaldatasets/{relationalDatasetDefinitionScope}/{relationalDatasetDefinitionCode}/$batchUpsert', '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 query_relational_data(self, relational_dataset_definition_scope : Annotated[StrictStr, Field(..., description="The Scope of the relational dataset definition.")], relational_dataset_definition_code : Annotated[StrictStr, Field(..., description="The Code of the relational dataset definition.")], as_at : Annotated[Optional[datetime], Field(description="The asAt datetime at which to retrieve the dataset(s). Defaults to returning the latest version of each dataset if not specified.")] = None, effective_at : Annotated[Optional[StrictStr], Field( description="The effective datetime or cut label at which to query the datasets.              Defaults to the current LUSID system datetime if not specified.")] = None, page : Annotated[Optional[StrictStr], Field( description="The pagination token to use to continue query datasets. This value is returned from the previous call.              If a pagination token is provided, the filter, customSortBy, effectiveAt and asAt fields must not have changed since the original request.")] = None, limit : Annotated[Optional[StrictInt], Field(description="When paginating, limit the results to this number. Defaults to 100 if not specified.")] = None, query_relational_dataset_request : Annotated[Optional[QueryRelationalDatasetRequest], Field(description="The query request.")] = None, **kwargs) -> PagedResourceListOfRelationalDataPointResponse:  # noqa: E501
        ...

    @overload
    def query_relational_data(self, relational_dataset_definition_scope : Annotated[StrictStr, Field(..., description="The Scope of the relational dataset definition.")], relational_dataset_definition_code : Annotated[StrictStr, Field(..., description="The Code of the relational dataset definition.")], as_at : Annotated[Optional[datetime], Field(description="The asAt datetime at which to retrieve the dataset(s). Defaults to returning the latest version of each dataset if not specified.")] = None, effective_at : Annotated[Optional[StrictStr], Field( description="The effective datetime or cut label at which to query the datasets.              Defaults to the current LUSID system datetime if not specified.")] = None, page : Annotated[Optional[StrictStr], Field( description="The pagination token to use to continue query datasets. This value is returned from the previous call.              If a pagination token is provided, the filter, customSortBy, effectiveAt and asAt fields must not have changed since the original request.")] = None, limit : Annotated[Optional[StrictInt], Field(description="When paginating, limit the results to this number. Defaults to 100 if not specified.")] = None, query_relational_dataset_request : Annotated[Optional[QueryRelationalDatasetRequest], Field(description="The query request.")] = None, async_req: Optional[bool]=True, **kwargs) -> PagedResourceListOfRelationalDataPointResponse:  # noqa: E501
        ...

    @validate_arguments
    def query_relational_data(self, relational_dataset_definition_scope : Annotated[StrictStr, Field(..., description="The Scope of the relational dataset definition.")], relational_dataset_definition_code : Annotated[StrictStr, Field(..., description="The Code of the relational dataset definition.")], as_at : Annotated[Optional[datetime], Field(description="The asAt datetime at which to retrieve the dataset(s). Defaults to returning the latest version of each dataset if not specified.")] = None, effective_at : Annotated[Optional[StrictStr], Field( description="The effective datetime or cut label at which to query the datasets.              Defaults to the current LUSID system datetime if not specified.")] = None, page : Annotated[Optional[StrictStr], Field( description="The pagination token to use to continue query datasets. This value is returned from the previous call.              If a pagination token is provided, the filter, customSortBy, effectiveAt and asAt fields must not have changed since the original request.")] = None, limit : Annotated[Optional[StrictInt], Field(description="When paginating, limit the results to this number. Defaults to 100 if not specified.")] = None, query_relational_dataset_request : Annotated[Optional[QueryRelationalDatasetRequest], Field(description="The query request.")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[PagedResourceListOfRelationalDataPointResponse, Awaitable[PagedResourceListOfRelationalDataPointResponse]]:  # noqa: E501
        """[EXPERIMENTAL] QueryRelationalData: Query Relational Data Points for a given Relational Dataset Definition.  # noqa: E501

        Query Relational Data Points for a given Relational Dataset Definition.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.query_relational_data(relational_dataset_definition_scope, relational_dataset_definition_code, as_at, effective_at, page, limit, query_relational_dataset_request, async_req=True)
        >>> result = thread.get()

        :param relational_dataset_definition_scope: The Scope of the relational dataset definition. (required)
        :type relational_dataset_definition_scope: str
        :param relational_dataset_definition_code: The Code of the relational dataset definition. (required)
        :type relational_dataset_definition_code: str
        :param as_at: The asAt datetime at which to retrieve the dataset(s). Defaults to returning the latest version of each dataset if not specified.
        :type as_at: datetime
        :param effective_at: The effective datetime or cut label at which to query the datasets.              Defaults to the current LUSID system datetime if not specified.
        :type effective_at: str
        :param page: The pagination token to use to continue query datasets. This value is returned from the previous call.              If a pagination token is provided, the filter, customSortBy, effectiveAt and asAt fields must not have changed since the original request.
        :type page: str
        :param limit: When paginating, limit the results to this number. Defaults to 100 if not specified.
        :type limit: int
        :param query_relational_dataset_request: The query request.
        :type query_relational_dataset_request: QueryRelationalDatasetRequest
        :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: PagedResourceListOfRelationalDataPointResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the query_relational_data_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.query_relational_data_with_http_info(relational_dataset_definition_scope, relational_dataset_definition_code, as_at, effective_at, page, limit, query_relational_dataset_request, **kwargs)  # noqa: E501

    @validate_arguments
    def query_relational_data_with_http_info(self, relational_dataset_definition_scope : Annotated[StrictStr, Field(..., description="The Scope of the relational dataset definition.")], relational_dataset_definition_code : Annotated[StrictStr, Field(..., description="The Code of the relational dataset definition.")], as_at : Annotated[Optional[datetime], Field(description="The asAt datetime at which to retrieve the dataset(s). Defaults to returning the latest version of each dataset if not specified.")] = None, effective_at : Annotated[Optional[StrictStr], Field( description="The effective datetime or cut label at which to query the datasets.              Defaults to the current LUSID system datetime if not specified.")] = None, page : Annotated[Optional[StrictStr], Field( description="The pagination token to use to continue query datasets. This value is returned from the previous call.              If a pagination token is provided, the filter, customSortBy, effectiveAt and asAt fields must not have changed since the original request.")] = None, limit : Annotated[Optional[StrictInt], Field(description="When paginating, limit the results to this number. Defaults to 100 if not specified.")] = None, query_relational_dataset_request : Annotated[Optional[QueryRelationalDatasetRequest], Field(description="The query request.")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """[EXPERIMENTAL] QueryRelationalData: Query Relational Data Points for a given Relational Dataset Definition.  # noqa: E501

        Query Relational Data Points for a given Relational Dataset Definition.  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.query_relational_data_with_http_info(relational_dataset_definition_scope, relational_dataset_definition_code, as_at, effective_at, page, limit, query_relational_dataset_request, async_req=True)
        >>> result = thread.get()

        :param relational_dataset_definition_scope: The Scope of the relational dataset definition. (required)
        :type relational_dataset_definition_scope: str
        :param relational_dataset_definition_code: The Code of the relational dataset definition. (required)
        :type relational_dataset_definition_code: str
        :param as_at: The asAt datetime at which to retrieve the dataset(s). Defaults to returning the latest version of each dataset if not specified.
        :type as_at: datetime
        :param effective_at: The effective datetime or cut label at which to query the datasets.              Defaults to the current LUSID system datetime if not specified.
        :type effective_at: str
        :param page: The pagination token to use to continue query datasets. This value is returned from the previous call.              If a pagination token is provided, the filter, customSortBy, effectiveAt and asAt fields must not have changed since the original request.
        :type page: str
        :param limit: When paginating, limit the results to this number. Defaults to 100 if not specified.
        :type limit: int
        :param query_relational_dataset_request: The query request.
        :type query_relational_dataset_request: QueryRelationalDatasetRequest
        :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(PagedResourceListOfRelationalDataPointResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'relational_dataset_definition_scope',
            'relational_dataset_definition_code',
            'as_at',
            'effective_at',
            'page',
            'limit',
            'query_relational_dataset_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 query_relational_data" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

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

        if _params['relational_dataset_definition_code']:
            _path_params['relationalDatasetDefinitionCode'] = _params['relational_dataset_definition_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('effective_at') is not None:  # noqa: E501
            _query_params.append(('effectiveAt', _params['effective_at']))

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

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

        # 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['query_relational_dataset_request'] is not None:
            _body_params = _params['query_relational_dataset_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': "PagedResourceListOfRelationalDataPointResponse",
            '400': "LusidValidationProblemDetails",
        }

        return self.api_client.call_api(
            '/api/relationaldatasets/{relationalDatasetDefinitionScope}/{relationalDatasetDefinitionCode}/$query', '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'))
