OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library datastore_v3_service; |
| 6 |
| 7 import 'dart:async'; |
| 8 |
| 9 import 'package:protobuf/protobuf.dart'; |
| 10 |
| 11 import '../../api/errors.dart'; |
| 12 import 'rpc/rpc_service.dart'; |
| 13 import 'internal/api_base.pb.dart'; |
| 14 import 'internal/datastore_v3.pb.dart'; |
| 15 |
| 16 class DataStoreV3ServiceClientRPCStub { |
| 17 final RPCService _rpcService; |
| 18 final String _ticket; |
| 19 |
| 20 DataStoreV3ServiceClientRPCStub(this._rpcService, this._ticket); |
| 21 |
| 22 Future<GetResponse> Get(GetRequest request) { |
| 23 return _rpcService.call( |
| 24 'datastore_v3', 'Get', request.writeToBuffer(), ticket: _ticket) |
| 25 .then((List<int> response) { |
| 26 try { |
| 27 return new GetResponse.fromBuffer(response); |
| 28 } on InvalidProtocolBufferException catch (error) { |
| 29 throw ProtocolError.INVALID_RESPONSE; |
| 30 } |
| 31 }); |
| 32 } |
| 33 |
| 34 Future<PutResponse> Put(PutRequest request) { |
| 35 return _rpcService.call( |
| 36 'datastore_v3', 'Put', request.writeToBuffer(), ticket: _ticket) |
| 37 .then((List<int> response) { |
| 38 try { |
| 39 return new PutResponse.fromBuffer(response); |
| 40 } on InvalidProtocolBufferException catch (error) { |
| 41 throw ProtocolError.INVALID_RESPONSE; |
| 42 } |
| 43 }); |
| 44 } |
| 45 |
| 46 Future<TouchResponse> Touch(TouchRequest request) { |
| 47 return _rpcService.call( |
| 48 'datastore_v3', 'Touch', request.writeToBuffer(), ticket: _ticket) |
| 49 .then((List<int> response) { |
| 50 try { |
| 51 return new TouchResponse.fromBuffer(response); |
| 52 } on InvalidProtocolBufferException catch (error) { |
| 53 throw ProtocolError.INVALID_RESPONSE; |
| 54 } |
| 55 }); |
| 56 } |
| 57 |
| 58 Future<DeleteResponse> Delete(DeleteRequest request) { |
| 59 return _rpcService.call( |
| 60 'datastore_v3', 'Delete', request.writeToBuffer(), ticket: _ticket) |
| 61 .then((List<int> response) { |
| 62 try { |
| 63 return new DeleteResponse.fromBuffer(response); |
| 64 } on InvalidProtocolBufferException catch (error) { |
| 65 throw ProtocolError.INVALID_RESPONSE; |
| 66 } |
| 67 }); |
| 68 } |
| 69 |
| 70 |
| 71 Future<QueryResult> RunQuery(Query request) { |
| 72 return _rpcService.call( |
| 73 'datastore_v3', 'RunQuery', request.writeToBuffer(), ticket: _ticket) |
| 74 .then((List<int> response) { |
| 75 try { |
| 76 return new QueryResult.fromBuffer(response); |
| 77 } on InvalidProtocolBufferException catch (error) { |
| 78 throw ProtocolError.INVALID_RESPONSE; |
| 79 } |
| 80 }); |
| 81 } |
| 82 |
| 83 |
| 84 Future<AddActionsResponse> AddActions(AddActionsRequest request) { |
| 85 return _rpcService.call( |
| 86 'datastore_v3', 'AddActions', request.writeToBuffer(), ticket: _ticket) |
| 87 .then((List<int> response) { |
| 88 try { |
| 89 return new AddActionsResponse.fromBuffer(response); |
| 90 } on InvalidProtocolBufferException catch (error) { |
| 91 throw ProtocolError.INVALID_RESPONSE; |
| 92 } |
| 93 }); |
| 94 } |
| 95 |
| 96 Future<QueryResult> Next(NextRequest request) { |
| 97 return _rpcService.call( |
| 98 'datastore_v3', 'Next', request.writeToBuffer(), ticket: _ticket) |
| 99 .then((List<int> response) { |
| 100 try { |
| 101 return new QueryResult.fromBuffer(response); |
| 102 } on InvalidProtocolBufferException catch (error) { |
| 103 throw ProtocolError.INVALID_RESPONSE; |
| 104 } |
| 105 }); |
| 106 } |
| 107 |
| 108 Future<VoidProto> DeleteCursor(Cursor request) { |
| 109 return _rpcService.call('datastore_v3', |
| 110 'DeleteCursor', |
| 111 request.writeToBuffer(), |
| 112 ticket: _ticket) |
| 113 .then((List<int> response) { |
| 114 try { |
| 115 return new VoidProto.fromBuffer(response); |
| 116 } on InvalidProtocolBufferException catch (error) { |
| 117 throw ProtocolError.INVALID_RESPONSE; |
| 118 } |
| 119 }); |
| 120 } |
| 121 |
| 122 |
| 123 Future<Transaction> BeginTransaction(BeginTransactionRequest request) { |
| 124 return _rpcService.call('datastore_v3', |
| 125 'BeginTransaction', |
| 126 request.writeToBuffer(), |
| 127 ticket: _ticket) |
| 128 .then((List<int> response) { |
| 129 try { |
| 130 return new Transaction.fromBuffer(response); |
| 131 } on InvalidProtocolBufferException catch (error) { |
| 132 throw ProtocolError.INVALID_RESPONSE; |
| 133 } |
| 134 }); |
| 135 } |
| 136 |
| 137 Future<CommitResponse> Commit(Transaction request) { |
| 138 return _rpcService.call( |
| 139 'datastore_v3', 'Commit', request.writeToBuffer(), ticket: _ticket) |
| 140 .then((List<int> response) { |
| 141 try { |
| 142 return new CommitResponse.fromBuffer(response); |
| 143 } on InvalidProtocolBufferException catch (error) { |
| 144 throw ProtocolError.INVALID_RESPONSE; |
| 145 } |
| 146 }); |
| 147 } |
| 148 |
| 149 Future<VoidProto> Rollback(Transaction request) { |
| 150 return _rpcService.call( |
| 151 'datastore_v3', 'Rollback', request.writeToBuffer(), ticket: _ticket) |
| 152 .then((List<int> response) { |
| 153 try { |
| 154 return new VoidProto.fromBuffer(response); |
| 155 } on InvalidProtocolBufferException catch (error) { |
| 156 throw ProtocolError.INVALID_RESPONSE; |
| 157 } |
| 158 }); |
| 159 } |
| 160 |
| 161 |
| 162 Future<AllocateIdsResponse> AllocateIds(AllocateIdsRequest request) { |
| 163 return _rpcService.call( |
| 164 'datastore_v3', 'AllocateIds', request.writeToBuffer(), ticket: _ticket) |
| 165 .then((List<int> response) { |
| 166 try { |
| 167 return new AllocateIdsResponse.fromBuffer(response); |
| 168 } on InvalidProtocolBufferException catch (error) { |
| 169 throw ProtocolError.INVALID_RESPONSE; |
| 170 } |
| 171 }); |
| 172 } |
| 173 |
| 174 |
| 175 Future<VoidProto> CreateIndex(CompositeIndex request) { |
| 176 return _rpcService.call( |
| 177 'datastore_v3', 'CreateIndex', request.writeToBuffer(), ticket: _ticket) |
| 178 .then((List<int> response) { |
| 179 try { |
| 180 return new VoidProto.fromBuffer(response); |
| 181 } on InvalidProtocolBufferException catch (error) { |
| 182 throw ProtocolError.INVALID_RESPONSE; |
| 183 } |
| 184 }); |
| 185 } |
| 186 |
| 187 Future<VoidProto> UpdateIndex(CompositeIndex request) { |
| 188 return _rpcService.call( |
| 189 'datastore_v3', 'UpdateIndex', request.writeToBuffer(), ticket: _ticket) |
| 190 .then((List<int> response) { |
| 191 try { |
| 192 return new VoidProto.fromBuffer(response); |
| 193 } on InvalidProtocolBufferException catch (error) { |
| 194 throw ProtocolError.INVALID_RESPONSE; |
| 195 } |
| 196 }); |
| 197 } |
| 198 |
| 199 Future<CompositeIndices> GetIndices(StringProto request) { |
| 200 return _rpcService.call( |
| 201 'datastore_v3', 'GetIndices', request.writeToBuffer(), ticket: _ticket) |
| 202 .then((List<int> response) { |
| 203 try { |
| 204 return new CompositeIndices.fromBuffer(response); |
| 205 } on InvalidProtocolBufferException catch (error) { |
| 206 throw ProtocolError.INVALID_RESPONSE; |
| 207 } |
| 208 }); |
| 209 } |
| 210 |
| 211 Future<VoidProto> DeleteIndex(CompositeIndex request) { |
| 212 return _rpcService.call( |
| 213 'datastore_v3', 'DeleteIndex', request.writeToBuffer(), ticket: _ticket) |
| 214 .then((List<int> response) { |
| 215 try { |
| 216 return new VoidProto.fromBuffer(response); |
| 217 } on InvalidProtocolBufferException catch (error) { |
| 218 throw ProtocolError.INVALID_RESPONSE; |
| 219 } |
| 220 }); |
| 221 } |
| 222 } |
OLD | NEW |