freebase-gen.go 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  1. // Package freebase provides access to the Freebase Search.
  2. //
  3. // See https://developers.google.com/freebase/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/freebase/v1"
  8. // ...
  9. // freebaseService, err := freebase.New(oauthHttpClient)
  10. package freebase // import "google.golang.org/api/freebase/v1"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "freebase:v1"
  41. const apiName = "freebase"
  42. const apiVersion = "v1"
  43. const basePath = "https://www.googleapis.com/freebase/v1/"
  44. func New(client *http.Client) (*Service, error) {
  45. if client == nil {
  46. return nil, errors.New("client is nil")
  47. }
  48. s := &Service{client: client, BasePath: basePath}
  49. return s, nil
  50. }
  51. type Service struct {
  52. client *http.Client
  53. BasePath string // API endpoint base URL
  54. UserAgent string // optional additional User-Agent fragment
  55. }
  56. func (s *Service) userAgent() string {
  57. if s.UserAgent == "" {
  58. return googleapi.UserAgent
  59. }
  60. return googleapi.UserAgent + " " + s.UserAgent
  61. }
  62. type ReconcileCandidate struct {
  63. // Confidence: Percentage likelihood that this candidate is the unique
  64. // matching entity. Value will be between 0.0 and 1.0
  65. Confidence float64 `json:"confidence,omitempty"`
  66. // Lang: Language code that candidate and notable names are displayed
  67. // in.
  68. Lang string `json:"lang,omitempty"`
  69. // Mid: Freebase MID of candidate entity.
  70. Mid string `json:"mid,omitempty"`
  71. // Name: Freebase name of matching entity in specified language.
  72. Name string `json:"name,omitempty"`
  73. // Notable: Type or profession the candidate is notable for.
  74. Notable *ReconcileCandidateNotable `json:"notable,omitempty"`
  75. // ForceSendFields is a list of field names (e.g. "Confidence") to
  76. // unconditionally include in API requests. By default, fields with
  77. // empty values are omitted from API requests. However, any non-pointer,
  78. // non-interface field appearing in ForceSendFields will be sent to the
  79. // server regardless of whether the field is empty or not. This may be
  80. // used to include empty fields in Patch requests.
  81. ForceSendFields []string `json:"-"`
  82. }
  83. func (s *ReconcileCandidate) MarshalJSON() ([]byte, error) {
  84. type noMethod ReconcileCandidate
  85. raw := noMethod(*s)
  86. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  87. }
  88. // ReconcileCandidateNotable: Type or profession the candidate is
  89. // notable for.
  90. type ReconcileCandidateNotable struct {
  91. // Id: MID of notable category.
  92. Id string `json:"id,omitempty"`
  93. // Name: Name of notable category in specified language.
  94. Name string `json:"name,omitempty"`
  95. // ForceSendFields is a list of field names (e.g. "Id") to
  96. // unconditionally include in API requests. By default, fields with
  97. // empty values are omitted from API requests. However, any non-pointer,
  98. // non-interface field appearing in ForceSendFields will be sent to the
  99. // server regardless of whether the field is empty or not. This may be
  100. // used to include empty fields in Patch requests.
  101. ForceSendFields []string `json:"-"`
  102. }
  103. func (s *ReconcileCandidateNotable) MarshalJSON() ([]byte, error) {
  104. type noMethod ReconcileCandidateNotable
  105. raw := noMethod(*s)
  106. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  107. }
  108. type ReconcileGet struct {
  109. // Candidate: If filled, then the listed candidates are potential
  110. // matches, and such should be evaluated by a more discerning algorithm
  111. // or human. The matches are ordered by confidence.
  112. Candidate []*ReconcileCandidate `json:"candidate,omitempty"`
  113. // Costs: Server costs for reconciling.
  114. Costs *ReconcileGetCosts `json:"costs,omitempty"`
  115. // Match: If filled, this entity is guaranteed to match at requested
  116. // confidence probability (default 99%).
  117. Match *ReconcileCandidate `json:"match,omitempty"`
  118. // Warning: If filled, then there were recoverable problems that
  119. // affected the request. For example, some of the properties were
  120. // ignored because they either are not valid Freebase predicates or are
  121. // not indexed for reconciliation. The candidates returned should be
  122. // considered valid results, with the caveat that sections of the
  123. // request were ignored as specified by the warning text.
  124. Warning []*ReconcileGetWarning `json:"warning,omitempty"`
  125. // ServerResponse contains the HTTP response code and headers from the
  126. // server.
  127. googleapi.ServerResponse `json:"-"`
  128. // ForceSendFields is a list of field names (e.g. "Candidate") to
  129. // unconditionally include in API requests. By default, fields with
  130. // empty values are omitted from API requests. However, any non-pointer,
  131. // non-interface field appearing in ForceSendFields will be sent to the
  132. // server regardless of whether the field is empty or not. This may be
  133. // used to include empty fields in Patch requests.
  134. ForceSendFields []string `json:"-"`
  135. }
  136. func (s *ReconcileGet) MarshalJSON() ([]byte, error) {
  137. type noMethod ReconcileGet
  138. raw := noMethod(*s)
  139. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  140. }
  141. // ReconcileGetCosts: Server costs for reconciling.
  142. type ReconcileGetCosts struct {
  143. // Hits: Total number of hits found.
  144. Hits int64 `json:"hits,omitempty"`
  145. // Ms: Total milliseconds spent.
  146. Ms int64 `json:"ms,omitempty"`
  147. // ForceSendFields is a list of field names (e.g. "Hits") to
  148. // unconditionally include in API requests. By default, fields with
  149. // empty values are omitted from API requests. However, any non-pointer,
  150. // non-interface field appearing in ForceSendFields will be sent to the
  151. // server regardless of whether the field is empty or not. This may be
  152. // used to include empty fields in Patch requests.
  153. ForceSendFields []string `json:"-"`
  154. }
  155. func (s *ReconcileGetCosts) MarshalJSON() ([]byte, error) {
  156. type noMethod ReconcileGetCosts
  157. raw := noMethod(*s)
  158. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  159. }
  160. type ReconcileGetWarning struct {
  161. // Location: Location of warning in the request e.g. invalid predicate.
  162. Location string `json:"location,omitempty"`
  163. // Message: Warning message to display to the user.
  164. Message string `json:"message,omitempty"`
  165. // Reason: Code for identifying classes of warnings.
  166. Reason string `json:"reason,omitempty"`
  167. // ForceSendFields is a list of field names (e.g. "Location") to
  168. // unconditionally include in API requests. By default, fields with
  169. // empty values are omitted from API requests. However, any non-pointer,
  170. // non-interface field appearing in ForceSendFields will be sent to the
  171. // server regardless of whether the field is empty or not. This may be
  172. // used to include empty fields in Patch requests.
  173. ForceSendFields []string `json:"-"`
  174. }
  175. func (s *ReconcileGetWarning) MarshalJSON() ([]byte, error) {
  176. type noMethod ReconcileGetWarning
  177. raw := noMethod(*s)
  178. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  179. }
  180. // method id "freebase.reconcile":
  181. type ReconcileCall struct {
  182. s *Service
  183. urlParams_ gensupport.URLParams
  184. ifNoneMatch_ string
  185. ctx_ context.Context
  186. }
  187. // Reconcile: Reconcile entities to Freebase open data.
  188. func (s *Service) Reconcile() *ReconcileCall {
  189. c := &ReconcileCall{s: s, urlParams_: make(gensupport.URLParams)}
  190. return c
  191. }
  192. // Confidence sets the optional parameter "confidence": Required
  193. // confidence for a candidate to match. Must be between .5 and 1.0
  194. func (c *ReconcileCall) Confidence(confidence float64) *ReconcileCall {
  195. c.urlParams_.Set("confidence", fmt.Sprint(confidence))
  196. return c
  197. }
  198. // Kind sets the optional parameter "kind": Classifications of entity
  199. // e.g. type, category, title.
  200. func (c *ReconcileCall) Kind(kind ...string) *ReconcileCall {
  201. c.urlParams_.SetMulti("kind", append([]string{}, kind...))
  202. return c
  203. }
  204. // Lang sets the optional parameter "lang": Languages for names and
  205. // values. First language is used for display. Default is 'en'.
  206. func (c *ReconcileCall) Lang(lang ...string) *ReconcileCall {
  207. c.urlParams_.SetMulti("lang", append([]string{}, lang...))
  208. return c
  209. }
  210. // Limit sets the optional parameter "limit": Maximum number of
  211. // candidates to return.
  212. func (c *ReconcileCall) Limit(limit int64) *ReconcileCall {
  213. c.urlParams_.Set("limit", fmt.Sprint(limit))
  214. return c
  215. }
  216. // Name sets the optional parameter "name": Name of entity.
  217. func (c *ReconcileCall) Name(name string) *ReconcileCall {
  218. c.urlParams_.Set("name", name)
  219. return c
  220. }
  221. // Prop sets the optional parameter "prop": Property values for entity
  222. // formatted as
  223. // :
  224. func (c *ReconcileCall) Prop(prop ...string) *ReconcileCall {
  225. c.urlParams_.SetMulti("prop", append([]string{}, prop...))
  226. return c
  227. }
  228. // Fields allows partial responses to be retrieved. See
  229. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  230. // for more information.
  231. func (c *ReconcileCall) Fields(s ...googleapi.Field) *ReconcileCall {
  232. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  233. return c
  234. }
  235. // IfNoneMatch sets the optional parameter which makes the operation
  236. // fail if the object's ETag matches the given value. This is useful for
  237. // getting updates only after the object has changed since the last
  238. // request. Use googleapi.IsNotModified to check whether the response
  239. // error from Do is the result of In-None-Match.
  240. func (c *ReconcileCall) IfNoneMatch(entityTag string) *ReconcileCall {
  241. c.ifNoneMatch_ = entityTag
  242. return c
  243. }
  244. // Context sets the context to be used in this call's Do method. Any
  245. // pending HTTP request will be aborted if the provided context is
  246. // canceled.
  247. func (c *ReconcileCall) Context(ctx context.Context) *ReconcileCall {
  248. c.ctx_ = ctx
  249. return c
  250. }
  251. func (c *ReconcileCall) doRequest(alt string) (*http.Response, error) {
  252. var body io.Reader = nil
  253. c.urlParams_.Set("alt", alt)
  254. urls := googleapi.ResolveRelative(c.s.BasePath, "reconcile")
  255. urls += "?" + c.urlParams_.Encode()
  256. req, _ := http.NewRequest("GET", urls, body)
  257. googleapi.SetOpaque(req.URL)
  258. req.Header.Set("User-Agent", c.s.userAgent())
  259. if c.ifNoneMatch_ != "" {
  260. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  261. }
  262. if c.ctx_ != nil {
  263. return ctxhttp.Do(c.ctx_, c.s.client, req)
  264. }
  265. return c.s.client.Do(req)
  266. }
  267. // Do executes the "freebase.reconcile" call.
  268. // Exactly one of *ReconcileGet or error will be non-nil. Any non-2xx
  269. // status code is an error. Response headers are in either
  270. // *ReconcileGet.ServerResponse.Header or (if a response was returned at
  271. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  272. // to check whether the returned error was because
  273. // http.StatusNotModified was returned.
  274. func (c *ReconcileCall) Do(opts ...googleapi.CallOption) (*ReconcileGet, error) {
  275. gensupport.SetOptions(c.urlParams_, opts...)
  276. res, err := c.doRequest("json")
  277. if res != nil && res.StatusCode == http.StatusNotModified {
  278. if res.Body != nil {
  279. res.Body.Close()
  280. }
  281. return nil, &googleapi.Error{
  282. Code: res.StatusCode,
  283. Header: res.Header,
  284. }
  285. }
  286. if err != nil {
  287. return nil, err
  288. }
  289. defer googleapi.CloseBody(res)
  290. if err := googleapi.CheckResponse(res); err != nil {
  291. return nil, err
  292. }
  293. ret := &ReconcileGet{
  294. ServerResponse: googleapi.ServerResponse{
  295. Header: res.Header,
  296. HTTPStatusCode: res.StatusCode,
  297. },
  298. }
  299. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  300. return nil, err
  301. }
  302. return ret, nil
  303. // {
  304. // "description": "Reconcile entities to Freebase open data.",
  305. // "httpMethod": "GET",
  306. // "id": "freebase.reconcile",
  307. // "parameters": {
  308. // "confidence": {
  309. // "default": "0.99",
  310. // "description": "Required confidence for a candidate to match. Must be between .5 and 1.0",
  311. // "format": "float",
  312. // "location": "query",
  313. // "maximum": "1.0",
  314. // "minimum": "0.0",
  315. // "type": "number"
  316. // },
  317. // "kind": {
  318. // "description": "Classifications of entity e.g. type, category, title.",
  319. // "location": "query",
  320. // "repeated": true,
  321. // "type": "string"
  322. // },
  323. // "lang": {
  324. // "description": "Languages for names and values. First language is used for display. Default is 'en'.",
  325. // "location": "query",
  326. // "repeated": true,
  327. // "type": "string"
  328. // },
  329. // "limit": {
  330. // "default": "3",
  331. // "description": "Maximum number of candidates to return.",
  332. // "format": "int32",
  333. // "location": "query",
  334. // "maximum": "25",
  335. // "minimum": "0",
  336. // "type": "integer"
  337. // },
  338. // "name": {
  339. // "description": "Name of entity.",
  340. // "location": "query",
  341. // "type": "string"
  342. // },
  343. // "prop": {
  344. // "description": "Property values for entity formatted as\n:",
  345. // "location": "query",
  346. // "repeated": true,
  347. // "type": "string"
  348. // }
  349. // },
  350. // "path": "reconcile",
  351. // "response": {
  352. // "$ref": "ReconcileGet"
  353. // }
  354. // }
  355. }
  356. // method id "freebase.search":
  357. type SearchCall struct {
  358. s *Service
  359. urlParams_ gensupport.URLParams
  360. ifNoneMatch_ string
  361. ctx_ context.Context
  362. }
  363. // Search: Search Freebase open data.
  364. func (s *Service) Search() *SearchCall {
  365. c := &SearchCall{s: s, urlParams_: make(gensupport.URLParams)}
  366. return c
  367. }
  368. // AsOfTime sets the optional parameter "as_of_time": A mql as_of_time
  369. // value to use with mql_output queries.
  370. func (c *SearchCall) AsOfTime(asOfTime string) *SearchCall {
  371. c.urlParams_.Set("as_of_time", asOfTime)
  372. return c
  373. }
  374. // Callback sets the optional parameter "callback": JS method name for
  375. // JSONP callbacks.
  376. func (c *SearchCall) Callback(callback string) *SearchCall {
  377. c.urlParams_.Set("callback", callback)
  378. return c
  379. }
  380. // Cursor sets the optional parameter "cursor": The cursor value to use
  381. // for the next page of results.
  382. func (c *SearchCall) Cursor(cursor int64) *SearchCall {
  383. c.urlParams_.Set("cursor", fmt.Sprint(cursor))
  384. return c
  385. }
  386. // Domain sets the optional parameter "domain": Restrict to topics with
  387. // this Freebase domain id.
  388. func (c *SearchCall) Domain(domain ...string) *SearchCall {
  389. c.urlParams_.SetMulti("domain", append([]string{}, domain...))
  390. return c
  391. }
  392. // Encode sets the optional parameter "encode": The encoding of the
  393. // response. You can use this parameter to enable html encoding.
  394. //
  395. // Possible values:
  396. // "html" - Encode certain characters in the response (such as tags
  397. // and ambersands) using html encoding.
  398. // "off" (default) - No encoding of the response. You should not print
  399. // the results directly on an web page without html-escaping the content
  400. // first.
  401. func (c *SearchCall) Encode(encode string) *SearchCall {
  402. c.urlParams_.Set("encode", encode)
  403. return c
  404. }
  405. // Exact sets the optional parameter "exact": Query on exact name and
  406. // keys only.
  407. func (c *SearchCall) Exact(exact bool) *SearchCall {
  408. c.urlParams_.Set("exact", fmt.Sprint(exact))
  409. return c
  410. }
  411. // Filter sets the optional parameter "filter": A filter to apply to the
  412. // query.
  413. func (c *SearchCall) Filter(filter ...string) *SearchCall {
  414. c.urlParams_.SetMulti("filter", append([]string{}, filter...))
  415. return c
  416. }
  417. // Format sets the optional parameter "format": Structural format of the
  418. // json response.
  419. //
  420. // Possible values:
  421. // "ac" - Compact format useful for autocomplete/suggest UIs.
  422. // "classic" - [DEPRECATED] Same format as was returned by
  423. // api.freebase.com.
  424. // "entity" (default) - Basic information about the entities.
  425. // "guids" - [DEPRECATED] Ordered list of a freebase guids.
  426. // "ids" - Ordered list of freebase ids.
  427. // "mids" - Ordered list of freebase mids.
  428. func (c *SearchCall) Format(format string) *SearchCall {
  429. c.urlParams_.Set("format", format)
  430. return c
  431. }
  432. // Help sets the optional parameter "help": The keyword to request help
  433. // on.
  434. //
  435. // Possible values:
  436. // "langs" - The language codes served by the service.
  437. // "mappings" - The property/path mappings supported by the filter and
  438. // output request parameters.
  439. // "predicates" - The predicates and path-terminating properties
  440. // supported by the filter and output request parameters.
  441. func (c *SearchCall) Help(help string) *SearchCall {
  442. c.urlParams_.Set("help", help)
  443. return c
  444. }
  445. // Indent sets the optional parameter "indent": Whether to indent the
  446. // json results or not.
  447. func (c *SearchCall) Indent(indent bool) *SearchCall {
  448. c.urlParams_.Set("indent", fmt.Sprint(indent))
  449. return c
  450. }
  451. // Lang sets the optional parameter "lang": The code of the language to
  452. // run the query with. Default is 'en'.
  453. func (c *SearchCall) Lang(lang ...string) *SearchCall {
  454. c.urlParams_.SetMulti("lang", append([]string{}, lang...))
  455. return c
  456. }
  457. // Limit sets the optional parameter "limit": Maximum number of results
  458. // to return.
  459. func (c *SearchCall) Limit(limit int64) *SearchCall {
  460. c.urlParams_.Set("limit", fmt.Sprint(limit))
  461. return c
  462. }
  463. // Mid sets the optional parameter "mid": A mid to use instead of a
  464. // query.
  465. func (c *SearchCall) Mid(mid ...string) *SearchCall {
  466. c.urlParams_.SetMulti("mid", append([]string{}, mid...))
  467. return c
  468. }
  469. // MqlOutput sets the optional parameter "mql_output": The MQL query to
  470. // run againist the results to extract more data.
  471. func (c *SearchCall) MqlOutput(mqlOutput string) *SearchCall {
  472. c.urlParams_.Set("mql_output", mqlOutput)
  473. return c
  474. }
  475. // Output sets the optional parameter "output": An output expression to
  476. // request data from matches.
  477. func (c *SearchCall) Output(output string) *SearchCall {
  478. c.urlParams_.Set("output", output)
  479. return c
  480. }
  481. // Prefixed sets the optional parameter "prefixed": Prefix match against
  482. // names and aliases.
  483. func (c *SearchCall) Prefixed(prefixed bool) *SearchCall {
  484. c.urlParams_.Set("prefixed", fmt.Sprint(prefixed))
  485. return c
  486. }
  487. // Query sets the optional parameter "query": Query term to search for.
  488. func (c *SearchCall) Query(query string) *SearchCall {
  489. c.urlParams_.Set("query", query)
  490. return c
  491. }
  492. // Scoring sets the optional parameter "scoring": Relevance scoring
  493. // algorithm to use.
  494. //
  495. // Possible values:
  496. // "entity" (default) - Use freebase and popularity entity ranking.
  497. // "freebase" - Use freebase entity ranking.
  498. // "schema" - Use schema ranking for properties and types.
  499. func (c *SearchCall) Scoring(scoring string) *SearchCall {
  500. c.urlParams_.Set("scoring", scoring)
  501. return c
  502. }
  503. // Spell sets the optional parameter "spell": Request 'did you mean'
  504. // suggestions
  505. //
  506. // Possible values:
  507. // "always" - Request spelling suggestions for any query at least
  508. // three characters long.
  509. // "no_results" - Request spelling suggestions if no results were
  510. // found.
  511. // "no_spelling" (default) - Don't request spelling suggestions.
  512. func (c *SearchCall) Spell(spell string) *SearchCall {
  513. c.urlParams_.Set("spell", spell)
  514. return c
  515. }
  516. // Stemmed sets the optional parameter "stemmed": Query on stemmed names
  517. // and aliases. May not be used with prefixed.
  518. func (c *SearchCall) Stemmed(stemmed bool) *SearchCall {
  519. c.urlParams_.Set("stemmed", fmt.Sprint(stemmed))
  520. return c
  521. }
  522. // Type sets the optional parameter "type": Restrict to topics with this
  523. // Freebase type id.
  524. func (c *SearchCall) Type(type_ ...string) *SearchCall {
  525. c.urlParams_.SetMulti("type", append([]string{}, type_...))
  526. return c
  527. }
  528. // With sets the optional parameter "with": A rule to match against.
  529. func (c *SearchCall) With(with ...string) *SearchCall {
  530. c.urlParams_.SetMulti("with", append([]string{}, with...))
  531. return c
  532. }
  533. // Without sets the optional parameter "without": A rule to not match
  534. // against.
  535. func (c *SearchCall) Without(without ...string) *SearchCall {
  536. c.urlParams_.SetMulti("without", append([]string{}, without...))
  537. return c
  538. }
  539. // Fields allows partial responses to be retrieved. See
  540. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  541. // for more information.
  542. func (c *SearchCall) Fields(s ...googleapi.Field) *SearchCall {
  543. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  544. return c
  545. }
  546. // IfNoneMatch sets the optional parameter which makes the operation
  547. // fail if the object's ETag matches the given value. This is useful for
  548. // getting updates only after the object has changed since the last
  549. // request. Use googleapi.IsNotModified to check whether the response
  550. // error from Do is the result of In-None-Match.
  551. func (c *SearchCall) IfNoneMatch(entityTag string) *SearchCall {
  552. c.ifNoneMatch_ = entityTag
  553. return c
  554. }
  555. // Context sets the context to be used in this call's Do and Download
  556. // methods. Any pending HTTP request will be aborted if the provided
  557. // context is canceled.
  558. func (c *SearchCall) Context(ctx context.Context) *SearchCall {
  559. c.ctx_ = ctx
  560. return c
  561. }
  562. func (c *SearchCall) doRequest(alt string) (*http.Response, error) {
  563. var body io.Reader = nil
  564. c.urlParams_.Set("alt", alt)
  565. urls := googleapi.ResolveRelative(c.s.BasePath, "search")
  566. urls += "?" + c.urlParams_.Encode()
  567. req, _ := http.NewRequest("GET", urls, body)
  568. googleapi.SetOpaque(req.URL)
  569. req.Header.Set("User-Agent", c.s.userAgent())
  570. if c.ifNoneMatch_ != "" {
  571. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  572. }
  573. if c.ctx_ != nil {
  574. return ctxhttp.Do(c.ctx_, c.s.client, req)
  575. }
  576. return c.s.client.Do(req)
  577. }
  578. // Download fetches the API endpoint's "media" value, instead of the normal
  579. // API response value. If the returned error is nil, the Response is guaranteed to
  580. // have a 2xx status code. Callers must close the Response.Body as usual.
  581. func (c *SearchCall) Download(opts ...googleapi.CallOption) (*http.Response, error) {
  582. gensupport.SetOptions(c.urlParams_, opts...)
  583. res, err := c.doRequest("media")
  584. if err != nil {
  585. return nil, err
  586. }
  587. if err := googleapi.CheckMediaResponse(res); err != nil {
  588. res.Body.Close()
  589. return nil, err
  590. }
  591. return res, nil
  592. }
  593. // Do executes the "freebase.search" call.
  594. func (c *SearchCall) Do(opts ...googleapi.CallOption) error {
  595. gensupport.SetOptions(c.urlParams_, opts...)
  596. res, err := c.doRequest("json")
  597. if err != nil {
  598. return err
  599. }
  600. defer googleapi.CloseBody(res)
  601. if err := googleapi.CheckResponse(res); err != nil {
  602. return err
  603. }
  604. return nil
  605. // {
  606. // "description": "Search Freebase open data.",
  607. // "httpMethod": "GET",
  608. // "id": "freebase.search",
  609. // "parameters": {
  610. // "as_of_time": {
  611. // "description": "A mql as_of_time value to use with mql_output queries.",
  612. // "location": "query",
  613. // "type": "string"
  614. // },
  615. // "callback": {
  616. // "description": "JS method name for JSONP callbacks.",
  617. // "location": "query",
  618. // "pattern": "([A-Za-z0-9_$.]|\\[|\\])+",
  619. // "type": "string"
  620. // },
  621. // "cursor": {
  622. // "description": "The cursor value to use for the next page of results.",
  623. // "format": "int32",
  624. // "location": "query",
  625. // "type": "integer"
  626. // },
  627. // "domain": {
  628. // "description": "Restrict to topics with this Freebase domain id.",
  629. // "location": "query",
  630. // "repeated": true,
  631. // "type": "string"
  632. // },
  633. // "encode": {
  634. // "default": "off",
  635. // "description": "The encoding of the response. You can use this parameter to enable html encoding.",
  636. // "enum": [
  637. // "html",
  638. // "off"
  639. // ],
  640. // "enumDescriptions": [
  641. // "Encode certain characters in the response (such as tags and ambersands) using html encoding.",
  642. // "No encoding of the response. You should not print the results directly on an web page without html-escaping the content first."
  643. // ],
  644. // "location": "query",
  645. // "type": "string"
  646. // },
  647. // "exact": {
  648. // "description": "Query on exact name and keys only.",
  649. // "location": "query",
  650. // "type": "boolean"
  651. // },
  652. // "filter": {
  653. // "description": "A filter to apply to the query.",
  654. // "location": "query",
  655. // "pattern": "^\\(.*\\)$",
  656. // "repeated": true,
  657. // "type": "string"
  658. // },
  659. // "format": {
  660. // "default": "entity",
  661. // "description": "Structural format of the json response.",
  662. // "enum": [
  663. // "ac",
  664. // "classic",
  665. // "entity",
  666. // "guids",
  667. // "ids",
  668. // "mids"
  669. // ],
  670. // "enumDescriptions": [
  671. // "Compact format useful for autocomplete/suggest UIs.",
  672. // "[DEPRECATED] Same format as was returned by api.freebase.com.",
  673. // "Basic information about the entities.",
  674. // "[DEPRECATED] Ordered list of a freebase guids.",
  675. // "Ordered list of freebase ids.",
  676. // "Ordered list of freebase mids."
  677. // ],
  678. // "location": "query",
  679. // "type": "string"
  680. // },
  681. // "help": {
  682. // "description": "The keyword to request help on.",
  683. // "enum": [
  684. // "langs",
  685. // "mappings",
  686. // "predicates"
  687. // ],
  688. // "enumDescriptions": [
  689. // "The language codes served by the service.",
  690. // "The property/path mappings supported by the filter and output request parameters.",
  691. // "The predicates and path-terminating properties supported by the filter and output request parameters."
  692. // ],
  693. // "location": "query",
  694. // "type": "string"
  695. // },
  696. // "indent": {
  697. // "description": "Whether to indent the json results or not.",
  698. // "location": "query",
  699. // "type": "boolean"
  700. // },
  701. // "lang": {
  702. // "description": "The code of the language to run the query with. Default is 'en'.",
  703. // "location": "query",
  704. // "repeated": true,
  705. // "type": "string"
  706. // },
  707. // "limit": {
  708. // "default": "20",
  709. // "description": "Maximum number of results to return.",
  710. // "format": "int32",
  711. // "location": "query",
  712. // "type": "integer"
  713. // },
  714. // "mid": {
  715. // "description": "A mid to use instead of a query.",
  716. // "location": "query",
  717. // "pattern": "^/[mgtx]/[0-2][0-9bcdfghjklmnpqrstvwxyz_]{1,24}$",
  718. // "repeated": true,
  719. // "type": "string"
  720. // },
  721. // "mql_output": {
  722. // "description": "The MQL query to run againist the results to extract more data.",
  723. // "location": "query",
  724. // "type": "string"
  725. // },
  726. // "output": {
  727. // "description": "An output expression to request data from matches.",
  728. // "location": "query",
  729. // "pattern": "^\\(.*\\)$",
  730. // "type": "string"
  731. // },
  732. // "prefixed": {
  733. // "description": "Prefix match against names and aliases.",
  734. // "location": "query",
  735. // "type": "boolean"
  736. // },
  737. // "query": {
  738. // "description": "Query term to search for.",
  739. // "location": "query",
  740. // "type": "string"
  741. // },
  742. // "scoring": {
  743. // "default": "entity",
  744. // "description": "Relevance scoring algorithm to use.",
  745. // "enum": [
  746. // "entity",
  747. // "freebase",
  748. // "schema"
  749. // ],
  750. // "enumDescriptions": [
  751. // "Use freebase and popularity entity ranking.",
  752. // "Use freebase entity ranking.",
  753. // "Use schema ranking for properties and types."
  754. // ],
  755. // "location": "query",
  756. // "type": "string"
  757. // },
  758. // "spell": {
  759. // "default": "no_spelling",
  760. // "description": "Request 'did you mean' suggestions",
  761. // "enum": [
  762. // "always",
  763. // "no_results",
  764. // "no_spelling"
  765. // ],
  766. // "enumDescriptions": [
  767. // "Request spelling suggestions for any query at least three characters long.",
  768. // "Request spelling suggestions if no results were found.",
  769. // "Don't request spelling suggestions."
  770. // ],
  771. // "location": "query",
  772. // "type": "string"
  773. // },
  774. // "stemmed": {
  775. // "description": "Query on stemmed names and aliases. May not be used with prefixed.",
  776. // "location": "query",
  777. // "type": "boolean"
  778. // },
  779. // "type": {
  780. // "description": "Restrict to topics with this Freebase type id.",
  781. // "location": "query",
  782. // "repeated": true,
  783. // "type": "string"
  784. // },
  785. // "with": {
  786. // "description": "A rule to match against.",
  787. // "location": "query",
  788. // "repeated": true,
  789. // "type": "string"
  790. // },
  791. // "without": {
  792. // "description": "A rule to not match against.",
  793. // "location": "query",
  794. // "repeated": true,
  795. // "type": "string"
  796. // }
  797. // },
  798. // "path": "search",
  799. // "supportsMediaDownload": true
  800. // }
  801. }