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_v4_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/datastore_v4.pb.dart'; |
| 14 |
| 15 class DataStoreV4ServiceClientRPCStub { |
| 16 final RPCService _rpcService; |
| 17 final String _ticket; |
| 18 |
| 19 DataStoreV4ServiceClientRPCStub(this._rpcService, this._ticket); |
| 20 |
| 21 Future<BeginTransactionResponse> |
| 22 BeginTransaction(BeginTransactionRequest request) { |
| 23 return _rpcService.call('datastore_v4', |
| 24 'BeginTransaction', |
| 25 request.writeToBuffer(), |
| 26 ticket: _ticket) |
| 27 .then((List<int> response) { |
| 28 try { |
| 29 return new BeginTransactionResponse.fromBuffer(response); |
| 30 } on InvalidProtocolBufferException catch (error) { |
| 31 throw ProtocolError.INVALID_RESPONSE; |
| 32 } |
| 33 }); |
| 34 } |
| 35 |
| 36 Future<RollbackResponse> Rollback(RollbackRequest request) { |
| 37 return _rpcService.call( |
| 38 'datastore_v4', 'Rollback', request.writeToBuffer(), ticket: _ticket) |
| 39 .then((List<int> response) { |
| 40 try { |
| 41 return new RollbackResponse.fromBuffer(response); |
| 42 } on InvalidProtocolBufferException catch (error) { |
| 43 throw ProtocolError.INVALID_RESPONSE; |
| 44 } |
| 45 }); |
| 46 } |
| 47 |
| 48 Future<CommitResponse> Commit(CommitRequest request) { |
| 49 return _rpcService.call( |
| 50 'datastore_v4', 'Commit', request.writeToBuffer(), ticket: _ticket) |
| 51 .then((List<int> response) { |
| 52 try { |
| 53 return new CommitResponse.fromBuffer(response); |
| 54 } on InvalidProtocolBufferException catch (error) { |
| 55 throw ProtocolError.INVALID_RESPONSE; |
| 56 } |
| 57 }); |
| 58 } |
| 59 |
| 60 Future<RunQueryResponse> RunQuery(RunQueryRequest request) { |
| 61 return _rpcService.call( |
| 62 'datastore_v4', 'RunQuery', request.writeToBuffer(), ticket: _ticket) |
| 63 .then((List<int> response) { |
| 64 try { |
| 65 return new RunQueryResponse.fromBuffer(response); |
| 66 } on InvalidProtocolBufferException catch (error) { |
| 67 throw ProtocolError.INVALID_RESPONSE; |
| 68 } |
| 69 }); |
| 70 } |
| 71 |
| 72 Future<ContinueQueryResponse> ContinueQuery(ContinueQueryRequest request) { |
| 73 return _rpcService.call('datastore_v4', |
| 74 'ContinueQuery', |
| 75 request.writeToBuffer(), |
| 76 ticket: _ticket) |
| 77 .then((List<int> response) { |
| 78 try { |
| 79 return new ContinueQueryResponse.fromBuffer(response); |
| 80 } on InvalidProtocolBufferException catch (error) { |
| 81 throw ProtocolError.INVALID_RESPONSE; |
| 82 } |
| 83 }); |
| 84 } |
| 85 |
| 86 Future<LookupResponse> Lookup(LookupRequest request) { |
| 87 return _rpcService.call( |
| 88 'datastore_v4', 'Lookup', request.writeToBuffer(), ticket: _ticket) |
| 89 .then((List<int> response) { |
| 90 try { |
| 91 return new LookupResponse.fromBuffer(response); |
| 92 } on InvalidProtocolBufferException catch (error) { |
| 93 throw ProtocolError.INVALID_RESPONSE; |
| 94 } |
| 95 }); |
| 96 } |
| 97 |
| 98 Future<AllocateIdsResponse> AllocateIds(AllocateIdsRequest request) { |
| 99 return _rpcService.call( |
| 100 'datastore_v4', 'AllocateIds', request.writeToBuffer(), ticket: _ticket) |
| 101 .then((List<int> response) { |
| 102 try { |
| 103 return new AllocateIdsResponse.fromBuffer(response); |
| 104 } on InvalidProtocolBufferException catch (error) { |
| 105 throw ProtocolError.INVALID_RESPONSE; |
| 106 } |
| 107 }); |
| 108 } |
| 109 } |
OLD | NEW |