<commit_before>"""REDCap API methods for Project user roles"""
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Union, overload

from redcap.methods.base import Base, Json

if TYPE_CHECKING:
    import pandas as pd


class UserRoles(Base):
    """Responsible for all API methods under 'Users Roles' in the API Playground"""

    @overload
    def export_user_roles(self, format_type: Literal["json"], df_kwargs: None) -> Json:
        ...

    @overload
    def export_user_roles(
        self, format_type: Literal["csv", "xml"], df_kwargs: None
    ) -> str:
        ...

    @overload
    def export_user_roles(
        self, format_type: Literal["df"], df_kwargs: Optional[Dict[str, Any]]
    ) -> "pd.DataFrame":
        ...

    def export_user_roles(
        self,
        format_type: Literal["json", "csv", "xml", "df"] = "json",
        df_kwargs: Optional[Dict[str, Any]] = None,
    ):
        """
        Export the user roles of the Project

        Args:
            format_type:
                Response return format
            df_kwargs:
                Passed to `pandas.read_csv` to control construction of
                returned DataFrame. By default, nothing

        Returns:
            Union[List[Dict[str, Any]], str, pandas.DataFrame]:
                List of user roles with assigned user rights

        Examples:
            >>> proj.export_user_roles()
            [{'unique_role_name': ..., 'role_label': 'Test role', 'design': '0', 'user_rights': '0',
            'data_access_groups': '0', 'reports': '0', 'stats_and_charts': '0',
            'manage_survey_participants': '0', 'calendar': '0', 'data_import_tool': '0',
            'data_comparison_tool': '0', 'logging': '0', 'file_repository': '0',
            'data_quality_create': '0', 'data_quality_execute': '0', 'api_export': '0',
            'api_import': '0', 'mobile_app': '0', 'mobile_app_download_data': '0',
            'record_create': '0', 'record_rename': '0', 'record_delete': '0',
            'lock_records_customization': '0', 'lock_records': '0', ...,
            'forms': {'form_1': 2}, 'forms_export': {'form_1': 0}}]
        """
        payload = self._initialize_payload(content="userRole", format_type=format_type)
        return_type = self._lookup_return_type(format_type, request_type="export")
        response = self._call_api(payload, return_type)

        return self._return_data(
            response=response,<commit_msg>:memo: Update user role docstring<commit_after>"""REDCap API methods for Project user roles"""
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Union, overload

from redcap.methods.base import Base, Json

if TYPE_CHECKING:
    import pandas as pd


class UserRoles(Base):
    """Responsible for all API methods under 'Users Roles' in the API Playground"""

    @overload
    def export_user_roles(self, format_type: Literal["json"], df_kwargs: None) -> Json:
        ...

    @overload
    def export_user_roles(
        self, format_type: Literal["csv", "xml"], df_kwargs: None
    ) -> str:
        ...

    @overload
    def export_user_roles(
        self, format_type: Literal["df"], df_kwargs: Optional[Dict[str, Any]]
    ) -> "pd.DataFrame":
        ...

    def export_user_roles(
        self,
        format_type: Literal["json", "csv", "xml", "df"] = "json",
        df_kwargs: Optional[Dict[str, Any]] = None,
    ):
        """
        Export the user roles of the Project

        Args:
            format_type:
                Response return format
            df_kwargs:
                Passed to `pandas.read_csv` to control construction of
                returned DataFrame. By default, nothing

        Returns:
            Union[List[Dict[str, Any]], str, pandas.DataFrame]:
                List of user roles with assigned user rights

        Examples:
            >>> proj.export_user_roles()
            [{'unique_role_name': ..., 'role_label': 'New Role', 'design': '0', 'user_rights': '0',
            'data_access_groups': '0', 'reports': '0', 'stats_and_charts': '0',
            'manage_survey_participants': '0', 'calendar': '0', 'data_import_tool': '0',
            'data_comparison_tool': '0', 'logging': '0', 'file_repository': '0',
            'data_quality_create': '0', 'data_quality_execute': '0', 'api_export': '0',
            'api_import': '0', 'mobile_app': '0', 'mobile_app_download_data': '0',
            'record_create': '0', 'record_rename': '0', 'record_delete': '0',
            'lock_records_customization': '0', 'lock_records': '0', ...,
            'forms': {'form_1': 0}, 'forms_export': {'form_1': 0}}]
        """
        payload = self._initialize_payload(content="userRole", format_type=format_type)
        return_type = self._lookup_return_type(format_type, request_type="export")
        response = self._call_api(payload, return_type)

        return self._return_data(
            response=response,
{'fraction_non_alphanumeric': 0.1426550818347141, 'fraction_numerical': 0.010507173166296221, 'mean_word_length': 2.6639526276831975, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3923531', 'n_tokens_mistral': 1538, 'n_tokens_neox': 1487, 'n_words': 383}