OLD | NEW |
| (Empty) |
1 // This is a generated file (see the discoveryapis_generator project). | |
2 | |
3 library googleapis.freebase.v1; | |
4 | |
5 import 'dart:core' as core; | |
6 import 'dart:async' as async; | |
7 import 'dart:convert' as convert; | |
8 | |
9 import 'package:_discoveryapis_commons/_discoveryapis_commons.dart' as commons; | |
10 import 'package:http/http.dart' as http; | |
11 | |
12 export 'package:_discoveryapis_commons/_discoveryapis_commons.dart' show | |
13 ApiRequestError, DetailedApiRequestError, Media, UploadOptions, | |
14 ResumableUploadOptions, DownloadOptions, PartialDownloadOptions, | |
15 ByteRange; | |
16 | |
17 const core.String USER_AGENT = 'dart-api-client freebase/v1'; | |
18 | |
19 /** Find Freebase entities using textual queries and other constraints. */ | |
20 class FreebaseApi { | |
21 | |
22 final commons.ApiRequester _requester; | |
23 | |
24 FreebaseApi(http.Client client, {core.String rootUrl: "https://www.googleapis.
com/", core.String servicePath: "freebase/v1/"}) : | |
25 _requester = new commons.ApiRequester(client, rootUrl, servicePath, USER_A
GENT); | |
26 | |
27 /** | |
28 * Reconcile entities to Freebase open data. | |
29 * | |
30 * Request parameters: | |
31 * | |
32 * [confidence] - Required confidence for a candidate to match. Must be | |
33 * between .5 and 1.0 | |
34 * Value must be between "0.0" and "1.0". | |
35 * | |
36 * [kind] - Classifications of entity e.g. type, category, title. | |
37 * | |
38 * [lang] - Languages for names and values. First language is used for | |
39 * display. Default is 'en'. | |
40 * | |
41 * [limit] - Maximum number of candidates to return. | |
42 * Value must be between "0" and "25". | |
43 * | |
44 * [name] - Name of entity. | |
45 * | |
46 * [prop] - Property values for entity formatted as | |
47 * : | |
48 * | |
49 * Completes with a [ReconcileGet]. | |
50 * | |
51 * Completes with a [commons.ApiRequestError] if the API endpoint returned an | |
52 * error. | |
53 * | |
54 * If the used [http.Client] completes with an error when making a REST call, | |
55 * this method will complete with the same error. | |
56 */ | |
57 async.Future<ReconcileGet> reconcile({core.double confidence, core.List<core.S
tring> kind, core.List<core.String> lang, core.int limit, core.String name, core
.List<core.String> prop}) { | |
58 var _url = null; | |
59 var _queryParams = new core.Map(); | |
60 var _uploadMedia = null; | |
61 var _uploadOptions = null; | |
62 var _downloadOptions = commons.DownloadOptions.Metadata; | |
63 var _body = null; | |
64 | |
65 if (confidence != null) { | |
66 _queryParams["confidence"] = ["${confidence}"]; | |
67 } | |
68 if (kind != null) { | |
69 _queryParams["kind"] = kind; | |
70 } | |
71 if (lang != null) { | |
72 _queryParams["lang"] = lang; | |
73 } | |
74 if (limit != null) { | |
75 _queryParams["limit"] = ["${limit}"]; | |
76 } | |
77 if (name != null) { | |
78 _queryParams["name"] = [name]; | |
79 } | |
80 if (prop != null) { | |
81 _queryParams["prop"] = prop; | |
82 } | |
83 | |
84 _url = 'reconcile'; | |
85 | |
86 var _response = _requester.request(_url, | |
87 "GET", | |
88 body: _body, | |
89 queryParams: _queryParams, | |
90 uploadOptions: _uploadOptions, | |
91 uploadMedia: _uploadMedia, | |
92 downloadOptions: _downloadOptions); | |
93 return _response.then((data) => new ReconcileGet.fromJson(data)); | |
94 } | |
95 | |
96 /** | |
97 * Search Freebase open data. | |
98 * | |
99 * Request parameters: | |
100 * | |
101 * [asOfTime] - A mql as_of_time value to use with mql_output queries. | |
102 * | |
103 * [callback] - JS method name for JSONP callbacks. | |
104 * Value must have pattern "([A-Za-z0-9_$.]|\[|\])+". | |
105 * | |
106 * [cursor] - The cursor value to use for the next page of results. | |
107 * | |
108 * [domain] - Restrict to topics with this Freebase domain id. | |
109 * | |
110 * [encode] - The encoding of the response. You can use this parameter to | |
111 * enable html encoding. | |
112 * Possible string values are: | |
113 * - "html" : Encode certain characters in the response (such as tags and | |
114 * ambersands) using html encoding. | |
115 * - "off" : No encoding of the response. You should not print the results | |
116 * directly on an web page without html-escaping the content first. | |
117 * | |
118 * [exact] - Query on exact name and keys only. | |
119 * | |
120 * [filter] - A filter to apply to the query. | |
121 * Value must have pattern "^\(.*\)$". | |
122 * | |
123 * [format] - Structural format of the json response. | |
124 * Possible string values are: | |
125 * - "ac" : Compact format useful for autocomplete/suggest UIs. | |
126 * - "classic" : [DEPRECATED] Same format as was returned by api.freebase.com. | |
127 * - "entity" : Basic information about the entities. | |
128 * - "guids" : [DEPRECATED] Ordered list of a freebase guids. | |
129 * - "ids" : Ordered list of freebase ids. | |
130 * - "mids" : Ordered list of freebase mids. | |
131 * | |
132 * [help] - The keyword to request help on. | |
133 * Possible string values are: | |
134 * - "langs" : The language codes served by the service. | |
135 * - "mappings" : The property/path mappings supported by the filter and | |
136 * output request parameters. | |
137 * - "predicates" : The predicates and path-terminating properties supported | |
138 * by the filter and output request parameters. | |
139 * | |
140 * [indent] - Whether to indent the json results or not. | |
141 * | |
142 * [lang] - The code of the language to run the query with. Default is 'en'. | |
143 * | |
144 * [limit] - Maximum number of results to return. | |
145 * | |
146 * [mid] - A mid to use instead of a query. | |
147 * Value must have pattern "^/[mgtx]/[0-2][0-9bcdfghjklmnpqrstvwxyz_]{1,24}$". | |
148 * | |
149 * [mqlOutput] - The MQL query to run againist the results to extract more | |
150 * data. | |
151 * | |
152 * [output] - An output expression to request data from matches. | |
153 * Value must have pattern "^\(.*\)$". | |
154 * | |
155 * [prefixed] - Prefix match against names and aliases. | |
156 * | |
157 * [query] - Query term to search for. | |
158 * | |
159 * [scoring] - Relevance scoring algorithm to use. | |
160 * Possible string values are: | |
161 * - "entity" : Use freebase and popularity entity ranking. | |
162 * - "freebase" : Use freebase entity ranking. | |
163 * - "schema" : Use schema ranking for properties and types. | |
164 * | |
165 * [spell] - Request 'did you mean' suggestions | |
166 * Possible string values are: | |
167 * - "always" : Request spelling suggestions for any query at least three | |
168 * characters long. | |
169 * - "no_results" : Request spelling suggestions if no results were found. | |
170 * - "no_spelling" : Don't request spelling suggestions. | |
171 * | |
172 * [stemmed] - Query on stemmed names and aliases. May not be used with | |
173 * prefixed. | |
174 * | |
175 * [type] - Restrict to topics with this Freebase type id. | |
176 * | |
177 * [with_] - A rule to match against. | |
178 * | |
179 * [without] - A rule to not match against. | |
180 * | |
181 * [downloadOptions] - Options for downloading. A download can be either a | |
182 * Metadata (default) or Media download. Partial Media downloads are possible | |
183 * as well. | |
184 * | |
185 * Completes with a [commons.ApiRequestError] if the API endpoint returned an | |
186 * error. | |
187 * | |
188 * If the used [http.Client] completes with an error when making a REST call, | |
189 * this method will complete with the same error. | |
190 */ | |
191 async.Future search({core.String asOfTime, core.String callback, core.int curs
or, core.List<core.String> domain, core.String encode, core.bool exact, core.Lis
t<core.String> filter, core.String format, core.String help, core.bool indent, c
ore.List<core.String> lang, core.int limit, core.List<core.String> mid, core.Str
ing mqlOutput, core.String output, core.bool prefixed, core.String query, core.S
tring scoring, core.String spell, core.bool stemmed, core.List<core.String> type
, core.List<core.String> with_, core.List<core.String> without, commons.Download
Options downloadOptions: commons.DownloadOptions.Metadata}) { | |
192 var _url = null; | |
193 var _queryParams = new core.Map(); | |
194 var _uploadMedia = null; | |
195 var _uploadOptions = null; | |
196 var _downloadOptions = commons.DownloadOptions.Metadata; | |
197 var _body = null; | |
198 | |
199 if (asOfTime != null) { | |
200 _queryParams["as_of_time"] = [asOfTime]; | |
201 } | |
202 if (callback != null) { | |
203 _queryParams["callback"] = [callback]; | |
204 } | |
205 if (cursor != null) { | |
206 _queryParams["cursor"] = ["${cursor}"]; | |
207 } | |
208 if (domain != null) { | |
209 _queryParams["domain"] = domain; | |
210 } | |
211 if (encode != null) { | |
212 _queryParams["encode"] = [encode]; | |
213 } | |
214 if (exact != null) { | |
215 _queryParams["exact"] = ["${exact}"]; | |
216 } | |
217 if (filter != null) { | |
218 _queryParams["filter"] = filter; | |
219 } | |
220 if (format != null) { | |
221 _queryParams["format"] = [format]; | |
222 } | |
223 if (help != null) { | |
224 _queryParams["help"] = [help]; | |
225 } | |
226 if (indent != null) { | |
227 _queryParams["indent"] = ["${indent}"]; | |
228 } | |
229 if (lang != null) { | |
230 _queryParams["lang"] = lang; | |
231 } | |
232 if (limit != null) { | |
233 _queryParams["limit"] = ["${limit}"]; | |
234 } | |
235 if (mid != null) { | |
236 _queryParams["mid"] = mid; | |
237 } | |
238 if (mqlOutput != null) { | |
239 _queryParams["mql_output"] = [mqlOutput]; | |
240 } | |
241 if (output != null) { | |
242 _queryParams["output"] = [output]; | |
243 } | |
244 if (prefixed != null) { | |
245 _queryParams["prefixed"] = ["${prefixed}"]; | |
246 } | |
247 if (query != null) { | |
248 _queryParams["query"] = [query]; | |
249 } | |
250 if (scoring != null) { | |
251 _queryParams["scoring"] = [scoring]; | |
252 } | |
253 if (spell != null) { | |
254 _queryParams["spell"] = [spell]; | |
255 } | |
256 if (stemmed != null) { | |
257 _queryParams["stemmed"] = ["${stemmed}"]; | |
258 } | |
259 if (type != null) { | |
260 _queryParams["type"] = type; | |
261 } | |
262 if (with_ != null) { | |
263 _queryParams["with"] = with_; | |
264 } | |
265 if (without != null) { | |
266 _queryParams["without"] = without; | |
267 } | |
268 | |
269 _downloadOptions = downloadOptions; | |
270 | |
271 _url = 'search'; | |
272 | |
273 var _response = _requester.request(_url, | |
274 "GET", | |
275 body: _body, | |
276 queryParams: _queryParams, | |
277 uploadOptions: _uploadOptions, | |
278 uploadMedia: _uploadMedia, | |
279 downloadOptions: _downloadOptions); | |
280 if (_downloadOptions == null || | |
281 _downloadOptions == commons.DownloadOptions.Metadata) { | |
282 return _response.then((data) => null); | |
283 } else { | |
284 return _response; | |
285 } | |
286 } | |
287 | |
288 } | |
289 | |
290 | |
291 | |
292 /** Type or profession the candidate is notable for. */ | |
293 class ReconcileCandidateNotable { | |
294 /** MID of notable category. */ | |
295 core.String id; | |
296 /** Name of notable category in specified language. */ | |
297 core.String name; | |
298 | |
299 ReconcileCandidateNotable(); | |
300 | |
301 ReconcileCandidateNotable.fromJson(core.Map _json) { | |
302 if (_json.containsKey("id")) { | |
303 id = _json["id"]; | |
304 } | |
305 if (_json.containsKey("name")) { | |
306 name = _json["name"]; | |
307 } | |
308 } | |
309 | |
310 core.Map toJson() { | |
311 var _json = new core.Map(); | |
312 if (id != null) { | |
313 _json["id"] = id; | |
314 } | |
315 if (name != null) { | |
316 _json["name"] = name; | |
317 } | |
318 return _json; | |
319 } | |
320 } | |
321 | |
322 class ReconcileCandidate { | |
323 /** | |
324 * Percentage likelihood that this candidate is the unique matching entity. | |
325 * Value will be between 0.0 and 1.0 | |
326 */ | |
327 core.double confidence; | |
328 /** Language code that candidate and notable names are displayed in. */ | |
329 core.String lang; | |
330 /** Freebase MID of candidate entity. */ | |
331 core.String mid; | |
332 /** Freebase name of matching entity in specified language. */ | |
333 core.String name; | |
334 /** Type or profession the candidate is notable for. */ | |
335 ReconcileCandidateNotable notable; | |
336 | |
337 ReconcileCandidate(); | |
338 | |
339 ReconcileCandidate.fromJson(core.Map _json) { | |
340 if (_json.containsKey("confidence")) { | |
341 confidence = _json["confidence"]; | |
342 } | |
343 if (_json.containsKey("lang")) { | |
344 lang = _json["lang"]; | |
345 } | |
346 if (_json.containsKey("mid")) { | |
347 mid = _json["mid"]; | |
348 } | |
349 if (_json.containsKey("name")) { | |
350 name = _json["name"]; | |
351 } | |
352 if (_json.containsKey("notable")) { | |
353 notable = new ReconcileCandidateNotable.fromJson(_json["notable"]); | |
354 } | |
355 } | |
356 | |
357 core.Map toJson() { | |
358 var _json = new core.Map(); | |
359 if (confidence != null) { | |
360 _json["confidence"] = confidence; | |
361 } | |
362 if (lang != null) { | |
363 _json["lang"] = lang; | |
364 } | |
365 if (mid != null) { | |
366 _json["mid"] = mid; | |
367 } | |
368 if (name != null) { | |
369 _json["name"] = name; | |
370 } | |
371 if (notable != null) { | |
372 _json["notable"] = (notable).toJson(); | |
373 } | |
374 return _json; | |
375 } | |
376 } | |
377 | |
378 /** Server costs for reconciling. */ | |
379 class ReconcileGetCosts { | |
380 /** Total number of hits found. */ | |
381 core.int hits; | |
382 /** Total milliseconds spent. */ | |
383 core.int ms; | |
384 | |
385 ReconcileGetCosts(); | |
386 | |
387 ReconcileGetCosts.fromJson(core.Map _json) { | |
388 if (_json.containsKey("hits")) { | |
389 hits = _json["hits"]; | |
390 } | |
391 if (_json.containsKey("ms")) { | |
392 ms = _json["ms"]; | |
393 } | |
394 } | |
395 | |
396 core.Map toJson() { | |
397 var _json = new core.Map(); | |
398 if (hits != null) { | |
399 _json["hits"] = hits; | |
400 } | |
401 if (ms != null) { | |
402 _json["ms"] = ms; | |
403 } | |
404 return _json; | |
405 } | |
406 } | |
407 | |
408 class ReconcileGetWarning { | |
409 /** Location of warning in the request e.g. invalid predicate. */ | |
410 core.String location; | |
411 /** Warning message to display to the user. */ | |
412 core.String message; | |
413 /** Code for identifying classes of warnings. */ | |
414 core.String reason; | |
415 | |
416 ReconcileGetWarning(); | |
417 | |
418 ReconcileGetWarning.fromJson(core.Map _json) { | |
419 if (_json.containsKey("location")) { | |
420 location = _json["location"]; | |
421 } | |
422 if (_json.containsKey("message")) { | |
423 message = _json["message"]; | |
424 } | |
425 if (_json.containsKey("reason")) { | |
426 reason = _json["reason"]; | |
427 } | |
428 } | |
429 | |
430 core.Map toJson() { | |
431 var _json = new core.Map(); | |
432 if (location != null) { | |
433 _json["location"] = location; | |
434 } | |
435 if (message != null) { | |
436 _json["message"] = message; | |
437 } | |
438 if (reason != null) { | |
439 _json["reason"] = reason; | |
440 } | |
441 return _json; | |
442 } | |
443 } | |
444 | |
445 class ReconcileGet { | |
446 /** | |
447 * If filled, then the listed candidates are potential matches, and such | |
448 * should be evaluated by a more discerning algorithm or human. The matches | |
449 * are ordered by confidence. | |
450 */ | |
451 core.List<ReconcileCandidate> candidate; | |
452 /** Server costs for reconciling. */ | |
453 ReconcileGetCosts costs; | |
454 /** | |
455 * If filled, this entity is guaranteed to match at requested confidence | |
456 * probability (default 99%). | |
457 */ | |
458 ReconcileCandidate match; | |
459 /** | |
460 * If filled, then there were recoverable problems that affected the request. | |
461 * For example, some of the properties were ignored because they either are | |
462 * not valid Freebase predicates or are not indexed for reconciliation. The | |
463 * candidates returned should be considered valid results, with the caveat | |
464 * that sections of the request were ignored as specified by the warning text. | |
465 */ | |
466 core.List<ReconcileGetWarning> warning; | |
467 | |
468 ReconcileGet(); | |
469 | |
470 ReconcileGet.fromJson(core.Map _json) { | |
471 if (_json.containsKey("candidate")) { | |
472 candidate = _json["candidate"].map((value) => new ReconcileCandidate.fromJ
son(value)).toList(); | |
473 } | |
474 if (_json.containsKey("costs")) { | |
475 costs = new ReconcileGetCosts.fromJson(_json["costs"]); | |
476 } | |
477 if (_json.containsKey("match")) { | |
478 match = new ReconcileCandidate.fromJson(_json["match"]); | |
479 } | |
480 if (_json.containsKey("warning")) { | |
481 warning = _json["warning"].map((value) => new ReconcileGetWarning.fromJson
(value)).toList(); | |
482 } | |
483 } | |
484 | |
485 core.Map toJson() { | |
486 var _json = new core.Map(); | |
487 if (candidate != null) { | |
488 _json["candidate"] = candidate.map((value) => (value).toJson()).toList(); | |
489 } | |
490 if (costs != null) { | |
491 _json["costs"] = (costs).toJson(); | |
492 } | |
493 if (match != null) { | |
494 _json["match"] = (match).toJson(); | |
495 } | |
496 if (warning != null) { | |
497 _json["warning"] = warning.map((value) => (value).toJson()).toList(); | |
498 } | |
499 return _json; | |
500 } | |
501 } | |
OLD | NEW |