""" Group.

Do not edit this file by hand.
This is generated by parsing api.html service doc.
"""
from ambra_sdk.exceptions.service import AccountNotFound
from ambra_sdk.exceptions.service import ActiveQuery
from ambra_sdk.exceptions.service import Already
from ambra_sdk.exceptions.service import CanNotPromote
from ambra_sdk.exceptions.service import DupNamespaceName
from ambra_sdk.exceptions.service import DupShareCode
from ambra_sdk.exceptions.service import FilterNotFound
from ambra_sdk.exceptions.service import InvalidCondition
from ambra_sdk.exceptions.service import InvalidCustomfield
from ambra_sdk.exceptions.service import InvalidField
from ambra_sdk.exceptions.service import InvalidFlag
from ambra_sdk.exceptions.service import InvalidJson
from ambra_sdk.exceptions.service import InvalidSortField
from ambra_sdk.exceptions.service import InvalidSortOrder
from ambra_sdk.exceptions.service import MissingFields
from ambra_sdk.exceptions.service import NotEmpty
from ambra_sdk.exceptions.service import NotFound
from ambra_sdk.exceptions.service import NotPermitted
from ambra_sdk.exceptions.service import RoleNamespaceMismatch
from ambra_sdk.exceptions.service import RoleNotFound
from ambra_sdk.exceptions.service import SiteNotAllowed
from ambra_sdk.exceptions.service import UserNotFound
from ambra_sdk.service.query import QueryO
from ambra_sdk.service.query import AsyncQueryO
from ambra_sdk.service.query import QueryOPSF
from ambra_sdk.service.query import AsyncQueryOPSF

class Group:
    """Group."""

    def __init__(self, api):
        self._api = api

    
    def list(
        self,
        account_id,
    ):
        """List.

        :param account_id: uuid of the account
        """
        request_data = {
           'account_id': account_id,
        }
	
        errors_mapping = {}
        errors_mapping[('FILTER_NOT_FOUND', None)] = FilterNotFound('The filter can not be found. The error_subtype will hold the filter UUID')
        errors_mapping[('INVALID_CONDITION', None)] = InvalidCondition('The condition is not support. The error_subtype will hold the filter expression this applies to')
        errors_mapping[('INVALID_FIELD', None)] = InvalidField('The field is not valid for this object. The error_subtype will hold the filter expression this applies to')
        errors_mapping[('INVALID_SORT_FIELD', None)] = InvalidSortField('The field is not valid for this object. The error_subtype will hold the field name this applies to')
        errors_mapping[('INVALID_SORT_ORDER', None)] = InvalidSortOrder('The sort order for the field is invalid. The error_subtype will hold the field name this applies to')
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The account can not be found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to view this list')
        query_data = {
            'api': self._api,
            'url': '/group/list',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        query_data['paginated_field'] = 'groups'
        return QueryOPSF(**query_data)
    
    def add(
        self,
        account_id,
        name,
        customfield_param=None,
        hl7_template=None,
        must_approve=None,
        must_approve_harvest=None,
        must_approve_move=None,
        must_approve_upload=None,
        no_share=None,
        role_id=None,
        search_threshold=None,
        share_code=None,
        share_description=None,
        share_settings=None,
        share_via_gateway=None,
        site_id=None,
    ):
        """Add.

        :param account_id: uuid of the account
        :param name: Name of the group
        :param customfield_param: Expected values are CUSTOMFIELD_UUID. Custom field(s) (optional)
        :param hl7_template: The HL7 reporting template for the group (optional)
        :param must_approve: Flag if shared studies must be approved for the group (optional)
        :param must_approve_harvest: Flag if harvested studies must be approved (optional)
        :param must_approve_move: Flag if moved studies must be approved (optional)
        :param must_approve_upload: Flag if uploaded studies must be approved (optional)
        :param no_share: Flag if studies can not be shared with this group (optional). Studies can still be shared with users in the group.
        :param role_id: Id for the default role for the group (optional)
        :param search_threshold: The number of studies record in the namespace to switch the UI from list to search mode (optional)
        :param share_code: The share code of the group (optional)
        :param share_description: The share description of the group (optional)
        :param share_settings: Share settings JSON structure of the share display settings (optional)
        :param share_via_gateway: Flag if a gateway share is allowed (optional)
        :param site_id: The associated site id. Required in case require_site_id_for_groups account setting is set (optional)
        """
        request_data = {
           'account_id': account_id,
           'hl7_template': hl7_template,
           'must_approve': must_approve,
           'must_approve_harvest': must_approve_harvest,
           'must_approve_move': must_approve_move,
           'must_approve_upload': must_approve_upload,
           'name': name,
           'no_share': no_share,
           'role_id': role_id,
           'search_threshold': search_threshold,
           'share_code': share_code,
           'share_description': share_description,
           'share_settings': share_settings,
           'share_via_gateway': share_via_gateway,
           'site_id': site_id,
        }
        if customfield_param is not None:
            customfield_param_dict = {'{prefix}{k}'.format(prefix='customfield-', k=k): v for k,v in customfield_param.items()}
            request_data.update(customfield_param_dict)
	
        errors_mapping = {}
        errors_mapping[('ACCOUNT_NOT_FOUND', None)] = AccountNotFound('The account was not found')
        errors_mapping[('DUP_NAMESPACE_NAME', None)] = DupNamespaceName('namespace_names_globally_unique is enabled and there is another namespace with the same name')
        errors_mapping[('DUP_SHARE_CODE', None)] = DupShareCode('The share code is already used')
        errors_mapping[('INVALID_CUSTOMFIELD', None)] = InvalidCustomfield('Invalid custom field(s) name or value were passed. The error_subtype holds an array of the error details')
        errors_mapping[('INVALID_FLAG', None)] = InvalidFlag('An invalid flag was passed. The error_subtype holds the name of the invalid flag')
        errors_mapping[('INVALID_JSON', None)] = InvalidJson('The field is not in valid JSON format. The error_subtype holds the name of the field')
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The object was not found. The error_subtype holds the name of field that triggered the error')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to add a group to that account')
        errors_mapping[('ROLE_NAMESPACE_MISMATCH', 'GLOBAL_USER_WITH_RESTRICTED_ROLE')] = RoleNamespaceMismatch('You are adding the group to the account with a global user with restricted role, data contains role_id and user_id')
        errors_mapping[('ROLE_NAMESPACE_MISMATCH', 'INCOMPATIBLE_ROLE')] = RoleNamespaceMismatch('The role cannot be used for a group, data contains role_id and namespace_id')
        errors_mapping[('SITE_NOT_ALLOWED', None)] = SiteNotAllowed('The account is not listed in the site account&#39;s linked_study_accounts setting')
        query_data = {
            'api': self._api,
            'url': '/group/add',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return QueryO(**query_data)
    
    def set(
        self,
        uuid,
        customfield_param=None,
        hl7_template=None,
        must_approve=None,
        must_approve_harvest=None,
        must_approve_move=None,
        must_approve_upload=None,
        name=None,
        no_share=None,
        role_id=None,
        search_threshold=None,
        share_code=None,
        share_description=None,
        share_settings=None,
        share_via_gateway=None,
        site_id=None,
        site_inactive=None,
        site_qualified=None,
    ):
        """Set.

        :param uuid: The group uuid
        :param customfield_param: Expected values are CUSTOMFIELD_UUID. Custom field(s) (optional)
        :param hl7_template: The HL7 reporting template for the group (optional)
        :param must_approve: Flag if shared studies must be approved for the group (optional)
        :param must_approve_harvest: Flag if harvested studies must be approved (optional)
        :param must_approve_move: Flag if moved studies must be approved (optional)
        :param must_approve_upload: Flag if uploaded studies must be approved (optional)
        :param name: Name of the group (optional)
        :param no_share: Flag if studies can not be shared with this group (optional). Studies can still be shared with users in the group.
        :param role_id: Id for the default role for the group (optional)
        :param search_threshold: The number of studies record in the namespace to switch the UI from list to search mode (optional)
        :param share_code: The share code of the group (optional)
        :param share_description: The share description of the group (optional)
        :param share_settings: Share settings JSON structure of the share display settings (optional)
        :param share_via_gateway: Flag if a gateway share is allowed (optional)
        :param site_id: The associated site id. Required in case require_site_id_for_groups account setting is set (optional)
        :param site_inactive: Inactive flag to deactivate the site in a Trial Account (optional)
        :param site_qualified: Flag if the site is qualified for the trial (optional)
        """
        request_data = {
           'hl7_template': hl7_template,
           'must_approve': must_approve,
           'must_approve_harvest': must_approve_harvest,
           'must_approve_move': must_approve_move,
           'must_approve_upload': must_approve_upload,
           'name': name,
           'no_share': no_share,
           'role_id': role_id,
           'search_threshold': search_threshold,
           'share_code': share_code,
           'share_description': share_description,
           'share_settings': share_settings,
           'share_via_gateway': share_via_gateway,
           'site_id': site_id,
           'site_inactive': site_inactive,
           'site_qualified': site_qualified,
           'uuid': uuid,
        }
        if customfield_param is not None:
            customfield_param_dict = {'{prefix}{k}'.format(prefix='customfield-', k=k): v for k,v in customfield_param.items()}
            request_data.update(customfield_param_dict)
	
        errors_mapping = {}
        errors_mapping[('DUP_NAMESPACE_NAME', None)] = DupNamespaceName('namespace_names_globally_unique is enabled and there is another namespace with the same name')
        errors_mapping[('DUP_SHARE_CODE', None)] = DupShareCode('The share code is already used')
        errors_mapping[('INVALID_CUSTOMFIELD', None)] = InvalidCustomfield('Invalid custom field(s) name or value were passed. The error_subtype holds an array of the error details')
        errors_mapping[('INVALID_FLAG', None)] = InvalidFlag('An invalid flag was passed. The error_subtype holds the name of the invalid flag')
        errors_mapping[('INVALID_JSON', None)] = InvalidJson('The field is not in valid JSON format. The error_subtype holds the name of the field')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The object was not found. The error_subtype holds the name of field that triggered the error')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to edit the location')
        errors_mapping[('ROLE_NAMESPACE_MISMATCH', 'INCOMPATIBLE_ROLE')] = RoleNamespaceMismatch('The role cannot be used for groups, data contains role_id and namespace_id')
        errors_mapping[('SITE_NOT_ALLOWED', None)] = SiteNotAllowed('The account is not listed in the site account&#39;s linked_study_accounts setting')
        query_data = {
            'api': self._api,
            'url': '/group/set',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return QueryO(**query_data)
    
    def get(
        self,
        uuid,
    ):
        """Get.

        :param uuid: The group uuid
        """
        request_data = {
           'uuid': uuid,
        }
	
        errors_mapping = {}
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The group can not be found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to view this group')
        query_data = {
            'api': self._api,
            'url': '/group/get',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return QueryO(**query_data)
    
    def delete(
        self,
        uuid,
    ):
        """Delete.

        :param uuid: The group uuid
        """
        request_data = {
           'uuid': uuid,
        }
	
        errors_mapping = {}
        errors_mapping[('ACTIVE_QUERY', None)] = ActiveQuery('The group has outstanding Queries')
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_EMPTY', None)] = NotEmpty('The group still has studies in it')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The group can not be found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to delete this group')
        query_data = {
            'api': self._api,
            'url': '/group/delete',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return QueryO(**query_data)
    
    def user_add(
        self,
        user_id,
        uuid,
        event_approve=None,
        event_case_assignment=None,
        event_harvest=None,
        event_incoming_study_request=None,
        event_link=None,
        event_link_mine=None,
        event_message=None,
        event_new_report=None,
        event_node=None,
        event_query_add=None,
        event_query_edit=None,
        event_query_new_recipient=None,
        event_query_reply=None,
        event_report_remove=None,
        event_share=None,
        event_site_qualified=None,
        event_status_change=None,
        event_study_comment=None,
        event_thin_study_fail=None,
        event_thin_study_success=None,
        event_upload=None,
        event_upload_fail=None,
        no_physician_alias_share=None,
        role_id=None,
    ):
        """User add.

        :param user_id: Id of the user
        :param uuid: The group id
        :param event_approve: Notify the user on a approval needed into the group namespace (optional)
        :param event_case_assignment: Notify the user when they are assigned a case as a medical or admin user (optional)
        :param event_harvest: Notify the user on a harvest into the group namespace (optional)
        :param event_incoming_study_request: Notify the user when they get an incoming study request (optional)
        :param event_link: Notify the user when an anonymous link is hit in the namespace (optional)
        :param event_link_mine: Notify the user when an anonymous link created by the user is hit in the namespace (optional)
        :param event_message: Notify the user when a message is sent to the group namespace (optional)
        :param event_new_report: Notify the user when a report is attached in the group namespace (optional)
        :param event_node: Notify the user when a group node sends an event (optional)
        :param event_query_add: Notify the user when a new query is issued (optional)
        :param event_query_edit: Notify the user when a query is edited (optional)
        :param event_query_new_recipient: Notify the user when they are added to a query as a new recipient (optional)
        :param event_query_reply: Notify the user when they leave a new reply in a query (optional)
        :param event_report_remove: Notify the user when a report is removed in the group namespace (optional)
        :param event_share: Notify the user on a share into the group namespace (optional)
        :param event_site_qualified: Notify the user when a trial site is qualified for the clinical trial account (optional)
        :param event_status_change: Notify the user when the status of a study is changed (optional)
        :param event_study_comment: Notify the user when a comment is attached to a study in the namespace (optional)
        :param event_thin_study_fail: Notify the user when a thin study retrieval they initiated fails (optional)
        :param event_thin_study_success: Notify the user when a thin study retrieval they initiated succeeds (optional)
        :param event_upload: Notify the user on an upload into the group namespace (optional)
        :param event_upload_fail: Notify the user on a failed upload into the group namespace (optional)
        :param no_physician_alias_share: Flag to exclude this group from a physician alias share (optional)
        :param role_id: Id of the users role within the group (optional). If not passed the default group role will be assigned
        """
        request_data = {
           'event_approve': event_approve,
           'event_case_assignment': event_case_assignment,
           'event_harvest': event_harvest,
           'event_incoming_study_request': event_incoming_study_request,
           'event_link': event_link,
           'event_link_mine': event_link_mine,
           'event_message': event_message,
           'event_new_report': event_new_report,
           'event_node': event_node,
           'event_query_add': event_query_add,
           'event_query_edit': event_query_edit,
           'event_query_new_recipient': event_query_new_recipient,
           'event_query_reply': event_query_reply,
           'event_report_remove': event_report_remove,
           'event_share': event_share,
           'event_site_qualified': event_site_qualified,
           'event_status_change': event_status_change,
           'event_study_comment': event_study_comment,
           'event_thin_study_fail': event_thin_study_fail,
           'event_thin_study_success': event_thin_study_success,
           'event_upload': event_upload,
           'event_upload_fail': event_upload_fail,
           'no_physician_alias_share': no_physician_alias_share,
           'role_id': role_id,
           'user_id': user_id,
           'uuid': uuid,
        }
	
        errors_mapping = {}
        errors_mapping[('CAN_NOT_PROMOTE', None)] = CanNotPromote('A user can not switch themselves to an admin role if they are currently not in an admin role')
        errors_mapping[('INVALID_FLAG', None)] = InvalidFlag('An invalid flag was passed. The error_subtype holds the name of the invalid flag')
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The group can not be found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to edit the group')
        errors_mapping[('ROLE_NAMESPACE_MISMATCH', 'INCOMPATIBLE_ROLE')] = RoleNamespaceMismatch('The role cannot be used for groups, data contains role_id and namespace_id')
        errors_mapping[('ROLE_NOT_FOUND', None)] = RoleNotFound('The role was not found or is not in the account')
        errors_mapping[('USER_NOT_FOUND', None)] = UserNotFound('The user was not found or is not in the account')
        query_data = {
            'api': self._api,
            'url': '/group/user/add',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return QueryO(**query_data)
    
    def user_delete(
        self,
        user_id,
        uuid,
    ):
        """User delete.

        :param user_id: Id of the user
        :param uuid: The group id
        """
        request_data = {
           'user_id': user_id,
           'uuid': uuid,
        }
	
        errors_mapping = {}
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The group can not be found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to edit the group')
        query_data = {
            'api': self._api,
            'url': '/group/user/delete',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return QueryO(**query_data)
    
    def user_list(
        self,
        uuid,
    ):
        """User list.

        :param uuid: The group id
        """
        request_data = {
           'uuid': uuid,
        }
	
        errors_mapping = {}
        errors_mapping[('FILTER_NOT_FOUND', None)] = FilterNotFound('The filter can not be found. The error_subtype will hold the filter UUID')
        errors_mapping[('INVALID_CONDITION', None)] = InvalidCondition('The condition is not support. The error_subtype will hold the filter expression this applies to')
        errors_mapping[('INVALID_FIELD', None)] = InvalidField('The field is not valid for this object. The error_subtype will hold the filter expression this applies to')
        errors_mapping[('INVALID_SORT_FIELD', None)] = InvalidSortField('The field is not valid for this object. The error_subtype will hold the field name this applies to')
        errors_mapping[('INVALID_SORT_ORDER', None)] = InvalidSortOrder('The sort order for the field is invalid. The error_subtype will hold the field name this applies to')
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The group can not be found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted list the group')
        query_data = {
            'api': self._api,
            'url': '/group/user/list',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        query_data['paginated_field'] = 'users'
        return QueryOPSF(**query_data)
    
    def scanner_validate(
        self,
        invalidate,
        scanner_id,
        uuid,
        study_uid=None,
    ):
        """Scanner validate.

        :param invalidate: Flag if the scaner is being invalidated
        :param scanner_id: The scanner id
        :param uuid: The group id
        :param study_uid: The study uid used to validate the scaner. Required when validating (optional)
        """
        request_data = {
           'invalidate': invalidate,
           'scanner_id': scanner_id,
           'study_uid': study_uid,
           'uuid': uuid,
        }
	
        errors_mapping = {}
        errors_mapping[('ALREADY', None)] = Already('The scanner is already validated/invalidated')
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The group or scanner was not found. The error_subtype holds the type of field not found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to validate scanners')
        query_data = {
            'api': self._api,
            'url': '/group/scanner/validate',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return QueryO(**query_data)
    


class AsyncGroup:
    """AsyncGroup."""

    def __init__(self, api):
        self._api = api

    
    def list(
        self,
        account_id,
    ):
        """List.

        :param account_id: uuid of the account
        """
        request_data = {
           'account_id': account_id,
        }
	
        errors_mapping = {}
        errors_mapping[('FILTER_NOT_FOUND', None)] = FilterNotFound('The filter can not be found. The error_subtype will hold the filter UUID')
        errors_mapping[('INVALID_CONDITION', None)] = InvalidCondition('The condition is not support. The error_subtype will hold the filter expression this applies to')
        errors_mapping[('INVALID_FIELD', None)] = InvalidField('The field is not valid for this object. The error_subtype will hold the filter expression this applies to')
        errors_mapping[('INVALID_SORT_FIELD', None)] = InvalidSortField('The field is not valid for this object. The error_subtype will hold the field name this applies to')
        errors_mapping[('INVALID_SORT_ORDER', None)] = InvalidSortOrder('The sort order for the field is invalid. The error_subtype will hold the field name this applies to')
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The account can not be found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to view this list')
        query_data = {
            'api': self._api,
            'url': '/group/list',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        query_data['paginated_field'] = 'groups'
        return AsyncQueryOPSF(**query_data)
    
    def add(
        self,
        account_id,
        name,
        customfield_param=None,
        hl7_template=None,
        must_approve=None,
        must_approve_harvest=None,
        must_approve_move=None,
        must_approve_upload=None,
        no_share=None,
        role_id=None,
        search_threshold=None,
        share_code=None,
        share_description=None,
        share_settings=None,
        share_via_gateway=None,
        site_id=None,
    ):
        """Add.

        :param account_id: uuid of the account
        :param name: Name of the group
        :param customfield_param: Expected values are CUSTOMFIELD_UUID. Custom field(s) (optional)
        :param hl7_template: The HL7 reporting template for the group (optional)
        :param must_approve: Flag if shared studies must be approved for the group (optional)
        :param must_approve_harvest: Flag if harvested studies must be approved (optional)
        :param must_approve_move: Flag if moved studies must be approved (optional)
        :param must_approve_upload: Flag if uploaded studies must be approved (optional)
        :param no_share: Flag if studies can not be shared with this group (optional). Studies can still be shared with users in the group.
        :param role_id: Id for the default role for the group (optional)
        :param search_threshold: The number of studies record in the namespace to switch the UI from list to search mode (optional)
        :param share_code: The share code of the group (optional)
        :param share_description: The share description of the group (optional)
        :param share_settings: Share settings JSON structure of the share display settings (optional)
        :param share_via_gateway: Flag if a gateway share is allowed (optional)
        :param site_id: The associated site id. Required in case require_site_id_for_groups account setting is set (optional)
        """
        request_data = {
           'account_id': account_id,
           'hl7_template': hl7_template,
           'must_approve': must_approve,
           'must_approve_harvest': must_approve_harvest,
           'must_approve_move': must_approve_move,
           'must_approve_upload': must_approve_upload,
           'name': name,
           'no_share': no_share,
           'role_id': role_id,
           'search_threshold': search_threshold,
           'share_code': share_code,
           'share_description': share_description,
           'share_settings': share_settings,
           'share_via_gateway': share_via_gateway,
           'site_id': site_id,
        }
        if customfield_param is not None:
            customfield_param_dict = {'{prefix}{k}'.format(prefix='customfield-', k=k): v for k,v in customfield_param.items()}
            request_data.update(customfield_param_dict)
	
        errors_mapping = {}
        errors_mapping[('ACCOUNT_NOT_FOUND', None)] = AccountNotFound('The account was not found')
        errors_mapping[('DUP_NAMESPACE_NAME', None)] = DupNamespaceName('namespace_names_globally_unique is enabled and there is another namespace with the same name')
        errors_mapping[('DUP_SHARE_CODE', None)] = DupShareCode('The share code is already used')
        errors_mapping[('INVALID_CUSTOMFIELD', None)] = InvalidCustomfield('Invalid custom field(s) name or value were passed. The error_subtype holds an array of the error details')
        errors_mapping[('INVALID_FLAG', None)] = InvalidFlag('An invalid flag was passed. The error_subtype holds the name of the invalid flag')
        errors_mapping[('INVALID_JSON', None)] = InvalidJson('The field is not in valid JSON format. The error_subtype holds the name of the field')
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The object was not found. The error_subtype holds the name of field that triggered the error')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to add a group to that account')
        errors_mapping[('ROLE_NAMESPACE_MISMATCH', 'GLOBAL_USER_WITH_RESTRICTED_ROLE')] = RoleNamespaceMismatch('You are adding the group to the account with a global user with restricted role, data contains role_id and user_id')
        errors_mapping[('ROLE_NAMESPACE_MISMATCH', 'INCOMPATIBLE_ROLE')] = RoleNamespaceMismatch('The role cannot be used for a group, data contains role_id and namespace_id')
        errors_mapping[('SITE_NOT_ALLOWED', None)] = SiteNotAllowed('The account is not listed in the site account&#39;s linked_study_accounts setting')
        query_data = {
            'api': self._api,
            'url': '/group/add',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return AsyncQueryO(**query_data)
    
    def set(
        self,
        uuid,
        customfield_param=None,
        hl7_template=None,
        must_approve=None,
        must_approve_harvest=None,
        must_approve_move=None,
        must_approve_upload=None,
        name=None,
        no_share=None,
        role_id=None,
        search_threshold=None,
        share_code=None,
        share_description=None,
        share_settings=None,
        share_via_gateway=None,
        site_id=None,
        site_inactive=None,
        site_qualified=None,
    ):
        """Set.

        :param uuid: The group uuid
        :param customfield_param: Expected values are CUSTOMFIELD_UUID. Custom field(s) (optional)
        :param hl7_template: The HL7 reporting template for the group (optional)
        :param must_approve: Flag if shared studies must be approved for the group (optional)
        :param must_approve_harvest: Flag if harvested studies must be approved (optional)
        :param must_approve_move: Flag if moved studies must be approved (optional)
        :param must_approve_upload: Flag if uploaded studies must be approved (optional)
        :param name: Name of the group (optional)
        :param no_share: Flag if studies can not be shared with this group (optional). Studies can still be shared with users in the group.
        :param role_id: Id for the default role for the group (optional)
        :param search_threshold: The number of studies record in the namespace to switch the UI from list to search mode (optional)
        :param share_code: The share code of the group (optional)
        :param share_description: The share description of the group (optional)
        :param share_settings: Share settings JSON structure of the share display settings (optional)
        :param share_via_gateway: Flag if a gateway share is allowed (optional)
        :param site_id: The associated site id. Required in case require_site_id_for_groups account setting is set (optional)
        :param site_inactive: Inactive flag to deactivate the site in a Trial Account (optional)
        :param site_qualified: Flag if the site is qualified for the trial (optional)
        """
        request_data = {
           'hl7_template': hl7_template,
           'must_approve': must_approve,
           'must_approve_harvest': must_approve_harvest,
           'must_approve_move': must_approve_move,
           'must_approve_upload': must_approve_upload,
           'name': name,
           'no_share': no_share,
           'role_id': role_id,
           'search_threshold': search_threshold,
           'share_code': share_code,
           'share_description': share_description,
           'share_settings': share_settings,
           'share_via_gateway': share_via_gateway,
           'site_id': site_id,
           'site_inactive': site_inactive,
           'site_qualified': site_qualified,
           'uuid': uuid,
        }
        if customfield_param is not None:
            customfield_param_dict = {'{prefix}{k}'.format(prefix='customfield-', k=k): v for k,v in customfield_param.items()}
            request_data.update(customfield_param_dict)
	
        errors_mapping = {}
        errors_mapping[('DUP_NAMESPACE_NAME', None)] = DupNamespaceName('namespace_names_globally_unique is enabled and there is another namespace with the same name')
        errors_mapping[('DUP_SHARE_CODE', None)] = DupShareCode('The share code is already used')
        errors_mapping[('INVALID_CUSTOMFIELD', None)] = InvalidCustomfield('Invalid custom field(s) name or value were passed. The error_subtype holds an array of the error details')
        errors_mapping[('INVALID_FLAG', None)] = InvalidFlag('An invalid flag was passed. The error_subtype holds the name of the invalid flag')
        errors_mapping[('INVALID_JSON', None)] = InvalidJson('The field is not in valid JSON format. The error_subtype holds the name of the field')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The object was not found. The error_subtype holds the name of field that triggered the error')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to edit the location')
        errors_mapping[('ROLE_NAMESPACE_MISMATCH', 'INCOMPATIBLE_ROLE')] = RoleNamespaceMismatch('The role cannot be used for groups, data contains role_id and namespace_id')
        errors_mapping[('SITE_NOT_ALLOWED', None)] = SiteNotAllowed('The account is not listed in the site account&#39;s linked_study_accounts setting')
        query_data = {
            'api': self._api,
            'url': '/group/set',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return AsyncQueryO(**query_data)
    
    def get(
        self,
        uuid,
    ):
        """Get.

        :param uuid: The group uuid
        """
        request_data = {
           'uuid': uuid,
        }
	
        errors_mapping = {}
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The group can not be found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to view this group')
        query_data = {
            'api': self._api,
            'url': '/group/get',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return AsyncQueryO(**query_data)
    
    def delete(
        self,
        uuid,
    ):
        """Delete.

        :param uuid: The group uuid
        """
        request_data = {
           'uuid': uuid,
        }
	
        errors_mapping = {}
        errors_mapping[('ACTIVE_QUERY', None)] = ActiveQuery('The group has outstanding Queries')
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_EMPTY', None)] = NotEmpty('The group still has studies in it')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The group can not be found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to delete this group')
        query_data = {
            'api': self._api,
            'url': '/group/delete',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return AsyncQueryO(**query_data)
    
    def user_add(
        self,
        user_id,
        uuid,
        event_approve=None,
        event_case_assignment=None,
        event_harvest=None,
        event_incoming_study_request=None,
        event_link=None,
        event_link_mine=None,
        event_message=None,
        event_new_report=None,
        event_node=None,
        event_query_add=None,
        event_query_edit=None,
        event_query_new_recipient=None,
        event_query_reply=None,
        event_report_remove=None,
        event_share=None,
        event_site_qualified=None,
        event_status_change=None,
        event_study_comment=None,
        event_thin_study_fail=None,
        event_thin_study_success=None,
        event_upload=None,
        event_upload_fail=None,
        no_physician_alias_share=None,
        role_id=None,
    ):
        """User add.

        :param user_id: Id of the user
        :param uuid: The group id
        :param event_approve: Notify the user on a approval needed into the group namespace (optional)
        :param event_case_assignment: Notify the user when they are assigned a case as a medical or admin user (optional)
        :param event_harvest: Notify the user on a harvest into the group namespace (optional)
        :param event_incoming_study_request: Notify the user when they get an incoming study request (optional)
        :param event_link: Notify the user when an anonymous link is hit in the namespace (optional)
        :param event_link_mine: Notify the user when an anonymous link created by the user is hit in the namespace (optional)
        :param event_message: Notify the user when a message is sent to the group namespace (optional)
        :param event_new_report: Notify the user when a report is attached in the group namespace (optional)
        :param event_node: Notify the user when a group node sends an event (optional)
        :param event_query_add: Notify the user when a new query is issued (optional)
        :param event_query_edit: Notify the user when a query is edited (optional)
        :param event_query_new_recipient: Notify the user when they are added to a query as a new recipient (optional)
        :param event_query_reply: Notify the user when they leave a new reply in a query (optional)
        :param event_report_remove: Notify the user when a report is removed in the group namespace (optional)
        :param event_share: Notify the user on a share into the group namespace (optional)
        :param event_site_qualified: Notify the user when a trial site is qualified for the clinical trial account (optional)
        :param event_status_change: Notify the user when the status of a study is changed (optional)
        :param event_study_comment: Notify the user when a comment is attached to a study in the namespace (optional)
        :param event_thin_study_fail: Notify the user when a thin study retrieval they initiated fails (optional)
        :param event_thin_study_success: Notify the user when a thin study retrieval they initiated succeeds (optional)
        :param event_upload: Notify the user on an upload into the group namespace (optional)
        :param event_upload_fail: Notify the user on a failed upload into the group namespace (optional)
        :param no_physician_alias_share: Flag to exclude this group from a physician alias share (optional)
        :param role_id: Id of the users role within the group (optional). If not passed the default group role will be assigned
        """
        request_data = {
           'event_approve': event_approve,
           'event_case_assignment': event_case_assignment,
           'event_harvest': event_harvest,
           'event_incoming_study_request': event_incoming_study_request,
           'event_link': event_link,
           'event_link_mine': event_link_mine,
           'event_message': event_message,
           'event_new_report': event_new_report,
           'event_node': event_node,
           'event_query_add': event_query_add,
           'event_query_edit': event_query_edit,
           'event_query_new_recipient': event_query_new_recipient,
           'event_query_reply': event_query_reply,
           'event_report_remove': event_report_remove,
           'event_share': event_share,
           'event_site_qualified': event_site_qualified,
           'event_status_change': event_status_change,
           'event_study_comment': event_study_comment,
           'event_thin_study_fail': event_thin_study_fail,
           'event_thin_study_success': event_thin_study_success,
           'event_upload': event_upload,
           'event_upload_fail': event_upload_fail,
           'no_physician_alias_share': no_physician_alias_share,
           'role_id': role_id,
           'user_id': user_id,
           'uuid': uuid,
        }
	
        errors_mapping = {}
        errors_mapping[('CAN_NOT_PROMOTE', None)] = CanNotPromote('A user can not switch themselves to an admin role if they are currently not in an admin role')
        errors_mapping[('INVALID_FLAG', None)] = InvalidFlag('An invalid flag was passed. The error_subtype holds the name of the invalid flag')
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The group can not be found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to edit the group')
        errors_mapping[('ROLE_NAMESPACE_MISMATCH', 'INCOMPATIBLE_ROLE')] = RoleNamespaceMismatch('The role cannot be used for groups, data contains role_id and namespace_id')
        errors_mapping[('ROLE_NOT_FOUND', None)] = RoleNotFound('The role was not found or is not in the account')
        errors_mapping[('USER_NOT_FOUND', None)] = UserNotFound('The user was not found or is not in the account')
        query_data = {
            'api': self._api,
            'url': '/group/user/add',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return AsyncQueryO(**query_data)
    
    def user_delete(
        self,
        user_id,
        uuid,
    ):
        """User delete.

        :param user_id: Id of the user
        :param uuid: The group id
        """
        request_data = {
           'user_id': user_id,
           'uuid': uuid,
        }
	
        errors_mapping = {}
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The group can not be found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to edit the group')
        query_data = {
            'api': self._api,
            'url': '/group/user/delete',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return AsyncQueryO(**query_data)
    
    def user_list(
        self,
        uuid,
    ):
        """User list.

        :param uuid: The group id
        """
        request_data = {
           'uuid': uuid,
        }
	
        errors_mapping = {}
        errors_mapping[('FILTER_NOT_FOUND', None)] = FilterNotFound('The filter can not be found. The error_subtype will hold the filter UUID')
        errors_mapping[('INVALID_CONDITION', None)] = InvalidCondition('The condition is not support. The error_subtype will hold the filter expression this applies to')
        errors_mapping[('INVALID_FIELD', None)] = InvalidField('The field is not valid for this object. The error_subtype will hold the filter expression this applies to')
        errors_mapping[('INVALID_SORT_FIELD', None)] = InvalidSortField('The field is not valid for this object. The error_subtype will hold the field name this applies to')
        errors_mapping[('INVALID_SORT_ORDER', None)] = InvalidSortOrder('The sort order for the field is invalid. The error_subtype will hold the field name this applies to')
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The group can not be found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted list the group')
        query_data = {
            'api': self._api,
            'url': '/group/user/list',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        query_data['paginated_field'] = 'users'
        return AsyncQueryOPSF(**query_data)
    
    def scanner_validate(
        self,
        invalidate,
        scanner_id,
        uuid,
        study_uid=None,
    ):
        """Scanner validate.

        :param invalidate: Flag if the scaner is being invalidated
        :param scanner_id: The scanner id
        :param uuid: The group id
        :param study_uid: The study uid used to validate the scaner. Required when validating (optional)
        """
        request_data = {
           'invalidate': invalidate,
           'scanner_id': scanner_id,
           'study_uid': study_uid,
           'uuid': uuid,
        }
	
        errors_mapping = {}
        errors_mapping[('ALREADY', None)] = Already('The scanner is already validated/invalidated')
        errors_mapping[('MISSING_FIELDS', None)] = MissingFields('A required field is missing or does not have data in it. The error_subtype holds a array of all the missing fields')
        errors_mapping[('NOT_FOUND', None)] = NotFound('The group or scanner was not found. The error_subtype holds the type of field not found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted('You are not permitted to validate scanners')
        query_data = {
            'api': self._api,
            'url': '/group/scanner/validate',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return AsyncQueryO(**query_data)
    