Esempio n. 1
0
    def get_all(self,
                service_id=None,
                field_id=None,
                group_id=None,
                no_group=False,
                tenant_id=None,
                filter_tenant=False):
        """Get the mapping list

        :param service_id: Service UUID to filter on.
        :param field_id: Field UUID to filter on.
        :param group_id: Group UUID to filter on.
        :param no_group: Filter on orphaned mappings.
        :param tenant_id: Tenant UUID to filter on.
        :param filter_tenant: Explicitly filter on tenant (default is to not
        filter on tenant). Useful if you want to filter on tenant being None.
        :return: List of every mappings.
        """
        hashmap = db_api.get_instance()
        mapping_list = []
        search_opts = dict()
        if filter_tenant:
            search_opts['tenant_uuid'] = tenant_id
        mappings_uuid_list = hashmap.list_mappings(service_uuid=service_id,
                                                   field_uuid=field_id,
                                                   group_uuid=group_id,
                                                   no_group=no_group,
                                                   **search_opts)
        for mapping_uuid in mappings_uuid_list:
            mapping_db = hashmap.get_mapping(uuid=mapping_uuid)
            mapping_list.append(
                mapping_models.Mapping(**mapping_db.export_model()))
        res = mapping_models.MappingCollection(mappings=mapping_list)
        return res
Esempio n. 2
0
    def mappings(self, group_id):
        """Get the mappings attached to the group.

        :param group_id: UUID of the group to filter on.
        """
        hashmap = db_api.get_instance()
        mapping_list = []
        mappings_uuid_list = hashmap.list_mappings(group_uuid=group_id)
        for mapping_uuid in mappings_uuid_list:
            mapping_db = hashmap.get_mapping(uuid=mapping_uuid)
            mapping_list.append(
                mapping_models.Mapping(**mapping_db.export_model()))
        res = mapping_models.MappingCollection(mappings=mapping_list)
        return res
Esempio n. 3
0
    def get_all(self,
                service_id=None,
                field_id=None,
                group_id=None,
                no_group=False):
        """Get the mapping list

        :param service_id: Service UUID to filter on.
        :param field_id: Field UUID to filter on.
        :param group_id: Group UUID to filter on.
        :param no_group: Filter on orphaned mappings.
        :return: List of every mappings.
        """
        hashmap = db_api.get_instance()
        mapping_list = []
        mappings_uuid_list = hashmap.list_mappings(service_uuid=service_id,
                                                   field_uuid=field_id,
                                                   group_uuid=group_id)
        for mapping_uuid in mappings_uuid_list:
            mapping_db = hashmap.get_mapping(uuid=mapping_uuid)
            mapping_list.append(
                mapping_models.Mapping(**mapping_db.export_model()))
        res = mapping_models.MappingCollection(mappings=mapping_list)
        return res