# 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 pydantic.v1 import Field, constr, validator

from typing import List, Optional

from finbourne_access.models.add_policy_collection_to_role_request import AddPolicyCollectionToRoleRequest
from finbourne_access.models.role_creation_request import RoleCreationRequest
from finbourne_access.models.role_response import RoleResponse
from finbourne_access.models.role_update_request import RoleUpdateRequest

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 RolesApi:
    """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 add_policy_collection_to_role(self, scope : Annotated[constr(strict=True), Field(..., description="The scope of the Role")], code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], add_policy_collection_to_role_request : Annotated[AddPolicyCollectionToRoleRequest, Field(..., description="The policy collections to add")], **kwargs) -> RoleResponse:  # noqa: E501
        ...

    @overload
    def add_policy_collection_to_role(self, scope : Annotated[constr(strict=True), Field(..., description="The scope of the Role")], code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], add_policy_collection_to_role_request : Annotated[AddPolicyCollectionToRoleRequest, Field(..., description="The policy collections to add")], async_req: Optional[bool]=True, **kwargs) -> RoleResponse:  # noqa: E501
        ...

    @validate_arguments
    def add_policy_collection_to_role(self, scope : Annotated[constr(strict=True), Field(..., description="The scope of the Role")], code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], add_policy_collection_to_role_request : Annotated[AddPolicyCollectionToRoleRequest, Field(..., description="The policy collections to add")], async_req: Optional[bool]=None, **kwargs) -> Union[RoleResponse, Awaitable[RoleResponse]]:  # noqa: E501
        """AddPolicyCollectionToRole: Add policy collections to a role  # noqa: E501

        Assigns policy collections to a role  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

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

        :param scope: The scope of the Role (required)
        :type scope: str
        :param code: The code of the Role (required)
        :type code: str
        :param add_policy_collection_to_role_request: The policy collections to add (required)
        :type add_policy_collection_to_role_request: AddPolicyCollectionToRoleRequest
        :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: RoleResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the add_policy_collection_to_role_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.add_policy_collection_to_role_with_http_info(scope, code, add_policy_collection_to_role_request, **kwargs)  # noqa: E501

    @validate_arguments
    def add_policy_collection_to_role_with_http_info(self, scope : Annotated[constr(strict=True), Field(..., description="The scope of the Role")], code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], add_policy_collection_to_role_request : Annotated[AddPolicyCollectionToRoleRequest, Field(..., description="The policy collections to add")], **kwargs) -> ApiResponse:  # noqa: E501
        """AddPolicyCollectionToRole: Add policy collections to a role  # noqa: E501

        Assigns policy collections to a role  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

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

        :param scope: The scope of the Role (required)
        :type scope: str
        :param code: The code of the Role (required)
        :type code: str
        :param add_policy_collection_to_role_request: The policy collections to add (required)
        :type add_policy_collection_to_role_request: AddPolicyCollectionToRoleRequest
        :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(RoleResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'scope',
            'code',
            'add_policy_collection_to_role_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 add_policy_collection_to_role" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

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

        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['add_policy_collection_to_role_request'] is not None:
            _body_params = _params['add_policy_collection_to_role_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': "RoleResponse",
            '400': "LusidValidationProblemDetails",
        }

        return self.api_client.call_api(
            '/api/roles/{scope}/{code}/policycollections', '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 create_role(self, role_creation_request : Annotated[RoleCreationRequest, Field(..., description="The definition of the Role")], **kwargs) -> RoleResponse:  # noqa: E501
        ...

    @overload
    def create_role(self, role_creation_request : Annotated[RoleCreationRequest, Field(..., description="The definition of the Role")], async_req: Optional[bool]=True, **kwargs) -> RoleResponse:  # noqa: E501
        ...

    @validate_arguments
    def create_role(self, role_creation_request : Annotated[RoleCreationRequest, Field(..., description="The definition of the Role")], async_req: Optional[bool]=None, **kwargs) -> Union[RoleResponse, Awaitable[RoleResponse]]:  # noqa: E501
        """CreateRole: Create Role  # noqa: E501

        Creates a Role  # 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_role(role_creation_request, async_req=True)
        >>> result = thread.get()

        :param role_creation_request: The definition of the Role (required)
        :type role_creation_request: RoleCreationRequest
        :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: RoleResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the create_role_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_role_with_http_info(role_creation_request, **kwargs)  # noqa: E501

    @validate_arguments
    def create_role_with_http_info(self, role_creation_request : Annotated[RoleCreationRequest, Field(..., description="The definition of the Role")], **kwargs) -> ApiResponse:  # noqa: E501
        """CreateRole: Create Role  # noqa: E501

        Creates a Role  # 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_role_with_http_info(role_creation_request, async_req=True)
        >>> result = thread.get()

        :param role_creation_request: The definition of the Role (required)
        :type role_creation_request: RoleCreationRequest
        :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(RoleResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'role_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_role" % _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['role_creation_request'] is not None:
            _body_params = _params['role_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': "RoleResponse",
            '400': "LusidValidationProblemDetails",
        }

        return self.api_client.call_api(
            '/api/roles', '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_role(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], scope : Annotated[Optional[constr(strict=True)], Field(description=">Optional. Will use default scope if not supplied. The scope of the Role")] = None, **kwargs) -> None:  # noqa: E501
        ...

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

    @validate_arguments
    def delete_role(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], scope : Annotated[Optional[constr(strict=True)], Field(description=">Optional. Will use default scope if not supplied. The scope of the Role")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[None, Awaitable[None]]:  # noqa: E501
        """DeleteRole: Delete Role  # noqa: E501

        Deletes an identified Role  # 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_role(code, scope, async_req=True)
        >>> result = thread.get()

        :param code: The code of the Role (required)
        :type code: str
        :param scope: >Optional. Will use default scope if not supplied. The scope of the Role
        :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_role_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_role_with_http_info(code, scope, **kwargs)  # noqa: E501

    @validate_arguments
    def delete_role_with_http_info(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], scope : Annotated[Optional[constr(strict=True)], Field(description=">Optional. Will use default scope if not supplied. The scope of the Role")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """DeleteRole: Delete Role  # noqa: E501

        Deletes an identified Role  # 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_role_with_http_info(code, scope, async_req=True)
        >>> result = thread.get()

        :param code: The code of the Role (required)
        :type code: str
        :param scope: >Optional. Will use default scope if not supplied. The scope of the Role
        :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_role" % _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/roles/{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 get_role(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. Will use default scope if not supplied. The scope of the Role")] = None, **kwargs) -> RoleResponse:  # noqa: E501
        ...

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

    @validate_arguments
    def get_role(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. Will use default scope if not supplied. The scope of the Role")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[RoleResponse, Awaitable[RoleResponse]]:  # noqa: E501
        """GetRole: Get Role  # noqa: E501

        Gets an identified Role  # 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_role(code, scope, async_req=True)
        >>> result = thread.get()

        :param code: The code of the Role (required)
        :type code: str
        :param scope: Optional. Will use default scope if not supplied. The scope of the Role
        :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: RoleResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the get_role_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_role_with_http_info(code, scope, **kwargs)  # noqa: E501

    @validate_arguments
    def get_role_with_http_info(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. Will use default scope if not supplied. The scope of the Role")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """GetRole: Get Role  # noqa: E501

        Gets an identified Role  # 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_role_with_http_info(code, scope, async_req=True)
        >>> result = thread.get()

        :param code: The code of the Role (required)
        :type code: str
        :param scope: Optional. Will use default scope if not supplied. The scope of the Role
        :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(RoleResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _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 get_role" % _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 = {
            '200': "RoleResponse",
            '400': "LusidValidationProblemDetails",
        }

        return self.api_client.call_api(
            '/api/roles/{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_roles(self, scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. Will use all scopes if not supplied. The requested scope")] = None, **kwargs) -> List[RoleResponse]:  # noqa: E501
        ...

    @overload
    def list_roles(self, scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. Will use all scopes if not supplied. The requested scope")] = None, async_req: Optional[bool]=True, **kwargs) -> List[RoleResponse]:  # noqa: E501
        ...

    @validate_arguments
    def list_roles(self, scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. Will use all scopes if not supplied. The requested scope")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[List[RoleResponse], Awaitable[List[RoleResponse]]]:  # noqa: E501
        """ListRoles: List Roles  # noqa: E501

        Gets all Roles in a scope  # 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_roles(scope, async_req=True)
        >>> result = thread.get()

        :param scope: Optional. Will use all scopes if not supplied. The requested scope
        :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: List[RoleResponse]
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the list_roles_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_roles_with_http_info(scope, **kwargs)  # noqa: E501

    @validate_arguments
    def list_roles_with_http_info(self, scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. Will use all scopes if not supplied. The requested scope")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """ListRoles: List Roles  # noqa: E501

        Gets all Roles in a scope  # 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_roles_with_http_info(scope, async_req=True)
        >>> result = thread.get()

        :param scope: Optional. Will use all scopes if not supplied. The requested scope
        :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(List[RoleResponse], status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

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

        _collection_formats = {}

        # process the path parameters
        _path_params = {}

        # 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 = {
            '200': "List[RoleResponse]",
            '400': "LusidValidationProblemDetails",
        }

        return self.api_client.call_api(
            '/api/roles', '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 remove_policy_collection_from_role(self, scope : Annotated[constr(strict=True), Field(..., description="The scope of the Role")], code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], policycollectionscope : Annotated[constr(strict=True), Field(..., description="The scope of policy collection to remove from the Role")], policycollectioncode : Annotated[constr(strict=True), Field(..., description="The code of the policy collection to remove from the Role")], **kwargs) -> RoleResponse:  # noqa: E501
        ...

    @overload
    def remove_policy_collection_from_role(self, scope : Annotated[constr(strict=True), Field(..., description="The scope of the Role")], code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], policycollectionscope : Annotated[constr(strict=True), Field(..., description="The scope of policy collection to remove from the Role")], policycollectioncode : Annotated[constr(strict=True), Field(..., description="The code of the policy collection to remove from the Role")], async_req: Optional[bool]=True, **kwargs) -> RoleResponse:  # noqa: E501
        ...

    @validate_arguments
    def remove_policy_collection_from_role(self, scope : Annotated[constr(strict=True), Field(..., description="The scope of the Role")], code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], policycollectionscope : Annotated[constr(strict=True), Field(..., description="The scope of policy collection to remove from the Role")], policycollectioncode : Annotated[constr(strict=True), Field(..., description="The code of the policy collection to remove from the Role")], async_req: Optional[bool]=None, **kwargs) -> Union[RoleResponse, Awaitable[RoleResponse]]:  # noqa: E501
        """RemovePolicyCollectionFromRole: Remove policy collection from role  # noqa: E501

        Removes a policy collection from a role  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.remove_policy_collection_from_role(scope, code, policycollectionscope, policycollectioncode, async_req=True)
        >>> result = thread.get()

        :param scope: The scope of the Role (required)
        :type scope: str
        :param code: The code of the Role (required)
        :type code: str
        :param policycollectionscope: The scope of policy collection to remove from the Role (required)
        :type policycollectionscope: str
        :param policycollectioncode: The code of the policy collection to remove from the Role (required)
        :type policycollectioncode: 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: RoleResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the remove_policy_collection_from_role_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.remove_policy_collection_from_role_with_http_info(scope, code, policycollectionscope, policycollectioncode, **kwargs)  # noqa: E501

    @validate_arguments
    def remove_policy_collection_from_role_with_http_info(self, scope : Annotated[constr(strict=True), Field(..., description="The scope of the Role")], code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], policycollectionscope : Annotated[constr(strict=True), Field(..., description="The scope of policy collection to remove from the Role")], policycollectioncode : Annotated[constr(strict=True), Field(..., description="The code of the policy collection to remove from the Role")], **kwargs) -> ApiResponse:  # noqa: E501
        """RemovePolicyCollectionFromRole: Remove policy collection from role  # noqa: E501

        Removes a policy collection from a role  # noqa: E501
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True

        >>> thread = api.remove_policy_collection_from_role_with_http_info(scope, code, policycollectionscope, policycollectioncode, async_req=True)
        >>> result = thread.get()

        :param scope: The scope of the Role (required)
        :type scope: str
        :param code: The code of the Role (required)
        :type code: str
        :param policycollectionscope: The scope of policy collection to remove from the Role (required)
        :type policycollectionscope: str
        :param policycollectioncode: The code of the policy collection to remove from the Role (required)
        :type policycollectioncode: 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(RoleResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'scope',
            'code',
            'policycollectionscope',
            'policycollectioncode'
        ]
        _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 remove_policy_collection_from_role" % _key
                )
            _params[_key] = _val
        del _params['kwargs']

        _collection_formats = {}

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

        if _params['code']:
            _path_params['code'] = _params['code']

        if _params['policycollectionscope']:
            _path_params['policycollectionscope'] = _params['policycollectionscope']

        if _params['policycollectioncode']:
            _path_params['policycollectioncode'] = _params['policycollectioncode']


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

        return self.api_client.call_api(
            '/api/roles/{scope}/{code}/policycollections/{policycollectionscope}/{policycollectioncode}', '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 update_role(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], role_update_request : Annotated[RoleUpdateRequest, Field(..., description="The updated definition of the Role")], scope : Annotated[Optional[constr(strict=True)], Field(description=">Optional. Will use default scope if not supplied. The scope of the Role")] = None, before_scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. The scope of the Role. Will use default scope if not supplied.")] = None, before_code : Annotated[Optional[constr(strict=True)], Field(description="Optional. The code of the Role")] = None, after_scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. The scope of the Role. Will use default scope if not supplied.")] = None, after_code : Annotated[Optional[constr(strict=True)], Field(description="Optional. The code of the Role")] = None, **kwargs) -> RoleResponse:  # noqa: E501
        ...

    @overload
    def update_role(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], role_update_request : Annotated[RoleUpdateRequest, Field(..., description="The updated definition of the Role")], scope : Annotated[Optional[constr(strict=True)], Field(description=">Optional. Will use default scope if not supplied. The scope of the Role")] = None, before_scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. The scope of the Role. Will use default scope if not supplied.")] = None, before_code : Annotated[Optional[constr(strict=True)], Field(description="Optional. The code of the Role")] = None, after_scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. The scope of the Role. Will use default scope if not supplied.")] = None, after_code : Annotated[Optional[constr(strict=True)], Field(description="Optional. The code of the Role")] = None, async_req: Optional[bool]=True, **kwargs) -> RoleResponse:  # noqa: E501
        ...

    @validate_arguments
    def update_role(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], role_update_request : Annotated[RoleUpdateRequest, Field(..., description="The updated definition of the Role")], scope : Annotated[Optional[constr(strict=True)], Field(description=">Optional. Will use default scope if not supplied. The scope of the Role")] = None, before_scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. The scope of the Role. Will use default scope if not supplied.")] = None, before_code : Annotated[Optional[constr(strict=True)], Field(description="Optional. The code of the Role")] = None, after_scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. The scope of the Role. Will use default scope if not supplied.")] = None, after_code : Annotated[Optional[constr(strict=True)], Field(description="Optional. The code of the Role")] = None, async_req: Optional[bool]=None, **kwargs) -> Union[RoleResponse, Awaitable[RoleResponse]]:  # noqa: E501
        """UpdateRole: Update Role  # noqa: E501

        Updates a Role  # 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_role(code, role_update_request, scope, before_scope, before_code, after_scope, after_code, async_req=True)
        >>> result = thread.get()

        :param code: The code of the Role (required)
        :type code: str
        :param role_update_request: The updated definition of the Role (required)
        :type role_update_request: RoleUpdateRequest
        :param scope: >Optional. Will use default scope if not supplied. The scope of the Role
        :type scope: str
        :param before_scope: Optional. The scope of the Role. Will use default scope if not supplied.
        :type before_scope: str
        :param before_code: Optional. The code of the Role
        :type before_code: str
        :param after_scope: Optional. The scope of the Role. Will use default scope if not supplied.
        :type after_scope: str
        :param after_code: Optional. The code of the Role
        :type after_code: 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: RoleResponse
        """
        kwargs['_return_http_data_only'] = True
        if '_preload_content' in kwargs:
            message = "Error! Please call the update_role_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_role_with_http_info(code, role_update_request, scope, before_scope, before_code, after_scope, after_code, **kwargs)  # noqa: E501

    @validate_arguments
    def update_role_with_http_info(self, code : Annotated[constr(strict=True), Field(..., description="The code of the Role")], role_update_request : Annotated[RoleUpdateRequest, Field(..., description="The updated definition of the Role")], scope : Annotated[Optional[constr(strict=True)], Field(description=">Optional. Will use default scope if not supplied. The scope of the Role")] = None, before_scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. The scope of the Role. Will use default scope if not supplied.")] = None, before_code : Annotated[Optional[constr(strict=True)], Field(description="Optional. The code of the Role")] = None, after_scope : Annotated[Optional[constr(strict=True)], Field(description="Optional. The scope of the Role. Will use default scope if not supplied.")] = None, after_code : Annotated[Optional[constr(strict=True)], Field(description="Optional. The code of the Role")] = None, **kwargs) -> ApiResponse:  # noqa: E501
        """UpdateRole: Update Role  # noqa: E501

        Updates a Role  # 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_role_with_http_info(code, role_update_request, scope, before_scope, before_code, after_scope, after_code, async_req=True)
        >>> result = thread.get()

        :param code: The code of the Role (required)
        :type code: str
        :param role_update_request: The updated definition of the Role (required)
        :type role_update_request: RoleUpdateRequest
        :param scope: >Optional. Will use default scope if not supplied. The scope of the Role
        :type scope: str
        :param before_scope: Optional. The scope of the Role. Will use default scope if not supplied.
        :type before_scope: str
        :param before_code: Optional. The code of the Role
        :type before_code: str
        :param after_scope: Optional. The scope of the Role. Will use default scope if not supplied.
        :type after_scope: str
        :param after_code: Optional. The code of the Role
        :type after_code: 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(RoleResponse, status_code(int), headers(HTTPHeaderDict))
        """

        _params = locals()

        _all_params = [
            'code',
            'role_update_request',
            'scope',
            'before_scope',
            'before_code',
            'after_scope',
            'after_code'
        ]
        _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_role" % _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']))

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

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

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

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

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

        return self.api_client.call_api(
            '/api/roles/{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'))
