| OLD | NEW |
| 1 // This is a generated file (see the discoveryapis_generator project). | 1 // This is a generated file (see the discoveryapis_generator project). |
| 2 | 2 |
| 3 library googleapis.kgsearch.v1; | 3 library googleapis.kgsearch.v1; |
| 4 | 4 |
| 5 import 'dart:core' as core; | 5 import 'dart:core' as core; |
| 6 import 'dart:async' as async; | 6 import 'dart:async' as async; |
| 7 import 'dart:convert' as convert; | 7 import 'dart:convert' as convert; |
| 8 | 8 |
| 9 import 'package:_discoveryapis_commons/_discoveryapis_commons.dart' as commons; | 9 import 'package:_discoveryapis_commons/_discoveryapis_commons.dart' as commons; |
| 10 import 'package:http/http.dart' as http; | 10 import 'package:http/http.dart' as http; |
| 11 | 11 |
| 12 export 'package:_discoveryapis_commons/_discoveryapis_commons.dart' show | 12 export 'package:_discoveryapis_commons/_discoveryapis_commons.dart' show |
| 13 ApiRequestError, DetailedApiRequestError; | 13 ApiRequestError, DetailedApiRequestError; |
| 14 | 14 |
| 15 const core.String USER_AGENT = 'dart-api-client kgsearch/v1'; | 15 const core.String USER_AGENT = 'dart-api-client kgsearch/v1'; |
| 16 | 16 |
| 17 /** | 17 /** Searches the Google Knowledge Graph for entities. */ |
| 18 * Knowledge Graph Search API allows developers to search the Google Knowledge | |
| 19 * Graph for entities. | |
| 20 */ | |
| 21 class KgsearchApi { | 18 class KgsearchApi { |
| 22 | 19 |
| 23 final commons.ApiRequester _requester; | 20 final commons.ApiRequester _requester; |
| 24 | 21 |
| 25 EntitiesResourceApi get entities => new EntitiesResourceApi(_requester); | 22 EntitiesResourceApi get entities => new EntitiesResourceApi(_requester); |
| 26 | 23 |
| 27 KgsearchApi(http.Client client, {core.String rootUrl: "https://kgsearch.google
apis.com/", core.String servicePath: ""}) : | 24 KgsearchApi(http.Client client, {core.String rootUrl: "https://kgsearch.google
apis.com/", core.String servicePath: ""}) : |
| 28 _requester = new commons.ApiRequester(client, rootUrl, servicePath, USER_A
GENT); | 25 _requester = new commons.ApiRequester(client, rootUrl, servicePath, USER_A
GENT); |
| 29 } | 26 } |
| 30 | 27 |
| 31 | 28 |
| 32 class EntitiesResourceApi { | 29 class EntitiesResourceApi { |
| 33 final commons.ApiRequester _requester; | 30 final commons.ApiRequester _requester; |
| 34 | 31 |
| 35 EntitiesResourceApi(commons.ApiRequester client) : | 32 EntitiesResourceApi(commons.ApiRequester client) : |
| 36 _requester = client; | 33 _requester = client; |
| 37 | 34 |
| 38 /** | 35 /** |
| 39 * Searches Knowledge Graph for entities that match the constraints. A list of | 36 * Searches Knowledge Graph for entities that match the constraints. |
| 40 * matched entities will be returned in response, which will be in JSON-LD | 37 * A list of matched entities will be returned in response, which will be in |
| 41 * format and compatible with http://schema.org | 38 * JSON-LD format and compatible with http://schema.org |
| 42 * | 39 * |
| 43 * Request parameters: | 40 * Request parameters: |
| 44 * | 41 * |
| 45 * [query] - The literal query string for search. | 42 * [limit] - Limits the number of entities to be returned. |
| 46 * | 43 * |
| 47 * [ids] - The list of entity id to be used for search instead of query | 44 * [ids] - The list of entity id to be used for search instead of query |
| 48 * string. | 45 * string. |
| 46 * To specify multiple ids in the HTTP request, repeat the parameter in the |
| 47 * URL as in ...?ids=A&ids=B |
| 49 * | 48 * |
| 50 * [languages] - The list of language codes (defined in ISO 693) to run the | 49 * [prefix] - Enables prefix match against names and aliases of entities |
| 51 * query with, e.g. 'en'. | |
| 52 * | 50 * |
| 53 * [types] - Restricts returned entities with these types, e.g. Person (as | 51 * [query] - The literal query string for search. |
| 54 * defined in http://schema.org/Person). | |
| 55 * | 52 * |
| 56 * [indent] - Enables indenting of json results. | 53 * [indent] - Enables indenting of json results. |
| 57 * | 54 * |
| 58 * [prefix] - Enables prefix match against names and aliases of entities | 55 * [types] - Restricts returned entities with these types, e.g. Person |
| 56 * (as defined in http://schema.org/Person). If multiple types are specified, |
| 57 * returned entities will contain one or more of these types. |
| 59 * | 58 * |
| 60 * [limit] - Limits the number of entities to be returned. | 59 * [languages] - The list of language codes (defined in ISO 693) to run the |
| 60 * query with, |
| 61 * e.g. 'en'. |
| 61 * | 62 * |
| 62 * Completes with a [SearchResponse]. | 63 * Completes with a [SearchResponse]. |
| 63 * | 64 * |
| 64 * Completes with a [commons.ApiRequestError] if the API endpoint returned an | 65 * Completes with a [commons.ApiRequestError] if the API endpoint returned an |
| 65 * error. | 66 * error. |
| 66 * | 67 * |
| 67 * If the used [http.Client] completes with an error when making a REST call, | 68 * If the used [http.Client] completes with an error when making a REST call, |
| 68 * this method will complete with the same error. | 69 * this method will complete with the same error. |
| 69 */ | 70 */ |
| 70 async.Future<SearchResponse> search({core.String query, core.List<core.String>
ids, core.List<core.String> languages, core.List<core.String> types, core.bool
indent, core.bool prefix, core.int limit}) { | 71 async.Future<SearchResponse> search({core.int limit, core.List<core.String> id
s, core.bool prefix, core.String query, core.bool indent, core.List<core.String>
types, core.List<core.String> languages}) { |
| 71 var _url = null; | 72 var _url = null; |
| 72 var _queryParams = new core.Map(); | 73 var _queryParams = new core.Map(); |
| 73 var _uploadMedia = null; | 74 var _uploadMedia = null; |
| 74 var _uploadOptions = null; | 75 var _uploadOptions = null; |
| 75 var _downloadOptions = commons.DownloadOptions.Metadata; | 76 var _downloadOptions = commons.DownloadOptions.Metadata; |
| 76 var _body = null; | 77 var _body = null; |
| 77 | 78 |
| 78 if (query != null) { | 79 if (limit != null) { |
| 79 _queryParams["query"] = [query]; | 80 _queryParams["limit"] = ["${limit}"]; |
| 80 } | 81 } |
| 81 if (ids != null) { | 82 if (ids != null) { |
| 82 _queryParams["ids"] = ids; | 83 _queryParams["ids"] = ids; |
| 83 } | 84 } |
| 84 if (languages != null) { | 85 if (prefix != null) { |
| 85 _queryParams["languages"] = languages; | 86 _queryParams["prefix"] = ["${prefix}"]; |
| 87 } |
| 88 if (query != null) { |
| 89 _queryParams["query"] = [query]; |
| 90 } |
| 91 if (indent != null) { |
| 92 _queryParams["indent"] = ["${indent}"]; |
| 86 } | 93 } |
| 87 if (types != null) { | 94 if (types != null) { |
| 88 _queryParams["types"] = types; | 95 _queryParams["types"] = types; |
| 89 } | 96 } |
| 90 if (indent != null) { | 97 if (languages != null) { |
| 91 _queryParams["indent"] = ["${indent}"]; | 98 _queryParams["languages"] = languages; |
| 92 } | |
| 93 if (prefix != null) { | |
| 94 _queryParams["prefix"] = ["${prefix}"]; | |
| 95 } | |
| 96 if (limit != null) { | |
| 97 _queryParams["limit"] = ["${limit}"]; | |
| 98 } | 99 } |
| 99 | 100 |
| 100 _url = 'v1/entities:search'; | 101 _url = 'v1/entities:search'; |
| 101 | 102 |
| 102 var _response = _requester.request(_url, | 103 var _response = _requester.request(_url, |
| 103 "GET", | 104 "GET", |
| 104 body: _body, | 105 body: _body, |
| 105 queryParams: _queryParams, | 106 queryParams: _queryParams, |
| 106 uploadOptions: _uploadOptions, | 107 uploadOptions: _uploadOptions, |
| 107 uploadMedia: _uploadMedia, | 108 uploadMedia: _uploadMedia, |
| 108 downloadOptions: _downloadOptions); | 109 downloadOptions: _downloadOptions); |
| 109 return _response.then((data) => new SearchResponse.fromJson(data)); | 110 return _response.then((data) => new SearchResponse.fromJson(data)); |
| 110 } | 111 } |
| 111 | 112 |
| 112 } | 113 } |
| 113 | 114 |
| 114 | 115 |
| 115 | 116 |
| 116 /** | 117 /** |
| 117 * Response message includes the context and a list of matching results which | 118 * Response message includes the context and a list of matching results |
| 118 * contain the detail of associated entities. | 119 * which contain the detail of associated entities. |
| 119 */ | 120 */ |
| 120 class SearchResponse { | 121 class SearchResponse { |
| 121 /** | 122 /** |
| 122 * The local context applicable for the response. See more details at | 123 * The local context applicable for the response. See more details at |
| 123 * http://www.w3.org/TR/json-ld/#context-definitions. | 124 * http://www.w3.org/TR/json-ld/#context-definitions. |
| 124 * | 125 * |
| 125 * The values for Object must be JSON objects. It can consist of `num`, | 126 * The values for Object must be JSON objects. It can consist of `num`, |
| 126 * `String`, `bool` and `null` as well as `Map` and `List` values. | 127 * `String`, `bool` and `null` as well as `Map` and `List` values. |
| 127 */ | 128 */ |
| 128 core.Object context; | 129 core.Object P_context; |
| 130 /** |
| 131 * The schema type of top-level JSON-LD object, e.g. ItemList. |
| 132 * |
| 133 * The values for Object must be JSON objects. It can consist of `num`, |
| 134 * `String`, `bool` and `null` as well as `Map` and `List` values. |
| 135 */ |
| 136 core.Object P_type; |
| 129 /** | 137 /** |
| 130 * The item list of search results. | 138 * The item list of search results. |
| 131 * | 139 * |
| 132 * The values for Object must be JSON objects. It can consist of `num`, | 140 * The values for Object must be JSON objects. It can consist of `num`, |
| 133 * `String`, `bool` and `null` as well as `Map` and `List` values. | 141 * `String`, `bool` and `null` as well as `Map` and `List` values. |
| 134 */ | 142 */ |
| 135 core.List<core.Object> itemListElement; | 143 core.List<core.Object> itemListElement; |
| 136 /** | |
| 137 * The schema type of top-level JSON-LD object, e.g. ItemList. | |
| 138 * | |
| 139 * The values for Object must be JSON objects. It can consist of `num`, | |
| 140 * `String`, `bool` and `null` as well as `Map` and `List` values. | |
| 141 */ | |
| 142 core.Object type; | |
| 143 | 144 |
| 144 SearchResponse(); | 145 SearchResponse(); |
| 145 | 146 |
| 146 SearchResponse.fromJson(core.Map _json) { | 147 SearchResponse.fromJson(core.Map _json) { |
| 147 if (_json.containsKey("context")) { | 148 if (_json.containsKey("@context")) { |
| 148 context = _json["context"]; | 149 P_context = _json["@context"]; |
| 150 } |
| 151 if (_json.containsKey("@type")) { |
| 152 P_type = _json["@type"]; |
| 149 } | 153 } |
| 150 if (_json.containsKey("itemListElement")) { | 154 if (_json.containsKey("itemListElement")) { |
| 151 itemListElement = _json["itemListElement"]; | 155 itemListElement = _json["itemListElement"]; |
| 152 } | 156 } |
| 153 if (_json.containsKey("type")) { | |
| 154 type = _json["type"]; | |
| 155 } | |
| 156 } | 157 } |
| 157 | 158 |
| 158 core.Map toJson() { | 159 core.Map toJson() { |
| 159 var _json = new core.Map(); | 160 var _json = new core.Map(); |
| 160 if (context != null) { | 161 if (P_context != null) { |
| 161 _json["context"] = context; | 162 _json["@context"] = P_context; |
| 163 } |
| 164 if (P_type != null) { |
| 165 _json["@type"] = P_type; |
| 162 } | 166 } |
| 163 if (itemListElement != null) { | 167 if (itemListElement != null) { |
| 164 _json["itemListElement"] = itemListElement; | 168 _json["itemListElement"] = itemListElement; |
| 165 } | 169 } |
| 166 if (type != null) { | |
| 167 _json["type"] = type; | |
| 168 } | |
| 169 return _json; | 170 return _json; |
| 170 } | 171 } |
| 171 } | 172 } |
| OLD | NEW |