Beispiel #1
0
class SearchParams(PaginatedMixin, SortableMixin, Model):

    class Options:
        serialize_when_none = False

    id = ListType(StringType)
    q = StringType()
    label = ListType(StringType)
    category = ListType(StringType)
    start = ModelType(DateTimeRange)
    start_around = ModelType(DateAround)
    end = ModelType(DateTimeRange)
    end_around = ModelType(DateAround)
    active = ModelType(DateTimeRange)
    updated = ModelType(DateTimeRange)
    state = StringType(choices=('active', 'deleted'))
    local_rank_level = ListType(IntType(min_value=1, max_value=5))
    local_rank = ModelType(IntRange)
    rank_level = ListType(IntType(min_value=1, max_value=5))
    rank = ModelType(IntRange)
    country = ListType(StringType)
    location_around = ModelType(LocationAround)
    within = StringListType(StringModelType(Area), separator="+")
    place = ModelType(Place)
    signal = ModelType(Signal)
    relevance = ListType(StringType)
Beispiel #2
0
class Dimension(Model):
    class Options:
        serialize_when_none = True
        roles = {"create": wholelist(), "update": wholelist()}

    name = StringType(required=True)
    type = StringType(choices=("category", "number", "date"), required=True)
Beispiel #3
0
class AccessToken(Model):

    access_token = StringType()
    token_type = StringType()
    scope = StringListType(StringType, separator=" ")
    refresh_token = StringType(serialize_when_none=False)
    expires_in = IntType(serialize_when_none=False)
Beispiel #4
0
class SearchParams(PaginatedMixin, SortableMixin, Model):
    class Options:
        serialize_when_none = False

    id = ListType(StringType)
    q = StringType()
    label = ListType(StringType)
    category = ListType(StringType)
    start = ModelType(DateTimeRange)
    start_around = ModelType(DateAround)
    end = ModelType(DateTimeRange)
    end_around = ModelType(DateAround)
    active = ModelType(DateTimeRange)
    updated = ModelType(DateTimeRange)
    state = StringType(choices=('active', 'deleted'))
    rank = ModelType(IntRange)
    rank_level = ListType(IntType(min_value=1, max_value=5))

    # `local_rank` and `aviation_rank` are paid features.
    # If you haven't subscribed to a paid feature, using it as a
    # search param will have no effect on your search results.
    local_rank = ModelType(IntRange)
    local_rank_level = ListType(IntType(min_value=1, max_value=5))
    aviation_rank = ModelType(IntRange)
    aviation_rank_level = ListType(IntType(min_value=1, max_value=5))

    country = ListType(StringType)
    location_around = ModelType(LocationAround)
    within = StringListType(StringModelType(Area), separator="+")
    place = ModelType(Place)
    signal = ModelType(Signal)
    relevance = ListType(StringType)
    brand_unsafe = ModelType(BrandUnsafe)
    entity = ModelType(Entity)
Beispiel #5
0
class Account(Model):

    id = StringType()
    name = StringType()
    description = StringType()
    industry = ModelType(Industry)
    created_at = DateTimeType()
    updated_at = DateTimeType()
Beispiel #6
0
class Entities(Model):
    class Options:
        serialize_when_none = True

    entity_id = StringType()
    name = StringType()
    type = StringType()
    formatted_address = StringType()
Beispiel #7
0
class RevokeTokenParams(Model):

    class Options:
        serialize_when_none = False

    client_id = StringType(default=lambda: config.OAUTH2_CLIENT_ID, required=True)
    client_secret = StringType(default=lambda: config.OAUTH2_CLIENT_SECRET, required=True)
    token = StringType(required=True)
    token_type_hint = StringType(choices=('access_token', 'refresh_token'), default='access_token', required=True)
Beispiel #8
0
class GetTokenParams(Model):

    class Options:
        serialize_when_none = False

    client_id = StringType(default=lambda: config.OAUTH2_CLIENT_ID, required=True)
    client_secret = StringType(default=lambda: config.OAUTH2_CLIENT_SECRET, required=True)
    scope = StringListType(StringType, default=lambda: config.OAUTH2_SCOPE, separator=" ")
    grant_type = StringType(choices=('client_credentials',), default='client_credentials', required=True)
Beispiel #9
0
class Signal(Model):
    class Options:
        serialize_when_none = True
        roles = {
            "create": whitelist("name", "country", "dimensions"),
            "update": blacklist("created_at", "updated_at")
        }

    id = StringType()
    name = StringType(required=True)
    country = StringType(max_length=2, min_length=2, required=True)
    dimensions = ListType(ModelType(Dimension), default=[])
    created_at = DateTimeType()
    updated_at = DateTimeType()

    def add_dimension(self, dimension_name, dimension_type):
        self.dimensions.append(
            Dimension({
                "name": dimension_name,
                "type": dimension_type
            }))

    def remove_dimension(self, dimension_name):
        self.dimensions = [
            dimension for dimension in self.dimensions
            if dimension.name != dimension_name
        ]

    def save(self, endpoint=None):
        if endpoint is not None:
            self._endpoint = endpoint
        if self.id:
            return self._endpoint.update(self)
        else:
            return self._endpoint.create(self)

    def delete(self):
        self._endpoint.delete(id=self.id)

    def sink(self, data_points, chunk_size=1000):
        return self._endpoint.sink(id=self.id,
                                   data_points=data_points,
                                   chunk_size=chunk_size)

    def summary(self):
        return self._endpoint.dimensions(id=self.id)

    def analysis(self, **params):
        return self._endpoint.analysis(id=self.id, **params)
Beispiel #10
0
class DataPoint(Model):

    uid = StringType(required=True)
    date = DateTimeType(required=True)
    latitude = FloatType(min_value=-90, max_value=90, required=True)
    longitude = FloatType(min_value=-180, max_value=180, required=True)
    initiated = DateTimeType()
    completed = DateTimeType()
Beispiel #11
0
class NumberDimension(Model):

    type = StringType()
    count = IntType()
    min = IntType()
    max = IntType()
    avg = FloatType()
    std_deviation = FloatType()
Beispiel #12
0
class SearchParams(LimitMixin, Model):
    class Options:
        serialize_when_none = False

    q = StringType()
    id = ListType(StringType)
    location = StringListType(StringModelType(Location), separator="+")
    country = ListType(StringType)
    type = ListType(
        StringType(choices=('planet', 'continent', 'country', 'region',
                            'county', 'local', 'major', 'metro', 'all')))

    def validate(self, *args, **kwargs):
        super(SearchParams, self).validate(*args, **kwargs)
        if not any((self.q, self.id, self.location, self.country)):
            raise SchematicsValidationError(
                "Places search requires one of q, id, location or country")
Beispiel #13
0
class Place(Model):

    id = StringType()
    type = StringType()
    name = StringType()
    county = StringType()
    region = StringType()
    country = StringType()
    country_alpha2 = StringType()
    country_alpha3 = StringType()
    location = GeoJSONPointType()
Beispiel #14
0
class AnalysisParams(PaginatedMixin, SortableMixin, Model):
    class Options:
        serialize_when_none = False

    id = StringType(required=True)
    date = ModelType(DateTimeRange)
    initiated = ModelType(DateTimeRange)
    completed = ModelType(DateTimeRange)
    within = StringListType(StringModelType(Area), separator="+")
    significance = FloatType(min_value=0, max_value=100)
    place = ModelType(Place)
Beispiel #15
0
class Event(Model):

    class Options:
        serialize_when_none = True

    id = StringType()
    title = StringType()
    description = StringType()
    start = DateTimeType()
    end = DateTimeType()
    timezone = StringType()
    duration = IntType()
    category = StringType()
    labels = ListType(StringType())
    country = StringType()
    rank = IntType()
    local_rank = IntType()
    location = GeoJSONPointType()
    place_hierarchies = ListType(ListType(StringType()))
    scope = StringType()
    relevance = FloatType()
Beispiel #16
0
class GeoDimension(Model):

    type = StringType()
    bbox = ListType(FloatType)
Beispiel #17
0
class DateDimension(Model):

    type = StringType()
    count = IntType()
    min = DateTimeType()
    max = DateTimeType()
Beispiel #18
0
class CategoryDimensionComponent(Model):

    name = StringType()
    count = IntType()
Beispiel #19
0
class SignalID(Model):

    id = StringType(required=True)
Beispiel #20
0
class SignalDataPoints(Model):

    id = StringType(required=True)
    data_points = ListType(ModelType(DataPoint), required=True)
    chunk_size = IntType(default=1000, max_value=5000, required=True)
Beispiel #21
0
class Event(Model):
    class Options:
        serialize_when_none = True

    id = StringType()
    title = StringType()
    description = StringType()
    start = DateTimeType()
    end = DateTimeType()
    timezone = StringType()
    duration = IntType()
    category = StringType()
    labels = ListType(StringType())
    country = StringType()
    rank = IntType()

    # `local_rank`, `aviation_rank`, and `phq_attendance` are paid features.
    # They will only show up in your response body if you
    # have subscribed to them.
    local_rank = IntType()
    aviation_rank = IntType()
    phq_attendance = IntType()

    entities = ListType(ModelType(Entities))
    location = GeoJSONPointType()
    place_hierarchies = ListType(ListType(StringType()))
    scope = StringType()
    relevance = FloatType()
    state = StringType()
    first_seen = DateTimeType()
    updated = DateTimeType()
    deleted_reason = StringType()
    duplicate_of_id = StringType()
Beispiel #22
0
class CalendarParams(SearchParams):

    top_events = ModelType(TopEventsSearchParams)
    view = StringType(choices=('active', 'start'))
Beispiel #23
0
class Industry(Model):

    id = StringType()
    name = StringType()
Beispiel #24
0
class ImpactParams(SearchParams):

    top_events = ModelType(TopEventsSearchParams)
    impact_rank = StringType(choices=('rank', 'aviation_rank'))
Beispiel #25
0
class CategoryDimension(Model):

    type = StringType()
    options = ListType(ModelType(CategoryDimensionComponent))