Ejemplo n.º 1
0
    def user_delete(
        self,
        user_id,
        uuid,
    ):
        """User delete.
        :param user_id: The user uuid
        :param uuid: The account uuid
        """
        request_data = {
            'uuid': uuid,
            'user_id': user_id,
        }

        errors_mapping = {}
        errors_mapping['MISSING_FIELDS'] = 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'] = NotFound('The account can not be found')
        errors_mapping['NOT_PERMITTED'] = NotPermitted(
            'You are not permitted to delete this user')
        errors_mapping['USER_NOT_FOUND'] = UserNotFound(
            'The user can not be found or is not a member of this account')
        query_data = {
            'api': self._api,
            'url': '/account/user/delete',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return QueryO(**query_data)
Ejemplo n.º 2
0
    def user_delete(
        self,
        user_id,
        uuid,
    ):
        """User delete.

        :param user_id: Id of the user
        :param uuid: The site 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 site can not be found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted(
            'You are not permitted to delete users from the contact list')
        errors_mapping[('USER_NOT_FOUND', None)] = UserNotFound(
            'The user can not be found in the contact list')
        query_data = {
            'api': self._api,
            'url': '/site/user/delete',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return AsyncQueryO(**query_data)
Ejemplo n.º 3
0
    def user_add(
        self,
        role_name,
        uuid,
        email=None,
        user_id=None,
    ):
        """User add.

        :param role_name: The role name that should be used for the user in groups
        :param uuid: The group id
        :param email: email
        :param user_id: user_id
        """
        request_data = {
            'email': email,
            'role_name': role_name,
            'user_id': user_id,
            'uuid': uuid,
        }

        errors_mapping = {}
        errors_mapping[(
            'ALREADY_EXISTS',
            None)] = AlreadyExists('The user is in the contact list already')
        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 site can not be found')
        errors_mapping[('NOT_PERMITTED', None)] = NotPermitted(
            'You are not permitted to add users to the site')
        errors_mapping[('USER_NOT_FOUND',
                        None)] = UserNotFound('The user was not found')
        query_data = {
            'api': self._api,
            'url': '/site/user/add',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return AsyncQueryO(**query_data)
Ejemplo n.º 4
0
    def user_add(
        self,
        event_upload_fail,
        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_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,
        no_physician_alias_share=None,
        role_id=None,
    ):
        """User add.

        :param event_upload_fail: Notify the user on a failed upload into the location namespace
        :param user_id: Id of the user
        :param uuid: The location id
        :param event_approve: Notify the user on a approval needed into the location 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 location 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 location namespace (optional)
        :param event_new_report: Notify the user when a report is attached in the location namespace (optional)
        :param event_node: Notify the user when a location 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 edites (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 location namespace (optional)
        :param event_share: Notify the user on a share into the location 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 location namespace (optional)
        :param no_physician_alias_share: Flag to exclude this location from a physician alias share (optional)
        :param role_id: Id of the users role within the location (optional). If not passed the default location 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_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 location can not be found')
        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 locations, 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': '/location/user/add',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return AsyncQueryO(**query_data)
Ejemplo n.º 5
0
    def add(
        self,
        account_id,
        event,
        name,
        url,
        auth=None,
        by_accession_number=None,
        by_uid=None,
        cron=None,
        delay=None,
        filter_field=None,
        filter_regexp=None,
        max_age=None,
        method=None,
        node_id=None,
        once=None,
        parameters=None,
        retry=None,
        sid_user_id=None,
        suspended=None,
    ):
        """Add.
        :param account_id: uuid of the account
        :param event: Event to call it on (See the notes for the available events)
        :param name: Name of the webhook
        :param url: URL to call
        :param auth: A JSON hash with the authentication details (optional)
        :param by_accession_number: Flag to expand the once search to include studies with the same accession_number (optional)
        :param by_uid: Flag to expand the once search to include studies with the same study_uid (optional)
        :param cron: Cron timing string for CRON events e.g 0 9 * * mon-fri(optional)
        :param delay: Number of seconds to delay running this webhook for after it is triggered (optional)
        :param filter_field: Name of the study field to filter on (optional)
        :param filter_regexp: Regular expression to match the value of the filter_field against (optional)
        :param max_age: Ignore studies that are more than this number of days old based on the study_date (optional)
        :param method: method
        :param node_id: uuid of the node to proxy the webhook through (optional)
        :param once: Flag that this webhook should only be run once for a specific study (optional)
        :param parameters: A JSON object of the parameter names and values (optional)
        :param retry: Retry the webhook if it fails (optional)
        :param sid_user_id: UUID of the user to generate a sid as (optional)
        :param suspended: This webhook is suspended and not triggered (optional)

        Notes:
        method - Method to call it with (POST OR GET OR POST_JSON OR PUT)
        """
        request_data = {
            'retry': retry,
            'max_age': max_age,
            'node_id': node_id,
            'url': url,
            'by_accession_number': by_accession_number,
            'cron': cron,
            'filter_field': filter_field,
            'auth': auth,
            'filter_regexp': filter_regexp,
            'parameters': parameters,
            'suspended': suspended,
            'name': name,
            'event': event,
            'by_uid': by_uid,
            'once': once,
            'method': method,
            'sid_user_id': sid_user_id,
            'delay': delay,
            'account_id': account_id,
        }

        errors_mapping = {}
        errors_mapping['ACCOUNT_NOT_FOUND'] = AccountNotFound(
            'The account can not be found')
        errors_mapping['CUSTOM_NOT_HASH'] = CustomNotHash(
            'The custom auth value is not a JSON hash')
        errors_mapping['INCOMPLETE_FILTER'] = IncompleteFilter(
            'Both a field and regexp are required')
        errors_mapping['INVALID_CRON'] = InvalidCron(
            'The cron value is invalid')
        errors_mapping['INVALID_EVENT'] = InvalidEvent(
            'An invalid event was passed')
        errors_mapping['INVALID_FILTER_FIELD'] = InvalidFilterField(
            'Invalid filter field name')
        errors_mapping['INVALID_JSON'] = InvalidJson(
            'The parameters field is not in valid JSON format.')
        errors_mapping['INVALID_METHOD'] = InvalidMethod(
            'An invalid method was passed')
        errors_mapping['INVALID_REGEXP'] = InvalidRegexp(
            'Invalid regular expression')
        errors_mapping[
            'INVALID_TRANSFORM_CONDITION'] = InvalidTransformCondition(
                'The transform condition is invalid')
        errors_mapping['MISSING_FIELDS'] = 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['NODE_NOT_FOUND'] = NodeNotFound(
            'The node can not be found')
        errors_mapping['NOT_HASH'] = NotHash(
            'The parameter or auth field is not a hash.')
        errors_mapping['NOT_PERMITTED'] = NotPermitted(
            'You are not permitted to add a webhook to this account')
        errors_mapping['NOT_WITH_CRON'] = NotWithCron(
            'The delay or retry option can not be used for cron events')
        errors_mapping['SFDC_MISSING_FIELDS'] = SfdcMissingFields(
            'Fields are missing for the SFDC auth hash')
        errors_mapping['SFDC_NOT_HASH'] = SfdcNotHash(
            'The SFDC auth value is not a JSON hash')
        errors_mapping['SID_USER_NOT_FOUND'] = SidUserNotFound(
            'The sid user can not be found')
        errors_mapping['SID_USER_NOT_IN_ACCOUNT'] = SidUserNotInAccount(
            'The sid user is not a member of this account')
        errors_mapping['USER_NOT_FOUND'] = UserNotFound(
            'The basic authentication user can not be found')
        query_data = {
            'api': self._api,
            'url': '/webhook/add',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return QueryO(**query_data)
Ejemplo n.º 6
0
    def user_add(
        self,
        user_id,
        uuid,
        event_approve=None,
        event_case_assignment=None,
        event_harvest=None,
        event_link=None,
        event_link_mine=None,
        event_message=None,
        event_new_report=None,
        event_node=None,
        event_share=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_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_share: Notify the user on a share into the group namespace (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_status_change': event_status_change,
            'event_share': event_share,
            'event_thin_study_success': event_thin_study_success,
            'event_link_mine': event_link_mine,
            'no_physician_alias_share': no_physician_alias_share,
            'event_study_comment': event_study_comment,
            'role_id': role_id,
            'event_node': event_node,
            'event_harvest': event_harvest,
            'event_message': event_message,
            'event_upload_fail': event_upload_fail,
            'event_thin_study_fail': event_thin_study_fail,
            'event_new_report': event_new_report,
            'uuid': uuid,
            'event_approve': event_approve,
            'event_case_assignment': event_case_assignment,
            'user_id': user_id,
            'event_upload': event_upload,
            'event_link': event_link,
        }

        errors_mapping = {}
        errors_mapping['INVALID_FLAG'] = InvalidFlag(
            'An invalid flag was passed. The error_subtype holds the name of the invalid flag'
        )
        errors_mapping['MISSING_FIELDS'] = 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'] = NotFound('The group can not be found')
        errors_mapping['NOT_PERMITTED'] = NotPermitted(
            'You are not permitted to edit the group')
        errors_mapping['ROLE_NOT_FOUND'] = RoleNotFound(
            'The role was not found or is not in the account')
        errors_mapping['USER_NOT_FOUND'] = 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)
Ejemplo n.º 7
0
    def user_set(
        self,
        user_id,
        uuid,
        account_alias=None,
        account_email=None,
        account_login=None,
        account_password=None,
        customfield_param=None,
        event_approve=None,
        event_case_assignment=None,
        event_harvest=None,
        event_join=None,
        event_link=None,
        event_link_mine=None,
        event_message=None,
        event_new_report=None,
        event_node=None,
        event_purge=None,
        event_share=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,
        global_param=None,
        max_sessions=None,
        password_reset=None,
        role_id=None,
        session_expire=None,
        setting_param=None,
        settings=None,
    ):
        """User set.
        :param user_id: The users uuid
        :param uuid: The account uuid
        :param account_alias: Users alias in the account. (optional).
        :param account_email: Users account_email. Only set this if it is different than the users login email (optional).
        :param account_login: Users login name in the account. (optional).
        :param account_password: Password for the account_password. (optional).
        :param customfield_param: Custom field(s) (optional)
        :param event_approve: Notify the user on a approval needed into the account 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 account namespace (optional)
        :param event_join: Notify the user on a join request for the account (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 account namespace (optional)
        :param event_new_report: Notify the user when a report is attached in the account namespace (optional)
        :param event_node: Notify the user when an account node sends an event (optional)
        :param event_purge: Notify the user the results of a purge job for the account (optional)
        :param event_share: Notify the user on a share into the account namespace (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 account namespace (optional)
        :param event_upload_fail: Notify the user on a failed upload into the account namespace (optional)
        :param global_param: Flag if this is a global user. (optional).
        :param max_sessions: Over-ride value for the max number of simultaneous sessions the user can have. (optional).
        :param password_reset: Flag if the password needs to be reset. (optional).
        :param role_id: uuid of the users role in the account (optional).
        :param session_expire: Number of minutes before an idle session expires. (optional)
        :param setting_param: Set an individual setting. This is an alternative to the settings hash for easier use in the API tester (optional)
        :param settings: A hash of the account settings that the user can override (optional)
        """
        request_data = {
            'password_reset': password_reset,
            'event_status_change': event_status_change,
            'event_share': event_share,
            'account_password': account_password,
            'event_thin_study_success': event_thin_study_success,
            'event_link_mine': event_link_mine,
            'account_login': account_login,
            'event_study_comment': event_study_comment,
            'role_id': role_id,
            'event_purge': event_purge,
            'event_node': event_node,
            'global_param': global_param,
            'max_sessions': max_sessions,
            'event_message': event_message,
            'event_link': event_link,
            'settings': settings,
            'event_upload_fail': event_upload_fail,
            'event_thin_study_fail': event_thin_study_fail,
            'event_new_report': event_new_report,
            'uuid': uuid,
            'event_approve': event_approve,
            'account_email': account_email,
            'account_alias': account_alias,
            'session_expire': session_expire,
            'event_case_assignment': event_case_assignment,
            'user_id': user_id,
            'event_upload': event_upload,
            'event_join': event_join,
            'event_harvest': event_harvest,
        }
        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)
        if setting_param is not None:
            setting_param_dict = {
                '{prefix}{k}'.format(prefix='setting_', k=k): v
                for k, v in setting_param.items()
            }
            request_data.update(setting_param_dict)

        errors_mapping = {}
        errors_mapping['BAD_PASSWORD'] = BadPassword(
            'Password needs to be at least 8 characters long, contain at least two numbers, contain at least two characters and can't be one of your last three passwords'
        )
        errors_mapping['CAN_NOT_PROMOTE'] = CanNotPromote(
            'A user can not switch themselves to an admin role if they are currently not in an admin role'
        )
        errors_mapping['DUPLICATE_NAME'] = DuplicateName(
            'The account_login is already in use')
        errors_mapping['INVALID_CUSTOMFIELD'] = InvalidCustomfield(
            'Invalid custom field(s) name or value were passed. The error_subtype holds an array of the error details'
        )
        errors_mapping['INVALID_FLAG'] = InvalidFlag(
            'An invalid flag was passed. The error_subtype holds the name of the invalid flag'
        )
        errors_mapping['MISSING_FIELDS'] = 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'] = NotFound('The account can not be found')
        errors_mapping['NOT_PERMITTED'] = NotPermitted(
            'You are not permitted to edit this user')
        errors_mapping['NO_USER_OVERRIDE'] = NoUserOverride(
            'The setting does not allow a user override')
        errors_mapping['ROLE_NOT_FOUND'] = RoleNotFound(
            'The role was not found or is not an account role')
        errors_mapping['USER_NOT_FOUND'] = UserNotFound(
            'The user can not be found or is not a member of this account')
        query_data = {
            'api': self._api,
            'url': '/account/user/set',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return QueryO(**query_data)