def summary(self, raw):
        """Use the Backscatter.io summary data to create a view."""
        taxonomies = list()
        level = 'info'
        namespace = 'Backscatter.io'

        if self.service == 'observations':
            summary = raw.get('results', dict()).get('summary', dict())
            taxonomies = taxonomies + [
                self.build_taxonomy(level, namespace, 'Observations', summary.get('observations_count', 0)),
                self.build_taxonomy(level, namespace, 'IP Addresses', summary.get('ip_address_count', 0)),
                self.build_taxonomy(level, namespace, 'Networks', summary.get('network_count', 0)),
                self.build_taxonomy(level, namespace, 'AS', summary.get('autonomous_system_count', 0)),
                self.build_taxonomy(level, namespace, 'Ports', summary.get('port_count', 0)),
                self.build_taxonomy(level, namespace, 'Protocols', summary.get('protocol_count', 0))
            ]
        elif self.service == 'enrichment':
            summary = raw.get('results', dict())
            if self.data_type == 'ip':
                taxonomies = taxonomies + [
                    self.build_taxonomy(level, namespace, 'Network', summary.get('network')),
                    self.build_taxonomy(level, namespace, 'Network Broadcast', summary.get('network_broadcast')),
                    self.build_taxonomy(level, namespace, 'Network Size', summary.get('network_size')),
                    self.build_taxonomy(level, namespace, 'Country', summary.get('country_name')),
                    self.build_taxonomy(level, namespace, 'AS Number', summary.get('as_num')),
                    self.build_taxonomy(level, namespace, 'AS Name', summary.get('as_name')),
                ]
            elif self.data_type == 'network':
                taxonomies = taxonomies + [
                    self.build_taxonomy(level, namespace, 'Network Size', summary.get('network_size'))
                ]
            elif self.data_type == 'autonomous-system':
                taxonomies = taxonomies + [
                    self.build_taxonomy(level, namespace, 'Prefix Count', summary.get('prefix_count')),
                    self.build_taxonomy(level, namespace, 'AS Number', summary.get('as_num')),
                    self.build_taxonomy(level, namespace, 'AS Name', summary.get('as_name'))
                ]
            elif self.data_type == 'port':
                for result in raw.get('results', list()):
                    display = "%s (%s)" % (result.get('service'), result.get('protocol'))
                    taxonomies.append(self.build_taxonomy(level, namespace, 'Service', display))
            else:
                pass
        else:
            pass
        return {"taxonomies": taxonomies}
def summary ( self , raw ) : taxonomies = list ( ) level = 'info' namespace = 'Backscatter.io' if self . service == 'observations' : summary = raw . get ( 'results' , dict ( ) ) . get ( 'summary' , dict ( ) ) taxonomies = taxonomies + [ self . build_taxonomy ( level , namespace , 'Observations' , summary . get ( 'observations_count' , 0 ) ) , self . build_taxonomy ( level , namespace , 'IP Addresses' , summary . get ( 'ip_address_count' , 0 ) ) , self . build_taxonomy ( level , namespace , 'Networks' , summary . get ( 'network_count' , 0 ) ) , self . build_taxonomy ( level , namespace , 'AS' , summary . get ( 'autonomous_system_count' , 0 ) ) , self . build_taxonomy ( level , namespace , 'Ports' , summary . get ( 'port_count' , 0 ) ) , self . build_taxonomy ( level , namespace , 'Protocols' , summary . get ( 'protocol_count' , 0 ) ) ] elif self . service == 'enrichment' : summary = raw . get ( 'results' , dict ( ) ) if self . data_type == 'ip' : taxonomies = taxonomies + [ self . build_taxonomy ( level , namespace , 'Network' , summary . get ( 'network' ) ) , self . build_taxonomy ( level , namespace , 'Network Broadcast' , summary . get ( 'network_broadcast' ) ) , self . build_taxonomy ( level , namespace , 'Network Size' , summary . get ( 'network_size' ) ) , self . build_taxonomy ( level , namespace , 'Country' , summary . get ( 'country_name' ) ) , self . build_taxonomy ( level , namespace , 'AS Number' , summary . get ( 'as_num' ) ) , self . build_taxonomy ( level , namespace , 'AS Name' , summary . get ( 'as_name' ) ) , ] elif self . data_type == 'network' : taxonomies = taxonomies + [ self . build_taxonomy ( level , namespace , 'Network Size' , summary . get ( 'network_size' ) ) ] elif self . data_type == 'autonomous-system' : taxonomies = taxonomies + [ self . build_taxonomy ( level , namespace , 'Prefix Count' , summary . get ( 'prefix_count' ) ) , self . build_taxonomy ( level , namespace , 'AS Number' , summary . get ( 'as_num' ) ) , self . build_taxonomy ( level , namespace , 'AS Name' , summary . get ( 'as_name' ) ) ] elif self . data_type == 'port' : for result in raw . get ( 'results' , list ( ) ) : display = "%s (%s)" % ( result . get ( 'service' ) , result . get ( 'protocol' ) ) taxonomies . append ( self . build_taxonomy ( level , namespace , 'Service' , display ) ) else : pass else : pass return { "taxonomies" : taxonomies }
Use the Backscatter.io summary data to create a view.