1
// Package freebase provides access to the Freebase Search.
3
// See https://developers.google.com/freebase/
7
// import "google.golang.org/api/freebase/v1-sandbox"
9
// freebaseService, err := freebase.New(oauthHttpClient)
17
"google.golang.org/api/googleapi"
25
// Always reference these packages, just in case the auto-generated code
27
var _ = bytes.NewBuffer
30
var _ = json.NewDecoder
33
var _ = googleapi.Version
35
var _ = strings.Replace
37
const apiId = "freebase:v1-sandbox"
38
const apiName = "freebase"
39
const apiVersion = "v1-sandbox"
40
const basePath = "https://www.googleapis.com/freebase/v1-sandbox/"
42
func New(client *http.Client) (*Service, error) {
44
return nil, errors.New("client is nil")
46
s := &Service{client: client, BasePath: basePath}
52
BasePath string // API endpoint base URL
55
type ReconcileCandidate struct {
56
// Confidence: Percentage likelihood that this candidate is the unique
57
// matching entity. Value will be between 0.0 and 1.0
58
Confidence float64 `json:"confidence,omitempty"`
60
// Lang: Language code that candidate and notable names are displayed
62
Lang string `json:"lang,omitempty"`
64
// Mid: Freebase MID of candidate entity.
65
Mid string `json:"mid,omitempty"`
67
// Name: Freebase name of matching entity in specified language.
68
Name string `json:"name,omitempty"`
70
// Notable: Type or profession the candidate is notable for.
71
Notable *ReconcileCandidateNotable `json:"notable,omitempty"`
74
type ReconcileCandidateNotable struct {
75
// Id: MID of notable category.
76
Id string `json:"id,omitempty"`
78
// Name: Name of notable category in specified language.
79
Name string `json:"name,omitempty"`
82
type ReconcileGet struct {
83
// Candidate: If filled, then the listed candidates are potential
84
// matches, and such should be evaluated by a more discerning algorithm
85
// or human. The matches are ordered by confidence.
86
Candidate []*ReconcileCandidate `json:"candidate,omitempty"`
88
// Costs: Server costs for reconciling.
89
Costs *ReconcileGetCosts `json:"costs,omitempty"`
91
// Match: If filled, this entity is guaranteed to match at requested
92
// confidence probability (default 99%).
93
Match *ReconcileCandidate `json:"match,omitempty"`
95
// Warning: If filled, then there were recoverable problems that
96
// affected the request. For example, some of the properties were
97
// ignored because they either are not valid Freebase predicates or are
98
// not indexed for reconciliation. The candidates returned should be
99
// considered valid results, with the caveat that sections of the
100
// request were ignored as specified by the warning text.
101
Warning []*ReconcileGetWarning `json:"warning,omitempty"`
104
type ReconcileGetCosts struct {
105
// Hits: Total number of hits found.
106
Hits int64 `json:"hits,omitempty"`
108
// Ms: Total milliseconds spent.
109
Ms int64 `json:"ms,omitempty"`
112
type ReconcileGetWarning struct {
113
// Location: Location of warning in the request e.g. invalid predicate.
114
Location string `json:"location,omitempty"`
116
// Message: Warning message to display to the user.
117
Message string `json:"message,omitempty"`
119
// Reason: Code for identifying classes of warnings.
120
Reason string `json:"reason,omitempty"`
123
// method id "freebase.reconcile":
125
type ReconcileCall struct {
127
opt_ map[string]interface{}
130
// Reconcile: Reconcile entities to Freebase open data.
131
func (s *Service) Reconcile() *ReconcileCall {
132
c := &ReconcileCall{s: s, opt_: make(map[string]interface{})}
136
// Confidence sets the optional parameter "confidence": Required
137
// confidence for a candidate to match. Must be between .5 and 1.0
138
func (c *ReconcileCall) Confidence(confidence float64) *ReconcileCall {
139
c.opt_["confidence"] = confidence
143
// Kind sets the optional parameter "kind": Classifications of entity
144
// e.g. type, category, title.
145
func (c *ReconcileCall) Kind(kind string) *ReconcileCall {
146
c.opt_["kind"] = kind
150
// Lang sets the optional parameter "lang": Languages for names and
151
// values. First language is used for display. Default is 'en'.
152
func (c *ReconcileCall) Lang(lang string) *ReconcileCall {
153
c.opt_["lang"] = lang
157
// Limit sets the optional parameter "limit": Maximum number of
158
// candidates to return.
159
func (c *ReconcileCall) Limit(limit int64) *ReconcileCall {
160
c.opt_["limit"] = limit
164
// Name sets the optional parameter "name": Name of entity.
165
func (c *ReconcileCall) Name(name string) *ReconcileCall {
166
c.opt_["name"] = name
170
// Prop sets the optional parameter "prop": Property values for entity
173
func (c *ReconcileCall) Prop(prop string) *ReconcileCall {
174
c.opt_["prop"] = prop
178
// Fields allows partial responses to be retrieved.
179
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
180
// for more information.
181
func (c *ReconcileCall) Fields(s ...googleapi.Field) *ReconcileCall {
182
c.opt_["fields"] = googleapi.CombineFields(s)
186
func (c *ReconcileCall) Do() (*ReconcileGet, error) {
187
var body io.Reader = nil
188
params := make(url.Values)
189
params.Set("alt", "json")
190
if v, ok := c.opt_["confidence"]; ok {
191
params.Set("confidence", fmt.Sprintf("%v", v))
193
if v, ok := c.opt_["kind"]; ok {
194
params.Set("kind", fmt.Sprintf("%v", v))
196
if v, ok := c.opt_["lang"]; ok {
197
params.Set("lang", fmt.Sprintf("%v", v))
199
if v, ok := c.opt_["limit"]; ok {
200
params.Set("limit", fmt.Sprintf("%v", v))
202
if v, ok := c.opt_["name"]; ok {
203
params.Set("name", fmt.Sprintf("%v", v))
205
if v, ok := c.opt_["prop"]; ok {
206
params.Set("prop", fmt.Sprintf("%v", v))
208
if v, ok := c.opt_["fields"]; ok {
209
params.Set("fields", fmt.Sprintf("%v", v))
211
urls := googleapi.ResolveRelative(c.s.BasePath, "reconcile")
212
urls += "?" + params.Encode()
213
req, _ := http.NewRequest("GET", urls, body)
214
googleapi.SetOpaque(req.URL)
215
req.Header.Set("User-Agent", "google-api-go-client/0.5")
216
res, err := c.s.client.Do(req)
220
defer googleapi.CloseBody(res)
221
if err := googleapi.CheckResponse(res); err != nil {
224
var ret *ReconcileGet
225
if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
230
// "description": "Reconcile entities to Freebase open data.",
231
// "httpMethod": "GET",
232
// "id": "freebase.reconcile",
235
// "default": "0.99",
236
// "description": "Required confidence for a candidate to match. Must be between .5 and 1.0",
237
// "format": "float",
238
// "location": "query",
244
// "description": "Classifications of entity e.g. type, category, title.",
245
// "location": "query",
250
// "description": "Languages for names and values. First language is used for display. Default is 'en'.",
251
// "location": "query",
257
// "description": "Maximum number of candidates to return.",
258
// "format": "int32",
259
// "location": "query",
265
// "description": "Name of entity.",
266
// "location": "query",
270
// "description": "Property values for entity formatted as\n:",
271
// "location": "query",
276
// "path": "reconcile",
278
// "$ref": "ReconcileGet"
284
// method id "freebase.search":
286
type SearchCall struct {
288
opt_ map[string]interface{}
291
// Search: Search Freebase open data.
292
func (s *Service) Search() *SearchCall {
293
c := &SearchCall{s: s, opt_: make(map[string]interface{})}
297
// As_of_time sets the optional parameter "as_of_time": A mql as_of_time
298
// value to use with mql_output queries.
299
func (c *SearchCall) As_of_time(as_of_time string) *SearchCall {
300
c.opt_["as_of_time"] = as_of_time
304
// Callback sets the optional parameter "callback": JS method name for
306
func (c *SearchCall) Callback(callback string) *SearchCall {
307
c.opt_["callback"] = callback
311
// Cursor sets the optional parameter "cursor": The cursor value to use
312
// for the next page of results.
313
func (c *SearchCall) Cursor(cursor int64) *SearchCall {
314
c.opt_["cursor"] = cursor
318
// Domain sets the optional parameter "domain": Restrict to topics with
319
// this Freebase domain id.
320
func (c *SearchCall) Domain(domain string) *SearchCall {
321
c.opt_["domain"] = domain
325
// Encode sets the optional parameter "encode": The encoding of the
326
// response. You can use this parameter to enable html encoding.
327
func (c *SearchCall) Encode(encode string) *SearchCall {
328
c.opt_["encode"] = encode
332
// Exact sets the optional parameter "exact": Query on exact name and
334
func (c *SearchCall) Exact(exact bool) *SearchCall {
335
c.opt_["exact"] = exact
339
// Filter sets the optional parameter "filter": A filter to apply to the
341
func (c *SearchCall) Filter(filter string) *SearchCall {
342
c.opt_["filter"] = filter
346
// Format sets the optional parameter "format": Structural format of the
348
func (c *SearchCall) Format(format string) *SearchCall {
349
c.opt_["format"] = format
353
// Help sets the optional parameter "help": The keyword to request help
355
func (c *SearchCall) Help(help string) *SearchCall {
356
c.opt_["help"] = help
360
// Indent sets the optional parameter "indent": Whether to indent the
361
// json results or not.
362
func (c *SearchCall) Indent(indent bool) *SearchCall {
363
c.opt_["indent"] = indent
367
// Lang sets the optional parameter "lang": The code of the language to
368
// run the query with. Default is 'en'.
369
func (c *SearchCall) Lang(lang string) *SearchCall {
370
c.opt_["lang"] = lang
374
// Limit sets the optional parameter "limit": Maximum number of results
376
func (c *SearchCall) Limit(limit int64) *SearchCall {
377
c.opt_["limit"] = limit
381
// Mid sets the optional parameter "mid": A mid to use instead of a
383
func (c *SearchCall) Mid(mid string) *SearchCall {
388
// Mql_output sets the optional parameter "mql_output": The MQL query to
389
// run againist the results to extract more data.
390
func (c *SearchCall) Mql_output(mql_output string) *SearchCall {
391
c.opt_["mql_output"] = mql_output
395
// Output sets the optional parameter "output": An output expression to
396
// request data from matches.
397
func (c *SearchCall) Output(output string) *SearchCall {
398
c.opt_["output"] = output
402
// Prefixed sets the optional parameter "prefixed": Prefix match against
403
// names and aliases.
404
func (c *SearchCall) Prefixed(prefixed bool) *SearchCall {
405
c.opt_["prefixed"] = prefixed
409
// Query sets the optional parameter "query": Query term to search for.
410
func (c *SearchCall) Query(query string) *SearchCall {
411
c.opt_["query"] = query
415
// Scoring sets the optional parameter "scoring": Relevance scoring
417
func (c *SearchCall) Scoring(scoring string) *SearchCall {
418
c.opt_["scoring"] = scoring
422
// Spell sets the optional parameter "spell": Request 'did you mean'
424
func (c *SearchCall) Spell(spell string) *SearchCall {
425
c.opt_["spell"] = spell
429
// Stemmed sets the optional parameter "stemmed": Query on stemmed names
430
// and aliases. May not be used with prefixed.
431
func (c *SearchCall) Stemmed(stemmed bool) *SearchCall {
432
c.opt_["stemmed"] = stemmed
436
// Type sets the optional parameter "type": Restrict to topics with this
438
func (c *SearchCall) Type(type_ string) *SearchCall {
439
c.opt_["type"] = type_
443
// With sets the optional parameter "with": A rule to match against.
444
func (c *SearchCall) With(with string) *SearchCall {
445
c.opt_["with"] = with
449
// Without sets the optional parameter "without": A rule to not match
451
func (c *SearchCall) Without(without string) *SearchCall {
452
c.opt_["without"] = without
456
// Fields allows partial responses to be retrieved.
457
// See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
458
// for more information.
459
func (c *SearchCall) Fields(s ...googleapi.Field) *SearchCall {
460
c.opt_["fields"] = googleapi.CombineFields(s)
464
func (c *SearchCall) Do() error {
465
var body io.Reader = nil
466
params := make(url.Values)
467
params.Set("alt", "json")
468
if v, ok := c.opt_["as_of_time"]; ok {
469
params.Set("as_of_time", fmt.Sprintf("%v", v))
471
if v, ok := c.opt_["callback"]; ok {
472
params.Set("callback", fmt.Sprintf("%v", v))
474
if v, ok := c.opt_["cursor"]; ok {
475
params.Set("cursor", fmt.Sprintf("%v", v))
477
if v, ok := c.opt_["domain"]; ok {
478
params.Set("domain", fmt.Sprintf("%v", v))
480
if v, ok := c.opt_["encode"]; ok {
481
params.Set("encode", fmt.Sprintf("%v", v))
483
if v, ok := c.opt_["exact"]; ok {
484
params.Set("exact", fmt.Sprintf("%v", v))
486
if v, ok := c.opt_["filter"]; ok {
487
params.Set("filter", fmt.Sprintf("%v", v))
489
if v, ok := c.opt_["format"]; ok {
490
params.Set("format", fmt.Sprintf("%v", v))
492
if v, ok := c.opt_["help"]; ok {
493
params.Set("help", fmt.Sprintf("%v", v))
495
if v, ok := c.opt_["indent"]; ok {
496
params.Set("indent", fmt.Sprintf("%v", v))
498
if v, ok := c.opt_["lang"]; ok {
499
params.Set("lang", fmt.Sprintf("%v", v))
501
if v, ok := c.opt_["limit"]; ok {
502
params.Set("limit", fmt.Sprintf("%v", v))
504
if v, ok := c.opt_["mid"]; ok {
505
params.Set("mid", fmt.Sprintf("%v", v))
507
if v, ok := c.opt_["mql_output"]; ok {
508
params.Set("mql_output", fmt.Sprintf("%v", v))
510
if v, ok := c.opt_["output"]; ok {
511
params.Set("output", fmt.Sprintf("%v", v))
513
if v, ok := c.opt_["prefixed"]; ok {
514
params.Set("prefixed", fmt.Sprintf("%v", v))
516
if v, ok := c.opt_["query"]; ok {
517
params.Set("query", fmt.Sprintf("%v", v))
519
if v, ok := c.opt_["scoring"]; ok {
520
params.Set("scoring", fmt.Sprintf("%v", v))
522
if v, ok := c.opt_["spell"]; ok {
523
params.Set("spell", fmt.Sprintf("%v", v))
525
if v, ok := c.opt_["stemmed"]; ok {
526
params.Set("stemmed", fmt.Sprintf("%v", v))
528
if v, ok := c.opt_["type"]; ok {
529
params.Set("type", fmt.Sprintf("%v", v))
531
if v, ok := c.opt_["with"]; ok {
532
params.Set("with", fmt.Sprintf("%v", v))
534
if v, ok := c.opt_["without"]; ok {
535
params.Set("without", fmt.Sprintf("%v", v))
537
if v, ok := c.opt_["fields"]; ok {
538
params.Set("fields", fmt.Sprintf("%v", v))
540
urls := googleapi.ResolveRelative(c.s.BasePath, "search")
541
urls += "?" + params.Encode()
542
req, _ := http.NewRequest("GET", urls, body)
543
googleapi.SetOpaque(req.URL)
544
req.Header.Set("User-Agent", "google-api-go-client/0.5")
545
res, err := c.s.client.Do(req)
549
defer googleapi.CloseBody(res)
550
if err := googleapi.CheckResponse(res); err != nil {
555
// "description": "Search Freebase open data.",
556
// "httpMethod": "GET",
557
// "id": "freebase.search",
560
// "description": "A mql as_of_time value to use with mql_output queries.",
561
// "location": "query",
565
// "description": "JS method name for JSONP callbacks.",
566
// "location": "query",
567
// "pattern": "([A-Za-z0-9_$.]|\\[|\\])+",
571
// "description": "The cursor value to use for the next page of results.",
572
// "format": "int32",
573
// "location": "query",
577
// "description": "Restrict to topics with this Freebase domain id.",
578
// "location": "query",
584
// "description": "The encoding of the response. You can use this parameter to enable html encoding.",
589
// "enumDescriptions": [
590
// "Encode certain characters in the response (such as tags and ambersands) using html encoding.",
591
// "No encoding of the response. You should not print the results directly on an web page without html-escaping the content first."
593
// "location": "query",
597
// "description": "Query on exact name and keys only.",
598
// "location": "query",
602
// "description": "A filter to apply to the query.",
603
// "location": "query",
604
// "pattern": "^\\(.*\\)$",
609
// "default": "entity",
610
// "description": "Structural format of the json response.",
619
// "enumDescriptions": [
620
// "Compact format useful for autocomplete/suggest UIs.",
621
// "[DEPRECATED] Same format as was returned by api.freebase.com.",
622
// "Basic information about the entities.",
623
// "[DEPRECATED] Ordered list of a freebase guids.",
624
// "Ordered list of freebase ids.",
625
// "Ordered list of freebase mids."
627
// "location": "query",
631
// "description": "The keyword to request help on.",
637
// "enumDescriptions": [
638
// "The language codes served by the service.",
639
// "The property/path mappings supported by the filter and output request parameters.",
640
// "The predicates and path-terminating properties supported by the filter and output request parameters."
642
// "location": "query",
646
// "description": "Whether to indent the json results or not.",
647
// "location": "query",
651
// "description": "The code of the language to run the query with. Default is 'en'.",
652
// "location": "query",
658
// "description": "Maximum number of results to return.",
659
// "format": "int32",
660
// "location": "query",
664
// "description": "A mid to use instead of a query.",
665
// "location": "query",
666
// "pattern": "^/[mgtx]/[0-2][0-9bcdfghjklmnpqrstvwxyz_]{1,24}$",
671
// "description": "The MQL query to run againist the results to extract more data.",
672
// "location": "query",
676
// "description": "An output expression to request data from matches.",
677
// "location": "query",
678
// "pattern": "^\\(.*\\)$",
682
// "description": "Prefix match against names and aliases.",
683
// "location": "query",
687
// "description": "Query term to search for.",
688
// "location": "query",
692
// "default": "entity",
693
// "description": "Relevance scoring algorithm to use.",
699
// "enumDescriptions": [
700
// "Use freebase and popularity entity ranking.",
701
// "Use freebase entity ranking.",
702
// "Use schema ranking for properties and types."
704
// "location": "query",
708
// "default": "no_spelling",
709
// "description": "Request 'did you mean' suggestions",
715
// "enumDescriptions": [
716
// "Request spelling suggestions for any query at least three characters long.",
717
// "Request spelling suggestions if no results were found.",
718
// "Don't request spelling suggestions."
720
// "location": "query",
724
// "description": "Query on stemmed names and aliases. May not be used with prefixed.",
725
// "location": "query",
729
// "description": "Restrict to topics with this Freebase type id.",
730
// "location": "query",
735
// "description": "A rule to match against.",
736
// "location": "query",
741
// "description": "A rule to not match against.",
742
// "location": "query",
748
// "supportsMediaDownload": true