コード例 #1
0
ファイル: role.py プロジェクト: dyens/sdk-python
    def add(
        self,
        account_id,
        name,
        permissions=None,
    ):
        """Add.
        :param account_id: uuid of the account
        :param name: Name of the role
        :param permissions: A hash of the role permissions (optional)
        """
        request_data = {
            'name': name,
            'permissions': permissions,
            'account_id': account_id,
        }

        errors_mapping = {}
        errors_mapping['ACCOUNT_NOT_FOUND'] = AccountNotFound(
            'The account was not found')
        errors_mapping['INVALID_JSON'] = InvalidJson(
            'The field is not in valid JSON format. The error_subtype holds the name of the field'
        )
        errors_mapping['INVALID_PERMISSION'] = InvalidPermission(
            'Invalid permission flag. The error_subtype holds the name of the permission flag.'
        )
        errors_mapping['INVALID_PERMISSION_VALUE'] = InvalidPermissionValue(
            'The permission flag has an invalid value. The error_subtype holds the name of the permission 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_PERMITTED'] = NotPermitted(
            'You are not permitted to add a role to that account')
        query_data = {
            'api': self._api,
            'url': '/role/add',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return QueryO(**query_data)
コード例 #2
0
    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,
    ):
        """Add.

        :param account_id: uuid of the account
        :param name: Name of the location
        :param customfield_param: Expected values are CUSTOMFIELD_UUID. Custom field(s) (optional)
        :param hl7_template: The HL7 reporting template for the location (optional)
        :param must_approve: Flag if shared studies must be approved for the location (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 location (optional). Studies can still be shared with users in the location.
        :param role_id: Id for the default role for the location (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 location (optional)
        :param share_description: The share description of the location (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)
        """
        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,
        }
        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 location to the account')
        errors_mapping[(
            'ROLE_NAMESPACE_MISMATCH', 'GLOBAL_USER_WITH_RESTRICTED_ROLE'
        )] = RoleNamespaceMismatch(
            'You are adding the location 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 location, data contains role_id and namespace_id'
        )
        query_data = {
            'api': self._api,
            'url': '/location/add',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return QueryO(**query_data)
コード例 #3
0
ファイル: webhook.py プロジェクト: dyens/sdk-python
    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)
コード例 #4
0
ファイル: route.py プロジェクト: dyens/sdk-python
    def add(
        self,
        actions,
        conditions,
        name,
        on_harvest,
        on_share,
        account_id=None,
        delay=None,
        delay_till_schedule=None,
        group_id=None,
        location_id=None,
        manual_roles=None,
        namespace_id=None,
        no_re_run=None,
        on_manual_route=None,
        on_thin=None,
        on_upload=None,
        options=None,
        other_namespaces=None,
        schedule=None,
        suspended=None,
    ):
        """Add.
        :param actions: Route actions in JSON format
        :param conditions: Route conditions in JSON format
        :param name: Name of the route
        :param on_harvest: Apply the rule to studies harvested into the namespace
        :param on_share: Apply the rule to studies shared into the namespace
        :param account_id: account_id
        :param delay: Number of minutes to delay running this rule for after it is triggered (optional)
        :param delay_till_schedule: Delay running this rule after it is triggered until the next scheduled time - flag (optional)
        :param group_id: group_id
        :param location_id: location_id
        :param manual_roles: A comma separated list of the uuid of roles that can run the rule manually (optional)
        :param namespace_id: namespace_id
        :param no_re_run: Do not run this rule on a re-notification from storage - flag (optional)
        :param on_manual_route: Apply this rule for a manually routed study - flag (optional)
        :param on_thin: Apply this rule to thin studies when they are created - flag (optional)
        :param on_upload: Apply the rule to studies uploaded into the namespace - flag (optional)
        :param options: Route options in JSON format (optional)
        :param other_namespaces: A comma separated list of the uuid of other namespaces to apply this rule to (optional)
        :param schedule: Route schedule in JSON format (optional)
        :param suspended: This rule is suspended and not applied - flag (optional)

        Notes:
        (account_id OR group_id OR location_id OR namespace_id) - uuid of the account, group or location or namespace the route is linked with
        """
        request_data = {
           'namespace_id': namespace_id,
           'on_manual_route': on_manual_route,
           'group_id': group_id,
           'manual_roles': manual_roles,
           'on_upload': on_upload,
           'on_harvest': on_harvest,
           'delay_till_schedule': delay_till_schedule,
           'actions': actions,
           'suspended': suspended,
           'name': name,
           'options': options,
           'conditions': conditions,
           'delay': delay,
           'schedule': schedule,
           'other_namespaces': other_namespaces,
           'on_share': on_share,
           'location_id': location_id,
           'account_id': account_id,
           'no_re_run': no_re_run,
           'on_thin': on_thin,
        }
	
        errors_mapping = {}
        errors_mapping['ACCOUNT_NOT_FOUND'] = AccountNotFound('The account was not found')
        errors_mapping['INVALID_ACTION'] = InvalidAction('An action is invalid. The error_subtype holds the error detail')
        errors_mapping['INVALID_CONDITION'] = InvalidCondition('A condition is invalid. The error_subtype holds the condition')
        errors_mapping['INVALID_FLAG'] = InvalidFlag('An invalid flag was passed. The error_subtype holds the name of the invalid flag')
        errors_mapping['INVALID_JSON'] = InvalidJson('The field is not in valid JSON format. The error_subtype holds the name of the field')
        errors_mapping['INVALID_LINKAGE'] = InvalidLinkage('The linkage is invalid')
        errors_mapping['INVALID_MANUAL_ROLES'] = InvalidManualRoles('The manual_roles is invalid. The error_subtype holds the error detail')
        errors_mapping['INVALID_OPTION'] = InvalidOption('An option is invalid. The error_subtype holds the error detail')
        errors_mapping['INVALID_OTHER_NAMESPACES'] = InvalidOtherNamespaces('The other_namespaces is invalid. The error_subtype holds the error detail')
        errors_mapping['INVALID_SCHEDULE'] = InvalidSchedule('The schedule is invalid. The error_subtype holds the error detail')
        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_PERMITTED'] = NotPermitted('You are not permitted to add a route to that account')
        query_data = {
            'api': self._api,
            'url': '/route/add',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return QueryO(**query_data)
コード例 #5
0
    def add(
        self,
        accelerator_id,
        name,
        account_id=None,
        category=None,
        ctc_bucket=None,
        facility_contact=None,
        facility_contact_title=None,
        facility_email=None,
        facility_name=None,
        facility_notes=None,
        facility_zip=None,
        group_id=None,
        is_public=None,
        location_id=None,
        type=None,
        uuid=None,
    ):
        """Add.
        :param accelerator_id: uuid of the accelerator if this is an accelerator node
        :param name: Description of the node
        :param account_id: account_id
        :param category: category
        :param ctc_bucket: Name of the S3 bucket to use for a cloud to cloud gateway (optional)
        :param facility_contact: Name of the facility contact (optional)
        :param facility_contact_title: Title of the facility contact (optional)
        :param facility_email: Email of the facility contact (optional)
        :param facility_name: Name of the facility it is installed at (optional)
        :param facility_notes: Notes about the facility (optional)
        :param facility_zip: Zip code of the facility it is installed at (optional)
        :param group_id: group_id
        :param is_public: Flag if the node is public (optional)
        :param location_id: location_id
        :param type: type
        :param uuid: uuid of the node (optional, you can use this to explicitly set the UUID)

        Notes:
        category - Node category (ACTIVE OR INACTIVE OR MIGRATION OR TEST OR DUPLICATE OR INTEGRATED OR ACCELERATOR) (optional)
        (account_id OR location_id OR group_id) - uuid of the account, location or group to link this node to
        type - Type of node (STORAGE OR HARVESTER OR ACCELERATOR OR CLEARINGHOUSE OR VIRTUAL OR UTILITY)
        """
        request_data = {
           'accelerator_id': accelerator_id,
           'facility_name': facility_name,
           'group_id': group_id,
           'facility_contact': facility_contact,
           'facility_email': facility_email,
           'ctc_bucket': ctc_bucket,
           'facility_notes': facility_notes,
           'type': type,
           'name': name,
           'is_public': is_public,
           'uuid': uuid,
           'facility_contact_title': facility_contact_title,
           'category': category,
           'location_id': location_id,
           'account_id': account_id,
           'facility_zip': facility_zip,
        }
	
        errors_mapping = {}
        errors_mapping['ACCOUNT_NOT_FOUND'] = AccountNotFound('The account was not found')
        errors_mapping['INVALID_LINKAGE'] = InvalidLinkage('The linkage is invalid')
        errors_mapping['INVALID_TYPE'] = InvalidType('Invalid type of node')
        errors_mapping['INVALID_UUID'] = InvalidUuid('Invalid uuid format or this uuid is already in use')
        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_PERMITTED'] = NotPermitted('You are not permitted to add a node to this account')
        query_data = {
            'api': self._api,
            'url': '/node/add',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return QueryO(**query_data)
コード例 #6
0
ファイル: group.py プロジェクト: dyens/sdk-python
    def add(
        self,
        account_id,
        name,
        customfield_param=None,
        hl7_template=None,
        must_approve=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,
    ):
        """Add.
        :param account_id: uuid of the account
        :param name: Name of the group
        :param customfield_param: 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_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)
        """
        request_data = {
            'share_via_gateway': share_via_gateway,
            'share_code': share_code,
            'role_id': role_id,
            'share_settings': share_settings,
            'search_threshold': search_threshold,
            'must_approve_upload': must_approve_upload,
            'must_approve': must_approve,
            'name': name,
            'hl7_template': hl7_template,
            'share_description': share_description,
            'no_share': no_share,
            'account_id': account_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'] = AccountNotFound(
            'The account was not found')
        errors_mapping['DUP_SHARE_CODE'] = DupShareCode(
            'The share code is already used')
        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['INVALID_JSON'] = InvalidJson(
            'The field is not in valid JSON format. The error_subtype holds the name of the field'
        )
        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 object was not found. The error_subtype holds the name of field that triggered the error'
        )
        errors_mapping['NOT_PERMITTED'] = NotPermitted(
            'You are not permitted to add a group to that account')
        query_data = {
            'api': self._api,
            'url': '/group/add',
            'request_data': request_data,
            'errors_mapping': errors_mapping,
            'required_sid': True,
        }
        return QueryO(**query_data)