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