Exemplo n.º 1
0
class Client(base.Client):
    def __init__(self, api_key=None):
        self.client = SolveClient(api_key)

    def service(self):
        return {'name': 'Solvebio API'}

    def namespaces(self):
        return self.client.get_namespaces()

    def datasets(self, namespace_name):
        namespace = self.client.get_namespace(namespace_name)
        return namespace['datasets']

    def fields(self, namespace_name, dataset_name):
        dataset = self.client.get_dataset(namespace_name, dataset_name)
        return dataset['fields']

    def facets(self, namespace_name, dataset_name, field_name):
        field = self.client.get_dataset_field(namespace_name, dataset_name,
                                              field_name)
        if not field or not field['facets']:
            return {}

        if field['data_type'] == 'string':
            return {'values': field['facets']}

        if field['data_type'] in ('integer', 'double', 'long', 'float'):
            return {
                'min_value': field['facets'][0],
                'max_value': field['facets'][1],
            }
Exemplo n.º 2
0
 def __init__(self, api_key=None):
     self.client = SolveClient(api_key)