-
Notifications
You must be signed in to change notification settings - Fork 10
/
schemas.py
122 lines (90 loc) · 3.2 KB
/
schemas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import, print_function
from predicthq.endpoints.schemas import (
PaginatedMixin, SortableMixin, Model, ResultSet, ListType, StringType, GeoJSONPointType,
StringListType, StringModelType, Area, ModelType, IntRange, IntType, DateTimeRange,
DateTimeType, FloatType, ResultType, DictType, DateType, Place, Signal, DateAround,
LocationAround, BooleanType, BrandUnsafe, Entity
)
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)
brand_unsafe = ModelType(BrandUnsafe)
entity = ModelType(Entity)
class Entities(Model):
class Options:
serialize_when_none = True
entity_id = StringType()
name = StringType()
type = StringType()
formatted_address = StringType()
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()
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()
class EventResultSet(ResultSet):
overflow = BooleanType()
results = ResultType(Event)
class Count(Model):
count = IntType()
top_rank = FloatType()
rank_levels = DictType(IntType)
categories = DictType(IntType)
labels = DictType(IntType)
class TopEventsSearchParams(SortableMixin, Model):
limit = IntType(min_value=0, max_value=10)
class CalendarParams(SearchParams):
top_events = ModelType(TopEventsSearchParams)
view = StringType(choices=('active', 'start'))
class CalendarDay(Model):
date = DateType()
count = IntType()
top_rank = FloatType()
rank_levels = DictType(IntType)
categories = DictType(IntType)
labels = DictType(IntType)
top_events = ModelType(EventResultSet)
class CalendarResultSet(ResultSet):
results = ResultType(CalendarDay)