From d197e98b49e608f4c008108c842effdc9f46e86e Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Mon, 14 Sep 2020 09:48:08 -0400 Subject: [PATCH 01/21] Add status details as Uint8List to GrpcError --- lib/src/client/call.dart | 24 +++++++++++++++++-- lib/src/shared/status.dart | 49 +++++++++++++++++++++++--------------- 2 files changed, 52 insertions(+), 21 deletions(-) diff --git a/lib/src/client/call.dart b/lib/src/client/call.dart index b30eb887..980a2003 100644 --- a/lib/src/client/call.dart +++ b/lib/src/client/call.dart @@ -14,6 +14,8 @@ // limitations under the License. import 'dart:async'; +import 'dart:convert'; +import 'dart:typed_data'; import '../shared/message.dart'; import '../shared/status.dart'; @@ -246,7 +248,11 @@ class ClientCall implements Response { ? null : Uri.decodeFull(metadata['grpc-message']); if (status != 0) { - _responseError(GrpcError.custom(status, message)); + _responseError(GrpcError.custom( + status, + message, + _decodeStatusDetails(metadata['grpc-status-details-bin']), + )); } } } else { @@ -284,11 +290,16 @@ class ClientCall implements Response { final status = _headerMetadata['grpc-status']; // If status code is missing, we must treat it as '0'. As in 'success'. final statusCode = status != null ? int.parse(status) : 0; + if (statusCode != 0) { final message = _headerMetadata['grpc-message'] == null ? null : Uri.decodeFull(_headerMetadata['grpc-message']); - _responseError(GrpcError.custom(statusCode, message)); + _responseError(GrpcError.custom( + statusCode, + message, + _decodeStatusDetails(_headerMetadata['grpc-status-details-bin']), + )); } } _timeoutTimer?.cancel(); @@ -352,3 +363,12 @@ class ClientCall implements Response { } catch (_) {} } } + +Uint8List _decodeStatusDetails(String data) { + /// Parse details out of message. Length must be an even multiple of 4 so we pad it if needed. + var details = data; + while (details.length % 4 != 0) { + details += '='; + } + return base64Url.decode(details); +} diff --git a/lib/src/shared/status.dart b/lib/src/shared/status.dart index 9c0067e9..9c394d02 100644 --- a/lib/src/shared/status.dart +++ b/lib/src/shared/status.dart @@ -13,6 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +import 'dart:convert'; +import 'dart:typed_data'; + class StatusCode { /// The operation completed successfully. static const ok = 0; @@ -120,54 +123,58 @@ class StatusCode { class GrpcError implements Exception { final int code; final String message; + final Uint8List details; /// Custom error code. - GrpcError.custom(this.code, [this.message]); + GrpcError.custom(this.code, [this.message, this.details]); /// The operation completed successfully. - GrpcError.ok([this.message]) : code = StatusCode.ok; + GrpcError.ok([this.message, this.details]) : code = StatusCode.ok; /// The operation was cancelled (typically by the caller). - GrpcError.cancelled([this.message]) : code = StatusCode.cancelled; + GrpcError.cancelled([this.message, this.details]) + : code = StatusCode.cancelled; /// Unknown error. An example of where this error may be returned is if a /// Status value received from another address space belongs to an error-space /// that is not known in this address space. Also errors raised by APIs that /// do not return enough error information may be converted to this error. - GrpcError.unknown([this.message]) : code = StatusCode.unknown; + GrpcError.unknown([this.message, this.details]) : code = StatusCode.unknown; /// Client specified an invalid argument. Note that this differs from /// [failedPrecondition]. [invalidArgument] indicates arguments that are /// problematic regardless of the state of the system (e.g., a malformed file /// name). - GrpcError.invalidArgument([this.message]) : code = StatusCode.invalidArgument; + GrpcError.invalidArgument([this.message, this.details]) + : code = StatusCode.invalidArgument; /// Deadline expired before operation could complete. For operations that /// change the state of the system, this error may be returned even if the /// operation has completed successfully. For example, a successful response /// from a server could have been delayed long enough for the deadline to /// expire. - GrpcError.deadlineExceeded([this.message]) + GrpcError.deadlineExceeded([this.message, this.details]) : code = StatusCode.deadlineExceeded; /// Some requested entity (e.g., file or directory) was not found. - GrpcError.notFound([this.message]) : code = StatusCode.notFound; + GrpcError.notFound([this.message, this.details]) : code = StatusCode.notFound; /// Some entity that we attempted to create (e.g., file or directory) already /// exists. - GrpcError.alreadyExists([this.message]) : code = StatusCode.alreadyExists; + GrpcError.alreadyExists([this.message, this.details]) + : code = StatusCode.alreadyExists; /// The caller does not have permission to execute the specified operation. /// [permissionDenied] must not be used for rejections caused by exhausting /// some resource (use [resourceExhausted] instead for those errors). /// [permissionDenied] must not be used if the caller cannot be identified /// (use [unauthenticated] instead for those errors). - GrpcError.permissionDenied([this.message]) + GrpcError.permissionDenied([this.message, this.details]) : code = StatusCode.permissionDenied; /// Some resource has been exhausted, perhaps a per-user quota, or perhaps the /// entire file system is out of space. - GrpcError.resourceExhausted([this.message]) + GrpcError.resourceExhausted([this.message, this.details]) : code = StatusCode.resourceExhausted; /// Operation was rejected because the system is not in a state required for @@ -184,7 +191,7 @@ class GrpcError implements Exception { /// because the directory is non-empty, [failedPrecondition] should be /// returned since the client should not retry unless they have first /// fixed up the directory by deleting files from it. - GrpcError.failedPrecondition([this.message]) + GrpcError.failedPrecondition([this.message, this.details]) : code = StatusCode.failedPrecondition; /// The operation was aborted, typically due to a concurrency issue like @@ -192,7 +199,7 @@ class GrpcError implements Exception { /// /// See litmus test above for deciding between [failedPrecondition], /// [aborted], and [unavailable]. - GrpcError.aborted([this.message]) : code = StatusCode.aborted; + GrpcError.aborted([this.message, this.details]) : code = StatusCode.aborted; /// Operation was attempted past the valid range. E.g., seeking or reading /// past end of file. @@ -207,29 +214,33 @@ class GrpcError implements Exception { /// [outOfRange]. We recommend using [outOfRange] (the more specific error) /// when it applies so that callers who are iterating through a space can /// easily look for an [outOfRange] error to detect when they are done. - GrpcError.outOfRange([this.message]) : code = StatusCode.outOfRange; + GrpcError.outOfRange([this.message, this.details]) + : code = StatusCode.outOfRange; /// Operation is not implemented or not supported/enabled in this service. - GrpcError.unimplemented([this.message]) : code = StatusCode.unimplemented; + GrpcError.unimplemented([this.message, this.details]) + : code = StatusCode.unimplemented; /// Internal errors. Means some invariants expected by underlying system has /// been broken. If you see one of these errors, something is very broken. // TODO(sigurdm): This should probably not be an [Exception]. - GrpcError.internal([this.message]) : code = StatusCode.internal; + GrpcError.internal([this.message, this.details]) : code = StatusCode.internal; /// The service is currently unavailable. This is a most likely a transient /// condition and may be corrected by retrying with a backoff. /// /// See litmus test above for deciding between [failedPrecondition], /// [aborted], and [unavailable]. - GrpcError.unavailable([this.message]) : code = StatusCode.unavailable; + GrpcError.unavailable([this.message, this.details]) + : code = StatusCode.unavailable; /// Unrecoverable data loss or corruption. - GrpcError.dataLoss([this.message]) : code = StatusCode.dataLoss; + GrpcError.dataLoss([this.message, this.details]) : code = StatusCode.dataLoss; /// The request does not have valid authentication credentials for the /// operation. - GrpcError.unauthenticated([this.message]) : code = StatusCode.unauthenticated; + GrpcError.unauthenticated([this.message, this.details]) + : code = StatusCode.unauthenticated; @override bool operator ==(other) { @@ -241,5 +252,5 @@ class GrpcError implements Exception { int get hashCode => code.hashCode ^ (message?.hashCode ?? 17); @override - String toString() => 'gRPC Error ($code, $message)'; + String toString() => 'gRPC Error ($code, $message, ${utf8.decode(details)})'; } From 9d08aeebfd783c02b8fb89331cf01a577dea9f7f Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Mon, 14 Sep 2020 10:15:40 -0400 Subject: [PATCH 02/21] Handle case where grpc-status-details-bin might be null --- lib/src/client/call.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/client/call.dart b/lib/src/client/call.dart index 980a2003..3ecce583 100644 --- a/lib/src/client/call.dart +++ b/lib/src/client/call.dart @@ -366,7 +366,7 @@ class ClientCall implements Response { Uint8List _decodeStatusDetails(String data) { /// Parse details out of message. Length must be an even multiple of 4 so we pad it if needed. - var details = data; + var details = data ?? ''; while (details.length % 4 != 0) { details += '='; } From d7f806fd2a953680df656d898710ea8291fd50fa Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Mon, 14 Sep 2020 11:26:15 -0400 Subject: [PATCH 03/21] Added handling of all detail Any types such as RetryInfo and BadRequest --- interop/lib/src/generated/empty.pb.dart | 19 +- interop/lib/src/generated/empty.pbenum.dart | 5 - interop/lib/src/generated/empty.pbjson.dart | 9 - interop/lib/src/generated/messages.pb.dart | 317 ++++++-- .../lib/src/generated/messages.pbenum.dart | 7 +- .../lib/src/generated/messages.pbjson.dart | 231 ------ interop/lib/src/generated/test.pb.dart | 8 +- interop/lib/src/generated/test.pbenum.dart | 5 - interop/lib/src/generated/test.pbgrpc.dart | 27 +- interop/lib/src/generated/test.pbjson.dart | 5 - lib/src/client/call.dart | 12 +- lib/src/generated/google/protobuf/any.pb.dart | 79 ++ .../generated/google/protobuf/any.pbenum.dart | 6 + .../generated/google/protobuf/any.pbjson.dart | 14 + .../google/protobuf/duration.pb.dart | 69 ++ .../google/protobuf/duration.pbenum.dart | 6 + .../google/protobuf/duration.pbjson.dart | 14 + lib/src/generated/google/rpc/code.pb.dart | 10 + lib/src/generated/google/rpc/code.pbenum.dart | 56 ++ lib/src/generated/google/rpc/code.pbjson.dart | 29 + .../google/rpc/error_details.pb.dart | 715 ++++++++++++++++++ .../google/rpc/error_details.pbenum.dart | 6 + .../google/rpc/error_details.pbjson.dart | 173 +++++ lib/src/generated/google/rpc/status.pb.dart | 69 ++ .../generated/google/rpc/status.pbenum.dart | 6 + .../generated/google/rpc/status.pbjson.dart | 22 + lib/src/protos/google/protobuf/any.proto | 158 ++++ lib/src/protos/google/protobuf/duration.proto | 116 +++ lib/src/protos/google/rpc/code.proto | 186 +++++ lib/src/protos/google/rpc/error_details.proto | 249 ++++++ lib/src/protos/google/rpc/status.proto | 47 ++ lib/src/shared/status.dart | 47 +- lib/src/tool/regenerate.sh | 6 + pubspec.yaml | 1 + 34 files changed, 2360 insertions(+), 369 deletions(-) delete mode 100644 interop/lib/src/generated/empty.pbenum.dart delete mode 100644 interop/lib/src/generated/empty.pbjson.dart delete mode 100644 interop/lib/src/generated/messages.pbjson.dart delete mode 100644 interop/lib/src/generated/test.pbenum.dart delete mode 100644 interop/lib/src/generated/test.pbjson.dart create mode 100644 lib/src/generated/google/protobuf/any.pb.dart create mode 100644 lib/src/generated/google/protobuf/any.pbenum.dart create mode 100644 lib/src/generated/google/protobuf/any.pbjson.dart create mode 100644 lib/src/generated/google/protobuf/duration.pb.dart create mode 100644 lib/src/generated/google/protobuf/duration.pbenum.dart create mode 100644 lib/src/generated/google/protobuf/duration.pbjson.dart create mode 100644 lib/src/generated/google/rpc/code.pb.dart create mode 100644 lib/src/generated/google/rpc/code.pbenum.dart create mode 100644 lib/src/generated/google/rpc/code.pbjson.dart create mode 100644 lib/src/generated/google/rpc/error_details.pb.dart create mode 100644 lib/src/generated/google/rpc/error_details.pbenum.dart create mode 100644 lib/src/generated/google/rpc/error_details.pbjson.dart create mode 100644 lib/src/generated/google/rpc/status.pb.dart create mode 100644 lib/src/generated/google/rpc/status.pbenum.dart create mode 100644 lib/src/generated/google/rpc/status.pbjson.dart create mode 100644 lib/src/protos/google/protobuf/any.proto create mode 100644 lib/src/protos/google/protobuf/duration.proto create mode 100644 lib/src/protos/google/rpc/code.proto create mode 100644 lib/src/protos/google/rpc/error_details.proto create mode 100644 lib/src/protos/google/rpc/status.proto create mode 100755 lib/src/tool/regenerate.sh diff --git a/interop/lib/src/generated/empty.pb.dart b/interop/lib/src/generated/empty.pb.dart index ce4c095b..8040c0ed 100644 --- a/interop/lib/src/generated/empty.pb.dart +++ b/interop/lib/src/generated/empty.pb.dart @@ -1,18 +1,19 @@ /// // Generated code. Do not modify. // source: empty.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; class Empty extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = - $pb.BuilderInfo('Empty', package: const $pb.PackageName('grpc.testing')) - ..hasRequiredFields = false; + static final $pb.BuilderInfo _i = $pb.BuilderInfo('Empty', + package: const $pb.PackageName('grpc.testing'), + createEmptyInstance: create) + ..hasRequiredFields = false; Empty._() : super(); factory Empty() => create(); @@ -30,6 +31,8 @@ class Empty extends $pb.GeneratedMessage { static Empty create() => Empty._(); Empty createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static Empty getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static Empty getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); static Empty _defaultInstance; } diff --git a/interop/lib/src/generated/empty.pbenum.dart b/interop/lib/src/generated/empty.pbenum.dart deleted file mode 100644 index 0ceae430..00000000 --- a/interop/lib/src/generated/empty.pbenum.dart +++ /dev/null @@ -1,5 +0,0 @@ -/// -// Generated code. Do not modify. -// source: empty.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name diff --git a/interop/lib/src/generated/empty.pbjson.dart b/interop/lib/src/generated/empty.pbjson.dart deleted file mode 100644 index 170ef668..00000000 --- a/interop/lib/src/generated/empty.pbjson.dart +++ /dev/null @@ -1,9 +0,0 @@ -/// -// Generated code. Do not modify. -// source: empty.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name - -const Empty$json = { - '1': 'Empty', -}; diff --git a/interop/lib/src/generated/messages.pb.dart b/interop/lib/src/generated/messages.pb.dart index 65273a53..8b92662e 100644 --- a/interop/lib/src/generated/messages.pb.dart +++ b/interop/lib/src/generated/messages.pb.dart @@ -1,11 +1,11 @@ /// // Generated code. Do not modify. // source: messages.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; @@ -15,7 +15,8 @@ export 'messages.pbenum.dart'; class BoolValue extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('BoolValue', - package: const $pb.PackageName('grpc.testing')) + package: const $pb.PackageName('grpc.testing'), + createEmptyInstance: create) ..aOB(1, 'value') ..hasRequiredFields = false; @@ -35,25 +36,34 @@ class BoolValue extends $pb.GeneratedMessage { static BoolValue create() => BoolValue._(); BoolValue createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static BoolValue getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static BoolValue getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); static BoolValue _defaultInstance; - $core.bool get value => $_get(0, false); + @$pb.TagNumber(1) + $core.bool get value => $_getBF(0); + @$pb.TagNumber(1) set value($core.bool v) { $_setBool(0, v); } + @$pb.TagNumber(1) $core.bool hasValue() => $_has(0); + @$pb.TagNumber(1) void clearValue() => clearField(1); } class Payload extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = - $pb.BuilderInfo('Payload', package: const $pb.PackageName('grpc.testing')) - ..e(1, 'type', $pb.PbFieldType.OE, - PayloadType.COMPRESSABLE, PayloadType.valueOf, PayloadType.values) - ..a<$core.List<$core.int>>(2, 'body', $pb.PbFieldType.OY) - ..hasRequiredFields = false; + static final $pb.BuilderInfo _i = $pb.BuilderInfo('Payload', + package: const $pb.PackageName('grpc.testing'), + createEmptyInstance: create) + ..e(1, 'type', $pb.PbFieldType.OE, + defaultOrMaker: PayloadType.COMPRESSABLE, + valueOf: PayloadType.valueOf, + enumValues: PayloadType.values) + ..a<$core.List<$core.int>>(2, 'body', $pb.PbFieldType.OY) + ..hasRequiredFields = false; Payload._() : super(); factory Payload() => create(); @@ -71,29 +81,40 @@ class Payload extends $pb.GeneratedMessage { static Payload create() => Payload._(); Payload createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static Payload getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static Payload getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); static Payload _defaultInstance; + @$pb.TagNumber(1) PayloadType get type => $_getN(0); + @$pb.TagNumber(1) set type(PayloadType v) { setField(1, v); } + @$pb.TagNumber(1) $core.bool hasType() => $_has(0); + @$pb.TagNumber(1) void clearType() => clearField(1); + @$pb.TagNumber(2) $core.List<$core.int> get body => $_getN(1); + @$pb.TagNumber(2) set body($core.List<$core.int> v) { $_setBytes(1, v); } + @$pb.TagNumber(2) $core.bool hasBody() => $_has(1); + @$pb.TagNumber(2) void clearBody() => clearField(2); } class EchoStatus extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('EchoStatus', - package: const $pb.PackageName('grpc.testing')) + package: const $pb.PackageName('grpc.testing'), + createEmptyInstance: create) ..a<$core.int>(1, 'code', $pb.PbFieldType.O3) ..aOS(2, 'message') ..hasRequiredFields = false; @@ -114,42 +135,51 @@ class EchoStatus extends $pb.GeneratedMessage { static EchoStatus create() => EchoStatus._(); EchoStatus createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static EchoStatus getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static EchoStatus getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static EchoStatus _defaultInstance; - $core.int get code => $_get(0, 0); + @$pb.TagNumber(1) + $core.int get code => $_getIZ(0); + @$pb.TagNumber(1) set code($core.int v) { $_setSignedInt32(0, v); } + @$pb.TagNumber(1) $core.bool hasCode() => $_has(0); + @$pb.TagNumber(1) void clearCode() => clearField(1); - $core.String get message => $_getS(1, ''); + @$pb.TagNumber(2) + $core.String get message => $_getSZ(1); + @$pb.TagNumber(2) set message($core.String v) { $_setString(1, v); } + @$pb.TagNumber(2) $core.bool hasMessage() => $_has(1); + @$pb.TagNumber(2) void clearMessage() => clearField(2); } class SimpleRequest extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('SimpleRequest', - package: const $pb.PackageName('grpc.testing')) + package: const $pb.PackageName('grpc.testing'), + createEmptyInstance: create) ..e(1, 'responseType', $pb.PbFieldType.OE, - PayloadType.COMPRESSABLE, PayloadType.valueOf, PayloadType.values) + defaultOrMaker: PayloadType.COMPRESSABLE, + valueOf: PayloadType.valueOf, + enumValues: PayloadType.values) ..a<$core.int>(2, 'responseSize', $pb.PbFieldType.O3) - ..a( - 3, 'payload', $pb.PbFieldType.OM, Payload.getDefault, Payload.create) + ..aOM(3, 'payload', subBuilder: Payload.create) ..aOB(4, 'fillUsername') ..aOB(5, 'fillOauthScope') - ..a(6, 'responseCompressed', $pb.PbFieldType.OM, - BoolValue.getDefault, BoolValue.create) - ..a(7, 'responseStatus', $pb.PbFieldType.OM, - EchoStatus.getDefault, EchoStatus.create) - ..a(8, 'expectCompressed', $pb.PbFieldType.OM, - BoolValue.getDefault, BoolValue.create) + ..aOM(6, 'responseCompressed', subBuilder: BoolValue.create) + ..aOM(7, 'responseStatus', subBuilder: EchoStatus.create) + ..aOM(8, 'expectCompressed', subBuilder: BoolValue.create) ..hasRequiredFields = false; SimpleRequest._() : super(); @@ -169,79 +199,121 @@ class SimpleRequest extends $pb.GeneratedMessage { SimpleRequest createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static SimpleRequest getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static SimpleRequest getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static SimpleRequest _defaultInstance; + @$pb.TagNumber(1) PayloadType get responseType => $_getN(0); + @$pb.TagNumber(1) set responseType(PayloadType v) { setField(1, v); } + @$pb.TagNumber(1) $core.bool hasResponseType() => $_has(0); + @$pb.TagNumber(1) void clearResponseType() => clearField(1); - $core.int get responseSize => $_get(1, 0); + @$pb.TagNumber(2) + $core.int get responseSize => $_getIZ(1); + @$pb.TagNumber(2) set responseSize($core.int v) { $_setSignedInt32(1, v); } + @$pb.TagNumber(2) $core.bool hasResponseSize() => $_has(1); + @$pb.TagNumber(2) void clearResponseSize() => clearField(2); + @$pb.TagNumber(3) Payload get payload => $_getN(2); + @$pb.TagNumber(3) set payload(Payload v) { setField(3, v); } + @$pb.TagNumber(3) $core.bool hasPayload() => $_has(2); + @$pb.TagNumber(3) void clearPayload() => clearField(3); + @$pb.TagNumber(3) + Payload ensurePayload() => $_ensure(2); - $core.bool get fillUsername => $_get(3, false); + @$pb.TagNumber(4) + $core.bool get fillUsername => $_getBF(3); + @$pb.TagNumber(4) set fillUsername($core.bool v) { $_setBool(3, v); } + @$pb.TagNumber(4) $core.bool hasFillUsername() => $_has(3); + @$pb.TagNumber(4) void clearFillUsername() => clearField(4); - $core.bool get fillOauthScope => $_get(4, false); + @$pb.TagNumber(5) + $core.bool get fillOauthScope => $_getBF(4); + @$pb.TagNumber(5) set fillOauthScope($core.bool v) { $_setBool(4, v); } + @$pb.TagNumber(5) $core.bool hasFillOauthScope() => $_has(4); + @$pb.TagNumber(5) void clearFillOauthScope() => clearField(5); + @$pb.TagNumber(6) BoolValue get responseCompressed => $_getN(5); + @$pb.TagNumber(6) set responseCompressed(BoolValue v) { setField(6, v); } + @$pb.TagNumber(6) $core.bool hasResponseCompressed() => $_has(5); + @$pb.TagNumber(6) void clearResponseCompressed() => clearField(6); + @$pb.TagNumber(6) + BoolValue ensureResponseCompressed() => $_ensure(5); + @$pb.TagNumber(7) EchoStatus get responseStatus => $_getN(6); + @$pb.TagNumber(7) set responseStatus(EchoStatus v) { setField(7, v); } + @$pb.TagNumber(7) $core.bool hasResponseStatus() => $_has(6); + @$pb.TagNumber(7) void clearResponseStatus() => clearField(7); + @$pb.TagNumber(7) + EchoStatus ensureResponseStatus() => $_ensure(6); + @$pb.TagNumber(8) BoolValue get expectCompressed => $_getN(7); + @$pb.TagNumber(8) set expectCompressed(BoolValue v) { setField(8, v); } + @$pb.TagNumber(8) $core.bool hasExpectCompressed() => $_has(7); + @$pb.TagNumber(8) void clearExpectCompressed() => clearField(8); + @$pb.TagNumber(8) + BoolValue ensureExpectCompressed() => $_ensure(7); } class SimpleResponse extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('SimpleResponse', - package: const $pb.PackageName('grpc.testing')) - ..a( - 1, 'payload', $pb.PbFieldType.OM, Payload.getDefault, Payload.create) + package: const $pb.PackageName('grpc.testing'), + createEmptyInstance: create) + ..aOM(1, 'payload', subBuilder: Payload.create) ..aOS(2, 'username') ..aOS(3, 'oauthScope') ..hasRequiredFields = false; @@ -263,41 +335,56 @@ class SimpleResponse extends $pb.GeneratedMessage { SimpleResponse createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static SimpleResponse getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static SimpleResponse getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static SimpleResponse _defaultInstance; + @$pb.TagNumber(1) Payload get payload => $_getN(0); + @$pb.TagNumber(1) set payload(Payload v) { setField(1, v); } + @$pb.TagNumber(1) $core.bool hasPayload() => $_has(0); + @$pb.TagNumber(1) void clearPayload() => clearField(1); + @$pb.TagNumber(1) + Payload ensurePayload() => $_ensure(0); - $core.String get username => $_getS(1, ''); + @$pb.TagNumber(2) + $core.String get username => $_getSZ(1); + @$pb.TagNumber(2) set username($core.String v) { $_setString(1, v); } + @$pb.TagNumber(2) $core.bool hasUsername() => $_has(1); + @$pb.TagNumber(2) void clearUsername() => clearField(2); - $core.String get oauthScope => $_getS(2, ''); + @$pb.TagNumber(3) + $core.String get oauthScope => $_getSZ(2); + @$pb.TagNumber(3) set oauthScope($core.String v) { $_setString(2, v); } + @$pb.TagNumber(3) $core.bool hasOauthScope() => $_has(2); + @$pb.TagNumber(3) void clearOauthScope() => clearField(3); } class StreamingInputCallRequest extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('StreamingInputCallRequest', - package: const $pb.PackageName('grpc.testing')) - ..a( - 1, 'payload', $pb.PbFieldType.OM, Payload.getDefault, Payload.create) - ..a(2, 'expectCompressed', $pb.PbFieldType.OM, - BoolValue.getDefault, BoolValue.create) + package: const $pb.PackageName('grpc.testing'), + createEmptyInstance: create) + ..aOM(1, 'payload', subBuilder: Payload.create) + ..aOM(2, 'expectCompressed', subBuilder: BoolValue.create) ..hasRequiredFields = false; StreamingInputCallRequest._() : super(); @@ -320,31 +407,45 @@ class StreamingInputCallRequest extends $pb.GeneratedMessage { StreamingInputCallRequest createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static StreamingInputCallRequest getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static StreamingInputCallRequest getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static StreamingInputCallRequest _defaultInstance; + @$pb.TagNumber(1) Payload get payload => $_getN(0); + @$pb.TagNumber(1) set payload(Payload v) { setField(1, v); } + @$pb.TagNumber(1) $core.bool hasPayload() => $_has(0); + @$pb.TagNumber(1) void clearPayload() => clearField(1); + @$pb.TagNumber(1) + Payload ensurePayload() => $_ensure(0); + @$pb.TagNumber(2) BoolValue get expectCompressed => $_getN(1); + @$pb.TagNumber(2) set expectCompressed(BoolValue v) { setField(2, v); } + @$pb.TagNumber(2) $core.bool hasExpectCompressed() => $_has(1); + @$pb.TagNumber(2) void clearExpectCompressed() => clearField(2); + @$pb.TagNumber(2) + BoolValue ensureExpectCompressed() => $_ensure(1); } class StreamingInputCallResponse extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo( 'StreamingInputCallResponse', - package: const $pb.PackageName('grpc.testing')) + package: const $pb.PackageName('grpc.testing'), + createEmptyInstance: create) ..a<$core.int>(1, 'aggregatedPayloadSize', $pb.PbFieldType.O3) ..hasRequiredFields = false; @@ -368,26 +469,31 @@ class StreamingInputCallResponse extends $pb.GeneratedMessage { StreamingInputCallResponse createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static StreamingInputCallResponse getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static StreamingInputCallResponse getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static StreamingInputCallResponse _defaultInstance; - $core.int get aggregatedPayloadSize => $_get(0, 0); + @$pb.TagNumber(1) + $core.int get aggregatedPayloadSize => $_getIZ(0); + @$pb.TagNumber(1) set aggregatedPayloadSize($core.int v) { $_setSignedInt32(0, v); } + @$pb.TagNumber(1) $core.bool hasAggregatedPayloadSize() => $_has(0); + @$pb.TagNumber(1) void clearAggregatedPayloadSize() => clearField(1); } class ResponseParameters extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('ResponseParameters', - package: const $pb.PackageName('grpc.testing')) + package: const $pb.PackageName('grpc.testing'), + createEmptyInstance: create) ..a<$core.int>(1, 'size', $pb.PbFieldType.O3) ..a<$core.int>(2, 'intervalUs', $pb.PbFieldType.O3) - ..a(3, 'compressed', $pb.PbFieldType.OM, BoolValue.getDefault, - BoolValue.create) + ..aOM(3, 'compressed', subBuilder: BoolValue.create) ..hasRequiredFields = false; ResponseParameters._() : super(); @@ -407,47 +513,63 @@ class ResponseParameters extends $pb.GeneratedMessage { ResponseParameters createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static ResponseParameters getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static ResponseParameters getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static ResponseParameters _defaultInstance; - $core.int get size => $_get(0, 0); + @$pb.TagNumber(1) + $core.int get size => $_getIZ(0); + @$pb.TagNumber(1) set size($core.int v) { $_setSignedInt32(0, v); } + @$pb.TagNumber(1) $core.bool hasSize() => $_has(0); + @$pb.TagNumber(1) void clearSize() => clearField(1); - $core.int get intervalUs => $_get(1, 0); + @$pb.TagNumber(2) + $core.int get intervalUs => $_getIZ(1); + @$pb.TagNumber(2) set intervalUs($core.int v) { $_setSignedInt32(1, v); } + @$pb.TagNumber(2) $core.bool hasIntervalUs() => $_has(1); + @$pb.TagNumber(2) void clearIntervalUs() => clearField(2); + @$pb.TagNumber(3) BoolValue get compressed => $_getN(2); + @$pb.TagNumber(3) set compressed(BoolValue v) { setField(3, v); } + @$pb.TagNumber(3) $core.bool hasCompressed() => $_has(2); + @$pb.TagNumber(3) void clearCompressed() => clearField(3); + @$pb.TagNumber(3) + BoolValue ensureCompressed() => $_ensure(2); } class StreamingOutputCallRequest extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo( 'StreamingOutputCallRequest', - package: const $pb.PackageName('grpc.testing')) + package: const $pb.PackageName('grpc.testing'), + createEmptyInstance: create) ..e(1, 'responseType', $pb.PbFieldType.OE, - PayloadType.COMPRESSABLE, PayloadType.valueOf, PayloadType.values) - ..pc( - 2, 'responseParameters', $pb.PbFieldType.PM, ResponseParameters.create) - ..a( - 3, 'payload', $pb.PbFieldType.OM, Payload.getDefault, Payload.create) - ..a(7, 'responseStatus', $pb.PbFieldType.OM, - EchoStatus.getDefault, EchoStatus.create) + defaultOrMaker: PayloadType.COMPRESSABLE, + valueOf: PayloadType.valueOf, + enumValues: PayloadType.values) + ..pc(2, 'responseParameters', $pb.PbFieldType.PM, + subBuilder: ResponseParameters.create) + ..aOM(3, 'payload', subBuilder: Payload.create) + ..aOM(7, 'responseStatus', subBuilder: EchoStatus.create) ..hasRequiredFields = false; StreamingOutputCallRequest._() : super(); @@ -470,43 +592,61 @@ class StreamingOutputCallRequest extends $pb.GeneratedMessage { StreamingOutputCallRequest createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static StreamingOutputCallRequest getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static StreamingOutputCallRequest getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static StreamingOutputCallRequest _defaultInstance; + @$pb.TagNumber(1) PayloadType get responseType => $_getN(0); + @$pb.TagNumber(1) set responseType(PayloadType v) { setField(1, v); } + @$pb.TagNumber(1) $core.bool hasResponseType() => $_has(0); + @$pb.TagNumber(1) void clearResponseType() => clearField(1); + @$pb.TagNumber(2) $core.List get responseParameters => $_getList(1); + @$pb.TagNumber(3) Payload get payload => $_getN(2); + @$pb.TagNumber(3) set payload(Payload v) { setField(3, v); } + @$pb.TagNumber(3) $core.bool hasPayload() => $_has(2); + @$pb.TagNumber(3) void clearPayload() => clearField(3); + @$pb.TagNumber(3) + Payload ensurePayload() => $_ensure(2); + @$pb.TagNumber(7) EchoStatus get responseStatus => $_getN(3); + @$pb.TagNumber(7) set responseStatus(EchoStatus v) { setField(7, v); } + @$pb.TagNumber(7) $core.bool hasResponseStatus() => $_has(3); + @$pb.TagNumber(7) void clearResponseStatus() => clearField(7); + @$pb.TagNumber(7) + EchoStatus ensureResponseStatus() => $_ensure(3); } class StreamingOutputCallResponse extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo( 'StreamingOutputCallResponse', - package: const $pb.PackageName('grpc.testing')) - ..a( - 1, 'payload', $pb.PbFieldType.OM, Payload.getDefault, Payload.create) + package: const $pb.PackageName('grpc.testing'), + createEmptyInstance: create) + ..aOM(1, 'payload', subBuilder: Payload.create) ..hasRequiredFields = false; StreamingOutputCallResponse._() : super(); @@ -530,22 +670,30 @@ class StreamingOutputCallResponse extends $pb.GeneratedMessage { StreamingOutputCallResponse createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static StreamingOutputCallResponse getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static StreamingOutputCallResponse getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static StreamingOutputCallResponse _defaultInstance; + @$pb.TagNumber(1) Payload get payload => $_getN(0); + @$pb.TagNumber(1) set payload(Payload v) { setField(1, v); } + @$pb.TagNumber(1) $core.bool hasPayload() => $_has(0); + @$pb.TagNumber(1) void clearPayload() => clearField(1); + @$pb.TagNumber(1) + Payload ensurePayload() => $_ensure(0); } class ReconnectParams extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('ReconnectParams', - package: const $pb.PackageName('grpc.testing')) + package: const $pb.PackageName('grpc.testing'), + createEmptyInstance: create) ..a<$core.int>(1, 'maxReconnectBackoffMs', $pb.PbFieldType.O3) ..hasRequiredFields = false; @@ -566,22 +714,28 @@ class ReconnectParams extends $pb.GeneratedMessage { ReconnectParams createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static ReconnectParams getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static ReconnectParams getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static ReconnectParams _defaultInstance; - $core.int get maxReconnectBackoffMs => $_get(0, 0); + @$pb.TagNumber(1) + $core.int get maxReconnectBackoffMs => $_getIZ(0); + @$pb.TagNumber(1) set maxReconnectBackoffMs($core.int v) { $_setSignedInt32(0, v); } + @$pb.TagNumber(1) $core.bool hasMaxReconnectBackoffMs() => $_has(0); + @$pb.TagNumber(1) void clearMaxReconnectBackoffMs() => clearField(1); } class ReconnectInfo extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('ReconnectInfo', - package: const $pb.PackageName('grpc.testing')) + package: const $pb.PackageName('grpc.testing'), + createEmptyInstance: create) ..aOB(1, 'passed') ..p<$core.int>(2, 'backoffMs', $pb.PbFieldType.P3) ..hasRequiredFields = false; @@ -603,16 +757,23 @@ class ReconnectInfo extends $pb.GeneratedMessage { ReconnectInfo createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static ReconnectInfo getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static ReconnectInfo getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static ReconnectInfo _defaultInstance; - $core.bool get passed => $_get(0, false); + @$pb.TagNumber(1) + $core.bool get passed => $_getBF(0); + @$pb.TagNumber(1) set passed($core.bool v) { $_setBool(0, v); } + @$pb.TagNumber(1) $core.bool hasPassed() => $_has(0); + @$pb.TagNumber(1) void clearPassed() => clearField(1); + @$pb.TagNumber(2) $core.List<$core.int> get backoffMs => $_getList(1); } diff --git a/interop/lib/src/generated/messages.pbenum.dart b/interop/lib/src/generated/messages.pbenum.dart index ba2bd9ac..0166a381 100644 --- a/interop/lib/src/generated/messages.pbenum.dart +++ b/interop/lib/src/generated/messages.pbenum.dart @@ -1,11 +1,12 @@ /// // Generated code. Do not modify. // source: messages.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type // ignore_for_file: UNDEFINED_SHOWN_NAME,UNUSED_SHOWN_NAME -import 'dart:core' as $core show int, dynamic, String, List, Map; +import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; class PayloadType extends $pb.ProtobufEnum { diff --git a/interop/lib/src/generated/messages.pbjson.dart b/interop/lib/src/generated/messages.pbjson.dart deleted file mode 100644 index 71e11d74..00000000 --- a/interop/lib/src/generated/messages.pbjson.dart +++ /dev/null @@ -1,231 +0,0 @@ -/// -// Generated code. Do not modify. -// source: messages.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name - -const PayloadType$json = { - '1': 'PayloadType', - '2': [ - {'1': 'COMPRESSABLE', '2': 0}, - ], -}; - -const BoolValue$json = { - '1': 'BoolValue', - '2': [ - {'1': 'value', '3': 1, '4': 1, '5': 8, '10': 'value'}, - ], -}; - -const Payload$json = { - '1': 'Payload', - '2': [ - { - '1': 'type', - '3': 1, - '4': 1, - '5': 14, - '6': '.grpc.testing.PayloadType', - '10': 'type' - }, - {'1': 'body', '3': 2, '4': 1, '5': 12, '10': 'body'}, - ], -}; - -const EchoStatus$json = { - '1': 'EchoStatus', - '2': [ - {'1': 'code', '3': 1, '4': 1, '5': 5, '10': 'code'}, - {'1': 'message', '3': 2, '4': 1, '5': 9, '10': 'message'}, - ], -}; - -const SimpleRequest$json = { - '1': 'SimpleRequest', - '2': [ - { - '1': 'response_type', - '3': 1, - '4': 1, - '5': 14, - '6': '.grpc.testing.PayloadType', - '10': 'responseType' - }, - {'1': 'response_size', '3': 2, '4': 1, '5': 5, '10': 'responseSize'}, - { - '1': 'payload', - '3': 3, - '4': 1, - '5': 11, - '6': '.grpc.testing.Payload', - '10': 'payload' - }, - {'1': 'fill_username', '3': 4, '4': 1, '5': 8, '10': 'fillUsername'}, - {'1': 'fill_oauth_scope', '3': 5, '4': 1, '5': 8, '10': 'fillOauthScope'}, - { - '1': 'response_compressed', - '3': 6, - '4': 1, - '5': 11, - '6': '.grpc.testing.BoolValue', - '10': 'responseCompressed' - }, - { - '1': 'response_status', - '3': 7, - '4': 1, - '5': 11, - '6': '.grpc.testing.EchoStatus', - '10': 'responseStatus' - }, - { - '1': 'expect_compressed', - '3': 8, - '4': 1, - '5': 11, - '6': '.grpc.testing.BoolValue', - '10': 'expectCompressed' - }, - ], -}; - -const SimpleResponse$json = { - '1': 'SimpleResponse', - '2': [ - { - '1': 'payload', - '3': 1, - '4': 1, - '5': 11, - '6': '.grpc.testing.Payload', - '10': 'payload' - }, - {'1': 'username', '3': 2, '4': 1, '5': 9, '10': 'username'}, - {'1': 'oauth_scope', '3': 3, '4': 1, '5': 9, '10': 'oauthScope'}, - ], -}; - -const StreamingInputCallRequest$json = { - '1': 'StreamingInputCallRequest', - '2': [ - { - '1': 'payload', - '3': 1, - '4': 1, - '5': 11, - '6': '.grpc.testing.Payload', - '10': 'payload' - }, - { - '1': 'expect_compressed', - '3': 2, - '4': 1, - '5': 11, - '6': '.grpc.testing.BoolValue', - '10': 'expectCompressed' - }, - ], -}; - -const StreamingInputCallResponse$json = { - '1': 'StreamingInputCallResponse', - '2': [ - { - '1': 'aggregated_payload_size', - '3': 1, - '4': 1, - '5': 5, - '10': 'aggregatedPayloadSize' - }, - ], -}; - -const ResponseParameters$json = { - '1': 'ResponseParameters', - '2': [ - {'1': 'size', '3': 1, '4': 1, '5': 5, '10': 'size'}, - {'1': 'interval_us', '3': 2, '4': 1, '5': 5, '10': 'intervalUs'}, - { - '1': 'compressed', - '3': 3, - '4': 1, - '5': 11, - '6': '.grpc.testing.BoolValue', - '10': 'compressed' - }, - ], -}; - -const StreamingOutputCallRequest$json = { - '1': 'StreamingOutputCallRequest', - '2': [ - { - '1': 'response_type', - '3': 1, - '4': 1, - '5': 14, - '6': '.grpc.testing.PayloadType', - '10': 'responseType' - }, - { - '1': 'response_parameters', - '3': 2, - '4': 3, - '5': 11, - '6': '.grpc.testing.ResponseParameters', - '10': 'responseParameters' - }, - { - '1': 'payload', - '3': 3, - '4': 1, - '5': 11, - '6': '.grpc.testing.Payload', - '10': 'payload' - }, - { - '1': 'response_status', - '3': 7, - '4': 1, - '5': 11, - '6': '.grpc.testing.EchoStatus', - '10': 'responseStatus' - }, - ], -}; - -const StreamingOutputCallResponse$json = { - '1': 'StreamingOutputCallResponse', - '2': [ - { - '1': 'payload', - '3': 1, - '4': 1, - '5': 11, - '6': '.grpc.testing.Payload', - '10': 'payload' - }, - ], -}; - -const ReconnectParams$json = { - '1': 'ReconnectParams', - '2': [ - { - '1': 'max_reconnect_backoff_ms', - '3': 1, - '4': 1, - '5': 5, - '10': 'maxReconnectBackoffMs' - }, - ], -}; - -const ReconnectInfo$json = { - '1': 'ReconnectInfo', - '2': [ - {'1': 'passed', '3': 1, '4': 1, '5': 8, '10': 'passed'}, - {'1': 'backoff_ms', '3': 2, '4': 3, '5': 5, '10': 'backoffMs'}, - ], -}; diff --git a/interop/lib/src/generated/test.pb.dart b/interop/lib/src/generated/test.pb.dart index 7d383228..4c1714ee 100644 --- a/interop/lib/src/generated/test.pb.dart +++ b/interop/lib/src/generated/test.pb.dart @@ -1,8 +1,8 @@ /// // Generated code. Do not modify. // source: test.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; diff --git a/interop/lib/src/generated/test.pbenum.dart b/interop/lib/src/generated/test.pbenum.dart deleted file mode 100644 index 0fb92b1f..00000000 --- a/interop/lib/src/generated/test.pbenum.dart +++ /dev/null @@ -1,5 +0,0 @@ -/// -// Generated code. Do not modify. -// source: test.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name diff --git a/interop/lib/src/generated/test.pbgrpc.dart b/interop/lib/src/generated/test.pbgrpc.dart index 25e82863..ba85b9e2 100644 --- a/interop/lib/src/generated/test.pbgrpc.dart +++ b/interop/lib/src/generated/test.pbgrpc.dart @@ -1,12 +1,13 @@ /// // Generated code. Do not modify. // source: test.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type import 'dart:async' as $async; -import 'dart:core' as $core show int, String, List; +import 'dart:core' as $core; import 'package:grpc/service_api.dart' as $grpc; import 'empty.pb.dart' as $0; @@ -193,28 +194,28 @@ abstract class TestServiceBase extends $grpc.Service { } $async.Future<$0.Empty> emptyCall_Pre( - $grpc.ServiceCall call, $async.Future request) async { + $grpc.ServiceCall call, $async.Future<$0.Empty> request) async { return emptyCall(call, await request); } $async.Future<$1.SimpleResponse> unaryCall_Pre( - $grpc.ServiceCall call, $async.Future request) async { + $grpc.ServiceCall call, $async.Future<$1.SimpleRequest> request) async { return unaryCall(call, await request); } $async.Future<$1.SimpleResponse> cacheableUnaryCall_Pre( - $grpc.ServiceCall call, $async.Future request) async { + $grpc.ServiceCall call, $async.Future<$1.SimpleRequest> request) async { return cacheableUnaryCall(call, await request); } $async.Stream<$1.StreamingOutputCallResponse> streamingOutputCall_Pre( - $grpc.ServiceCall call, $async.Future request) async* { - yield* streamingOutputCall( - call, (await request) as $1.StreamingOutputCallRequest); + $grpc.ServiceCall call, + $async.Future<$1.StreamingOutputCallRequest> request) async* { + yield* streamingOutputCall(call, await request); } $async.Future<$0.Empty> unimplementedCall_Pre( - $grpc.ServiceCall call, $async.Future request) async { + $grpc.ServiceCall call, $async.Future<$0.Empty> request) async { return unimplementedCall(call, await request); } @@ -271,7 +272,7 @@ abstract class UnimplementedServiceBase extends $grpc.Service { } $async.Future<$0.Empty> unimplementedCall_Pre( - $grpc.ServiceCall call, $async.Future request) async { + $grpc.ServiceCall call, $async.Future<$0.Empty> request) async { return unimplementedCall(call, await request); } @@ -329,12 +330,12 @@ abstract class ReconnectServiceBase extends $grpc.Service { } $async.Future<$0.Empty> start_Pre( - $grpc.ServiceCall call, $async.Future request) async { + $grpc.ServiceCall call, $async.Future<$1.ReconnectParams> request) async { return start(call, await request); } $async.Future<$1.ReconnectInfo> stop_Pre( - $grpc.ServiceCall call, $async.Future request) async { + $grpc.ServiceCall call, $async.Future<$0.Empty> request) async { return stop(call, await request); } diff --git a/interop/lib/src/generated/test.pbjson.dart b/interop/lib/src/generated/test.pbjson.dart deleted file mode 100644 index 0fb92b1f..00000000 --- a/interop/lib/src/generated/test.pbjson.dart +++ /dev/null @@ -1,5 +0,0 @@ -/// -// Generated code. Do not modify. -// source: test.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name diff --git a/lib/src/client/call.dart b/lib/src/client/call.dart index 3ecce583..283d7c14 100644 --- a/lib/src/client/call.dart +++ b/lib/src/client/call.dart @@ -15,11 +15,12 @@ import 'dart:async'; import 'dart:convert'; -import 'dart:typed_data'; + +import 'package:grpc/src/generated/google/rpc/status.pb.dart'; +import 'package:protobuf/protobuf.dart'; import '../shared/message.dart'; import '../shared/status.dart'; - import 'common.dart'; import 'connection.dart'; import 'method.dart'; @@ -364,11 +365,14 @@ class ClientCall implements Response { } } -Uint8List _decodeStatusDetails(String data) { +List _decodeStatusDetails(String data) { /// Parse details out of message. Length must be an even multiple of 4 so we pad it if needed. var details = data ?? ''; while (details.length % 4 != 0) { details += '='; } - return base64Url.decode(details); + + /// Parse each Any type into the correct GeneratedMessage + final parsedStatus = Status.fromBuffer(base64Url.decode(details)); + return parsedStatus.details.map((e) => parseGeneratedMessage(e)).toList(); } diff --git a/lib/src/generated/google/protobuf/any.pb.dart b/lib/src/generated/google/protobuf/any.pb.dart new file mode 100644 index 00000000..806956f6 --- /dev/null +++ b/lib/src/generated/google/protobuf/any.pb.dart @@ -0,0 +1,79 @@ +/// +// Generated code. Do not modify. +// source: google/protobuf/any.proto +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type + +import 'dart:core' as $core; + +import 'package:protobuf/protobuf.dart' as $pb; + +import 'package:protobuf/src/protobuf/mixins/well_known.dart' as $mixin; + +class Any extends $pb.GeneratedMessage with $mixin.AnyMixin { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('Any', + package: const $pb.PackageName('google.protobuf'), + createEmptyInstance: create, + toProto3Json: $mixin.AnyMixin.toProto3JsonHelper, + fromProto3Json: $mixin.AnyMixin.fromProto3JsonHelper) + ..aOS(1, 'typeUrl') + ..a<$core.List<$core.int>>(2, 'value', $pb.PbFieldType.OY) + ..hasRequiredFields = false; + + Any._() : super(); + factory Any() => create(); + factory Any.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Any.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + Any clone() => Any()..mergeFromMessage(this); + Any copyWith(void Function(Any) updates) => + super.copyWith((message) => updates(message as Any)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static Any create() => Any._(); + Any createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Any getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Any _defaultInstance; + + @$pb.TagNumber(1) + $core.String get typeUrl => $_getSZ(0); + @$pb.TagNumber(1) + set typeUrl($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasTypeUrl() => $_has(0); + @$pb.TagNumber(1) + void clearTypeUrl() => clearField(1); + + @$pb.TagNumber(2) + $core.List<$core.int> get value => $_getN(1); + @$pb.TagNumber(2) + set value($core.List<$core.int> v) { + $_setBytes(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasValue() => $_has(1); + @$pb.TagNumber(2) + void clearValue() => clearField(2); + + /// Creates a new [Any] encoding [message]. + /// + /// The [typeUrl] will be [typeUrlPrefix]/`fullName` where `fullName` is + /// the fully qualified name of the type of [message]. + static Any pack($pb.GeneratedMessage message, + {$core.String typeUrlPrefix = 'type.googleapis.com'}) { + final result = create(); + $mixin.AnyMixin.packIntoAny(result, message, typeUrlPrefix: typeUrlPrefix); + return result; + } +} diff --git a/lib/src/generated/google/protobuf/any.pbenum.dart b/lib/src/generated/google/protobuf/any.pbenum.dart new file mode 100644 index 00000000..ed3dc035 --- /dev/null +++ b/lib/src/generated/google/protobuf/any.pbenum.dart @@ -0,0 +1,6 @@ +/// +// Generated code. Do not modify. +// source: google/protobuf/any.proto +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type diff --git a/lib/src/generated/google/protobuf/any.pbjson.dart b/lib/src/generated/google/protobuf/any.pbjson.dart new file mode 100644 index 00000000..8e0463ea --- /dev/null +++ b/lib/src/generated/google/protobuf/any.pbjson.dart @@ -0,0 +1,14 @@ +/// +// Generated code. Do not modify. +// source: google/protobuf/any.proto +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type + +const Any$json = const { + '1': 'Any', + '2': const [ + const {'1': 'type_url', '3': 1, '4': 1, '5': 9, '10': 'typeUrl'}, + const {'1': 'value', '3': 2, '4': 1, '5': 12, '10': 'value'}, + ], +}; diff --git a/lib/src/generated/google/protobuf/duration.pb.dart b/lib/src/generated/google/protobuf/duration.pb.dart new file mode 100644 index 00000000..c612a3e5 --- /dev/null +++ b/lib/src/generated/google/protobuf/duration.pb.dart @@ -0,0 +1,69 @@ +/// +// Generated code. Do not modify. +// source: google/protobuf/duration.proto +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type + +import 'dart:core' as $core; + +import 'package:fixnum/fixnum.dart' as $fixnum; +import 'package:protobuf/protobuf.dart' as $pb; + +import 'package:protobuf/src/protobuf/mixins/well_known.dart' as $mixin; + +class Duration extends $pb.GeneratedMessage with $mixin.DurationMixin { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('Duration', + package: const $pb.PackageName('google.protobuf'), + createEmptyInstance: create, + toProto3Json: $mixin.DurationMixin.toProto3JsonHelper, + fromProto3Json: $mixin.DurationMixin.fromProto3JsonHelper) + ..aInt64(1, 'seconds') + ..a<$core.int>(2, 'nanos', $pb.PbFieldType.O3) + ..hasRequiredFields = false; + + Duration._() : super(); + factory Duration() => create(); + factory Duration.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Duration.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + Duration clone() => Duration()..mergeFromMessage(this); + Duration copyWith(void Function(Duration) updates) => + super.copyWith((message) => updates(message as Duration)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static Duration create() => Duration._(); + Duration createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Duration getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Duration _defaultInstance; + + @$pb.TagNumber(1) + $fixnum.Int64 get seconds => $_getI64(0); + @$pb.TagNumber(1) + set seconds($fixnum.Int64 v) { + $_setInt64(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasSeconds() => $_has(0); + @$pb.TagNumber(1) + void clearSeconds() => clearField(1); + + @$pb.TagNumber(2) + $core.int get nanos => $_getIZ(1); + @$pb.TagNumber(2) + set nanos($core.int v) { + $_setSignedInt32(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasNanos() => $_has(1); + @$pb.TagNumber(2) + void clearNanos() => clearField(2); +} diff --git a/lib/src/generated/google/protobuf/duration.pbenum.dart b/lib/src/generated/google/protobuf/duration.pbenum.dart new file mode 100644 index 00000000..9cfc0031 --- /dev/null +++ b/lib/src/generated/google/protobuf/duration.pbenum.dart @@ -0,0 +1,6 @@ +/// +// Generated code. Do not modify. +// source: google/protobuf/duration.proto +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type diff --git a/lib/src/generated/google/protobuf/duration.pbjson.dart b/lib/src/generated/google/protobuf/duration.pbjson.dart new file mode 100644 index 00000000..7a83954e --- /dev/null +++ b/lib/src/generated/google/protobuf/duration.pbjson.dart @@ -0,0 +1,14 @@ +/// +// Generated code. Do not modify. +// source: google/protobuf/duration.proto +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type + +const Duration$json = const { + '1': 'Duration', + '2': const [ + const {'1': 'seconds', '3': 1, '4': 1, '5': 3, '10': 'seconds'}, + const {'1': 'nanos', '3': 2, '4': 1, '5': 5, '10': 'nanos'}, + ], +}; diff --git a/lib/src/generated/google/rpc/code.pb.dart b/lib/src/generated/google/rpc/code.pb.dart new file mode 100644 index 00000000..06d9d25f --- /dev/null +++ b/lib/src/generated/google/rpc/code.pb.dart @@ -0,0 +1,10 @@ +/// +// Generated code. Do not modify. +// source: google/rpc/code.proto +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type + +import 'dart:core' as $core; + +export 'code.pbenum.dart'; diff --git a/lib/src/generated/google/rpc/code.pbenum.dart b/lib/src/generated/google/rpc/code.pbenum.dart new file mode 100644 index 00000000..2d75de9f --- /dev/null +++ b/lib/src/generated/google/rpc/code.pbenum.dart @@ -0,0 +1,56 @@ +/// +// Generated code. Do not modify. +// source: google/rpc/code.proto +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type + +// ignore_for_file: UNDEFINED_SHOWN_NAME,UNUSED_SHOWN_NAME +import 'dart:core' as $core; +import 'package:protobuf/protobuf.dart' as $pb; + +class Code extends $pb.ProtobufEnum { + static const Code OK = Code._(0, 'OK'); + static const Code CANCELLED = Code._(1, 'CANCELLED'); + static const Code UNKNOWN = Code._(2, 'UNKNOWN'); + static const Code INVALID_ARGUMENT = Code._(3, 'INVALID_ARGUMENT'); + static const Code DEADLINE_EXCEEDED = Code._(4, 'DEADLINE_EXCEEDED'); + static const Code NOT_FOUND = Code._(5, 'NOT_FOUND'); + static const Code ALREADY_EXISTS = Code._(6, 'ALREADY_EXISTS'); + static const Code PERMISSION_DENIED = Code._(7, 'PERMISSION_DENIED'); + static const Code UNAUTHENTICATED = Code._(16, 'UNAUTHENTICATED'); + static const Code RESOURCE_EXHAUSTED = Code._(8, 'RESOURCE_EXHAUSTED'); + static const Code FAILED_PRECONDITION = Code._(9, 'FAILED_PRECONDITION'); + static const Code ABORTED = Code._(10, 'ABORTED'); + static const Code OUT_OF_RANGE = Code._(11, 'OUT_OF_RANGE'); + static const Code UNIMPLEMENTED = Code._(12, 'UNIMPLEMENTED'); + static const Code INTERNAL = Code._(13, 'INTERNAL'); + static const Code UNAVAILABLE = Code._(14, 'UNAVAILABLE'); + static const Code DATA_LOSS = Code._(15, 'DATA_LOSS'); + + static const $core.List values = [ + OK, + CANCELLED, + UNKNOWN, + INVALID_ARGUMENT, + DEADLINE_EXCEEDED, + NOT_FOUND, + ALREADY_EXISTS, + PERMISSION_DENIED, + UNAUTHENTICATED, + RESOURCE_EXHAUSTED, + FAILED_PRECONDITION, + ABORTED, + OUT_OF_RANGE, + UNIMPLEMENTED, + INTERNAL, + UNAVAILABLE, + DATA_LOSS, + ]; + + static final $core.Map<$core.int, Code> _byValue = + $pb.ProtobufEnum.initByValue(values); + static Code valueOf($core.int value) => _byValue[value]; + + const Code._($core.int v, $core.String n) : super(v, n); +} diff --git a/lib/src/generated/google/rpc/code.pbjson.dart b/lib/src/generated/google/rpc/code.pbjson.dart new file mode 100644 index 00000000..af2179f1 --- /dev/null +++ b/lib/src/generated/google/rpc/code.pbjson.dart @@ -0,0 +1,29 @@ +/// +// Generated code. Do not modify. +// source: google/rpc/code.proto +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type + +const Code$json = const { + '1': 'Code', + '2': const [ + const {'1': 'OK', '2': 0}, + const {'1': 'CANCELLED', '2': 1}, + const {'1': 'UNKNOWN', '2': 2}, + const {'1': 'INVALID_ARGUMENT', '2': 3}, + const {'1': 'DEADLINE_EXCEEDED', '2': 4}, + const {'1': 'NOT_FOUND', '2': 5}, + const {'1': 'ALREADY_EXISTS', '2': 6}, + const {'1': 'PERMISSION_DENIED', '2': 7}, + const {'1': 'UNAUTHENTICATED', '2': 16}, + const {'1': 'RESOURCE_EXHAUSTED', '2': 8}, + const {'1': 'FAILED_PRECONDITION', '2': 9}, + const {'1': 'ABORTED', '2': 10}, + const {'1': 'OUT_OF_RANGE', '2': 11}, + const {'1': 'UNIMPLEMENTED', '2': 12}, + const {'1': 'INTERNAL', '2': 13}, + const {'1': 'UNAVAILABLE', '2': 14}, + const {'1': 'DATA_LOSS', '2': 15}, + ], +}; diff --git a/lib/src/generated/google/rpc/error_details.pb.dart b/lib/src/generated/google/rpc/error_details.pb.dart new file mode 100644 index 00000000..fa5a535a --- /dev/null +++ b/lib/src/generated/google/rpc/error_details.pb.dart @@ -0,0 +1,715 @@ +/// +// Generated code. Do not modify. +// source: google/rpc/error_details.proto +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type + +import 'dart:core' as $core; + +import 'package:protobuf/protobuf.dart' as $pb; + +import '../protobuf/duration.pb.dart' as $1; + +class RetryInfo extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('RetryInfo', + package: const $pb.PackageName('google.rpc'), createEmptyInstance: create) + ..aOM<$1.Duration>(1, 'retryDelay', subBuilder: $1.Duration.create) + ..hasRequiredFields = false; + + RetryInfo._() : super(); + factory RetryInfo() => create(); + factory RetryInfo.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory RetryInfo.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + RetryInfo clone() => RetryInfo()..mergeFromMessage(this); + RetryInfo copyWith(void Function(RetryInfo) updates) => + super.copyWith((message) => updates(message as RetryInfo)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static RetryInfo create() => RetryInfo._(); + RetryInfo createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static RetryInfo getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static RetryInfo _defaultInstance; + + @$pb.TagNumber(1) + $1.Duration get retryDelay => $_getN(0); + @$pb.TagNumber(1) + set retryDelay($1.Duration v) { + setField(1, v); + } + + @$pb.TagNumber(1) + $core.bool hasRetryDelay() => $_has(0); + @$pb.TagNumber(1) + void clearRetryDelay() => clearField(1); + @$pb.TagNumber(1) + $1.Duration ensureRetryDelay() => $_ensure(0); +} + +class DebugInfo extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('DebugInfo', + package: const $pb.PackageName('google.rpc'), createEmptyInstance: create) + ..pPS(1, 'stackEntries') + ..aOS(2, 'detail') + ..hasRequiredFields = false; + + DebugInfo._() : super(); + factory DebugInfo() => create(); + factory DebugInfo.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory DebugInfo.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + DebugInfo clone() => DebugInfo()..mergeFromMessage(this); + DebugInfo copyWith(void Function(DebugInfo) updates) => + super.copyWith((message) => updates(message as DebugInfo)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static DebugInfo create() => DebugInfo._(); + DebugInfo createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static DebugInfo getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static DebugInfo _defaultInstance; + + @$pb.TagNumber(1) + $core.List<$core.String> get stackEntries => $_getList(0); + + @$pb.TagNumber(2) + $core.String get detail => $_getSZ(1); + @$pb.TagNumber(2) + set detail($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasDetail() => $_has(1); + @$pb.TagNumber(2) + void clearDetail() => clearField(2); +} + +class QuotaFailure_Violation extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('QuotaFailure.Violation', + package: const $pb.PackageName('google.rpc'), createEmptyInstance: create) + ..aOS(1, 'subject') + ..aOS(2, 'description') + ..hasRequiredFields = false; + + QuotaFailure_Violation._() : super(); + factory QuotaFailure_Violation() => create(); + factory QuotaFailure_Violation.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory QuotaFailure_Violation.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + QuotaFailure_Violation clone() => + QuotaFailure_Violation()..mergeFromMessage(this); + QuotaFailure_Violation copyWith( + void Function(QuotaFailure_Violation) updates) => + super.copyWith((message) => updates(message as QuotaFailure_Violation)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static QuotaFailure_Violation create() => QuotaFailure_Violation._(); + QuotaFailure_Violation createEmptyInstance() => create(); + static $pb.PbList createRepeated() => + $pb.PbList(); + @$core.pragma('dart2js:noInline') + static QuotaFailure_Violation getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static QuotaFailure_Violation _defaultInstance; + + @$pb.TagNumber(1) + $core.String get subject => $_getSZ(0); + @$pb.TagNumber(1) + set subject($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasSubject() => $_has(0); + @$pb.TagNumber(1) + void clearSubject() => clearField(1); + + @$pb.TagNumber(2) + $core.String get description => $_getSZ(1); + @$pb.TagNumber(2) + set description($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasDescription() => $_has(1); + @$pb.TagNumber(2) + void clearDescription() => clearField(2); +} + +class QuotaFailure extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('QuotaFailure', + package: const $pb.PackageName('google.rpc'), createEmptyInstance: create) + ..pc(1, 'violations', $pb.PbFieldType.PM, + subBuilder: QuotaFailure_Violation.create) + ..hasRequiredFields = false; + + QuotaFailure._() : super(); + factory QuotaFailure() => create(); + factory QuotaFailure.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory QuotaFailure.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + QuotaFailure clone() => QuotaFailure()..mergeFromMessage(this); + QuotaFailure copyWith(void Function(QuotaFailure) updates) => + super.copyWith((message) => updates(message as QuotaFailure)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static QuotaFailure create() => QuotaFailure._(); + QuotaFailure createEmptyInstance() => create(); + static $pb.PbList createRepeated() => + $pb.PbList(); + @$core.pragma('dart2js:noInline') + static QuotaFailure getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static QuotaFailure _defaultInstance; + + @$pb.TagNumber(1) + $core.List get violations => $_getList(0); +} + +class ErrorInfo extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('ErrorInfo', + package: const $pb.PackageName('google.rpc'), createEmptyInstance: create) + ..aOS(1, 'reason') + ..aOS(2, 'domain') + ..m<$core.String, $core.String>(3, 'metadata', + entryClassName: 'ErrorInfo.MetadataEntry', + keyFieldType: $pb.PbFieldType.OS, + valueFieldType: $pb.PbFieldType.OS, + packageName: const $pb.PackageName('google.rpc')) + ..hasRequiredFields = false; + + ErrorInfo._() : super(); + factory ErrorInfo() => create(); + factory ErrorInfo.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory ErrorInfo.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + ErrorInfo clone() => ErrorInfo()..mergeFromMessage(this); + ErrorInfo copyWith(void Function(ErrorInfo) updates) => + super.copyWith((message) => updates(message as ErrorInfo)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static ErrorInfo create() => ErrorInfo._(); + ErrorInfo createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static ErrorInfo getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static ErrorInfo _defaultInstance; + + @$pb.TagNumber(1) + $core.String get reason => $_getSZ(0); + @$pb.TagNumber(1) + set reason($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasReason() => $_has(0); + @$pb.TagNumber(1) + void clearReason() => clearField(1); + + @$pb.TagNumber(2) + $core.String get domain => $_getSZ(1); + @$pb.TagNumber(2) + set domain($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasDomain() => $_has(1); + @$pb.TagNumber(2) + void clearDomain() => clearField(2); + + @$pb.TagNumber(3) + $core.Map<$core.String, $core.String> get metadata => $_getMap(2); +} + +class PreconditionFailure_Violation extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + 'PreconditionFailure.Violation', + package: const $pb.PackageName('google.rpc'), + createEmptyInstance: create) + ..aOS(1, 'type') + ..aOS(2, 'subject') + ..aOS(3, 'description') + ..hasRequiredFields = false; + + PreconditionFailure_Violation._() : super(); + factory PreconditionFailure_Violation() => create(); + factory PreconditionFailure_Violation.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory PreconditionFailure_Violation.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + PreconditionFailure_Violation clone() => + PreconditionFailure_Violation()..mergeFromMessage(this); + PreconditionFailure_Violation copyWith( + void Function(PreconditionFailure_Violation) updates) => + super.copyWith( + (message) => updates(message as PreconditionFailure_Violation)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static PreconditionFailure_Violation create() => + PreconditionFailure_Violation._(); + PreconditionFailure_Violation createEmptyInstance() => create(); + static $pb.PbList createRepeated() => + $pb.PbList(); + @$core.pragma('dart2js:noInline') + static PreconditionFailure_Violation getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static PreconditionFailure_Violation _defaultInstance; + + @$pb.TagNumber(1) + $core.String get type => $_getSZ(0); + @$pb.TagNumber(1) + set type($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasType() => $_has(0); + @$pb.TagNumber(1) + void clearType() => clearField(1); + + @$pb.TagNumber(2) + $core.String get subject => $_getSZ(1); + @$pb.TagNumber(2) + set subject($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasSubject() => $_has(1); + @$pb.TagNumber(2) + void clearSubject() => clearField(2); + + @$pb.TagNumber(3) + $core.String get description => $_getSZ(2); + @$pb.TagNumber(3) + set description($core.String v) { + $_setString(2, v); + } + + @$pb.TagNumber(3) + $core.bool hasDescription() => $_has(2); + @$pb.TagNumber(3) + void clearDescription() => clearField(3); +} + +class PreconditionFailure extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('PreconditionFailure', + package: const $pb.PackageName('google.rpc'), createEmptyInstance: create) + ..pc(1, 'violations', $pb.PbFieldType.PM, + subBuilder: PreconditionFailure_Violation.create) + ..hasRequiredFields = false; + + PreconditionFailure._() : super(); + factory PreconditionFailure() => create(); + factory PreconditionFailure.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory PreconditionFailure.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + PreconditionFailure clone() => PreconditionFailure()..mergeFromMessage(this); + PreconditionFailure copyWith(void Function(PreconditionFailure) updates) => + super.copyWith((message) => updates(message as PreconditionFailure)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static PreconditionFailure create() => PreconditionFailure._(); + PreconditionFailure createEmptyInstance() => create(); + static $pb.PbList createRepeated() => + $pb.PbList(); + @$core.pragma('dart2js:noInline') + static PreconditionFailure getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static PreconditionFailure _defaultInstance; + + @$pb.TagNumber(1) + $core.List get violations => $_getList(0); +} + +class BadRequest_FieldViolation extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('BadRequest.FieldViolation', + package: const $pb.PackageName('google.rpc'), createEmptyInstance: create) + ..aOS(1, 'field') + ..aOS(2, 'description') + ..hasRequiredFields = false; + + BadRequest_FieldViolation._() : super(); + factory BadRequest_FieldViolation() => create(); + factory BadRequest_FieldViolation.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory BadRequest_FieldViolation.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + BadRequest_FieldViolation clone() => + BadRequest_FieldViolation()..mergeFromMessage(this); + BadRequest_FieldViolation copyWith( + void Function(BadRequest_FieldViolation) updates) => + super + .copyWith((message) => updates(message as BadRequest_FieldViolation)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static BadRequest_FieldViolation create() => BadRequest_FieldViolation._(); + BadRequest_FieldViolation createEmptyInstance() => create(); + static $pb.PbList createRepeated() => + $pb.PbList(); + @$core.pragma('dart2js:noInline') + static BadRequest_FieldViolation getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static BadRequest_FieldViolation _defaultInstance; + + @$pb.TagNumber(1) + $core.String get field_1 => $_getSZ(0); + @$pb.TagNumber(1) + set field_1($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasField_1() => $_has(0); + @$pb.TagNumber(1) + void clearField_1() => clearField(1); + + @$pb.TagNumber(2) + $core.String get description => $_getSZ(1); + @$pb.TagNumber(2) + set description($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasDescription() => $_has(1); + @$pb.TagNumber(2) + void clearDescription() => clearField(2); +} + +class BadRequest extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('BadRequest', + package: const $pb.PackageName('google.rpc'), createEmptyInstance: create) + ..pc(1, 'fieldViolations', $pb.PbFieldType.PM, + subBuilder: BadRequest_FieldViolation.create) + ..hasRequiredFields = false; + + BadRequest._() : super(); + factory BadRequest() => create(); + factory BadRequest.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory BadRequest.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + BadRequest clone() => BadRequest()..mergeFromMessage(this); + BadRequest copyWith(void Function(BadRequest) updates) => + super.copyWith((message) => updates(message as BadRequest)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static BadRequest create() => BadRequest._(); + BadRequest createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static BadRequest getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static BadRequest _defaultInstance; + + @$pb.TagNumber(1) + $core.List get fieldViolations => $_getList(0); +} + +class RequestInfo extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('RequestInfo', + package: const $pb.PackageName('google.rpc'), createEmptyInstance: create) + ..aOS(1, 'requestId') + ..aOS(2, 'servingData') + ..hasRequiredFields = false; + + RequestInfo._() : super(); + factory RequestInfo() => create(); + factory RequestInfo.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory RequestInfo.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + RequestInfo clone() => RequestInfo()..mergeFromMessage(this); + RequestInfo copyWith(void Function(RequestInfo) updates) => + super.copyWith((message) => updates(message as RequestInfo)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static RequestInfo create() => RequestInfo._(); + RequestInfo createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static RequestInfo getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static RequestInfo _defaultInstance; + + @$pb.TagNumber(1) + $core.String get requestId => $_getSZ(0); + @$pb.TagNumber(1) + set requestId($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasRequestId() => $_has(0); + @$pb.TagNumber(1) + void clearRequestId() => clearField(1); + + @$pb.TagNumber(2) + $core.String get servingData => $_getSZ(1); + @$pb.TagNumber(2) + set servingData($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasServingData() => $_has(1); + @$pb.TagNumber(2) + void clearServingData() => clearField(2); +} + +class ResourceInfo extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('ResourceInfo', + package: const $pb.PackageName('google.rpc'), createEmptyInstance: create) + ..aOS(1, 'resourceType') + ..aOS(2, 'resourceName') + ..aOS(3, 'owner') + ..aOS(4, 'description') + ..hasRequiredFields = false; + + ResourceInfo._() : super(); + factory ResourceInfo() => create(); + factory ResourceInfo.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory ResourceInfo.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + ResourceInfo clone() => ResourceInfo()..mergeFromMessage(this); + ResourceInfo copyWith(void Function(ResourceInfo) updates) => + super.copyWith((message) => updates(message as ResourceInfo)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static ResourceInfo create() => ResourceInfo._(); + ResourceInfo createEmptyInstance() => create(); + static $pb.PbList createRepeated() => + $pb.PbList(); + @$core.pragma('dart2js:noInline') + static ResourceInfo getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static ResourceInfo _defaultInstance; + + @$pb.TagNumber(1) + $core.String get resourceType => $_getSZ(0); + @$pb.TagNumber(1) + set resourceType($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasResourceType() => $_has(0); + @$pb.TagNumber(1) + void clearResourceType() => clearField(1); + + @$pb.TagNumber(2) + $core.String get resourceName => $_getSZ(1); + @$pb.TagNumber(2) + set resourceName($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasResourceName() => $_has(1); + @$pb.TagNumber(2) + void clearResourceName() => clearField(2); + + @$pb.TagNumber(3) + $core.String get owner => $_getSZ(2); + @$pb.TagNumber(3) + set owner($core.String v) { + $_setString(2, v); + } + + @$pb.TagNumber(3) + $core.bool hasOwner() => $_has(2); + @$pb.TagNumber(3) + void clearOwner() => clearField(3); + + @$pb.TagNumber(4) + $core.String get description => $_getSZ(3); + @$pb.TagNumber(4) + set description($core.String v) { + $_setString(3, v); + } + + @$pb.TagNumber(4) + $core.bool hasDescription() => $_has(3); + @$pb.TagNumber(4) + void clearDescription() => clearField(4); +} + +class Help_Link extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('Help.Link', + package: const $pb.PackageName('google.rpc'), createEmptyInstance: create) + ..aOS(1, 'description') + ..aOS(2, 'url') + ..hasRequiredFields = false; + + Help_Link._() : super(); + factory Help_Link() => create(); + factory Help_Link.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Help_Link.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + Help_Link clone() => Help_Link()..mergeFromMessage(this); + Help_Link copyWith(void Function(Help_Link) updates) => + super.copyWith((message) => updates(message as Help_Link)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static Help_Link create() => Help_Link._(); + Help_Link createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Help_Link getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Help_Link _defaultInstance; + + @$pb.TagNumber(1) + $core.String get description => $_getSZ(0); + @$pb.TagNumber(1) + set description($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasDescription() => $_has(0); + @$pb.TagNumber(1) + void clearDescription() => clearField(1); + + @$pb.TagNumber(2) + $core.String get url => $_getSZ(1); + @$pb.TagNumber(2) + set url($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasUrl() => $_has(1); + @$pb.TagNumber(2) + void clearUrl() => clearField(2); +} + +class Help extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('Help', + package: const $pb.PackageName('google.rpc'), createEmptyInstance: create) + ..pc(1, 'links', $pb.PbFieldType.PM, + subBuilder: Help_Link.create) + ..hasRequiredFields = false; + + Help._() : super(); + factory Help() => create(); + factory Help.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Help.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + Help clone() => Help()..mergeFromMessage(this); + Help copyWith(void Function(Help) updates) => + super.copyWith((message) => updates(message as Help)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static Help create() => Help._(); + Help createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Help getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Help _defaultInstance; + + @$pb.TagNumber(1) + $core.List get links => $_getList(0); +} + +class LocalizedMessage extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('LocalizedMessage', + package: const $pb.PackageName('google.rpc'), createEmptyInstance: create) + ..aOS(1, 'locale') + ..aOS(2, 'message') + ..hasRequiredFields = false; + + LocalizedMessage._() : super(); + factory LocalizedMessage() => create(); + factory LocalizedMessage.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory LocalizedMessage.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + LocalizedMessage clone() => LocalizedMessage()..mergeFromMessage(this); + LocalizedMessage copyWith(void Function(LocalizedMessage) updates) => + super.copyWith((message) => updates(message as LocalizedMessage)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static LocalizedMessage create() => LocalizedMessage._(); + LocalizedMessage createEmptyInstance() => create(); + static $pb.PbList createRepeated() => + $pb.PbList(); + @$core.pragma('dart2js:noInline') + static LocalizedMessage getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static LocalizedMessage _defaultInstance; + + @$pb.TagNumber(1) + $core.String get locale => $_getSZ(0); + @$pb.TagNumber(1) + set locale($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasLocale() => $_has(0); + @$pb.TagNumber(1) + void clearLocale() => clearField(1); + + @$pb.TagNumber(2) + $core.String get message => $_getSZ(1); + @$pb.TagNumber(2) + set message($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasMessage() => $_has(1); + @$pb.TagNumber(2) + void clearMessage() => clearField(2); +} diff --git a/lib/src/generated/google/rpc/error_details.pbenum.dart b/lib/src/generated/google/rpc/error_details.pbenum.dart new file mode 100644 index 00000000..78483caf --- /dev/null +++ b/lib/src/generated/google/rpc/error_details.pbenum.dart @@ -0,0 +1,6 @@ +/// +// Generated code. Do not modify. +// source: google/rpc/error_details.proto +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type diff --git a/lib/src/generated/google/rpc/error_details.pbjson.dart b/lib/src/generated/google/rpc/error_details.pbjson.dart new file mode 100644 index 00000000..562404fd --- /dev/null +++ b/lib/src/generated/google/rpc/error_details.pbjson.dart @@ -0,0 +1,173 @@ +/// +// Generated code. Do not modify. +// source: google/rpc/error_details.proto +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type + +const RetryInfo$json = const { + '1': 'RetryInfo', + '2': const [ + const { + '1': 'retry_delay', + '3': 1, + '4': 1, + '5': 11, + '6': '.google.protobuf.Duration', + '10': 'retryDelay' + }, + ], +}; + +const DebugInfo$json = const { + '1': 'DebugInfo', + '2': const [ + const {'1': 'stack_entries', '3': 1, '4': 3, '5': 9, '10': 'stackEntries'}, + const {'1': 'detail', '3': 2, '4': 1, '5': 9, '10': 'detail'}, + ], +}; + +const QuotaFailure$json = const { + '1': 'QuotaFailure', + '2': const [ + const { + '1': 'violations', + '3': 1, + '4': 3, + '5': 11, + '6': '.google.rpc.QuotaFailure.Violation', + '10': 'violations' + }, + ], + '3': const [QuotaFailure_Violation$json], +}; + +const QuotaFailure_Violation$json = const { + '1': 'Violation', + '2': const [ + const {'1': 'subject', '3': 1, '4': 1, '5': 9, '10': 'subject'}, + const {'1': 'description', '3': 2, '4': 1, '5': 9, '10': 'description'}, + ], +}; + +const ErrorInfo$json = const { + '1': 'ErrorInfo', + '2': const [ + const {'1': 'reason', '3': 1, '4': 1, '5': 9, '10': 'reason'}, + const {'1': 'domain', '3': 2, '4': 1, '5': 9, '10': 'domain'}, + const { + '1': 'metadata', + '3': 3, + '4': 3, + '5': 11, + '6': '.google.rpc.ErrorInfo.MetadataEntry', + '10': 'metadata' + }, + ], + '3': const [ErrorInfo_MetadataEntry$json], +}; + +const ErrorInfo_MetadataEntry$json = const { + '1': 'MetadataEntry', + '2': const [ + const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, + const {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'}, + ], + '7': const {'7': true}, +}; + +const PreconditionFailure$json = const { + '1': 'PreconditionFailure', + '2': const [ + const { + '1': 'violations', + '3': 1, + '4': 3, + '5': 11, + '6': '.google.rpc.PreconditionFailure.Violation', + '10': 'violations' + }, + ], + '3': const [PreconditionFailure_Violation$json], +}; + +const PreconditionFailure_Violation$json = const { + '1': 'Violation', + '2': const [ + const {'1': 'type', '3': 1, '4': 1, '5': 9, '10': 'type'}, + const {'1': 'subject', '3': 2, '4': 1, '5': 9, '10': 'subject'}, + const {'1': 'description', '3': 3, '4': 1, '5': 9, '10': 'description'}, + ], +}; + +const BadRequest$json = const { + '1': 'BadRequest', + '2': const [ + const { + '1': 'field_violations', + '3': 1, + '4': 3, + '5': 11, + '6': '.google.rpc.BadRequest.FieldViolation', + '10': 'fieldViolations' + }, + ], + '3': const [BadRequest_FieldViolation$json], +}; + +const BadRequest_FieldViolation$json = const { + '1': 'FieldViolation', + '2': const [ + const {'1': 'field', '3': 1, '4': 1, '5': 9, '10': 'field'}, + const {'1': 'description', '3': 2, '4': 1, '5': 9, '10': 'description'}, + ], +}; + +const RequestInfo$json = const { + '1': 'RequestInfo', + '2': const [ + const {'1': 'request_id', '3': 1, '4': 1, '5': 9, '10': 'requestId'}, + const {'1': 'serving_data', '3': 2, '4': 1, '5': 9, '10': 'servingData'}, + ], +}; + +const ResourceInfo$json = const { + '1': 'ResourceInfo', + '2': const [ + const {'1': 'resource_type', '3': 1, '4': 1, '5': 9, '10': 'resourceType'}, + const {'1': 'resource_name', '3': 2, '4': 1, '5': 9, '10': 'resourceName'}, + const {'1': 'owner', '3': 3, '4': 1, '5': 9, '10': 'owner'}, + const {'1': 'description', '3': 4, '4': 1, '5': 9, '10': 'description'}, + ], +}; + +const Help$json = const { + '1': 'Help', + '2': const [ + const { + '1': 'links', + '3': 1, + '4': 3, + '5': 11, + '6': '.google.rpc.Help.Link', + '10': 'links' + }, + ], + '3': const [Help_Link$json], +}; + +const Help_Link$json = const { + '1': 'Link', + '2': const [ + const {'1': 'description', '3': 1, '4': 1, '5': 9, '10': 'description'}, + const {'1': 'url', '3': 2, '4': 1, '5': 9, '10': 'url'}, + ], +}; + +const LocalizedMessage$json = const { + '1': 'LocalizedMessage', + '2': const [ + const {'1': 'locale', '3': 1, '4': 1, '5': 9, '10': 'locale'}, + const {'1': 'message', '3': 2, '4': 1, '5': 9, '10': 'message'}, + ], +}; diff --git a/lib/src/generated/google/rpc/status.pb.dart b/lib/src/generated/google/rpc/status.pb.dart new file mode 100644 index 00000000..2e0370f6 --- /dev/null +++ b/lib/src/generated/google/rpc/status.pb.dart @@ -0,0 +1,69 @@ +/// +// Generated code. Do not modify. +// source: google/rpc/status.proto +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type + +import 'dart:core' as $core; + +import 'package:protobuf/protobuf.dart' as $pb; + +import '../protobuf/any.pb.dart' as $0; + +class Status extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('Status', + package: const $pb.PackageName('google.rpc'), createEmptyInstance: create) + ..a<$core.int>(1, 'code', $pb.PbFieldType.O3) + ..aOS(2, 'message') + ..pc<$0.Any>(3, 'details', $pb.PbFieldType.PM, subBuilder: $0.Any.create) + ..hasRequiredFields = false; + + Status._() : super(); + factory Status() => create(); + factory Status.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Status.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + Status clone() => Status()..mergeFromMessage(this); + Status copyWith(void Function(Status) updates) => + super.copyWith((message) => updates(message as Status)); + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static Status create() => Status._(); + Status createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Status getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Status _defaultInstance; + + @$pb.TagNumber(1) + $core.int get code => $_getIZ(0); + @$pb.TagNumber(1) + set code($core.int v) { + $_setSignedInt32(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasCode() => $_has(0); + @$pb.TagNumber(1) + void clearCode() => clearField(1); + + @$pb.TagNumber(2) + $core.String get message => $_getSZ(1); + @$pb.TagNumber(2) + set message($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasMessage() => $_has(1); + @$pb.TagNumber(2) + void clearMessage() => clearField(2); + + @$pb.TagNumber(3) + $core.List<$0.Any> get details => $_getList(2); +} diff --git a/lib/src/generated/google/rpc/status.pbenum.dart b/lib/src/generated/google/rpc/status.pbenum.dart new file mode 100644 index 00000000..3c022b46 --- /dev/null +++ b/lib/src/generated/google/rpc/status.pbenum.dart @@ -0,0 +1,6 @@ +/// +// Generated code. Do not modify. +// source: google/rpc/status.proto +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type diff --git a/lib/src/generated/google/rpc/status.pbjson.dart b/lib/src/generated/google/rpc/status.pbjson.dart new file mode 100644 index 00000000..cbb32ac9 --- /dev/null +++ b/lib/src/generated/google/rpc/status.pbjson.dart @@ -0,0 +1,22 @@ +/// +// Generated code. Do not modify. +// source: google/rpc/status.proto +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type + +const Status$json = const { + '1': 'Status', + '2': const [ + const {'1': 'code', '3': 1, '4': 1, '5': 5, '10': 'code'}, + const {'1': 'message', '3': 2, '4': 1, '5': 9, '10': 'message'}, + const { + '1': 'details', + '3': 3, + '4': 3, + '5': 11, + '6': '.google.protobuf.Any', + '10': 'details' + }, + ], +}; diff --git a/lib/src/protos/google/protobuf/any.proto b/lib/src/protos/google/protobuf/any.proto new file mode 100644 index 00000000..1c6a465c --- /dev/null +++ b/lib/src/protos/google/protobuf/any.proto @@ -0,0 +1,158 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option go_package = "google.golang.org/protobuf/types/known/anypb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "AnyProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; + +// `Any` contains an arbitrary serialized protocol buffer message along with a +// URL that describes the type of the serialized message. +// +// Protobuf library provides support to pack/unpack Any values in the form +// of utility functions or additional generated methods of the Any type. +// +// Example 1: Pack and unpack a message in C++. +// +// Foo foo = ...; +// Any any; +// any.PackFrom(foo); +// ... +// if (any.UnpackTo(&foo)) { +// ... +// } +// +// Example 2: Pack and unpack a message in Java. +// +// Foo foo = ...; +// Any any = Any.pack(foo); +// ... +// if (any.is(Foo.class)) { +// foo = any.unpack(Foo.class); +// } +// +// Example 3: Pack and unpack a message in Python. +// +// foo = Foo(...) +// any = Any() +// any.Pack(foo) +// ... +// if any.Is(Foo.DESCRIPTOR): +// any.Unpack(foo) +// ... +// +// Example 4: Pack and unpack a message in Go +// +// foo := &pb.Foo{...} +// any, err := anypb.New(foo) +// if err != nil { +// ... +// } +// ... +// foo := &pb.Foo{} +// if err := any.UnmarshalTo(foo); err != nil { +// ... +// } +// +// The pack methods provided by protobuf library will by default use +// 'type.googleapis.com/full.type.name' as the type URL and the unpack +// methods only use the fully qualified type name after the last '/' +// in the type URL, for example "foo.bar.com/x/y.z" will yield type +// name "y.z". +// +// +// JSON +// ==== +// The JSON representation of an `Any` value uses the regular +// representation of the deserialized, embedded message, with an +// additional field `@type` which contains the type URL. Example: +// +// package google.profile; +// message Person { +// string first_name = 1; +// string last_name = 2; +// } +// +// { +// "@type": "type.googleapis.com/google.profile.Person", +// "firstName": , +// "lastName": +// } +// +// If the embedded message type is well-known and has a custom JSON +// representation, that representation will be embedded adding a field +// `value` which holds the custom JSON in addition to the `@type` +// field. Example (for message [google.protobuf.Duration][]): +// +// { +// "@type": "type.googleapis.com/google.protobuf.Duration", +// "value": "1.212s" +// } +// +message Any { + // A URL/resource name that uniquely identifies the type of the serialized + // protocol buffer message. This string must contain at least + // one "/" character. The last segment of the URL's path must represent + // the fully qualified name of the type (as in + // `path/google.protobuf.Duration`). The name should be in a canonical form + // (e.g., leading "." is not accepted). + // + // In practice, teams usually precompile into the binary all types that they + // expect it to use in the context of Any. However, for URLs which use the + // scheme `http`, `https`, or no scheme, one can optionally set up a type + // server that maps type URLs to message definitions as follows: + // + // * If no scheme is provided, `https` is assumed. + // * An HTTP GET on the URL must yield a [google.protobuf.Type][] + // value in binary format, or produce an error. + // * Applications are allowed to cache lookup results based on the + // URL, or have them precompiled into a binary to avoid any + // lookup. Therefore, binary compatibility needs to be preserved + // on changes to types. (Use versioned type names to manage + // breaking changes.) + // + // Note: this functionality is not currently available in the official + // protobuf release, and it is not used for type URLs beginning with + // type.googleapis.com. + // + // Schemes other than `http`, `https` (or the empty scheme) might be + // used with implementation specific semantics. + // + string type_url = 1; + + // Must be a valid serialized protocol buffer of the above specified type. + bytes value = 2; +} \ No newline at end of file diff --git a/lib/src/protos/google/protobuf/duration.proto b/lib/src/protos/google/protobuf/duration.proto new file mode 100644 index 00000000..cb7cf0e9 --- /dev/null +++ b/lib/src/protos/google/protobuf/duration.proto @@ -0,0 +1,116 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option cc_enable_arenas = true; +option go_package = "google.golang.org/protobuf/types/known/durationpb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "DurationProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; + +// A Duration represents a signed, fixed-length span of time represented +// as a count of seconds and fractions of seconds at nanosecond +// resolution. It is independent of any calendar and concepts like "day" +// or "month". It is related to Timestamp in that the difference between +// two Timestamp values is a Duration and it can be added or subtracted +// from a Timestamp. Range is approximately +-10,000 years. +// +// # Examples +// +// Example 1: Compute Duration from two Timestamps in pseudo code. +// +// Timestamp start = ...; +// Timestamp end = ...; +// Duration duration = ...; +// +// duration.seconds = end.seconds - start.seconds; +// duration.nanos = end.nanos - start.nanos; +// +// if (duration.seconds < 0 && duration.nanos > 0) { +// duration.seconds += 1; +// duration.nanos -= 1000000000; +// } else if (duration.seconds > 0 && duration.nanos < 0) { +// duration.seconds -= 1; +// duration.nanos += 1000000000; +// } +// +// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. +// +// Timestamp start = ...; +// Duration duration = ...; +// Timestamp end = ...; +// +// end.seconds = start.seconds + duration.seconds; +// end.nanos = start.nanos + duration.nanos; +// +// if (end.nanos < 0) { +// end.seconds -= 1; +// end.nanos += 1000000000; +// } else if (end.nanos >= 1000000000) { +// end.seconds += 1; +// end.nanos -= 1000000000; +// } +// +// Example 3: Compute Duration from datetime.timedelta in Python. +// +// td = datetime.timedelta(days=3, minutes=10) +// duration = Duration() +// duration.FromTimedelta(td) +// +// # JSON Mapping +// +// In JSON format, the Duration type is encoded as a string rather than an +// object, where the string ends in the suffix "s" (indicating seconds) and +// is preceded by the number of seconds, with nanoseconds expressed as +// fractional seconds. For example, 3 seconds with 0 nanoseconds should be +// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should +// be expressed in JSON format as "3.000000001s", and 3 seconds and 1 +// microsecond should be expressed in JSON format as "3.000001s". +// +// +message Duration { + // Signed seconds of the span of time. Must be from -315,576,000,000 + // to +315,576,000,000 inclusive. Note: these bounds are computed from: + // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + int64 seconds = 1; + + // Signed fractions of a second at nanosecond resolution of the span + // of time. Durations less than one second are represented with a 0 + // `seconds` field and a positive or negative `nanos` field. For durations + // of one second or more, a non-zero value for the `nanos` field must be + // of the same sign as the `seconds` field. Must be from -999,999,999 + // to +999,999,999 inclusive. + int32 nanos = 2; +} \ No newline at end of file diff --git a/lib/src/protos/google/rpc/code.proto b/lib/src/protos/google/rpc/code.proto new file mode 100644 index 00000000..d115da14 --- /dev/null +++ b/lib/src/protos/google/rpc/code.proto @@ -0,0 +1,186 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.rpc; + +option go_package = "google.golang.org/genproto/googleapis/rpc/code;code"; +option java_multiple_files = true; +option java_outer_classname = "CodeProto"; +option java_package = "com.google.rpc"; +option objc_class_prefix = "RPC"; + +// The canonical error codes for gRPC APIs. +// +// +// Sometimes multiple error codes may apply. Services should return +// the most specific error code that applies. For example, prefer +// `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply. +// Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`. +enum Code { + // Not an error; returned on success + // + // HTTP Mapping: 200 OK + OK = 0; + + // The operation was cancelled, typically by the caller. + // + // HTTP Mapping: 499 Client Closed Request + CANCELLED = 1; + + // Unknown error. For example, this error may be returned when + // a `Status` value received from another address space belongs to + // an error space that is not known in this address space. Also + // errors raised by APIs that do not return enough error information + // may be converted to this error. + // + // HTTP Mapping: 500 Internal Server Error + UNKNOWN = 2; + + // The client specified an invalid argument. Note that this differs + // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments + // that are problematic regardless of the state of the system + // (e.g., a malformed file name). + // + // HTTP Mapping: 400 Bad Request + INVALID_ARGUMENT = 3; + + // The deadline expired before the operation could complete. For operations + // that change the state of the system, this error may be returned + // even if the operation has completed successfully. For example, a + // successful response from a server could have been delayed long + // enough for the deadline to expire. + // + // HTTP Mapping: 504 Gateway Timeout + DEADLINE_EXCEEDED = 4; + + // Some requested entity (e.g., file or directory) was not found. + // + // Note to server developers: if a request is denied for an entire class + // of users, such as gradual feature rollout or undocumented whitelist, + // `NOT_FOUND` may be used. If a request is denied for some users within + // a class of users, such as user-based access control, `PERMISSION_DENIED` + // must be used. + // + // HTTP Mapping: 404 Not Found + NOT_FOUND = 5; + + // The entity that a client attempted to create (e.g., file or directory) + // already exists. + // + // HTTP Mapping: 409 Conflict + ALREADY_EXISTS = 6; + + // The caller does not have permission to execute the specified + // operation. `PERMISSION_DENIED` must not be used for rejections + // caused by exhausting some resource (use `RESOURCE_EXHAUSTED` + // instead for those errors). `PERMISSION_DENIED` must not be + // used if the caller can not be identified (use `UNAUTHENTICATED` + // instead for those errors). This error code does not imply the + // request is valid or the requested entity exists or satisfies + // other pre-conditions. + // + // HTTP Mapping: 403 Forbidden + PERMISSION_DENIED = 7; + + // The request does not have valid authentication credentials for the + // operation. + // + // HTTP Mapping: 401 Unauthorized + UNAUTHENTICATED = 16; + + // Some resource has been exhausted, perhaps a per-user quota, or + // perhaps the entire file system is out of space. + // + // HTTP Mapping: 429 Too Many Requests + RESOURCE_EXHAUSTED = 8; + + // The operation was rejected because the system is not in a state + // required for the operation's execution. For example, the directory + // to be deleted is non-empty, an rmdir operation is applied to + // a non-directory, etc. + // + // Service implementors can use the following guidelines to decide + // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`: + // (a) Use `UNAVAILABLE` if the client can retry just the failing call. + // (b) Use `ABORTED` if the client should retry at a higher level + // (e.g., when a client-specified test-and-set fails, indicating the + // client should restart a read-modify-write sequence). + // (c) Use `FAILED_PRECONDITION` if the client should not retry until + // the system state has been explicitly fixed. E.g., if an "rmdir" + // fails because the directory is non-empty, `FAILED_PRECONDITION` + // should be returned since the client should not retry unless + // the files are deleted from the directory. + // + // HTTP Mapping: 400 Bad Request + FAILED_PRECONDITION = 9; + + // The operation was aborted, typically due to a concurrency issue such as + // a sequencer check failure or transaction abort. + // + // See the guidelines above for deciding between `FAILED_PRECONDITION`, + // `ABORTED`, and `UNAVAILABLE`. + // + // HTTP Mapping: 409 Conflict + ABORTED = 10; + + // The operation was attempted past the valid range. E.g., seeking or + // reading past end-of-file. + // + // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may + // be fixed if the system state changes. For example, a 32-bit file + // system will generate `INVALID_ARGUMENT` if asked to read at an + // offset that is not in the range [0,2^32-1], but it will generate + // `OUT_OF_RANGE` if asked to read from an offset past the current + // file size. + // + // There is a fair bit of overlap between `FAILED_PRECONDITION` and + // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific + // error) when it applies so that callers who are iterating through + // a space can easily look for an `OUT_OF_RANGE` error to detect when + // they are done. + // + // HTTP Mapping: 400 Bad Request + OUT_OF_RANGE = 11; + + // The operation is not implemented or is not supported/enabled in this + // service. + // + // HTTP Mapping: 501 Not Implemented + UNIMPLEMENTED = 12; + + // Internal errors. This means that some invariants expected by the + // underlying system have been broken. This error code is reserved + // for serious errors. + // + // HTTP Mapping: 500 Internal Server Error + INTERNAL = 13; + + // The service is currently unavailable. This is most likely a + // transient condition, which can be corrected by retrying with + // a backoff. Note that it is not always safe to retry + // non-idempotent operations. + // + // See the guidelines above for deciding between `FAILED_PRECONDITION`, + // `ABORTED`, and `UNAVAILABLE`. + // + // HTTP Mapping: 503 Service Unavailable + UNAVAILABLE = 14; + + // Unrecoverable data loss or corruption. + // + // HTTP Mapping: 500 Internal Server Error + DATA_LOSS = 15; +} \ No newline at end of file diff --git a/lib/src/protos/google/rpc/error_details.proto b/lib/src/protos/google/rpc/error_details.proto new file mode 100644 index 00000000..981d18ce --- /dev/null +++ b/lib/src/protos/google/rpc/error_details.proto @@ -0,0 +1,249 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.rpc; + +import "google/protobuf/duration.proto"; + +option go_package = "google.golang.org/genproto/googleapis/rpc/errdetails;errdetails"; +option java_multiple_files = true; +option java_outer_classname = "ErrorDetailsProto"; +option java_package = "com.google.rpc"; +option objc_class_prefix = "RPC"; + +// Describes when the clients can retry a failed request. Clients could ignore +// the recommendation here or retry when this information is missing from error +// responses. +// +// It's always recommended that clients should use exponential backoff when +// retrying. +// +// Clients should wait until `retry_delay` amount of time has passed since +// receiving the error response before retrying. If retrying requests also +// fail, clients should use an exponential backoff scheme to gradually increase +// the delay between retries based on `retry_delay`, until either a maximum +// number of retries have been reached or a maximum retry delay cap has been +// reached. +message RetryInfo { + // Clients should wait at least this long between retrying the same request. + google.protobuf.Duration retry_delay = 1; +} + +// Describes additional debugging info. +message DebugInfo { + // The stack trace entries indicating where the error occurred. + repeated string stack_entries = 1; + + // Additional debugging information provided by the server. + string detail = 2; +} + +// Describes how a quota check failed. +// +// For example if a daily limit was exceeded for the calling project, +// a service could respond with a QuotaFailure detail containing the project +// id and the description of the quota limit that was exceeded. If the +// calling project hasn't enabled the service in the developer console, then +// a service could respond with the project id and set `service_disabled` +// to true. +// +// Also see RetryInfo and Help types for other details about handling a +// quota failure. +message QuotaFailure { + // A message type used to describe a single quota violation. For example, a + // daily quota or a custom quota that was exceeded. + message Violation { + // The subject on which the quota check failed. + // For example, "clientip:" or "project:". + string subject = 1; + + // A description of how the quota check failed. Clients can use this + // description to find more about the quota configuration in the service's + // public documentation, or find the relevant quota limit to adjust through + // developer console. + // + // For example: "Service disabled" or "Daily Limit for read operations + // exceeded". + string description = 2; + } + + // Describes all quota violations. + repeated Violation violations = 1; +} + +// Describes the cause of the error with structured details. +// +// Example of an error when contacting the "pubsub.googleapis.com" API when it +// is not enabled: +// +// { "reason": "API_DISABLED" +// "domain": "googleapis.com" +// "metadata": { +// "resource": "projects/123", +// "service": "pubsub.googleapis.com" +// } +// } +// +// This response indicates that the pubsub.googleapis.com API is not enabled. +// +// Example of an error that is returned when attempting to create a Spanner +// instance in a region that is out of stock: +// +// { "reason": "STOCKOUT" +// "domain": "spanner.googleapis.com", +// "metadata": { +// "availableRegions": "us-central1,us-east2" +// } +// } +message ErrorInfo { + // The reason of the error. This is a constant value that identifies the + // proximate cause of the error. Error reasons are unique within a particular + // domain of errors. This should be at most 63 characters and match + // /[A-Z0-9_]+/. + string reason = 1; + + // The logical grouping to which the "reason" belongs. The error domain + // is typically the registered service name of the tool or product that + // generates the error. Example: "pubsub.googleapis.com". If the error is + // generated by some common infrastructure, the error domain must be a + // globally unique value that identifies the infrastructure. For Google API + // infrastructure, the error domain is "googleapis.com". + string domain = 2; + + // Additional structured details about this error. + // + // Keys should match /[a-zA-Z0-9-_]/ and be limited to 64 characters in + // length. When identifying the current value of an exceeded limit, the units + // should be contained in the key, not the value. For example, rather than + // {"instanceLimit": "100/request"}, should be returned as, + // {"instanceLimitPerRequest": "100"}, if the client exceeds the number of + // instances that can be created in a single (batch) request. + map metadata = 3; +} + +// Describes what preconditions have failed. +// +// For example, if an RPC failed because it required the Terms of Service to be +// acknowledged, it could list the terms of service violation in the +// PreconditionFailure message. +message PreconditionFailure { + // A message type used to describe a single precondition failure. + message Violation { + // The type of PreconditionFailure. We recommend using a service-specific + // enum type to define the supported precondition violation subjects. For + // example, "TOS" for "Terms of Service violation". + string type = 1; + + // The subject, relative to the type, that failed. + // For example, "google.com/cloud" relative to the "TOS" type would indicate + // which terms of service is being referenced. + string subject = 2; + + // A description of how the precondition failed. Developers can use this + // description to understand how to fix the failure. + // + // For example: "Terms of service not accepted". + string description = 3; + } + + // Describes all precondition violations. + repeated Violation violations = 1; +} + +// Describes violations in a client request. This error type focuses on the +// syntactic aspects of the request. +message BadRequest { + // A message type used to describe a single bad request field. + message FieldViolation { + // A path leading to a field in the request body. The value will be a + // sequence of dot-separated identifiers that identify a protocol buffer + // field. E.g., "field_violations.field" would identify this field. + string field = 1; + + // A description of why the request element is bad. + string description = 2; + } + + // Describes all violations in a client request. + repeated FieldViolation field_violations = 1; +} + +// Contains metadata about the request that clients can attach when filing a bug +// or providing other forms of feedback. +message RequestInfo { + // An opaque string that should only be interpreted by the service generating + // it. For example, it can be used to identify requests in the service's logs. + string request_id = 1; + + // Any data that was used to serve this request. For example, an encrypted + // stack trace that can be sent back to the service provider for debugging. + string serving_data = 2; +} + +// Describes the resource that is being accessed. +message ResourceInfo { + // A name for the type of resource being accessed, e.g. "sql table", + // "cloud storage bucket", "file", "Google calendar"; or the type URL + // of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic". + string resource_type = 1; + + // The name of the resource being accessed. For example, a shared calendar + // name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current + // error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED]. + string resource_name = 2; + + // The owner of the resource (optional). + // For example, "user:" or "project:". + string owner = 3; + + // Describes what error is encountered when accessing this resource. + // For example, updating a cloud project may require the `writer` permission + // on the developer console project. + string description = 4; +} + +// Provides links to documentation or for performing an out of band action. +// +// For example, if a quota check failed with an error indicating the calling +// project hasn't enabled the accessed service, this can contain a URL pointing +// directly to the right place in the developer console to flip the bit. +message Help { + // Describes a URL link. + message Link { + // Describes what the link offers. + string description = 1; + + // The URL of the link. + string url = 2; + } + + // URL(s) pointing to additional information on handling the current error. + repeated Link links = 1; +} + +// Provides a localized error message that is safe to return to the user +// which can be attached to an RPC error. +message LocalizedMessage { + // The locale used following the specification defined at + // http://www.rfc-editor.org/rfc/bcp/bcp47.txt. + // Examples are: "en-US", "fr-CH", "es-MX" + string locale = 1; + + // The localized error message in the above locale. + string message = 2; +} \ No newline at end of file diff --git a/lib/src/protos/google/rpc/status.proto b/lib/src/protos/google/rpc/status.proto new file mode 100644 index 00000000..5bd51aa2 --- /dev/null +++ b/lib/src/protos/google/rpc/status.proto @@ -0,0 +1,47 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.rpc; + +import "google/protobuf/any.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/rpc/status;status"; +option java_multiple_files = true; +option java_outer_classname = "StatusProto"; +option java_package = "com.google.rpc"; +option objc_class_prefix = "RPC"; + +// The `Status` type defines a logical error model that is suitable for +// different programming environments, including REST APIs and RPC APIs. It is +// used by [gRPC](https://github.com/grpc). Each `Status` message contains +// three pieces of data: error code, error message, and error details. +// +// You can find out more about this error model and how to work with it in the +// [API Design Guide](https://cloud.google.com/apis/design/errors). +message Status { + // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. + int32 code = 1; + + // A developer-facing error message, which should be in English. Any + // user-facing error message should be localized and sent in the + // [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. + string message = 2; + + // A list of messages that carry the error details. There is a common set of + // message types for APIs to use. + repeated google.protobuf.Any details = 3; +} \ No newline at end of file diff --git a/lib/src/shared/status.dart b/lib/src/shared/status.dart index 9c394d02..0b3ac0a3 100644 --- a/lib/src/shared/status.dart +++ b/lib/src/shared/status.dart @@ -13,8 +13,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import 'dart:convert'; -import 'dart:typed_data'; +import 'package:grpc/src/generated/google/protobuf/any.pb.dart'; +import 'package:grpc/src/generated/google/rpc/error_details.pb.dart'; +import 'package:protobuf/protobuf.dart'; class StatusCode { /// The operation completed successfully. @@ -123,7 +124,7 @@ class StatusCode { class GrpcError implements Exception { final int code; final String message; - final Uint8List details; + final List details; /// Custom error code. GrpcError.custom(this.code, [this.message, this.details]); @@ -252,5 +253,43 @@ class GrpcError implements Exception { int get hashCode => code.hashCode ^ (message?.hashCode ?? 17); @override - String toString() => 'gRPC Error ($code, $message, ${utf8.decode(details)})'; + String toString() => 'gRPC Error ($code, $message, $details)'; +} + +/// Parse error details into the right kind of GeneratedMessage. +GeneratedMessage parseGeneratedMessage(Any any) { + switch (any.typeUrl) { + case 'type.googleapis.com/google.rpc.RetryInfo': + return RetryInfo.fromBuffer(any.value); + + case 'type.googleapis.com/google.rpc.DebugInfo': + return DebugInfo.fromBuffer(any.value); + + case 'type.googleapis.com/google.rpc.QuotaFailure': + return QuotaFailure.fromBuffer(any.value); + + case 'type.googleapis.com/google.rpc.ErrorInfo': + return ErrorInfo.fromBuffer(any.value); + + case 'type.googleapis.com/google.rpc.PreconditionFailure': + return PreconditionFailure.fromBuffer(any.value); + + case 'type.googleapis.com/google.rpc.BadRequest': + return BadRequest.fromBuffer(any.value); + + case 'type.googleapis.com/google.rpc.RequestInfo': + return RequestInfo.fromBuffer(any.value); + + case 'type.googleapis.com/google.rpc.ResourceInfo': + return ResourceInfo.fromBuffer(any.value); + + case 'type.googleapis.com/google.rpc.Help': + return Help.fromBuffer(any.value); + + case 'type.googleapis.com/google.rpc.LocalizedMessage': + return LocalizedMessage.fromBuffer(any.value); + + default: + return any; + } } diff --git a/lib/src/tool/regenerate.sh b/lib/src/tool/regenerate.sh new file mode 100755 index 00000000..41934210 --- /dev/null +++ b/lib/src/tool/regenerate.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +mkdir -p generated +protoc --dart_out=grpc:generated -Iprotos/ $(find protos -iname "*.proto") +rm generated/*.pbjson.dart +rm generated/{empty,test}.pbenum.dart +dartfmt -w generated diff --git a/pubspec.yaml b/pubspec.yaml index eb8bb18e..f981f674 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,6 +16,7 @@ dependencies: meta: ^1.1.6 http: ^0.12.0 http2: ^1.0.0 + protobuf: ^1.0.1 dev_dependencies: build_runner: ^1.5.2 From bf6342788dd7a10b2d980f6cb956a4a3945ea9a1 Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Mon, 14 Sep 2020 11:34:04 -0400 Subject: [PATCH 04/21] Add export for status detail types to for easier consumption --- lib/grpc.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/grpc.dart b/lib/grpc.dart index 9681cbb3..2a3849f7 100644 --- a/lib/grpc.dart +++ b/lib/grpc.dart @@ -55,3 +55,6 @@ export 'src/shared/status.dart' show StatusCode, GrpcError; export 'src/shared/streams.dart' show GrpcHttpEncoder, GrpcHttpDecoder; export 'src/shared/timeout.dart' show toTimeoutString, fromTimeoutString; + +/// Status detail types +export 'src/generated/google/rpc/error_details.pb.dart'; From df0ba21933fb89fbe008116bf0629c3fc6658ea5 Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Mon, 14 Sep 2020 11:41:12 -0400 Subject: [PATCH 05/21] Add export for generated error details and cleanup empty space --- lib/grpc.dart | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/grpc.dart b/lib/grpc.dart index 2a3849f7..08731082 100644 --- a/lib/grpc.dart +++ b/lib/grpc.dart @@ -18,13 +18,11 @@ export 'src/auth/auth.dart' BaseAuthenticator, HttpBasedAuthenticator, JwtServiceAccountAuthenticator; - export 'src/auth/auth_io.dart' show applicationDefaultCredentialsAuthenticator, ComputeEngineAuthenticator, ServiceAccountAuthenticator; - export 'src/client/call.dart' show CallOptions, ClientCall, MetadataProvider; export 'src/client/client.dart' show Client; export 'src/client/common.dart' show Response, ResponseStream, ResponseFuture; @@ -37,24 +35,19 @@ export 'src/client/options.dart' BackoffStrategy, defaultBackoffStrategy, ChannelOptions; - export 'src/client/transport/http2_credentials.dart' show BadCertificateHandler, allowBadCertificates, ChannelCredentials; +/// Status detail types +export 'src/generated/google/rpc/error_details.pb.dart'; export 'src/server/call.dart' show ServiceCall; export 'src/server/interceptor.dart' show Interceptor; export 'src/server/server.dart' show ServerTlsCredentials, Server; export 'src/server/service.dart' show ServiceMethod, Service; - export 'src/shared/message.dart' show GrpcMessage, GrpcMetadata, GrpcData, grpcDecompressor; - export 'src/shared/security.dart' show supportedAlpnProtocols, createSecurityContext; export 'src/shared/status.dart' show StatusCode, GrpcError; export 'src/shared/streams.dart' show GrpcHttpEncoder, GrpcHttpDecoder; - export 'src/shared/timeout.dart' show toTimeoutString, fromTimeoutString; - -/// Status detail types -export 'src/generated/google/rpc/error_details.pb.dart'; From e6049a483d358c6ab794b3678293b139cb4c5638 Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Mon, 14 Sep 2020 12:51:19 -0400 Subject: [PATCH 06/21] Replace StatusCode implementation with auto-generated equivalent from code.proto. Includes status code string name in the error now --- interop/lib/src/client.dart | 16 ++-- lib/grpc.dart | 5 +- lib/src/client/call.dart | 37 ++++---- lib/src/server/handler.dart | 2 +- lib/src/shared/status.dart | 147 +++++------------------------ test/client_tests/client_test.dart | 4 +- test/server_test.dart | 32 +++---- test/src/server_utils.dart | 9 +- test/stream_test.dart | 8 +- test/timeout_test.dart | 2 +- 10 files changed, 75 insertions(+), 187 deletions(-) diff --git a/interop/lib/src/client.dart b/interop/lib/src/client.dart index 2cb93c87..6109ccb5 100644 --- a/interop/lib/src/client.dart +++ b/interop/lib/src/client.dart @@ -22,6 +22,7 @@ import 'package:grpc/grpc.dart'; import 'generated/empty.pb.dart'; import 'generated/messages.pb.dart'; import 'generated/test.pbgrpc.dart'; +import 'package:grpc/src/generated/google/rpc/code.pbenum.dart'; const _headerEchoKey = 'x-grpc-test-echo-initial'; const _headerEchoData = 'test_initial_metadata_value'; @@ -1000,9 +1001,10 @@ class Tester { /// * received status message is the same as the sent message for both /// Procedure steps 1 and 2 Future statusCodeAndMessage() async { - final expectedStatus = GrpcError.custom(2, 'test status message'); + final expectedStatus = + GrpcError.custom(Code.UNKNOWN, 'test status message'); final responseStatus = EchoStatus() - ..code = expectedStatus.code + ..code = expectedStatus.code.value ..message = expectedStatus.message; try { await client.unaryCall(SimpleRequest()..responseStatus = responseStatus); @@ -1044,7 +1046,7 @@ class Tester { await client.unimplementedCall(Empty()); throw 'Did not throw.'; } on GrpcError catch (e) { - if (e.code != StatusCode.unimplemented) { + if (e.code != Code.UNIMPLEMENTED) { throw 'Unexpected status code ${e.code} - ${e.message}.'; } } @@ -1064,7 +1066,7 @@ class Tester { await unimplementedServiceClient.unimplementedCall(Empty()); throw 'Did not throw.'; } on GrpcError catch (e) { - if (e.code != StatusCode.unimplemented) { + if (e.code != Code.UNIMPLEMENTED) { throw 'Unexpected status code ${e.code} - ${e.message}.'; } } @@ -1087,7 +1089,7 @@ class Tester { await call; throw 'Expected exception.'; } on GrpcError catch (e) { - if (e.code != StatusCode.cancelled) { + if (e.code != Code.CANCELLED) { throw 'Unexpected status code ${e.code} - ${e.message}'; } } @@ -1131,7 +1133,7 @@ class Tester { call.cancel(); }, onError: (e) { if (e is! GrpcError) completer.completeError('Unexpected error: $e.'); - if (e.code != StatusCode.cancelled) { + if (e.code != Code.CANCELLED) { completer .completeError('Unexpected status code ${e.code}: ${e.message}.'); } @@ -1175,7 +1177,7 @@ class Tester { } throw 'Expected exception.'; } on GrpcError catch (e) { - if (e.code != StatusCode.deadlineExceeded) { + if (e.code != Code.DEADLINE_EXCEEDED) { throw 'Unexpected status code ${e.code} - ${e.message}.'; } } finally { diff --git a/lib/grpc.dart b/lib/grpc.dart index 08731082..b3ea35b3 100644 --- a/lib/grpc.dart +++ b/lib/grpc.dart @@ -37,8 +37,7 @@ export 'src/client/options.dart' ChannelOptions; export 'src/client/transport/http2_credentials.dart' show BadCertificateHandler, allowBadCertificates, ChannelCredentials; - -/// Status detail types +export 'src/generated/google/rpc/code.pb.dart'; export 'src/generated/google/rpc/error_details.pb.dart'; export 'src/server/call.dart' show ServiceCall; export 'src/server/interceptor.dart' show Interceptor; @@ -48,6 +47,6 @@ export 'src/shared/message.dart' show GrpcMessage, GrpcMetadata, GrpcData, grpcDecompressor; export 'src/shared/security.dart' show supportedAlpnProtocols, createSecurityContext; -export 'src/shared/status.dart' show StatusCode, GrpcError; +export 'src/shared/status.dart' show GrpcError; export 'src/shared/streams.dart' show GrpcHttpEncoder, GrpcHttpDecoder; export 'src/shared/timeout.dart' show toTimeoutString, fromTimeoutString; diff --git a/lib/src/client/call.dart b/lib/src/client/call.dart index 283d7c14..a10e182a 100644 --- a/lib/src/client/call.dart +++ b/lib/src/client/call.dart @@ -16,8 +16,8 @@ import 'dart:async'; import 'dart:convert'; +import 'package:grpc/src/generated/google/rpc/code.pbenum.dart'; import 'package:grpc/src/generated/google/rpc/status.pb.dart'; -import 'package:protobuf/protobuf.dart'; import '../shared/message.dart'; import '../shared/status.dart'; @@ -244,15 +244,14 @@ class ClientCall implements Response { _trailers.complete(metadata); // TODO(jakobr): Parse more! if (metadata.containsKey('grpc-status')) { - final status = int.parse(metadata['grpc-status']); - final message = metadata['grpc-message'] == null - ? null - : Uri.decodeFull(metadata['grpc-message']); - if (status != 0) { + final details = + _parseStatusDetails(metadata['grpc-status-details-bin']); + final statusCode = details.code; + if (statusCode != 0) { _responseError(GrpcError.custom( - status, - message, - _decodeStatusDetails(metadata['grpc-status-details-bin']), + Code.values[statusCode], + details.message, + details.details.map((e) => parseGeneratedMessage(e)).toList(), )); } } @@ -288,18 +287,14 @@ class ClientCall implements Response { // Only received a header frame and no data frames, so the header // should contain "trailers" as well (Trailers-Only). _trailers.complete(_headerMetadata); - final status = _headerMetadata['grpc-status']; - // If status code is missing, we must treat it as '0'. As in 'success'. - final statusCode = status != null ? int.parse(status) : 0; - + final details = + _parseStatusDetails(_headerMetadata['grpc-status-details-bin']); + final statusCode = details.code; if (statusCode != 0) { - final message = _headerMetadata['grpc-message'] == null - ? null - : Uri.decodeFull(_headerMetadata['grpc-message']); _responseError(GrpcError.custom( - statusCode, - message, - _decodeStatusDetails(_headerMetadata['grpc-status-details-bin']), + Code.values[statusCode], + details.message, + details.details.map((e) => parseGeneratedMessage(e)).toList(), )); } } @@ -365,7 +360,7 @@ class ClientCall implements Response { } } -List _decodeStatusDetails(String data) { +Status _parseStatusDetails(String data) { /// Parse details out of message. Length must be an even multiple of 4 so we pad it if needed. var details = data ?? ''; while (details.length % 4 != 0) { @@ -374,5 +369,5 @@ List _decodeStatusDetails(String data) { /// Parse each Any type into the correct GeneratedMessage final parsedStatus = Status.fromBuffer(base64Url.decode(details)); - return parsedStatus.details.map((e) => parseGeneratedMessage(e)).toList(); + return parsedStatus; } diff --git a/lib/src/server/handler.dart b/lib/src/server/handler.dart index 0d27f7a9..c41b2635 100644 --- a/lib/src/server/handler.dart +++ b/lib/src/server/handler.dart @@ -349,7 +349,7 @@ class ServerHandler_ extends ServiceCall { } void _sendError(GrpcError error) { - sendTrailers(status: error.code, message: error.message); + sendTrailers(status: error.code.value, message: error.message); } void cancel() { diff --git a/lib/src/shared/status.dart b/lib/src/shared/status.dart index 0b3ac0a3..5fa6b3d9 100644 --- a/lib/src/shared/status.dart +++ b/lib/src/shared/status.dart @@ -14,115 +14,12 @@ // limitations under the License. import 'package:grpc/src/generated/google/protobuf/any.pb.dart'; +import 'package:grpc/src/generated/google/rpc/code.pbenum.dart'; import 'package:grpc/src/generated/google/rpc/error_details.pb.dart'; import 'package:protobuf/protobuf.dart'; -class StatusCode { - /// The operation completed successfully. - static const ok = 0; - - /// The operation was cancelled (typically by the caller). - static const cancelled = 1; - - /// Unknown error. An example of where this error may be returned is if a - /// Status value received from another address space belongs to an error-space - /// that is not known in this address space. Also errors raised by APIs that - /// do not return enough error information may be converted to this error. - static const unknown = 2; - - /// Client specified an invalid argument. Note that this differs from - /// [failedPrecondition]. [invalidArgument] indicates arguments that are - /// problematic regardless of the state of the system (e.g., a malformed file - /// name). - static const invalidArgument = 3; - - /// Deadline expired before operation could complete. For operations that - /// change the state of the system, this error may be returned even if the - /// operation has completed successfully. For example, a successful response - /// from a server could have been delayed long enough for the deadline to - /// expire. - static const deadlineExceeded = 4; - - /// Some requested entity (e.g., file or directory) was not found. - static const notFound = 5; - - /// Some entity that we attempted to create (e.g., file or directory) already - /// exists. - static const alreadyExists = 6; - - /// The caller does not have permission to execute the specified operation. - /// [permissionDenied] must not be used for rejections caused by exhausting - /// some resource (use [resourceExhausted] instead for those errors). - /// [permissionDenied] must not be used if the caller cannot be identified - /// (use [unauthenticated] instead for those errors). - static const permissionDenied = 7; - - /// Some resource has been exhausted, perhaps a per-user quota, or perhaps the - /// entire file system is out of space. - static const resourceExhausted = 8; - - /// Operation was rejected because the system is not in a state required for - /// the operation's execution. For example, directory to be deleted may be - /// non-empty, an rmdir operation is applied to a non-directory, etc. - /// - /// A litmus test that may help a service implementor in deciding between - /// [failedPrecondition], [aborted], and [unavailable]: - /// (a) Use [unavailable] if the client can retry just the failing call. - /// (b) Use [aborted] if the client should retry at a higher-level (e.g., - /// restarting a read-modify-write sequence). - /// (c) Use [failedPrecondition] if the client should not retry until the - /// system state has been explicitly fixed. E.g., if an "rmdir" fails - /// because the directory is non-empty, [failedPrecondition] should be - /// returned since the client should not retry unless they have first - /// fixed up the directory by deleting files from it. - static const failedPrecondition = 9; - - /// The operation was aborted, typically due to a concurrency issue like - /// sequencer check failures, transaction aborts, etc. - /// - /// See litmus test above for deciding between [failedPrecondition], - /// [aborted], and [unavailable]. - static const aborted = 10; - - /// Operation was attempted past the valid range. E.g., seeking or reading - /// past end of file. - /// - /// Unlike invalidArgument, this error indicates a problem that may be fixed - /// if the system state changes. For example, a 32-bit file system will - /// generate invalidArgument if asked to read at an offset that is not in the - /// range [0,2^32-1], but it will generate [outOfRange] if asked to read from - /// an offset past the current file size. - /// - /// There is a fair bit of overlap between [failedPrecondition] and - /// [outOfRange]. We recommend using [outOfRange] (the more specific error) - /// when it applies so that callers who are iterating through a space can - /// easily look for an [outOfRange] error to detect when they are done. - static const outOfRange = 11; - - /// Operation is not implemented or not supported/enabled in this service. - static const unimplemented = 12; - - /// Internal errors. Means some invariants expected by underlying system has - /// been broken. If you see one of these errors, something is very broken. - static const internal = 13; - - /// The service is currently unavailable. This is a most likely a transient - /// condition and may be corrected by retrying with a backoff. - /// - /// See litmus test above for deciding between [failedPrecondition], - /// [aborted], and [unavailable]. - static const unavailable = 14; - - /// Unrecoverable data loss or corruption. - static const dataLoss = 15; - - /// The request does not have valid authentication credentials for the - /// operation. - static const unauthenticated = 16; -} - class GrpcError implements Exception { - final int code; + final Code code; final String message; final List details; @@ -130,24 +27,23 @@ class GrpcError implements Exception { GrpcError.custom(this.code, [this.message, this.details]); /// The operation completed successfully. - GrpcError.ok([this.message, this.details]) : code = StatusCode.ok; + GrpcError.ok([this.message, this.details]) : code = Code.OK; /// The operation was cancelled (typically by the caller). - GrpcError.cancelled([this.message, this.details]) - : code = StatusCode.cancelled; + GrpcError.cancelled([this.message, this.details]) : code = Code.CANCELLED; /// Unknown error. An example of where this error may be returned is if a /// Status value received from another address space belongs to an error-space /// that is not known in this address space. Also errors raised by APIs that /// do not return enough error information may be converted to this error. - GrpcError.unknown([this.message, this.details]) : code = StatusCode.unknown; + GrpcError.unknown([this.message, this.details]) : code = Code.UNKNOWN; /// Client specified an invalid argument. Note that this differs from /// [failedPrecondition]. [invalidArgument] indicates arguments that are /// problematic regardless of the state of the system (e.g., a malformed file /// name). GrpcError.invalidArgument([this.message, this.details]) - : code = StatusCode.invalidArgument; + : code = Code.INVALID_ARGUMENT; /// Deadline expired before operation could complete. For operations that /// change the state of the system, this error may be returned even if the @@ -155,15 +51,15 @@ class GrpcError implements Exception { /// from a server could have been delayed long enough for the deadline to /// expire. GrpcError.deadlineExceeded([this.message, this.details]) - : code = StatusCode.deadlineExceeded; + : code = Code.DEADLINE_EXCEEDED; /// Some requested entity (e.g., file or directory) was not found. - GrpcError.notFound([this.message, this.details]) : code = StatusCode.notFound; + GrpcError.notFound([this.message, this.details]) : code = Code.NOT_FOUND; /// Some entity that we attempted to create (e.g., file or directory) already /// exists. GrpcError.alreadyExists([this.message, this.details]) - : code = StatusCode.alreadyExists; + : code = Code.ALREADY_EXISTS; /// The caller does not have permission to execute the specified operation. /// [permissionDenied] must not be used for rejections caused by exhausting @@ -171,12 +67,12 @@ class GrpcError implements Exception { /// [permissionDenied] must not be used if the caller cannot be identified /// (use [unauthenticated] instead for those errors). GrpcError.permissionDenied([this.message, this.details]) - : code = StatusCode.permissionDenied; + : code = Code.PERMISSION_DENIED; /// Some resource has been exhausted, perhaps a per-user quota, or perhaps the /// entire file system is out of space. GrpcError.resourceExhausted([this.message, this.details]) - : code = StatusCode.resourceExhausted; + : code = Code.RESOURCE_EXHAUSTED; /// Operation was rejected because the system is not in a state required for /// the operation's execution. For example, directory to be deleted may be @@ -193,14 +89,14 @@ class GrpcError implements Exception { /// returned since the client should not retry unless they have first /// fixed up the directory by deleting files from it. GrpcError.failedPrecondition([this.message, this.details]) - : code = StatusCode.failedPrecondition; + : code = Code.FAILED_PRECONDITION; /// The operation was aborted, typically due to a concurrency issue like /// sequencer check failures, transaction aborts, etc. /// /// See litmus test above for deciding between [failedPrecondition], /// [aborted], and [unavailable]. - GrpcError.aborted([this.message, this.details]) : code = StatusCode.aborted; + GrpcError.aborted([this.message, this.details]) : code = Code.ABORTED; /// Operation was attempted past the valid range. E.g., seeking or reading /// past end of file. @@ -215,33 +111,31 @@ class GrpcError implements Exception { /// [outOfRange]. We recommend using [outOfRange] (the more specific error) /// when it applies so that callers who are iterating through a space can /// easily look for an [outOfRange] error to detect when they are done. - GrpcError.outOfRange([this.message, this.details]) - : code = StatusCode.outOfRange; + GrpcError.outOfRange([this.message, this.details]) : code = Code.OUT_OF_RANGE; /// Operation is not implemented or not supported/enabled in this service. GrpcError.unimplemented([this.message, this.details]) - : code = StatusCode.unimplemented; + : code = Code.UNIMPLEMENTED; /// Internal errors. Means some invariants expected by underlying system has /// been broken. If you see one of these errors, something is very broken. // TODO(sigurdm): This should probably not be an [Exception]. - GrpcError.internal([this.message, this.details]) : code = StatusCode.internal; + GrpcError.internal([this.message, this.details]) : code = Code.INTERNAL; /// The service is currently unavailable. This is a most likely a transient /// condition and may be corrected by retrying with a backoff. /// /// See litmus test above for deciding between [failedPrecondition], /// [aborted], and [unavailable]. - GrpcError.unavailable([this.message, this.details]) - : code = StatusCode.unavailable; + GrpcError.unavailable([this.message, this.details]) : code = Code.UNAVAILABLE; /// Unrecoverable data loss or corruption. - GrpcError.dataLoss([this.message, this.details]) : code = StatusCode.dataLoss; + GrpcError.dataLoss([this.message, this.details]) : code = Code.DATA_LOSS; /// The request does not have valid authentication credentials for the /// operation. GrpcError.unauthenticated([this.message, this.details]) - : code = StatusCode.unauthenticated; + : code = Code.UNAUTHENTICATED; @override bool operator ==(other) { @@ -253,7 +147,8 @@ class GrpcError implements Exception { int get hashCode => code.hashCode ^ (message?.hashCode ?? 17); @override - String toString() => 'gRPC Error ($code, $message, $details)'; + String toString() => + 'gRPC Error (${code.value} ${code.name}, $message, $details)'; } /// Parse error details into the right kind of GeneratedMessage. diff --git a/test/client_tests/client_test.dart b/test/client_tests/client_test.dart index 70480df6..14e1f6a3 100644 --- a/test/client_tests/client_test.dart +++ b/test/client_tests/client_test.dart @@ -238,7 +238,7 @@ void main() { }); test('Call throws if non-zero status is received', () async { - const customStatusCode = 17; + const customStatusCode = Code.UNKNOWN; const customStatusMessage = 'Custom message'; void handleRequest(_) { @@ -258,7 +258,7 @@ void main() { }); test('Call throws decoded message', () async { - const customStatusCode = 17; + const customStatusCode = Code.UNKNOWN; const customStatusMessage = 'エラー'; const encodedCustomStatusMessage = '%E3%82%A8%E3%83%A9%E3%83%BC'; diff --git a/test/server_test.dart b/test/server_test.dart index c9fd0eb0..a13a071c 100644 --- a/test/server_test.dart +++ b/test/server_test.dart @@ -96,22 +96,21 @@ void main() { test('Server returns error on missing call header', () async { harness - ..expectErrorResponse(StatusCode.unimplemented, 'Expected header frame') + ..expectErrorResponse(Code.UNIMPLEMENTED, 'Expected header frame') ..sendData(dummyValue); await harness.fromServer.done; }); test('Server returns error on invalid path', () async { harness - ..expectErrorResponse(StatusCode.unimplemented, 'Invalid path') + ..expectErrorResponse(Code.UNIMPLEMENTED, 'Invalid path') ..sendRequestHeader('InvalidPath'); await harness.fromServer.done; }); test('Server returns error on unimplemented path', () async { harness - ..expectErrorResponse( - StatusCode.unimplemented, 'Path /Test/NotFound not found') + ..expectErrorResponse(Code.UNIMPLEMENTED, 'Path /Test/NotFound not found') ..sendRequestHeader('/Test/NotFound'); await harness.fromServer.done; }); @@ -161,7 +160,7 @@ void main() { harness ..service.unaryHandler = expectError(GrpcError.unimplemented('No request received')) - ..expectErrorResponse(StatusCode.unimplemented, 'No request received') + ..expectErrorResponse(Code.UNIMPLEMENTED, 'No request received') ..sendRequestHeader('/Test/Unary') ..toServer.close(); await harness.fromServer.done; @@ -174,7 +173,7 @@ void main() { harness ..service.unaryHandler = methodHandler - ..expectErrorResponse(StatusCode.unknown, '%E3%82%A8%E3%83%A9%E3%83%BC') + ..expectErrorResponse(Code.UNKNOWN, '%E3%82%A8%E3%83%A9%E3%83%BC') ..sendRequestHeader('/Test/Unary') ..sendData(dummyValue) ..toServer.close(); @@ -186,7 +185,7 @@ void main() { harness ..service.unaryHandler = expectError(GrpcError.unimplemented('Expected request')) - ..expectErrorResponse(StatusCode.unimplemented, 'Expected request') + ..expectErrorResponse(Code.UNIMPLEMENTED, 'Expected request') ..sendRequestHeader('/Test/Unary') ..toServer.add(HeadersStreamMessage([])) ..toServer.close(); @@ -197,7 +196,7 @@ void main() { harness ..service.unaryHandler = expectError(GrpcError.unimplemented('Too many requests')) - ..expectErrorResponse(StatusCode.unimplemented, 'Too many requests') + ..expectErrorResponse(Code.UNIMPLEMENTED, 'Too many requests') ..sendRequestHeader('/Test/Unary') ..sendData(dummyValue) ..sendData(dummyValue) @@ -210,7 +209,7 @@ void main() { ..service.bidirectionalHandler = expectErrorStreaming( GrpcError.internal('Error deserializing request: Failed')) ..expectErrorResponse( - StatusCode.internal, 'Error deserializing request: Failed') + Code.INTERNAL, 'Error deserializing request: Failed') ..sendRequestHeader('/Test/RequestError') ..sendData(dummyValue) ..toServer.close(); @@ -221,8 +220,7 @@ void main() { harness ..service.bidirectionalHandler = expectErrorStreaming( GrpcError.internal('Error sending response: Failed')) - ..expectErrorResponse( - StatusCode.internal, 'Error sending response: Failed') + ..expectErrorResponse(Code.INTERNAL, 'Error sending response: Failed') ..sendRequestHeader('/Test/ResponseError') ..sendData(dummyValue) ..sendData(dummyValue) @@ -239,7 +237,7 @@ void main() { harness ..service.unaryHandler = methodHandler - ..expectTrailingErrorResponse(StatusCode.internal, 'Headers already sent') + ..expectTrailingErrorResponse(Code.INTERNAL, 'Headers already sent') ..sendRequestHeader('/Test/Unary'); await harness.fromServer.done; }); @@ -288,7 +286,7 @@ void main() { () async { harness ..expectErrorResponse( - StatusCode.unavailable, 'Request stream closed unexpectedly') + Code.UNAVAILABLE, 'Request stream closed unexpectedly') ..toServer.close(); await harness.fromServer.done; }); @@ -335,7 +333,7 @@ void main() { harness ..interceptor.handler = handler ..expectErrorResponse( - StatusCode.unauthenticated, 'Request is unauthenticated') + Code.UNAUTHENTICATED, 'Request is unauthenticated') ..sendRequestHeader('/Test/Unary'); await harness.fromServer.done; @@ -354,8 +352,7 @@ void main() { Future doTest(Interceptor handler) async { harness ..interceptor.handler = handler - ..expectErrorResponse( - StatusCode.internal, 'Exception: Reason is unknown') + ..expectErrorResponse(Code.INTERNAL, 'Exception: Reason is unknown') ..sendRequestHeader('/Test/Unary'); await harness.fromServer.done; @@ -375,8 +372,7 @@ void main() { harness ..interceptor.handler = interceptor - ..expectErrorResponse( - StatusCode.internal, 'Exception: Reason is unknown') + ..expectErrorResponse(Code.INTERNAL, 'Exception: Reason is unknown') ..sendRequestHeader('/Test/Unary') ..sendData(1); diff --git a/test/src/server_utils.dart b/test/src/server_utils.dart index eb37a641..81a9b51a 100644 --- a/test/src/server_utils.dart +++ b/test/src/server_utils.dart @@ -156,14 +156,15 @@ class ServerHarness { onDone: expectAsync0(() {}, count: 1)); } - void expectErrorResponse(int status, String message) { - setupTest([errorTrailerValidator(status, message, validateHeader: true)]); + void expectErrorResponse(Code status, String message) { + setupTest( + [errorTrailerValidator(status.value, message, validateHeader: true)]); } - void expectTrailingErrorResponse(int status, String message) { + void expectTrailingErrorResponse(Code status, String message) { setupTest([ headerValidator(), - errorTrailerValidator(status, message, validateHeader: false) + errorTrailerValidator(status.value, message, validateHeader: false) ]); } diff --git a/test/stream_test.dart b/test/stream_test.dart index 5246f9d1..24f87396 100644 --- a/test/stream_test.dart +++ b/test/stream_test.dart @@ -69,7 +69,7 @@ void main() { await result; fail('Did not throw'); } on GrpcError catch (e) { - expect(e.code, StatusCode.unavailable); + expect(e.code, Code.UNAVAILABLE); expect(e.message, 'Closed in non-idle state'); } }); @@ -84,7 +84,7 @@ void main() { await result; fail('Did not throw'); } on GrpcError catch (e) { - expect(e.code, StatusCode.unavailable); + expect(e.code, Code.UNAVAILABLE); expect(e.message, 'Closed in non-idle state'); } }); @@ -101,7 +101,7 @@ void main() { await result; fail('Did not throw'); } on GrpcError catch (e) { - expect(e.code, StatusCode.unimplemented); + expect(e.code, Code.UNIMPLEMENTED); expect(e.message, 'Received header while reading data'); } }); @@ -117,7 +117,7 @@ void main() { await result; fail('Did not throw'); } on GrpcError catch (e) { - expect(e.code, StatusCode.unimplemented); + expect(e.code, Code.UNIMPLEMENTED); expect(e.message, 'Received header while reading data'); } }); diff --git a/test/timeout_test.dart b/test/timeout_test.dart index 578a9d9e..84abf70b 100644 --- a/test/timeout_test.dart +++ b/test/timeout_test.dart @@ -132,7 +132,7 @@ void main() { harness ..service.unaryHandler = methodHandler - ..expectErrorResponse(StatusCode.deadlineExceeded, 'Deadline exceeded') + ..expectErrorResponse(Code.DEADLINE_EXCEEDED, 'Deadline exceeded') ..sendRequestHeader('/Test/Unary', timeout: Duration(microseconds: 1)); await harness.fromServer.done; }); From 2600cc103d23a0059e33e23456048cdd4cf9fa6a Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Mon, 14 Sep 2020 13:17:12 -0400 Subject: [PATCH 07/21] Revert "Replace StatusCode implementation with auto-generated equivalent from code.proto. Includes status code string name in the error now" This reverts commit e6049a483d358c6ab794b3678293b139cb4c5638. --- interop/lib/src/client.dart | 16 ++-- lib/grpc.dart | 5 +- lib/src/client/call.dart | 37 ++++---- lib/src/server/handler.dart | 2 +- lib/src/shared/status.dart | 147 ++++++++++++++++++++++++----- test/client_tests/client_test.dart | 4 +- test/server_test.dart | 32 ++++--- test/src/server_utils.dart | 9 +- test/stream_test.dart | 8 +- test/timeout_test.dart | 2 +- 10 files changed, 187 insertions(+), 75 deletions(-) diff --git a/interop/lib/src/client.dart b/interop/lib/src/client.dart index 6109ccb5..2cb93c87 100644 --- a/interop/lib/src/client.dart +++ b/interop/lib/src/client.dart @@ -22,7 +22,6 @@ import 'package:grpc/grpc.dart'; import 'generated/empty.pb.dart'; import 'generated/messages.pb.dart'; import 'generated/test.pbgrpc.dart'; -import 'package:grpc/src/generated/google/rpc/code.pbenum.dart'; const _headerEchoKey = 'x-grpc-test-echo-initial'; const _headerEchoData = 'test_initial_metadata_value'; @@ -1001,10 +1000,9 @@ class Tester { /// * received status message is the same as the sent message for both /// Procedure steps 1 and 2 Future statusCodeAndMessage() async { - final expectedStatus = - GrpcError.custom(Code.UNKNOWN, 'test status message'); + final expectedStatus = GrpcError.custom(2, 'test status message'); final responseStatus = EchoStatus() - ..code = expectedStatus.code.value + ..code = expectedStatus.code ..message = expectedStatus.message; try { await client.unaryCall(SimpleRequest()..responseStatus = responseStatus); @@ -1046,7 +1044,7 @@ class Tester { await client.unimplementedCall(Empty()); throw 'Did not throw.'; } on GrpcError catch (e) { - if (e.code != Code.UNIMPLEMENTED) { + if (e.code != StatusCode.unimplemented) { throw 'Unexpected status code ${e.code} - ${e.message}.'; } } @@ -1066,7 +1064,7 @@ class Tester { await unimplementedServiceClient.unimplementedCall(Empty()); throw 'Did not throw.'; } on GrpcError catch (e) { - if (e.code != Code.UNIMPLEMENTED) { + if (e.code != StatusCode.unimplemented) { throw 'Unexpected status code ${e.code} - ${e.message}.'; } } @@ -1089,7 +1087,7 @@ class Tester { await call; throw 'Expected exception.'; } on GrpcError catch (e) { - if (e.code != Code.CANCELLED) { + if (e.code != StatusCode.cancelled) { throw 'Unexpected status code ${e.code} - ${e.message}'; } } @@ -1133,7 +1131,7 @@ class Tester { call.cancel(); }, onError: (e) { if (e is! GrpcError) completer.completeError('Unexpected error: $e.'); - if (e.code != Code.CANCELLED) { + if (e.code != StatusCode.cancelled) { completer .completeError('Unexpected status code ${e.code}: ${e.message}.'); } @@ -1177,7 +1175,7 @@ class Tester { } throw 'Expected exception.'; } on GrpcError catch (e) { - if (e.code != Code.DEADLINE_EXCEEDED) { + if (e.code != StatusCode.deadlineExceeded) { throw 'Unexpected status code ${e.code} - ${e.message}.'; } } finally { diff --git a/lib/grpc.dart b/lib/grpc.dart index b3ea35b3..08731082 100644 --- a/lib/grpc.dart +++ b/lib/grpc.dart @@ -37,7 +37,8 @@ export 'src/client/options.dart' ChannelOptions; export 'src/client/transport/http2_credentials.dart' show BadCertificateHandler, allowBadCertificates, ChannelCredentials; -export 'src/generated/google/rpc/code.pb.dart'; + +/// Status detail types export 'src/generated/google/rpc/error_details.pb.dart'; export 'src/server/call.dart' show ServiceCall; export 'src/server/interceptor.dart' show Interceptor; @@ -47,6 +48,6 @@ export 'src/shared/message.dart' show GrpcMessage, GrpcMetadata, GrpcData, grpcDecompressor; export 'src/shared/security.dart' show supportedAlpnProtocols, createSecurityContext; -export 'src/shared/status.dart' show GrpcError; +export 'src/shared/status.dart' show StatusCode, GrpcError; export 'src/shared/streams.dart' show GrpcHttpEncoder, GrpcHttpDecoder; export 'src/shared/timeout.dart' show toTimeoutString, fromTimeoutString; diff --git a/lib/src/client/call.dart b/lib/src/client/call.dart index a10e182a..283d7c14 100644 --- a/lib/src/client/call.dart +++ b/lib/src/client/call.dart @@ -16,8 +16,8 @@ import 'dart:async'; import 'dart:convert'; -import 'package:grpc/src/generated/google/rpc/code.pbenum.dart'; import 'package:grpc/src/generated/google/rpc/status.pb.dart'; +import 'package:protobuf/protobuf.dart'; import '../shared/message.dart'; import '../shared/status.dart'; @@ -244,14 +244,15 @@ class ClientCall implements Response { _trailers.complete(metadata); // TODO(jakobr): Parse more! if (metadata.containsKey('grpc-status')) { - final details = - _parseStatusDetails(metadata['grpc-status-details-bin']); - final statusCode = details.code; - if (statusCode != 0) { + final status = int.parse(metadata['grpc-status']); + final message = metadata['grpc-message'] == null + ? null + : Uri.decodeFull(metadata['grpc-message']); + if (status != 0) { _responseError(GrpcError.custom( - Code.values[statusCode], - details.message, - details.details.map((e) => parseGeneratedMessage(e)).toList(), + status, + message, + _decodeStatusDetails(metadata['grpc-status-details-bin']), )); } } @@ -287,14 +288,18 @@ class ClientCall implements Response { // Only received a header frame and no data frames, so the header // should contain "trailers" as well (Trailers-Only). _trailers.complete(_headerMetadata); - final details = - _parseStatusDetails(_headerMetadata['grpc-status-details-bin']); - final statusCode = details.code; + final status = _headerMetadata['grpc-status']; + // If status code is missing, we must treat it as '0'. As in 'success'. + final statusCode = status != null ? int.parse(status) : 0; + if (statusCode != 0) { + final message = _headerMetadata['grpc-message'] == null + ? null + : Uri.decodeFull(_headerMetadata['grpc-message']); _responseError(GrpcError.custom( - Code.values[statusCode], - details.message, - details.details.map((e) => parseGeneratedMessage(e)).toList(), + statusCode, + message, + _decodeStatusDetails(_headerMetadata['grpc-status-details-bin']), )); } } @@ -360,7 +365,7 @@ class ClientCall implements Response { } } -Status _parseStatusDetails(String data) { +List _decodeStatusDetails(String data) { /// Parse details out of message. Length must be an even multiple of 4 so we pad it if needed. var details = data ?? ''; while (details.length % 4 != 0) { @@ -369,5 +374,5 @@ Status _parseStatusDetails(String data) { /// Parse each Any type into the correct GeneratedMessage final parsedStatus = Status.fromBuffer(base64Url.decode(details)); - return parsedStatus; + return parsedStatus.details.map((e) => parseGeneratedMessage(e)).toList(); } diff --git a/lib/src/server/handler.dart b/lib/src/server/handler.dart index c41b2635..0d27f7a9 100644 --- a/lib/src/server/handler.dart +++ b/lib/src/server/handler.dart @@ -349,7 +349,7 @@ class ServerHandler_ extends ServiceCall { } void _sendError(GrpcError error) { - sendTrailers(status: error.code.value, message: error.message); + sendTrailers(status: error.code, message: error.message); } void cancel() { diff --git a/lib/src/shared/status.dart b/lib/src/shared/status.dart index 5fa6b3d9..0b3ac0a3 100644 --- a/lib/src/shared/status.dart +++ b/lib/src/shared/status.dart @@ -14,12 +14,115 @@ // limitations under the License. import 'package:grpc/src/generated/google/protobuf/any.pb.dart'; -import 'package:grpc/src/generated/google/rpc/code.pbenum.dart'; import 'package:grpc/src/generated/google/rpc/error_details.pb.dart'; import 'package:protobuf/protobuf.dart'; +class StatusCode { + /// The operation completed successfully. + static const ok = 0; + + /// The operation was cancelled (typically by the caller). + static const cancelled = 1; + + /// Unknown error. An example of where this error may be returned is if a + /// Status value received from another address space belongs to an error-space + /// that is not known in this address space. Also errors raised by APIs that + /// do not return enough error information may be converted to this error. + static const unknown = 2; + + /// Client specified an invalid argument. Note that this differs from + /// [failedPrecondition]. [invalidArgument] indicates arguments that are + /// problematic regardless of the state of the system (e.g., a malformed file + /// name). + static const invalidArgument = 3; + + /// Deadline expired before operation could complete. For operations that + /// change the state of the system, this error may be returned even if the + /// operation has completed successfully. For example, a successful response + /// from a server could have been delayed long enough for the deadline to + /// expire. + static const deadlineExceeded = 4; + + /// Some requested entity (e.g., file or directory) was not found. + static const notFound = 5; + + /// Some entity that we attempted to create (e.g., file or directory) already + /// exists. + static const alreadyExists = 6; + + /// The caller does not have permission to execute the specified operation. + /// [permissionDenied] must not be used for rejections caused by exhausting + /// some resource (use [resourceExhausted] instead for those errors). + /// [permissionDenied] must not be used if the caller cannot be identified + /// (use [unauthenticated] instead for those errors). + static const permissionDenied = 7; + + /// Some resource has been exhausted, perhaps a per-user quota, or perhaps the + /// entire file system is out of space. + static const resourceExhausted = 8; + + /// Operation was rejected because the system is not in a state required for + /// the operation's execution. For example, directory to be deleted may be + /// non-empty, an rmdir operation is applied to a non-directory, etc. + /// + /// A litmus test that may help a service implementor in deciding between + /// [failedPrecondition], [aborted], and [unavailable]: + /// (a) Use [unavailable] if the client can retry just the failing call. + /// (b) Use [aborted] if the client should retry at a higher-level (e.g., + /// restarting a read-modify-write sequence). + /// (c) Use [failedPrecondition] if the client should not retry until the + /// system state has been explicitly fixed. E.g., if an "rmdir" fails + /// because the directory is non-empty, [failedPrecondition] should be + /// returned since the client should not retry unless they have first + /// fixed up the directory by deleting files from it. + static const failedPrecondition = 9; + + /// The operation was aborted, typically due to a concurrency issue like + /// sequencer check failures, transaction aborts, etc. + /// + /// See litmus test above for deciding between [failedPrecondition], + /// [aborted], and [unavailable]. + static const aborted = 10; + + /// Operation was attempted past the valid range. E.g., seeking or reading + /// past end of file. + /// + /// Unlike invalidArgument, this error indicates a problem that may be fixed + /// if the system state changes. For example, a 32-bit file system will + /// generate invalidArgument if asked to read at an offset that is not in the + /// range [0,2^32-1], but it will generate [outOfRange] if asked to read from + /// an offset past the current file size. + /// + /// There is a fair bit of overlap between [failedPrecondition] and + /// [outOfRange]. We recommend using [outOfRange] (the more specific error) + /// when it applies so that callers who are iterating through a space can + /// easily look for an [outOfRange] error to detect when they are done. + static const outOfRange = 11; + + /// Operation is not implemented or not supported/enabled in this service. + static const unimplemented = 12; + + /// Internal errors. Means some invariants expected by underlying system has + /// been broken. If you see one of these errors, something is very broken. + static const internal = 13; + + /// The service is currently unavailable. This is a most likely a transient + /// condition and may be corrected by retrying with a backoff. + /// + /// See litmus test above for deciding between [failedPrecondition], + /// [aborted], and [unavailable]. + static const unavailable = 14; + + /// Unrecoverable data loss or corruption. + static const dataLoss = 15; + + /// The request does not have valid authentication credentials for the + /// operation. + static const unauthenticated = 16; +} + class GrpcError implements Exception { - final Code code; + final int code; final String message; final List details; @@ -27,23 +130,24 @@ class GrpcError implements Exception { GrpcError.custom(this.code, [this.message, this.details]); /// The operation completed successfully. - GrpcError.ok([this.message, this.details]) : code = Code.OK; + GrpcError.ok([this.message, this.details]) : code = StatusCode.ok; /// The operation was cancelled (typically by the caller). - GrpcError.cancelled([this.message, this.details]) : code = Code.CANCELLED; + GrpcError.cancelled([this.message, this.details]) + : code = StatusCode.cancelled; /// Unknown error. An example of where this error may be returned is if a /// Status value received from another address space belongs to an error-space /// that is not known in this address space. Also errors raised by APIs that /// do not return enough error information may be converted to this error. - GrpcError.unknown([this.message, this.details]) : code = Code.UNKNOWN; + GrpcError.unknown([this.message, this.details]) : code = StatusCode.unknown; /// Client specified an invalid argument. Note that this differs from /// [failedPrecondition]. [invalidArgument] indicates arguments that are /// problematic regardless of the state of the system (e.g., a malformed file /// name). GrpcError.invalidArgument([this.message, this.details]) - : code = Code.INVALID_ARGUMENT; + : code = StatusCode.invalidArgument; /// Deadline expired before operation could complete. For operations that /// change the state of the system, this error may be returned even if the @@ -51,15 +155,15 @@ class GrpcError implements Exception { /// from a server could have been delayed long enough for the deadline to /// expire. GrpcError.deadlineExceeded([this.message, this.details]) - : code = Code.DEADLINE_EXCEEDED; + : code = StatusCode.deadlineExceeded; /// Some requested entity (e.g., file or directory) was not found. - GrpcError.notFound([this.message, this.details]) : code = Code.NOT_FOUND; + GrpcError.notFound([this.message, this.details]) : code = StatusCode.notFound; /// Some entity that we attempted to create (e.g., file or directory) already /// exists. GrpcError.alreadyExists([this.message, this.details]) - : code = Code.ALREADY_EXISTS; + : code = StatusCode.alreadyExists; /// The caller does not have permission to execute the specified operation. /// [permissionDenied] must not be used for rejections caused by exhausting @@ -67,12 +171,12 @@ class GrpcError implements Exception { /// [permissionDenied] must not be used if the caller cannot be identified /// (use [unauthenticated] instead for those errors). GrpcError.permissionDenied([this.message, this.details]) - : code = Code.PERMISSION_DENIED; + : code = StatusCode.permissionDenied; /// Some resource has been exhausted, perhaps a per-user quota, or perhaps the /// entire file system is out of space. GrpcError.resourceExhausted([this.message, this.details]) - : code = Code.RESOURCE_EXHAUSTED; + : code = StatusCode.resourceExhausted; /// Operation was rejected because the system is not in a state required for /// the operation's execution. For example, directory to be deleted may be @@ -89,14 +193,14 @@ class GrpcError implements Exception { /// returned since the client should not retry unless they have first /// fixed up the directory by deleting files from it. GrpcError.failedPrecondition([this.message, this.details]) - : code = Code.FAILED_PRECONDITION; + : code = StatusCode.failedPrecondition; /// The operation was aborted, typically due to a concurrency issue like /// sequencer check failures, transaction aborts, etc. /// /// See litmus test above for deciding between [failedPrecondition], /// [aborted], and [unavailable]. - GrpcError.aborted([this.message, this.details]) : code = Code.ABORTED; + GrpcError.aborted([this.message, this.details]) : code = StatusCode.aborted; /// Operation was attempted past the valid range. E.g., seeking or reading /// past end of file. @@ -111,31 +215,33 @@ class GrpcError implements Exception { /// [outOfRange]. We recommend using [outOfRange] (the more specific error) /// when it applies so that callers who are iterating through a space can /// easily look for an [outOfRange] error to detect when they are done. - GrpcError.outOfRange([this.message, this.details]) : code = Code.OUT_OF_RANGE; + GrpcError.outOfRange([this.message, this.details]) + : code = StatusCode.outOfRange; /// Operation is not implemented or not supported/enabled in this service. GrpcError.unimplemented([this.message, this.details]) - : code = Code.UNIMPLEMENTED; + : code = StatusCode.unimplemented; /// Internal errors. Means some invariants expected by underlying system has /// been broken. If you see one of these errors, something is very broken. // TODO(sigurdm): This should probably not be an [Exception]. - GrpcError.internal([this.message, this.details]) : code = Code.INTERNAL; + GrpcError.internal([this.message, this.details]) : code = StatusCode.internal; /// The service is currently unavailable. This is a most likely a transient /// condition and may be corrected by retrying with a backoff. /// /// See litmus test above for deciding between [failedPrecondition], /// [aborted], and [unavailable]. - GrpcError.unavailable([this.message, this.details]) : code = Code.UNAVAILABLE; + GrpcError.unavailable([this.message, this.details]) + : code = StatusCode.unavailable; /// Unrecoverable data loss or corruption. - GrpcError.dataLoss([this.message, this.details]) : code = Code.DATA_LOSS; + GrpcError.dataLoss([this.message, this.details]) : code = StatusCode.dataLoss; /// The request does not have valid authentication credentials for the /// operation. GrpcError.unauthenticated([this.message, this.details]) - : code = Code.UNAUTHENTICATED; + : code = StatusCode.unauthenticated; @override bool operator ==(other) { @@ -147,8 +253,7 @@ class GrpcError implements Exception { int get hashCode => code.hashCode ^ (message?.hashCode ?? 17); @override - String toString() => - 'gRPC Error (${code.value} ${code.name}, $message, $details)'; + String toString() => 'gRPC Error ($code, $message, $details)'; } /// Parse error details into the right kind of GeneratedMessage. diff --git a/test/client_tests/client_test.dart b/test/client_tests/client_test.dart index 14e1f6a3..70480df6 100644 --- a/test/client_tests/client_test.dart +++ b/test/client_tests/client_test.dart @@ -238,7 +238,7 @@ void main() { }); test('Call throws if non-zero status is received', () async { - const customStatusCode = Code.UNKNOWN; + const customStatusCode = 17; const customStatusMessage = 'Custom message'; void handleRequest(_) { @@ -258,7 +258,7 @@ void main() { }); test('Call throws decoded message', () async { - const customStatusCode = Code.UNKNOWN; + const customStatusCode = 17; const customStatusMessage = 'エラー'; const encodedCustomStatusMessage = '%E3%82%A8%E3%83%A9%E3%83%BC'; diff --git a/test/server_test.dart b/test/server_test.dart index a13a071c..c9fd0eb0 100644 --- a/test/server_test.dart +++ b/test/server_test.dart @@ -96,21 +96,22 @@ void main() { test('Server returns error on missing call header', () async { harness - ..expectErrorResponse(Code.UNIMPLEMENTED, 'Expected header frame') + ..expectErrorResponse(StatusCode.unimplemented, 'Expected header frame') ..sendData(dummyValue); await harness.fromServer.done; }); test('Server returns error on invalid path', () async { harness - ..expectErrorResponse(Code.UNIMPLEMENTED, 'Invalid path') + ..expectErrorResponse(StatusCode.unimplemented, 'Invalid path') ..sendRequestHeader('InvalidPath'); await harness.fromServer.done; }); test('Server returns error on unimplemented path', () async { harness - ..expectErrorResponse(Code.UNIMPLEMENTED, 'Path /Test/NotFound not found') + ..expectErrorResponse( + StatusCode.unimplemented, 'Path /Test/NotFound not found') ..sendRequestHeader('/Test/NotFound'); await harness.fromServer.done; }); @@ -160,7 +161,7 @@ void main() { harness ..service.unaryHandler = expectError(GrpcError.unimplemented('No request received')) - ..expectErrorResponse(Code.UNIMPLEMENTED, 'No request received') + ..expectErrorResponse(StatusCode.unimplemented, 'No request received') ..sendRequestHeader('/Test/Unary') ..toServer.close(); await harness.fromServer.done; @@ -173,7 +174,7 @@ void main() { harness ..service.unaryHandler = methodHandler - ..expectErrorResponse(Code.UNKNOWN, '%E3%82%A8%E3%83%A9%E3%83%BC') + ..expectErrorResponse(StatusCode.unknown, '%E3%82%A8%E3%83%A9%E3%83%BC') ..sendRequestHeader('/Test/Unary') ..sendData(dummyValue) ..toServer.close(); @@ -185,7 +186,7 @@ void main() { harness ..service.unaryHandler = expectError(GrpcError.unimplemented('Expected request')) - ..expectErrorResponse(Code.UNIMPLEMENTED, 'Expected request') + ..expectErrorResponse(StatusCode.unimplemented, 'Expected request') ..sendRequestHeader('/Test/Unary') ..toServer.add(HeadersStreamMessage([])) ..toServer.close(); @@ -196,7 +197,7 @@ void main() { harness ..service.unaryHandler = expectError(GrpcError.unimplemented('Too many requests')) - ..expectErrorResponse(Code.UNIMPLEMENTED, 'Too many requests') + ..expectErrorResponse(StatusCode.unimplemented, 'Too many requests') ..sendRequestHeader('/Test/Unary') ..sendData(dummyValue) ..sendData(dummyValue) @@ -209,7 +210,7 @@ void main() { ..service.bidirectionalHandler = expectErrorStreaming( GrpcError.internal('Error deserializing request: Failed')) ..expectErrorResponse( - Code.INTERNAL, 'Error deserializing request: Failed') + StatusCode.internal, 'Error deserializing request: Failed') ..sendRequestHeader('/Test/RequestError') ..sendData(dummyValue) ..toServer.close(); @@ -220,7 +221,8 @@ void main() { harness ..service.bidirectionalHandler = expectErrorStreaming( GrpcError.internal('Error sending response: Failed')) - ..expectErrorResponse(Code.INTERNAL, 'Error sending response: Failed') + ..expectErrorResponse( + StatusCode.internal, 'Error sending response: Failed') ..sendRequestHeader('/Test/ResponseError') ..sendData(dummyValue) ..sendData(dummyValue) @@ -237,7 +239,7 @@ void main() { harness ..service.unaryHandler = methodHandler - ..expectTrailingErrorResponse(Code.INTERNAL, 'Headers already sent') + ..expectTrailingErrorResponse(StatusCode.internal, 'Headers already sent') ..sendRequestHeader('/Test/Unary'); await harness.fromServer.done; }); @@ -286,7 +288,7 @@ void main() { () async { harness ..expectErrorResponse( - Code.UNAVAILABLE, 'Request stream closed unexpectedly') + StatusCode.unavailable, 'Request stream closed unexpectedly') ..toServer.close(); await harness.fromServer.done; }); @@ -333,7 +335,7 @@ void main() { harness ..interceptor.handler = handler ..expectErrorResponse( - Code.UNAUTHENTICATED, 'Request is unauthenticated') + StatusCode.unauthenticated, 'Request is unauthenticated') ..sendRequestHeader('/Test/Unary'); await harness.fromServer.done; @@ -352,7 +354,8 @@ void main() { Future doTest(Interceptor handler) async { harness ..interceptor.handler = handler - ..expectErrorResponse(Code.INTERNAL, 'Exception: Reason is unknown') + ..expectErrorResponse( + StatusCode.internal, 'Exception: Reason is unknown') ..sendRequestHeader('/Test/Unary'); await harness.fromServer.done; @@ -372,7 +375,8 @@ void main() { harness ..interceptor.handler = interceptor - ..expectErrorResponse(Code.INTERNAL, 'Exception: Reason is unknown') + ..expectErrorResponse( + StatusCode.internal, 'Exception: Reason is unknown') ..sendRequestHeader('/Test/Unary') ..sendData(1); diff --git a/test/src/server_utils.dart b/test/src/server_utils.dart index 81a9b51a..eb37a641 100644 --- a/test/src/server_utils.dart +++ b/test/src/server_utils.dart @@ -156,15 +156,14 @@ class ServerHarness { onDone: expectAsync0(() {}, count: 1)); } - void expectErrorResponse(Code status, String message) { - setupTest( - [errorTrailerValidator(status.value, message, validateHeader: true)]); + void expectErrorResponse(int status, String message) { + setupTest([errorTrailerValidator(status, message, validateHeader: true)]); } - void expectTrailingErrorResponse(Code status, String message) { + void expectTrailingErrorResponse(int status, String message) { setupTest([ headerValidator(), - errorTrailerValidator(status.value, message, validateHeader: false) + errorTrailerValidator(status, message, validateHeader: false) ]); } diff --git a/test/stream_test.dart b/test/stream_test.dart index 24f87396..5246f9d1 100644 --- a/test/stream_test.dart +++ b/test/stream_test.dart @@ -69,7 +69,7 @@ void main() { await result; fail('Did not throw'); } on GrpcError catch (e) { - expect(e.code, Code.UNAVAILABLE); + expect(e.code, StatusCode.unavailable); expect(e.message, 'Closed in non-idle state'); } }); @@ -84,7 +84,7 @@ void main() { await result; fail('Did not throw'); } on GrpcError catch (e) { - expect(e.code, Code.UNAVAILABLE); + expect(e.code, StatusCode.unavailable); expect(e.message, 'Closed in non-idle state'); } }); @@ -101,7 +101,7 @@ void main() { await result; fail('Did not throw'); } on GrpcError catch (e) { - expect(e.code, Code.UNIMPLEMENTED); + expect(e.code, StatusCode.unimplemented); expect(e.message, 'Received header while reading data'); } }); @@ -117,7 +117,7 @@ void main() { await result; fail('Did not throw'); } on GrpcError catch (e) { - expect(e.code, Code.UNIMPLEMENTED); + expect(e.code, StatusCode.unimplemented); expect(e.message, 'Received header while reading data'); } }); diff --git a/test/timeout_test.dart b/test/timeout_test.dart index 84abf70b..578a9d9e 100644 --- a/test/timeout_test.dart +++ b/test/timeout_test.dart @@ -132,7 +132,7 @@ void main() { harness ..service.unaryHandler = methodHandler - ..expectErrorResponse(Code.DEADLINE_EXCEEDED, 'Deadline exceeded') + ..expectErrorResponse(StatusCode.deadlineExceeded, 'Deadline exceeded') ..sendRequestHeader('/Test/Unary', timeout: Duration(microseconds: 1)); await harness.fromServer.done; }); From 32f30c6efe8b100f06a66ba08c7989b75cc83d72 Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Mon, 14 Sep 2020 13:31:01 -0400 Subject: [PATCH 08/21] Added status code name to GrpcError --- lib/src/shared/status.dart | 73 ++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/lib/src/shared/status.dart b/lib/src/shared/status.dart index 0b3ac0a3..52366885 100644 --- a/lib/src/shared/status.dart +++ b/lib/src/shared/status.dart @@ -14,6 +14,7 @@ // limitations under the License. import 'package:grpc/src/generated/google/protobuf/any.pb.dart'; +import 'package:grpc/src/generated/google/rpc/code.pbenum.dart'; import 'package:grpc/src/generated/google/rpc/error_details.pb.dart'; import 'package:protobuf/protobuf.dart'; @@ -123,31 +124,39 @@ class StatusCode { class GrpcError implements Exception { final int code; + final String codeName; final String message; final List details; /// Custom error code. - GrpcError.custom(this.code, [this.message, this.details]); + GrpcError.custom(this.code, [this.message, this.details]) + : codeName = getStatusCodeValue(code); /// The operation completed successfully. - GrpcError.ok([this.message, this.details]) : code = StatusCode.ok; + GrpcError.ok([this.message, this.details]) + : code = StatusCode.ok, + codeName = getStatusCodeValue(StatusCode.ok); /// The operation was cancelled (typically by the caller). GrpcError.cancelled([this.message, this.details]) - : code = StatusCode.cancelled; + : code = StatusCode.cancelled, + codeName = getStatusCodeValue(StatusCode.cancelled); /// Unknown error. An example of where this error may be returned is if a /// Status value received from another address space belongs to an error-space /// that is not known in this address space. Also errors raised by APIs that /// do not return enough error information may be converted to this error. - GrpcError.unknown([this.message, this.details]) : code = StatusCode.unknown; + GrpcError.unknown([this.message, this.details]) + : code = StatusCode.unknown, + codeName = getStatusCodeValue(StatusCode.unknown); /// Client specified an invalid argument. Note that this differs from /// [failedPrecondition]. [invalidArgument] indicates arguments that are /// problematic regardless of the state of the system (e.g., a malformed file /// name). GrpcError.invalidArgument([this.message, this.details]) - : code = StatusCode.invalidArgument; + : code = StatusCode.invalidArgument, + codeName = getStatusCodeValue(StatusCode.invalidArgument); /// Deadline expired before operation could complete. For operations that /// change the state of the system, this error may be returned even if the @@ -155,15 +164,19 @@ class GrpcError implements Exception { /// from a server could have been delayed long enough for the deadline to /// expire. GrpcError.deadlineExceeded([this.message, this.details]) - : code = StatusCode.deadlineExceeded; + : code = StatusCode.deadlineExceeded, + codeName = getStatusCodeValue(StatusCode.deadlineExceeded); /// Some requested entity (e.g., file or directory) was not found. - GrpcError.notFound([this.message, this.details]) : code = StatusCode.notFound; + GrpcError.notFound([this.message, this.details]) + : code = StatusCode.notFound, + codeName = getStatusCodeValue(StatusCode.notFound); /// Some entity that we attempted to create (e.g., file or directory) already /// exists. GrpcError.alreadyExists([this.message, this.details]) - : code = StatusCode.alreadyExists; + : code = StatusCode.alreadyExists, + codeName = getStatusCodeValue(StatusCode.alreadyExists); /// The caller does not have permission to execute the specified operation. /// [permissionDenied] must not be used for rejections caused by exhausting @@ -171,12 +184,14 @@ class GrpcError implements Exception { /// [permissionDenied] must not be used if the caller cannot be identified /// (use [unauthenticated] instead for those errors). GrpcError.permissionDenied([this.message, this.details]) - : code = StatusCode.permissionDenied; + : code = StatusCode.permissionDenied, + codeName = getStatusCodeValue(StatusCode.permissionDenied); /// Some resource has been exhausted, perhaps a per-user quota, or perhaps the /// entire file system is out of space. GrpcError.resourceExhausted([this.message, this.details]) - : code = StatusCode.resourceExhausted; + : code = StatusCode.resourceExhausted, + codeName = getStatusCodeValue(StatusCode.resourceExhausted); /// Operation was rejected because the system is not in a state required for /// the operation's execution. For example, directory to be deleted may be @@ -193,14 +208,17 @@ class GrpcError implements Exception { /// returned since the client should not retry unless they have first /// fixed up the directory by deleting files from it. GrpcError.failedPrecondition([this.message, this.details]) - : code = StatusCode.failedPrecondition; + : code = StatusCode.failedPrecondition, + codeName = getStatusCodeValue(StatusCode.failedPrecondition); /// The operation was aborted, typically due to a concurrency issue like /// sequencer check failures, transaction aborts, etc. /// /// See litmus test above for deciding between [failedPrecondition], /// [aborted], and [unavailable]. - GrpcError.aborted([this.message, this.details]) : code = StatusCode.aborted; + GrpcError.aborted([this.message, this.details]) + : code = StatusCode.aborted, + codeName = getStatusCodeValue(StatusCode.aborted); /// Operation was attempted past the valid range. E.g., seeking or reading /// past end of file. @@ -216,16 +234,20 @@ class GrpcError implements Exception { /// when it applies so that callers who are iterating through a space can /// easily look for an [outOfRange] error to detect when they are done. GrpcError.outOfRange([this.message, this.details]) - : code = StatusCode.outOfRange; + : code = StatusCode.outOfRange, + codeName = getStatusCodeValue(StatusCode.outOfRange); /// Operation is not implemented or not supported/enabled in this service. GrpcError.unimplemented([this.message, this.details]) - : code = StatusCode.unimplemented; + : code = StatusCode.unimplemented, + codeName = getStatusCodeValue(StatusCode.unimplemented); /// Internal errors. Means some invariants expected by underlying system has /// been broken. If you see one of these errors, something is very broken. // TODO(sigurdm): This should probably not be an [Exception]. - GrpcError.internal([this.message, this.details]) : code = StatusCode.internal; + GrpcError.internal([this.message, this.details]) + : code = StatusCode.internal, + codeName = getStatusCodeValue(StatusCode.internal); /// The service is currently unavailable. This is a most likely a transient /// condition and may be corrected by retrying with a backoff. @@ -233,15 +255,19 @@ class GrpcError implements Exception { /// See litmus test above for deciding between [failedPrecondition], /// [aborted], and [unavailable]. GrpcError.unavailable([this.message, this.details]) - : code = StatusCode.unavailable; + : code = StatusCode.unavailable, + codeName = getStatusCodeValue(StatusCode.unavailable); /// Unrecoverable data loss or corruption. - GrpcError.dataLoss([this.message, this.details]) : code = StatusCode.dataLoss; + GrpcError.dataLoss([this.message, this.details]) + : code = StatusCode.dataLoss, + codeName = getStatusCodeValue(StatusCode.dataLoss); /// The request does not have valid authentication credentials for the /// operation. GrpcError.unauthenticated([this.message, this.details]) - : code = StatusCode.unauthenticated; + : code = StatusCode.unauthenticated, + codeName = getStatusCodeValue(StatusCode.unauthenticated); @override bool operator ==(other) { @@ -253,7 +279,16 @@ class GrpcError implements Exception { int get hashCode => code.hashCode ^ (message?.hashCode ?? 17); @override - String toString() => 'gRPC Error ($code, $message, $details)'; + String toString() => 'gRPC Error ($code, $codeName, $message, $details)'; +} + +/// Given a status code, return the name +String getStatusCodeValue(int code) { + if (code > Code.values.length - 1) { + return Code.UNKNOWN.name; + } else { + return Code.values[code].name; + } } /// Parse error details into the right kind of GeneratedMessage. From 7076f88eded5547055ab015bd5859388ec7c38e9 Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Mon, 14 Sep 2020 17:50:37 -0400 Subject: [PATCH 09/21] Fixed status code parsing to be consistent | Fixed status code name parsing --- lib/src/client/call.dart | 17 ++++++++++------- lib/src/shared/status.dart | 7 +++++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/src/client/call.dart b/lib/src/client/call.dart index 283d7c14..f056c0d1 100644 --- a/lib/src/client/call.dart +++ b/lib/src/client/call.dart @@ -244,13 +244,16 @@ class ClientCall implements Response { _trailers.complete(metadata); // TODO(jakobr): Parse more! if (metadata.containsKey('grpc-status')) { - final status = int.parse(metadata['grpc-status']); - final message = metadata['grpc-message'] == null - ? null - : Uri.decodeFull(metadata['grpc-message']); - if (status != 0) { + final status = metadata['grpc-status']; + final statusCode = status != null ? int.parse(status) : 0; + + if (statusCode != 0) { + final message = metadata['grpc-message'] == null + ? null + : Uri.decodeFull(metadata['grpc-message']); + _responseError(GrpcError.custom( - status, + statusCode, message, _decodeStatusDetails(metadata['grpc-status-details-bin']), )); @@ -289,13 +292,13 @@ class ClientCall implements Response { // should contain "trailers" as well (Trailers-Only). _trailers.complete(_headerMetadata); final status = _headerMetadata['grpc-status']; - // If status code is missing, we must treat it as '0'. As in 'success'. final statusCode = status != null ? int.parse(status) : 0; if (statusCode != 0) { final message = _headerMetadata['grpc-message'] == null ? null : Uri.decodeFull(_headerMetadata['grpc-message']); + _responseError(GrpcError.custom( statusCode, message, diff --git a/lib/src/shared/status.dart b/lib/src/shared/status.dart index 52366885..1374f88c 100644 --- a/lib/src/shared/status.dart +++ b/lib/src/shared/status.dart @@ -279,7 +279,8 @@ class GrpcError implements Exception { int get hashCode => code.hashCode ^ (message?.hashCode ?? 17); @override - String toString() => 'gRPC Error ($code, $codeName, $message, $details)'; + String toString() => + 'gRPC Error (code: $code, codeName: $codeName, message: $message, details: $details)'; } /// Given a status code, return the name @@ -287,7 +288,9 @@ String getStatusCodeValue(int code) { if (code > Code.values.length - 1) { return Code.UNKNOWN.name; } else { - return Code.values[code].name; + return Code.values + .firstWhere((e) => e.value == code, orElse: () => Code.UNKNOWN) + .name; } } From f970c33a221c0c5b851bc78c4fa049683042d64c Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Wed, 16 Sep 2020 10:29:23 -0400 Subject: [PATCH 10/21] Bump protobuf dependency in examples and interop --- example/googleapis/pubspec.yaml | 2 +- example/grpc-web/pubspec.yaml | 2 +- example/metadata/pubspec.yaml | 2 +- interop/pubspec.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/googleapis/pubspec.yaml b/example/googleapis/pubspec.yaml index ba6fd4ec..dfd1a7d0 100644 --- a/example/googleapis/pubspec.yaml +++ b/example/googleapis/pubspec.yaml @@ -9,7 +9,7 @@ dependencies: async: ^2.2.0 grpc: path: ../../ - protobuf: ^0.13.12 + protobuf: ^1.0.1 dev_dependencies: test: ^1.6.4 diff --git a/example/grpc-web/pubspec.yaml b/example/grpc-web/pubspec.yaml index 6b396aea..a11b2378 100644 --- a/example/grpc-web/pubspec.yaml +++ b/example/grpc-web/pubspec.yaml @@ -8,7 +8,7 @@ environment: dependencies: grpc: path: ../../ - protobuf: ^0.13.4 + protobuf: ^1.0.1 dev_dependencies: build_runner: ^1.5.2 diff --git a/example/metadata/pubspec.yaml b/example/metadata/pubspec.yaml index 40f6a926..b96ec2ea 100644 --- a/example/metadata/pubspec.yaml +++ b/example/metadata/pubspec.yaml @@ -9,7 +9,7 @@ dependencies: async: ^2.2.0 grpc: path: ../../ - protobuf: ^0.13.12 + protobuf: ^1.0.1 dev_dependencies: test: ^1.6.0 diff --git a/interop/pubspec.yaml b/interop/pubspec.yaml index 6d83ed0f..283849d8 100644 --- a/interop/pubspec.yaml +++ b/interop/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: collection: ^1.14.11 grpc: path: ../ - protobuf: ^0.13.12 + protobuf: ^1.0.1 dev_dependencies: test: ^1.6.4 From 490b2b94d457ea44f620b8a28dfcdb6577f002f7 Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Thu, 17 Sep 2020 12:31:03 -0400 Subject: [PATCH 11/21] Fix googleapis generated protobuf files by running generator again --- .../src/generated/google/api/label.pb.dart | 42 ++- .../generated/google/api/label.pbenum.dart | 7 +- .../generated/google/api/label.pbjson.dart | 27 +- .../generated/google/api/launch_stage.pb.dart | 8 +- .../google/api/launch_stage.pbenum.dart | 11 +- .../google/api/launch_stage.pbjson.dart | 23 +- .../google/api/monitored_resource.pb.dart | 121 +++++--- .../google/api/monitored_resource.pbenum.dart | 5 +- .../google/api/monitored_resource.pbjson.dart | 61 ++-- .../google/logging/type/http_request.pb.dart | 116 ++++++-- .../logging/type/http_request.pbenum.dart | 5 +- .../logging/type/http_request.pbjson.dart | 51 ++-- .../google/logging/type/log_severity.pb.dart | 8 +- .../logging/type/log_severity.pbenum.dart | 7 +- .../logging/type/log_severity.pbjson.dart | 27 +- .../google/logging/v2/log_entry.pb.dart | 229 +++++++++----- .../google/logging/v2/log_entry.pbenum.dart | 5 +- .../google/logging/v2/log_entry.pbjson.dart | 145 ++++++--- .../google/logging/v2/logging.pb.dart | 281 ++++++++++++------ .../google/logging/v2/logging.pbenum.dart | 5 +- .../google/logging/v2/logging.pbgrpc.dart | 131 ++++---- .../google/logging/v2/logging.pbjson.dart | 238 +++++++++++---- .../src/generated/google/protobuf/any.pb.dart | 68 ++--- .../generated/google/protobuf/any.pbenum.dart | 5 +- .../generated/google/protobuf/any.pbjson.dart | 13 +- .../google/protobuf/duration.pb.dart | 37 ++- .../google/protobuf/duration.pbenum.dart | 5 +- .../google/protobuf/duration.pbjson.dart | 13 +- .../generated/google/protobuf/empty.pb.dart | 15 +- .../google/protobuf/empty.pbenum.dart | 5 +- .../google/protobuf/empty.pbjson.dart | 7 +- .../generated/google/protobuf/struct.pb.dart | 107 +++++-- .../google/protobuf/struct.pbenum.dart | 7 +- .../google/protobuf/struct.pbjson.dart | 76 +++-- .../google/protobuf/timestamp.pb.dart | 52 ++-- .../google/protobuf/timestamp.pbenum.dart | 5 +- .../google/protobuf/timestamp.pbjson.dart | 13 +- .../src/generated/google/rpc/status.pb.dart | 37 ++- .../generated/google/rpc/status.pbenum.dart | 5 +- .../generated/google/rpc/status.pbjson.dart | 15 +- 40 files changed, 1309 insertions(+), 729 deletions(-) diff --git a/example/googleapis/lib/src/generated/google/api/label.pb.dart b/example/googleapis/lib/src/generated/google/api/label.pb.dart index 2d4be19a..9f68f247 100644 --- a/example/googleapis/lib/src/generated/google/api/label.pb.dart +++ b/example/googleapis/lib/src/generated/google/api/label.pb.dart @@ -1,11 +1,11 @@ /// // Generated code. Do not modify. // source: google/api/label.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; @@ -15,15 +15,12 @@ export 'label.pbenum.dart'; class LabelDescriptor extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('LabelDescriptor', - package: const $pb.PackageName('google.api')) + package: const $pb.PackageName('google.api'), createEmptyInstance: create) ..aOS(1, 'key') - ..e( - 2, - 'valueType', - $pb.PbFieldType.OE, - LabelDescriptor_ValueType.STRING, - LabelDescriptor_ValueType.valueOf, - LabelDescriptor_ValueType.values) + ..e(2, 'valueType', $pb.PbFieldType.OE, + defaultOrMaker: LabelDescriptor_ValueType.STRING, + valueOf: LabelDescriptor_ValueType.valueOf, + enumValues: LabelDescriptor_ValueType.values) ..aOS(3, 'description') ..hasRequiredFields = false; @@ -44,31 +41,44 @@ class LabelDescriptor extends $pb.GeneratedMessage { LabelDescriptor createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static LabelDescriptor getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static LabelDescriptor getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static LabelDescriptor _defaultInstance; - $core.String get key => $_getS(0, ''); + @$pb.TagNumber(1) + $core.String get key => $_getSZ(0); + @$pb.TagNumber(1) set key($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) $core.bool hasKey() => $_has(0); + @$pb.TagNumber(1) void clearKey() => clearField(1); + @$pb.TagNumber(2) LabelDescriptor_ValueType get valueType => $_getN(1); + @$pb.TagNumber(2) set valueType(LabelDescriptor_ValueType v) { setField(2, v); } + @$pb.TagNumber(2) $core.bool hasValueType() => $_has(1); + @$pb.TagNumber(2) void clearValueType() => clearField(2); - $core.String get description => $_getS(2, ''); + @$pb.TagNumber(3) + $core.String get description => $_getSZ(2); + @$pb.TagNumber(3) set description($core.String v) { $_setString(2, v); } + @$pb.TagNumber(3) $core.bool hasDescription() => $_has(2); + @$pb.TagNumber(3) void clearDescription() => clearField(3); } diff --git a/example/googleapis/lib/src/generated/google/api/label.pbenum.dart b/example/googleapis/lib/src/generated/google/api/label.pbenum.dart index 597f9000..9c71c4cf 100644 --- a/example/googleapis/lib/src/generated/google/api/label.pbenum.dart +++ b/example/googleapis/lib/src/generated/google/api/label.pbenum.dart @@ -1,11 +1,12 @@ /// // Generated code. Do not modify. // source: google/api/label.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type // ignore_for_file: UNDEFINED_SHOWN_NAME,UNUSED_SHOWN_NAME -import 'dart:core' as $core show int, dynamic, String, List, Map; +import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; class LabelDescriptor_ValueType extends $pb.ProtobufEnum { diff --git a/example/googleapis/lib/src/generated/google/api/label.pbjson.dart b/example/googleapis/lib/src/generated/google/api/label.pbjson.dart index 4c5001c0..39fc673d 100644 --- a/example/googleapis/lib/src/generated/google/api/label.pbjson.dart +++ b/example/googleapis/lib/src/generated/google/api/label.pbjson.dart @@ -1,14 +1,15 @@ /// // Generated code. Do not modify. // source: google/api/label.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -const LabelDescriptor$json = { +const LabelDescriptor$json = const { '1': 'LabelDescriptor', - '2': [ - {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, - { + '2': const [ + const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, + const { '1': 'value_type', '3': 2, '4': 1, @@ -16,16 +17,16 @@ const LabelDescriptor$json = { '6': '.google.api.LabelDescriptor.ValueType', '10': 'valueType' }, - {'1': 'description', '3': 3, '4': 1, '5': 9, '10': 'description'}, + const {'1': 'description', '3': 3, '4': 1, '5': 9, '10': 'description'}, ], - '4': [LabelDescriptor_ValueType$json], + '4': const [LabelDescriptor_ValueType$json], }; -const LabelDescriptor_ValueType$json = { +const LabelDescriptor_ValueType$json = const { '1': 'ValueType', - '2': [ - {'1': 'STRING', '2': 0}, - {'1': 'BOOL', '2': 1}, - {'1': 'INT64', '2': 2}, + '2': const [ + const {'1': 'STRING', '2': 0}, + const {'1': 'BOOL', '2': 1}, + const {'1': 'INT64', '2': 2}, ], }; diff --git a/example/googleapis/lib/src/generated/google/api/launch_stage.pb.dart b/example/googleapis/lib/src/generated/google/api/launch_stage.pb.dart index 781e4279..7f477ab1 100644 --- a/example/googleapis/lib/src/generated/google/api/launch_stage.pb.dart +++ b/example/googleapis/lib/src/generated/google/api/launch_stage.pb.dart @@ -1,10 +1,10 @@ /// // Generated code. Do not modify. // source: google/api/launch_stage.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; export 'launch_stage.pbenum.dart'; diff --git a/example/googleapis/lib/src/generated/google/api/launch_stage.pbenum.dart b/example/googleapis/lib/src/generated/google/api/launch_stage.pbenum.dart index 03163675..aa20896c 100644 --- a/example/googleapis/lib/src/generated/google/api/launch_stage.pbenum.dart +++ b/example/googleapis/lib/src/generated/google/api/launch_stage.pbenum.dart @@ -1,16 +1,19 @@ /// // Generated code. Do not modify. // source: google/api/launch_stage.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type // ignore_for_file: UNDEFINED_SHOWN_NAME,UNUSED_SHOWN_NAME -import 'dart:core' as $core show int, dynamic, String, List, Map; +import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; class LaunchStage extends $pb.ProtobufEnum { static const LaunchStage LAUNCH_STAGE_UNSPECIFIED = LaunchStage._(0, 'LAUNCH_STAGE_UNSPECIFIED'); + static const LaunchStage UNIMPLEMENTED = LaunchStage._(6, 'UNIMPLEMENTED'); + static const LaunchStage PRELAUNCH = LaunchStage._(7, 'PRELAUNCH'); static const LaunchStage EARLY_ACCESS = LaunchStage._(1, 'EARLY_ACCESS'); static const LaunchStage ALPHA = LaunchStage._(2, 'ALPHA'); static const LaunchStage BETA = LaunchStage._(3, 'BETA'); @@ -19,6 +22,8 @@ class LaunchStage extends $pb.ProtobufEnum { static const $core.List values = [ LAUNCH_STAGE_UNSPECIFIED, + UNIMPLEMENTED, + PRELAUNCH, EARLY_ACCESS, ALPHA, BETA, diff --git a/example/googleapis/lib/src/generated/google/api/launch_stage.pbjson.dart b/example/googleapis/lib/src/generated/google/api/launch_stage.pbjson.dart index b1167768..25055c54 100644 --- a/example/googleapis/lib/src/generated/google/api/launch_stage.pbjson.dart +++ b/example/googleapis/lib/src/generated/google/api/launch_stage.pbjson.dart @@ -1,17 +1,20 @@ /// // Generated code. Do not modify. // source: google/api/launch_stage.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -const LaunchStage$json = { +const LaunchStage$json = const { '1': 'LaunchStage', - '2': [ - {'1': 'LAUNCH_STAGE_UNSPECIFIED', '2': 0}, - {'1': 'EARLY_ACCESS', '2': 1}, - {'1': 'ALPHA', '2': 2}, - {'1': 'BETA', '2': 3}, - {'1': 'GA', '2': 4}, - {'1': 'DEPRECATED', '2': 5}, + '2': const [ + const {'1': 'LAUNCH_STAGE_UNSPECIFIED', '2': 0}, + const {'1': 'UNIMPLEMENTED', '2': 6}, + const {'1': 'PRELAUNCH', '2': 7}, + const {'1': 'EARLY_ACCESS', '2': 1}, + const {'1': 'ALPHA', '2': 2}, + const {'1': 'BETA', '2': 3}, + const {'1': 'GA', '2': 4}, + const {'1': 'DEPRECATED', '2': 5}, ], }; diff --git a/example/googleapis/lib/src/generated/google/api/monitored_resource.pb.dart b/example/googleapis/lib/src/generated/google/api/monitored_resource.pb.dart index d4617673..2fbf7aa9 100644 --- a/example/googleapis/lib/src/generated/google/api/monitored_resource.pb.dart +++ b/example/googleapis/lib/src/generated/google/api/monitored_resource.pb.dart @@ -1,11 +1,11 @@ /// // Generated code. Do not modify. // source: google/api/monitored_resource.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; @@ -17,20 +17,18 @@ import 'launch_stage.pbenum.dart' as $2; class MonitoredResourceDescriptor extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo( 'MonitoredResourceDescriptor', - package: const $pb.PackageName('google.api')) + package: const $pb.PackageName('google.api'), + createEmptyInstance: create) ..aOS(1, 'type') ..aOS(2, 'displayName') ..aOS(3, 'description') - ..pc<$0.LabelDescriptor>( - 4, 'labels', $pb.PbFieldType.PM, $0.LabelDescriptor.create) + ..pc<$0.LabelDescriptor>(4, 'labels', $pb.PbFieldType.PM, + subBuilder: $0.LabelDescriptor.create) ..aOS(5, 'name') - ..e<$2.LaunchStage>( - 7, - 'launchStage', - $pb.PbFieldType.OE, - $2.LaunchStage.LAUNCH_STAGE_UNSPECIFIED, - $2.LaunchStage.valueOf, - $2.LaunchStage.values) + ..e<$2.LaunchStage>(7, 'launchStage', $pb.PbFieldType.OE, + defaultOrMaker: $2.LaunchStage.LAUNCH_STAGE_UNSPECIFIED, + valueOf: $2.LaunchStage.valueOf, + enumValues: $2.LaunchStage.values) ..hasRequiredFields = false; MonitoredResourceDescriptor._() : super(); @@ -54,67 +52,84 @@ class MonitoredResourceDescriptor extends $pb.GeneratedMessage { MonitoredResourceDescriptor createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static MonitoredResourceDescriptor getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static MonitoredResourceDescriptor getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static MonitoredResourceDescriptor _defaultInstance; - $core.String get type => $_getS(0, ''); + @$pb.TagNumber(1) + $core.String get type => $_getSZ(0); + @$pb.TagNumber(1) set type($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) $core.bool hasType() => $_has(0); + @$pb.TagNumber(1) void clearType() => clearField(1); - $core.String get displayName => $_getS(1, ''); + @$pb.TagNumber(2) + $core.String get displayName => $_getSZ(1); + @$pb.TagNumber(2) set displayName($core.String v) { $_setString(1, v); } + @$pb.TagNumber(2) $core.bool hasDisplayName() => $_has(1); + @$pb.TagNumber(2) void clearDisplayName() => clearField(2); - $core.String get description => $_getS(2, ''); + @$pb.TagNumber(3) + $core.String get description => $_getSZ(2); + @$pb.TagNumber(3) set description($core.String v) { $_setString(2, v); } + @$pb.TagNumber(3) $core.bool hasDescription() => $_has(2); + @$pb.TagNumber(3) void clearDescription() => clearField(3); + @$pb.TagNumber(4) $core.List<$0.LabelDescriptor> get labels => $_getList(3); - $core.String get name => $_getS(4, ''); + @$pb.TagNumber(5) + $core.String get name => $_getSZ(4); + @$pb.TagNumber(5) set name($core.String v) { $_setString(4, v); } + @$pb.TagNumber(5) $core.bool hasName() => $_has(4); + @$pb.TagNumber(5) void clearName() => clearField(5); + @$pb.TagNumber(7) $2.LaunchStage get launchStage => $_getN(5); + @$pb.TagNumber(7) set launchStage($2.LaunchStage v) { setField(7, v); } + @$pb.TagNumber(7) $core.bool hasLaunchStage() => $_has(5); + @$pb.TagNumber(7) void clearLaunchStage() => clearField(7); } class MonitoredResource extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('MonitoredResource', - package: const $pb.PackageName('google.api')) + package: const $pb.PackageName('google.api'), createEmptyInstance: create) ..aOS(1, 'type') - ..m<$core.String, $core.String>( - 2, - 'labels', - 'MonitoredResource.LabelsEntry', - $pb.PbFieldType.OS, - $pb.PbFieldType.OS, - null, - null, - null, - const $pb.PackageName('google.api')) + ..m<$core.String, $core.String>(2, 'labels', + entryClassName: 'MonitoredResource.LabelsEntry', + keyFieldType: $pb.PbFieldType.OS, + valueFieldType: $pb.PbFieldType.OS, + packageName: const $pb.PackageName('google.api')) ..hasRequiredFields = false; MonitoredResource._() : super(); @@ -134,36 +149,36 @@ class MonitoredResource extends $pb.GeneratedMessage { MonitoredResource createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static MonitoredResource getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static MonitoredResource getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static MonitoredResource _defaultInstance; - $core.String get type => $_getS(0, ''); + @$pb.TagNumber(1) + $core.String get type => $_getSZ(0); + @$pb.TagNumber(1) set type($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) $core.bool hasType() => $_has(0); + @$pb.TagNumber(1) void clearType() => clearField(1); + @$pb.TagNumber(2) $core.Map<$core.String, $core.String> get labels => $_getMap(1); } class MonitoredResourceMetadata extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('MonitoredResourceMetadata', - package: const $pb.PackageName('google.api')) - ..a<$1.Struct>(1, 'systemLabels', $pb.PbFieldType.OM, $1.Struct.getDefault, - $1.Struct.create) - ..m<$core.String, $core.String>( - 2, - 'userLabels', - 'MonitoredResourceMetadata.UserLabelsEntry', - $pb.PbFieldType.OS, - $pb.PbFieldType.OS, - null, - null, - null, - const $pb.PackageName('google.api')) + package: const $pb.PackageName('google.api'), createEmptyInstance: create) + ..aOM<$1.Struct>(1, 'systemLabels', subBuilder: $1.Struct.create) + ..m<$core.String, $core.String>(2, 'userLabels', + entryClassName: 'MonitoredResourceMetadata.UserLabelsEntry', + keyFieldType: $pb.PbFieldType.OS, + valueFieldType: $pb.PbFieldType.OS, + packageName: const $pb.PackageName('google.api')) ..hasRequiredFields = false; MonitoredResourceMetadata._() : super(); @@ -186,17 +201,25 @@ class MonitoredResourceMetadata extends $pb.GeneratedMessage { MonitoredResourceMetadata createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static MonitoredResourceMetadata getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static MonitoredResourceMetadata getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static MonitoredResourceMetadata _defaultInstance; + @$pb.TagNumber(1) $1.Struct get systemLabels => $_getN(0); + @$pb.TagNumber(1) set systemLabels($1.Struct v) { setField(1, v); } + @$pb.TagNumber(1) $core.bool hasSystemLabels() => $_has(0); + @$pb.TagNumber(1) void clearSystemLabels() => clearField(1); + @$pb.TagNumber(1) + $1.Struct ensureSystemLabels() => $_ensure(0); + @$pb.TagNumber(2) $core.Map<$core.String, $core.String> get userLabels => $_getMap(1); } diff --git a/example/googleapis/lib/src/generated/google/api/monitored_resource.pbenum.dart b/example/googleapis/lib/src/generated/google/api/monitored_resource.pbenum.dart index a5ff4d5a..782b5f1b 100644 --- a/example/googleapis/lib/src/generated/google/api/monitored_resource.pbenum.dart +++ b/example/googleapis/lib/src/generated/google/api/monitored_resource.pbenum.dart @@ -1,5 +1,6 @@ /// // Generated code. Do not modify. // source: google/api/monitored_resource.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type diff --git a/example/googleapis/lib/src/generated/google/api/monitored_resource.pbjson.dart b/example/googleapis/lib/src/generated/google/api/monitored_resource.pbjson.dart index 48686271..a12f4196 100644 --- a/example/googleapis/lib/src/generated/google/api/monitored_resource.pbjson.dart +++ b/example/googleapis/lib/src/generated/google/api/monitored_resource.pbjson.dart @@ -1,17 +1,18 @@ /// // Generated code. Do not modify. // source: google/api/monitored_resource.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -const MonitoredResourceDescriptor$json = { +const MonitoredResourceDescriptor$json = const { '1': 'MonitoredResourceDescriptor', - '2': [ - {'1': 'name', '3': 5, '4': 1, '5': 9, '10': 'name'}, - {'1': 'type', '3': 1, '4': 1, '5': 9, '10': 'type'}, - {'1': 'display_name', '3': 2, '4': 1, '5': 9, '10': 'displayName'}, - {'1': 'description', '3': 3, '4': 1, '5': 9, '10': 'description'}, - { + '2': const [ + const {'1': 'name', '3': 5, '4': 1, '5': 9, '10': 'name'}, + const {'1': 'type', '3': 1, '4': 1, '5': 9, '10': 'type'}, + const {'1': 'display_name', '3': 2, '4': 1, '5': 9, '10': 'displayName'}, + const {'1': 'description', '3': 3, '4': 1, '5': 9, '10': 'description'}, + const { '1': 'labels', '3': 4, '4': 3, @@ -19,7 +20,7 @@ const MonitoredResourceDescriptor$json = { '6': '.google.api.LabelDescriptor', '10': 'labels' }, - { + const { '1': 'launch_stage', '3': 7, '4': 1, @@ -30,11 +31,11 @@ const MonitoredResourceDescriptor$json = { ], }; -const MonitoredResource$json = { +const MonitoredResource$json = const { '1': 'MonitoredResource', - '2': [ - {'1': 'type', '3': 1, '4': 1, '5': 9, '10': 'type'}, - { + '2': const [ + const {'1': 'type', '3': 1, '4': 1, '5': 9, '10': 'type'}, + const { '1': 'labels', '3': 2, '4': 3, @@ -43,22 +44,22 @@ const MonitoredResource$json = { '10': 'labels' }, ], - '3': [MonitoredResource_LabelsEntry$json], + '3': const [MonitoredResource_LabelsEntry$json], }; -const MonitoredResource_LabelsEntry$json = { +const MonitoredResource_LabelsEntry$json = const { '1': 'LabelsEntry', - '2': [ - {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, - {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'}, + '2': const [ + const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, + const {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'}, ], - '7': {'7': true}, + '7': const {'7': true}, }; -const MonitoredResourceMetadata$json = { +const MonitoredResourceMetadata$json = const { '1': 'MonitoredResourceMetadata', - '2': [ - { + '2': const [ + const { '1': 'system_labels', '3': 1, '4': 1, @@ -66,7 +67,7 @@ const MonitoredResourceMetadata$json = { '6': '.google.protobuf.Struct', '10': 'systemLabels' }, - { + const { '1': 'user_labels', '3': 2, '4': 3, @@ -75,14 +76,14 @@ const MonitoredResourceMetadata$json = { '10': 'userLabels' }, ], - '3': [MonitoredResourceMetadata_UserLabelsEntry$json], + '3': const [MonitoredResourceMetadata_UserLabelsEntry$json], }; -const MonitoredResourceMetadata_UserLabelsEntry$json = { +const MonitoredResourceMetadata_UserLabelsEntry$json = const { '1': 'UserLabelsEntry', - '2': [ - {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, - {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'}, + '2': const [ + const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, + const {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'}, ], - '7': {'7': true}, + '7': const {'7': true}, }; diff --git a/example/googleapis/lib/src/generated/google/logging/type/http_request.pb.dart b/example/googleapis/lib/src/generated/google/logging/type/http_request.pb.dart index 1d1d1124..e470c72b 100644 --- a/example/googleapis/lib/src/generated/google/logging/type/http_request.pb.dart +++ b/example/googleapis/lib/src/generated/google/logging/type/http_request.pb.dart @@ -1,20 +1,21 @@ /// // Generated code. Do not modify. // source: google/logging/type/http_request.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; -import 'package:fixnum/fixnum.dart'; +import 'package:fixnum/fixnum.dart' as $fixnum; import 'package:protobuf/protobuf.dart' as $pb; import '../../protobuf/duration.pb.dart' as $0; class HttpRequest extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('HttpRequest', - package: const $pb.PackageName('google.logging.type')) + package: const $pb.PackageName('google.logging.type'), + createEmptyInstance: create) ..aOS(1, 'requestMethod') ..aOS(2, 'requestUrl') ..aInt64(3, 'requestSize') @@ -28,8 +29,7 @@ class HttpRequest extends $pb.GeneratedMessage { ..aOB(11, 'cacheLookup') ..aInt64(12, 'cacheFillBytes') ..aOS(13, 'serverIp') - ..a<$0.Duration>(14, 'latency', $pb.PbFieldType.OM, $0.Duration.getDefault, - $0.Duration.create) + ..aOM<$0.Duration>(14, 'latency', subBuilder: $0.Duration.create) ..aOS(15, 'protocol') ..hasRequiredFields = false; @@ -49,126 +49,190 @@ class HttpRequest extends $pb.GeneratedMessage { static HttpRequest create() => HttpRequest._(); HttpRequest createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static HttpRequest getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static HttpRequest getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static HttpRequest _defaultInstance; - $core.String get requestMethod => $_getS(0, ''); + @$pb.TagNumber(1) + $core.String get requestMethod => $_getSZ(0); + @$pb.TagNumber(1) set requestMethod($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) $core.bool hasRequestMethod() => $_has(0); + @$pb.TagNumber(1) void clearRequestMethod() => clearField(1); - $core.String get requestUrl => $_getS(1, ''); + @$pb.TagNumber(2) + $core.String get requestUrl => $_getSZ(1); + @$pb.TagNumber(2) set requestUrl($core.String v) { $_setString(1, v); } + @$pb.TagNumber(2) $core.bool hasRequestUrl() => $_has(1); + @$pb.TagNumber(2) void clearRequestUrl() => clearField(2); - Int64 get requestSize => $_getI64(2); - set requestSize(Int64 v) { + @$pb.TagNumber(3) + $fixnum.Int64 get requestSize => $_getI64(2); + @$pb.TagNumber(3) + set requestSize($fixnum.Int64 v) { $_setInt64(2, v); } + @$pb.TagNumber(3) $core.bool hasRequestSize() => $_has(2); + @$pb.TagNumber(3) void clearRequestSize() => clearField(3); - $core.int get status => $_get(3, 0); + @$pb.TagNumber(4) + $core.int get status => $_getIZ(3); + @$pb.TagNumber(4) set status($core.int v) { $_setSignedInt32(3, v); } + @$pb.TagNumber(4) $core.bool hasStatus() => $_has(3); + @$pb.TagNumber(4) void clearStatus() => clearField(4); - Int64 get responseSize => $_getI64(4); - set responseSize(Int64 v) { + @$pb.TagNumber(5) + $fixnum.Int64 get responseSize => $_getI64(4); + @$pb.TagNumber(5) + set responseSize($fixnum.Int64 v) { $_setInt64(4, v); } + @$pb.TagNumber(5) $core.bool hasResponseSize() => $_has(4); + @$pb.TagNumber(5) void clearResponseSize() => clearField(5); - $core.String get userAgent => $_getS(5, ''); + @$pb.TagNumber(6) + $core.String get userAgent => $_getSZ(5); + @$pb.TagNumber(6) set userAgent($core.String v) { $_setString(5, v); } + @$pb.TagNumber(6) $core.bool hasUserAgent() => $_has(5); + @$pb.TagNumber(6) void clearUserAgent() => clearField(6); - $core.String get remoteIp => $_getS(6, ''); + @$pb.TagNumber(7) + $core.String get remoteIp => $_getSZ(6); + @$pb.TagNumber(7) set remoteIp($core.String v) { $_setString(6, v); } + @$pb.TagNumber(7) $core.bool hasRemoteIp() => $_has(6); + @$pb.TagNumber(7) void clearRemoteIp() => clearField(7); - $core.String get referer => $_getS(7, ''); + @$pb.TagNumber(8) + $core.String get referer => $_getSZ(7); + @$pb.TagNumber(8) set referer($core.String v) { $_setString(7, v); } + @$pb.TagNumber(8) $core.bool hasReferer() => $_has(7); + @$pb.TagNumber(8) void clearReferer() => clearField(8); - $core.bool get cacheHit => $_get(8, false); + @$pb.TagNumber(9) + $core.bool get cacheHit => $_getBF(8); + @$pb.TagNumber(9) set cacheHit($core.bool v) { $_setBool(8, v); } + @$pb.TagNumber(9) $core.bool hasCacheHit() => $_has(8); + @$pb.TagNumber(9) void clearCacheHit() => clearField(9); - $core.bool get cacheValidatedWithOriginServer => $_get(9, false); + @$pb.TagNumber(10) + $core.bool get cacheValidatedWithOriginServer => $_getBF(9); + @$pb.TagNumber(10) set cacheValidatedWithOriginServer($core.bool v) { $_setBool(9, v); } + @$pb.TagNumber(10) $core.bool hasCacheValidatedWithOriginServer() => $_has(9); + @$pb.TagNumber(10) void clearCacheValidatedWithOriginServer() => clearField(10); - $core.bool get cacheLookup => $_get(10, false); + @$pb.TagNumber(11) + $core.bool get cacheLookup => $_getBF(10); + @$pb.TagNumber(11) set cacheLookup($core.bool v) { $_setBool(10, v); } + @$pb.TagNumber(11) $core.bool hasCacheLookup() => $_has(10); + @$pb.TagNumber(11) void clearCacheLookup() => clearField(11); - Int64 get cacheFillBytes => $_getI64(11); - set cacheFillBytes(Int64 v) { + @$pb.TagNumber(12) + $fixnum.Int64 get cacheFillBytes => $_getI64(11); + @$pb.TagNumber(12) + set cacheFillBytes($fixnum.Int64 v) { $_setInt64(11, v); } + @$pb.TagNumber(12) $core.bool hasCacheFillBytes() => $_has(11); + @$pb.TagNumber(12) void clearCacheFillBytes() => clearField(12); - $core.String get serverIp => $_getS(12, ''); + @$pb.TagNumber(13) + $core.String get serverIp => $_getSZ(12); + @$pb.TagNumber(13) set serverIp($core.String v) { $_setString(12, v); } + @$pb.TagNumber(13) $core.bool hasServerIp() => $_has(12); + @$pb.TagNumber(13) void clearServerIp() => clearField(13); + @$pb.TagNumber(14) $0.Duration get latency => $_getN(13); + @$pb.TagNumber(14) set latency($0.Duration v) { setField(14, v); } + @$pb.TagNumber(14) $core.bool hasLatency() => $_has(13); + @$pb.TagNumber(14) void clearLatency() => clearField(14); + @$pb.TagNumber(14) + $0.Duration ensureLatency() => $_ensure(13); - $core.String get protocol => $_getS(14, ''); + @$pb.TagNumber(15) + $core.String get protocol => $_getSZ(14); + @$pb.TagNumber(15) set protocol($core.String v) { $_setString(14, v); } + @$pb.TagNumber(15) $core.bool hasProtocol() => $_has(14); + @$pb.TagNumber(15) void clearProtocol() => clearField(15); } diff --git a/example/googleapis/lib/src/generated/google/logging/type/http_request.pbenum.dart b/example/googleapis/lib/src/generated/google/logging/type/http_request.pbenum.dart index 35ec20c1..07424eb6 100644 --- a/example/googleapis/lib/src/generated/google/logging/type/http_request.pbenum.dart +++ b/example/googleapis/lib/src/generated/google/logging/type/http_request.pbenum.dart @@ -1,5 +1,6 @@ /// // Generated code. Do not modify. // source: google/logging/type/http_request.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type diff --git a/example/googleapis/lib/src/generated/google/logging/type/http_request.pbjson.dart b/example/googleapis/lib/src/generated/google/logging/type/http_request.pbjson.dart index 61b5b039..451fafc1 100644 --- a/example/googleapis/lib/src/generated/google/logging/type/http_request.pbjson.dart +++ b/example/googleapis/lib/src/generated/google/logging/type/http_request.pbjson.dart @@ -1,22 +1,29 @@ /// // Generated code. Do not modify. // source: google/logging/type/http_request.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -const HttpRequest$json = { +const HttpRequest$json = const { '1': 'HttpRequest', - '2': [ - {'1': 'request_method', '3': 1, '4': 1, '5': 9, '10': 'requestMethod'}, - {'1': 'request_url', '3': 2, '4': 1, '5': 9, '10': 'requestUrl'}, - {'1': 'request_size', '3': 3, '4': 1, '5': 3, '10': 'requestSize'}, - {'1': 'status', '3': 4, '4': 1, '5': 5, '10': 'status'}, - {'1': 'response_size', '3': 5, '4': 1, '5': 3, '10': 'responseSize'}, - {'1': 'user_agent', '3': 6, '4': 1, '5': 9, '10': 'userAgent'}, - {'1': 'remote_ip', '3': 7, '4': 1, '5': 9, '10': 'remoteIp'}, - {'1': 'server_ip', '3': 13, '4': 1, '5': 9, '10': 'serverIp'}, - {'1': 'referer', '3': 8, '4': 1, '5': 9, '10': 'referer'}, - { + '2': const [ + const { + '1': 'request_method', + '3': 1, + '4': 1, + '5': 9, + '10': 'requestMethod' + }, + const {'1': 'request_url', '3': 2, '4': 1, '5': 9, '10': 'requestUrl'}, + const {'1': 'request_size', '3': 3, '4': 1, '5': 3, '10': 'requestSize'}, + const {'1': 'status', '3': 4, '4': 1, '5': 5, '10': 'status'}, + const {'1': 'response_size', '3': 5, '4': 1, '5': 3, '10': 'responseSize'}, + const {'1': 'user_agent', '3': 6, '4': 1, '5': 9, '10': 'userAgent'}, + const {'1': 'remote_ip', '3': 7, '4': 1, '5': 9, '10': 'remoteIp'}, + const {'1': 'server_ip', '3': 13, '4': 1, '5': 9, '10': 'serverIp'}, + const {'1': 'referer', '3': 8, '4': 1, '5': 9, '10': 'referer'}, + const { '1': 'latency', '3': 14, '4': 1, @@ -24,16 +31,22 @@ const HttpRequest$json = { '6': '.google.protobuf.Duration', '10': 'latency' }, - {'1': 'cache_lookup', '3': 11, '4': 1, '5': 8, '10': 'cacheLookup'}, - {'1': 'cache_hit', '3': 9, '4': 1, '5': 8, '10': 'cacheHit'}, - { + const {'1': 'cache_lookup', '3': 11, '4': 1, '5': 8, '10': 'cacheLookup'}, + const {'1': 'cache_hit', '3': 9, '4': 1, '5': 8, '10': 'cacheHit'}, + const { '1': 'cache_validated_with_origin_server', '3': 10, '4': 1, '5': 8, '10': 'cacheValidatedWithOriginServer' }, - {'1': 'cache_fill_bytes', '3': 12, '4': 1, '5': 3, '10': 'cacheFillBytes'}, - {'1': 'protocol', '3': 15, '4': 1, '5': 9, '10': 'protocol'}, + const { + '1': 'cache_fill_bytes', + '3': 12, + '4': 1, + '5': 3, + '10': 'cacheFillBytes' + }, + const {'1': 'protocol', '3': 15, '4': 1, '5': 9, '10': 'protocol'}, ], }; diff --git a/example/googleapis/lib/src/generated/google/logging/type/log_severity.pb.dart b/example/googleapis/lib/src/generated/google/logging/type/log_severity.pb.dart index 96953329..63896e06 100644 --- a/example/googleapis/lib/src/generated/google/logging/type/log_severity.pb.dart +++ b/example/googleapis/lib/src/generated/google/logging/type/log_severity.pb.dart @@ -1,10 +1,10 @@ /// // Generated code. Do not modify. // source: google/logging/type/log_severity.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; export 'log_severity.pbenum.dart'; diff --git a/example/googleapis/lib/src/generated/google/logging/type/log_severity.pbenum.dart b/example/googleapis/lib/src/generated/google/logging/type/log_severity.pbenum.dart index e2b867e6..72e25ae4 100644 --- a/example/googleapis/lib/src/generated/google/logging/type/log_severity.pbenum.dart +++ b/example/googleapis/lib/src/generated/google/logging/type/log_severity.pbenum.dart @@ -1,11 +1,12 @@ /// // Generated code. Do not modify. // source: google/logging/type/log_severity.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type // ignore_for_file: UNDEFINED_SHOWN_NAME,UNUSED_SHOWN_NAME -import 'dart:core' as $core show int, dynamic, String, List, Map; +import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; class LogSeverity extends $pb.ProtobufEnum { diff --git a/example/googleapis/lib/src/generated/google/logging/type/log_severity.pbjson.dart b/example/googleapis/lib/src/generated/google/logging/type/log_severity.pbjson.dart index 426206d7..c825ab04 100644 --- a/example/googleapis/lib/src/generated/google/logging/type/log_severity.pbjson.dart +++ b/example/googleapis/lib/src/generated/google/logging/type/log_severity.pbjson.dart @@ -1,20 +1,21 @@ /// // Generated code. Do not modify. // source: google/logging/type/log_severity.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -const LogSeverity$json = { +const LogSeverity$json = const { '1': 'LogSeverity', - '2': [ - {'1': 'DEFAULT', '2': 0}, - {'1': 'DEBUG', '2': 100}, - {'1': 'INFO', '2': 200}, - {'1': 'NOTICE', '2': 300}, - {'1': 'WARNING', '2': 400}, - {'1': 'ERROR', '2': 500}, - {'1': 'CRITICAL', '2': 600}, - {'1': 'ALERT', '2': 700}, - {'1': 'EMERGENCY', '2': 800}, + '2': const [ + const {'1': 'DEFAULT', '2': 0}, + const {'1': 'DEBUG', '2': 100}, + const {'1': 'INFO', '2': 200}, + const {'1': 'NOTICE', '2': 300}, + const {'1': 'WARNING', '2': 400}, + const {'1': 'ERROR', '2': 500}, + const {'1': 'CRITICAL', '2': 600}, + const {'1': 'ALERT', '2': 700}, + const {'1': 'EMERGENCY', '2': 800}, ], }; diff --git a/example/googleapis/lib/src/generated/google/logging/v2/log_entry.pb.dart b/example/googleapis/lib/src/generated/google/logging/v2/log_entry.pb.dart index 24ecf50d..318c16e9 100644 --- a/example/googleapis/lib/src/generated/google/logging/v2/log_entry.pb.dart +++ b/example/googleapis/lib/src/generated/google/logging/v2/log_entry.pb.dart @@ -1,13 +1,13 @@ /// // Generated code. Do not modify. // source: google/logging/v2/log_entry.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; -import 'package:fixnum/fixnum.dart'; +import 'package:fixnum/fixnum.dart' as $fixnum; import 'package:protobuf/protobuf.dart' as $pb; import '../../protobuf/any.pb.dart' as $0; @@ -28,41 +28,33 @@ class LogEntry extends $pb.GeneratedMessage { 0: LogEntry_Payload.notSet }; static final $pb.BuilderInfo _i = $pb.BuilderInfo('LogEntry', - package: const $pb.PackageName('google.logging.v2')) + package: const $pb.PackageName('google.logging.v2'), + createEmptyInstance: create) ..oo(0, [2, 3, 6]) - ..a<$0.Any>( - 2, 'protoPayload', $pb.PbFieldType.OM, $0.Any.getDefault, $0.Any.create) + ..aOM<$0.Any>(2, 'protoPayload', subBuilder: $0.Any.create) ..aOS(3, 'textPayload') ..aOS(4, 'insertId') - ..a<$1.Struct>(6, 'jsonPayload', $pb.PbFieldType.OM, $1.Struct.getDefault, - $1.Struct.create) - ..a<$2.HttpRequest>(7, 'httpRequest', $pb.PbFieldType.OM, - $2.HttpRequest.getDefault, $2.HttpRequest.create) - ..a<$3.MonitoredResource>(8, 'resource', $pb.PbFieldType.OM, - $3.MonitoredResource.getDefault, $3.MonitoredResource.create) - ..a<$4.Timestamp>(9, 'timestamp', $pb.PbFieldType.OM, - $4.Timestamp.getDefault, $4.Timestamp.create) + ..aOM<$1.Struct>(6, 'jsonPayload', subBuilder: $1.Struct.create) + ..aOM<$2.HttpRequest>(7, 'httpRequest', subBuilder: $2.HttpRequest.create) + ..aOM<$3.MonitoredResource>(8, 'resource', + subBuilder: $3.MonitoredResource.create) + ..aOM<$4.Timestamp>(9, 'timestamp', subBuilder: $4.Timestamp.create) ..e<$5.LogSeverity>(10, 'severity', $pb.PbFieldType.OE, - $5.LogSeverity.DEFAULT, $5.LogSeverity.valueOf, $5.LogSeverity.values) - ..m<$core.String, $core.String>( - 11, - 'labels', - 'LogEntry.LabelsEntry', - $pb.PbFieldType.OS, - $pb.PbFieldType.OS, - null, - null, - null, - const $pb.PackageName('google.logging.v2')) + defaultOrMaker: $5.LogSeverity.DEFAULT, + valueOf: $5.LogSeverity.valueOf, + enumValues: $5.LogSeverity.values) + ..m<$core.String, $core.String>(11, 'labels', + entryClassName: 'LogEntry.LabelsEntry', + keyFieldType: $pb.PbFieldType.OS, + valueFieldType: $pb.PbFieldType.OS, + packageName: const $pb.PackageName('google.logging.v2')) ..aOS(12, 'logName') - ..a(15, 'operation', $pb.PbFieldType.OM, - LogEntryOperation.getDefault, LogEntryOperation.create) + ..aOM(15, 'operation', + subBuilder: LogEntryOperation.create) ..aOS(22, 'trace') - ..a(23, 'sourceLocation', $pb.PbFieldType.OM, - LogEntrySourceLocation.getDefault, LogEntrySourceLocation.create) - ..a<$4.Timestamp>( - 24, 'receiveTimestamp', $pb.PbFieldType.OM, $4.Timestamp.getDefault, $4.Timestamp.create) - ..a<$3.MonitoredResourceMetadata>(25, 'metadata', $pb.PbFieldType.OM, $3.MonitoredResourceMetadata.getDefault, $3.MonitoredResourceMetadata.create) + ..aOM(23, 'sourceLocation', + subBuilder: LogEntrySourceLocation.create) + ..aOM<$4.Timestamp>(24, 'receiveTimestamp', subBuilder: $4.Timestamp.create) ..aOS(27, 'spanId') ..aOB(30, 'traceSampled') ..hasRequiredFields = false; @@ -83,146 +75,218 @@ class LogEntry extends $pb.GeneratedMessage { static LogEntry create() => LogEntry._(); LogEntry createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static LogEntry getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static LogEntry getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); static LogEntry _defaultInstance; LogEntry_Payload whichPayload() => _LogEntry_PayloadByTag[$_whichOneof(0)]; void clearPayload() => clearField($_whichOneof(0)); + @$pb.TagNumber(2) $0.Any get protoPayload => $_getN(0); + @$pb.TagNumber(2) set protoPayload($0.Any v) { setField(2, v); } + @$pb.TagNumber(2) $core.bool hasProtoPayload() => $_has(0); + @$pb.TagNumber(2) void clearProtoPayload() => clearField(2); + @$pb.TagNumber(2) + $0.Any ensureProtoPayload() => $_ensure(0); - $core.String get textPayload => $_getS(1, ''); + @$pb.TagNumber(3) + $core.String get textPayload => $_getSZ(1); + @$pb.TagNumber(3) set textPayload($core.String v) { $_setString(1, v); } + @$pb.TagNumber(3) $core.bool hasTextPayload() => $_has(1); + @$pb.TagNumber(3) void clearTextPayload() => clearField(3); - $core.String get insertId => $_getS(2, ''); + @$pb.TagNumber(4) + $core.String get insertId => $_getSZ(2); + @$pb.TagNumber(4) set insertId($core.String v) { $_setString(2, v); } + @$pb.TagNumber(4) $core.bool hasInsertId() => $_has(2); + @$pb.TagNumber(4) void clearInsertId() => clearField(4); + @$pb.TagNumber(6) $1.Struct get jsonPayload => $_getN(3); + @$pb.TagNumber(6) set jsonPayload($1.Struct v) { setField(6, v); } + @$pb.TagNumber(6) $core.bool hasJsonPayload() => $_has(3); + @$pb.TagNumber(6) void clearJsonPayload() => clearField(6); + @$pb.TagNumber(6) + $1.Struct ensureJsonPayload() => $_ensure(3); + @$pb.TagNumber(7) $2.HttpRequest get httpRequest => $_getN(4); + @$pb.TagNumber(7) set httpRequest($2.HttpRequest v) { setField(7, v); } + @$pb.TagNumber(7) $core.bool hasHttpRequest() => $_has(4); + @$pb.TagNumber(7) void clearHttpRequest() => clearField(7); + @$pb.TagNumber(7) + $2.HttpRequest ensureHttpRequest() => $_ensure(4); + @$pb.TagNumber(8) $3.MonitoredResource get resource => $_getN(5); + @$pb.TagNumber(8) set resource($3.MonitoredResource v) { setField(8, v); } + @$pb.TagNumber(8) $core.bool hasResource() => $_has(5); + @$pb.TagNumber(8) void clearResource() => clearField(8); + @$pb.TagNumber(8) + $3.MonitoredResource ensureResource() => $_ensure(5); + @$pb.TagNumber(9) $4.Timestamp get timestamp => $_getN(6); + @$pb.TagNumber(9) set timestamp($4.Timestamp v) { setField(9, v); } + @$pb.TagNumber(9) $core.bool hasTimestamp() => $_has(6); + @$pb.TagNumber(9) void clearTimestamp() => clearField(9); + @$pb.TagNumber(9) + $4.Timestamp ensureTimestamp() => $_ensure(6); + @$pb.TagNumber(10) $5.LogSeverity get severity => $_getN(7); + @$pb.TagNumber(10) set severity($5.LogSeverity v) { setField(10, v); } + @$pb.TagNumber(10) $core.bool hasSeverity() => $_has(7); + @$pb.TagNumber(10) void clearSeverity() => clearField(10); + @$pb.TagNumber(11) $core.Map<$core.String, $core.String> get labels => $_getMap(8); - $core.String get logName => $_getS(9, ''); + @$pb.TagNumber(12) + $core.String get logName => $_getSZ(9); + @$pb.TagNumber(12) set logName($core.String v) { $_setString(9, v); } + @$pb.TagNumber(12) $core.bool hasLogName() => $_has(9); + @$pb.TagNumber(12) void clearLogName() => clearField(12); + @$pb.TagNumber(15) LogEntryOperation get operation => $_getN(10); + @$pb.TagNumber(15) set operation(LogEntryOperation v) { setField(15, v); } + @$pb.TagNumber(15) $core.bool hasOperation() => $_has(10); + @$pb.TagNumber(15) void clearOperation() => clearField(15); + @$pb.TagNumber(15) + LogEntryOperation ensureOperation() => $_ensure(10); - $core.String get trace => $_getS(11, ''); + @$pb.TagNumber(22) + $core.String get trace => $_getSZ(11); + @$pb.TagNumber(22) set trace($core.String v) { $_setString(11, v); } + @$pb.TagNumber(22) $core.bool hasTrace() => $_has(11); + @$pb.TagNumber(22) void clearTrace() => clearField(22); + @$pb.TagNumber(23) LogEntrySourceLocation get sourceLocation => $_getN(12); + @$pb.TagNumber(23) set sourceLocation(LogEntrySourceLocation v) { setField(23, v); } + @$pb.TagNumber(23) $core.bool hasSourceLocation() => $_has(12); + @$pb.TagNumber(23) void clearSourceLocation() => clearField(23); + @$pb.TagNumber(23) + LogEntrySourceLocation ensureSourceLocation() => $_ensure(12); + @$pb.TagNumber(24) $4.Timestamp get receiveTimestamp => $_getN(13); + @$pb.TagNumber(24) set receiveTimestamp($4.Timestamp v) { setField(24, v); } + @$pb.TagNumber(24) $core.bool hasReceiveTimestamp() => $_has(13); + @$pb.TagNumber(24) void clearReceiveTimestamp() => clearField(24); + @$pb.TagNumber(24) + $4.Timestamp ensureReceiveTimestamp() => $_ensure(13); - $3.MonitoredResourceMetadata get metadata => $_getN(14); - set metadata($3.MonitoredResourceMetadata v) { - setField(25, v); - } - - $core.bool hasMetadata() => $_has(14); - void clearMetadata() => clearField(25); - - $core.String get spanId => $_getS(15, ''); + @$pb.TagNumber(27) + $core.String get spanId => $_getSZ(14); + @$pb.TagNumber(27) set spanId($core.String v) { - $_setString(15, v); + $_setString(14, v); } - $core.bool hasSpanId() => $_has(15); + @$pb.TagNumber(27) + $core.bool hasSpanId() => $_has(14); + @$pb.TagNumber(27) void clearSpanId() => clearField(27); - $core.bool get traceSampled => $_get(16, false); + @$pb.TagNumber(30) + $core.bool get traceSampled => $_getBF(15); + @$pb.TagNumber(30) set traceSampled($core.bool v) { - $_setBool(16, v); + $_setBool(15, v); } - $core.bool hasTraceSampled() => $_has(16); + @$pb.TagNumber(30) + $core.bool hasTraceSampled() => $_has(15); + @$pb.TagNumber(30) void clearTraceSampled() => clearField(30); } class LogEntryOperation extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('LogEntryOperation', - package: const $pb.PackageName('google.logging.v2')) + package: const $pb.PackageName('google.logging.v2'), + createEmptyInstance: create) ..aOS(1, 'id') ..aOS(2, 'producer') ..aOB(3, 'first') @@ -246,46 +310,64 @@ class LogEntryOperation extends $pb.GeneratedMessage { LogEntryOperation createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static LogEntryOperation getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static LogEntryOperation getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static LogEntryOperation _defaultInstance; - $core.String get id => $_getS(0, ''); + @$pb.TagNumber(1) + $core.String get id => $_getSZ(0); + @$pb.TagNumber(1) set id($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) $core.bool hasId() => $_has(0); + @$pb.TagNumber(1) void clearId() => clearField(1); - $core.String get producer => $_getS(1, ''); + @$pb.TagNumber(2) + $core.String get producer => $_getSZ(1); + @$pb.TagNumber(2) set producer($core.String v) { $_setString(1, v); } + @$pb.TagNumber(2) $core.bool hasProducer() => $_has(1); + @$pb.TagNumber(2) void clearProducer() => clearField(2); - $core.bool get first => $_get(2, false); + @$pb.TagNumber(3) + $core.bool get first => $_getBF(2); + @$pb.TagNumber(3) set first($core.bool v) { $_setBool(2, v); } + @$pb.TagNumber(3) $core.bool hasFirst() => $_has(2); + @$pb.TagNumber(3) void clearFirst() => clearField(3); - $core.bool get last => $_get(3, false); + @$pb.TagNumber(4) + $core.bool get last => $_getBF(3); + @$pb.TagNumber(4) set last($core.bool v) { $_setBool(3, v); } + @$pb.TagNumber(4) $core.bool hasLast() => $_has(3); + @$pb.TagNumber(4) void clearLast() => clearField(4); } class LogEntrySourceLocation extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('LogEntrySourceLocation', - package: const $pb.PackageName('google.logging.v2')) + package: const $pb.PackageName('google.logging.v2'), + createEmptyInstance: create) ..aOS(1, 'file') ..aInt64(2, 'line') ..aOS(3, 'function') @@ -310,31 +392,44 @@ class LogEntrySourceLocation extends $pb.GeneratedMessage { LogEntrySourceLocation createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static LogEntrySourceLocation getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static LogEntrySourceLocation getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static LogEntrySourceLocation _defaultInstance; - $core.String get file => $_getS(0, ''); + @$pb.TagNumber(1) + $core.String get file => $_getSZ(0); + @$pb.TagNumber(1) set file($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) $core.bool hasFile() => $_has(0); + @$pb.TagNumber(1) void clearFile() => clearField(1); - Int64 get line => $_getI64(1); - set line(Int64 v) { + @$pb.TagNumber(2) + $fixnum.Int64 get line => $_getI64(1); + @$pb.TagNumber(2) + set line($fixnum.Int64 v) { $_setInt64(1, v); } + @$pb.TagNumber(2) $core.bool hasLine() => $_has(1); + @$pb.TagNumber(2) void clearLine() => clearField(2); - $core.String get function => $_getS(2, ''); + @$pb.TagNumber(3) + $core.String get function => $_getSZ(2); + @$pb.TagNumber(3) set function($core.String v) { $_setString(2, v); } + @$pb.TagNumber(3) $core.bool hasFunction() => $_has(2); + @$pb.TagNumber(3) void clearFunction() => clearField(3); } diff --git a/example/googleapis/lib/src/generated/google/logging/v2/log_entry.pbenum.dart b/example/googleapis/lib/src/generated/google/logging/v2/log_entry.pbenum.dart index 7cb0a323..d602707c 100644 --- a/example/googleapis/lib/src/generated/google/logging/v2/log_entry.pbenum.dart +++ b/example/googleapis/lib/src/generated/google/logging/v2/log_entry.pbenum.dart @@ -1,5 +1,6 @@ /// // Generated code. Do not modify. // source: google/logging/v2/log_entry.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type diff --git a/example/googleapis/lib/src/generated/google/logging/v2/log_entry.pbjson.dart b/example/googleapis/lib/src/generated/google/logging/v2/log_entry.pbjson.dart index bc6159d3..9b3a2fb1 100644 --- a/example/googleapis/lib/src/generated/google/logging/v2/log_entry.pbjson.dart +++ b/example/googleapis/lib/src/generated/google/logging/v2/log_entry.pbjson.dart @@ -1,22 +1,31 @@ /// // Generated code. Do not modify. // source: google/logging/v2/log_entry.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -const LogEntry$json = { +const LogEntry$json = const { '1': 'LogEntry', - '2': [ - {'1': 'log_name', '3': 12, '4': 1, '5': 9, '10': 'logName'}, - { + '2': const [ + const { + '1': 'log_name', + '3': 12, + '4': 1, + '5': 9, + '8': const {}, + '10': 'logName' + }, + const { '1': 'resource', '3': 8, '4': 1, '5': 11, '6': '.google.api.MonitoredResource', + '8': const {}, '10': 'resource' }, - { + const { '1': 'proto_payload', '3': 2, '4': 1, @@ -25,8 +34,15 @@ const LogEntry$json = { '9': 0, '10': 'protoPayload' }, - {'1': 'text_payload', '3': 3, '4': 1, '5': 9, '9': 0, '10': 'textPayload'}, - { + const { + '1': 'text_payload', + '3': 3, + '4': 1, + '5': 9, + '9': 0, + '10': 'textPayload' + }, + const { '1': 'json_payload', '3': 6, '4': 1, @@ -35,105 +51,140 @@ const LogEntry$json = { '9': 0, '10': 'jsonPayload' }, - { + const { '1': 'timestamp', '3': 9, '4': 1, '5': 11, '6': '.google.protobuf.Timestamp', + '8': const {}, '10': 'timestamp' }, - { + const { '1': 'receive_timestamp', '3': 24, '4': 1, '5': 11, '6': '.google.protobuf.Timestamp', + '8': const {}, '10': 'receiveTimestamp' }, - { + const { '1': 'severity', '3': 10, '4': 1, '5': 14, '6': '.google.logging.type.LogSeverity', + '8': const {}, '10': 'severity' }, - {'1': 'insert_id', '3': 4, '4': 1, '5': 9, '10': 'insertId'}, - { + const { + '1': 'insert_id', + '3': 4, + '4': 1, + '5': 9, + '8': const {}, + '10': 'insertId' + }, + const { '1': 'http_request', '3': 7, '4': 1, '5': 11, '6': '.google.logging.type.HttpRequest', + '8': const {}, '10': 'httpRequest' }, - { + const { '1': 'labels', '3': 11, '4': 3, '5': 11, '6': '.google.logging.v2.LogEntry.LabelsEntry', + '8': const {}, '10': 'labels' }, - { - '1': 'metadata', - '3': 25, - '4': 1, - '5': 11, - '6': '.google.api.MonitoredResourceMetadata', - '10': 'metadata' - }, - { + const { '1': 'operation', '3': 15, '4': 1, '5': 11, '6': '.google.logging.v2.LogEntryOperation', + '8': const {}, '10': 'operation' }, - {'1': 'trace', '3': 22, '4': 1, '5': 9, '10': 'trace'}, - {'1': 'span_id', '3': 27, '4': 1, '5': 9, '10': 'spanId'}, - {'1': 'trace_sampled', '3': 30, '4': 1, '5': 8, '10': 'traceSampled'}, - { + const {'1': 'trace', '3': 22, '4': 1, '5': 9, '8': const {}, '10': 'trace'}, + const { + '1': 'span_id', + '3': 27, + '4': 1, + '5': 9, + '8': const {}, + '10': 'spanId' + }, + const { + '1': 'trace_sampled', + '3': 30, + '4': 1, + '5': 8, + '8': const {}, + '10': 'traceSampled' + }, + const { '1': 'source_location', '3': 23, '4': 1, '5': 11, '6': '.google.logging.v2.LogEntrySourceLocation', + '8': const {}, '10': 'sourceLocation' }, ], - '3': [LogEntry_LabelsEntry$json], - '8': [ - {'1': 'payload'}, + '3': const [LogEntry_LabelsEntry$json], + '7': const {}, + '8': const [ + const {'1': 'payload'}, ], }; -const LogEntry_LabelsEntry$json = { +const LogEntry_LabelsEntry$json = const { '1': 'LabelsEntry', - '2': [ - {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, - {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'}, + '2': const [ + const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, + const {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'}, ], - '7': {'7': true}, + '7': const {'7': true}, }; -const LogEntryOperation$json = { +const LogEntryOperation$json = const { '1': 'LogEntryOperation', - '2': [ - {'1': 'id', '3': 1, '4': 1, '5': 9, '10': 'id'}, - {'1': 'producer', '3': 2, '4': 1, '5': 9, '10': 'producer'}, - {'1': 'first', '3': 3, '4': 1, '5': 8, '10': 'first'}, - {'1': 'last', '3': 4, '4': 1, '5': 8, '10': 'last'}, + '2': const [ + const {'1': 'id', '3': 1, '4': 1, '5': 9, '8': const {}, '10': 'id'}, + const { + '1': 'producer', + '3': 2, + '4': 1, + '5': 9, + '8': const {}, + '10': 'producer' + }, + const {'1': 'first', '3': 3, '4': 1, '5': 8, '8': const {}, '10': 'first'}, + const {'1': 'last', '3': 4, '4': 1, '5': 8, '8': const {}, '10': 'last'}, ], }; -const LogEntrySourceLocation$json = { +const LogEntrySourceLocation$json = const { '1': 'LogEntrySourceLocation', - '2': [ - {'1': 'file', '3': 1, '4': 1, '5': 9, '10': 'file'}, - {'1': 'line', '3': 2, '4': 1, '5': 3, '10': 'line'}, - {'1': 'function', '3': 3, '4': 1, '5': 9, '10': 'function'}, + '2': const [ + const {'1': 'file', '3': 1, '4': 1, '5': 9, '8': const {}, '10': 'file'}, + const {'1': 'line', '3': 2, '4': 1, '5': 3, '8': const {}, '10': 'line'}, + const { + '1': 'function', + '3': 3, + '4': 1, + '5': 9, + '8': const {}, + '10': 'function' + }, ], }; diff --git a/example/googleapis/lib/src/generated/google/logging/v2/logging.pb.dart b/example/googleapis/lib/src/generated/google/logging/v2/logging.pb.dart index a24744a0..afc23fb5 100644 --- a/example/googleapis/lib/src/generated/google/logging/v2/logging.pb.dart +++ b/example/googleapis/lib/src/generated/google/logging/v2/logging.pb.dart @@ -1,21 +1,22 @@ /// // Generated code. Do not modify. // source: google/logging/v2/logging.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; -import '../../api/monitored_resource.pb.dart' as $2; -import 'log_entry.pb.dart' as $3; -import '../../rpc/status.pb.dart' as $4; +import '../../api/monitored_resource.pb.dart' as $3; +import 'log_entry.pb.dart' as $4; +import '../../rpc/status.pb.dart' as $5; class DeleteLogRequest extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('DeleteLogRequest', - package: const $pb.PackageName('google.logging.v2')) + package: const $pb.PackageName('google.logging.v2'), + createEmptyInstance: create) ..aOS(1, 'logName') ..hasRequiredFields = false; @@ -36,36 +37,38 @@ class DeleteLogRequest extends $pb.GeneratedMessage { DeleteLogRequest createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static DeleteLogRequest getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static DeleteLogRequest getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static DeleteLogRequest _defaultInstance; - $core.String get logName => $_getS(0, ''); + @$pb.TagNumber(1) + $core.String get logName => $_getSZ(0); + @$pb.TagNumber(1) set logName($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) $core.bool hasLogName() => $_has(0); + @$pb.TagNumber(1) void clearLogName() => clearField(1); } class WriteLogEntriesRequest extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('WriteLogEntriesRequest', - package: const $pb.PackageName('google.logging.v2')) + package: const $pb.PackageName('google.logging.v2'), + createEmptyInstance: create) ..aOS(1, 'logName') - ..a<$2.MonitoredResource>(2, 'resource', $pb.PbFieldType.OM, - $2.MonitoredResource.getDefault, $2.MonitoredResource.create) - ..m<$core.String, $core.String>( - 3, - 'labels', - 'WriteLogEntriesRequest.LabelsEntry', - $pb.PbFieldType.OS, - $pb.PbFieldType.OS, - null, - null, - null, - const $pb.PackageName('google.logging.v2')) - ..pc<$3.LogEntry>(4, 'entries', $pb.PbFieldType.PM, $3.LogEntry.create) + ..aOM<$3.MonitoredResource>(2, 'resource', + subBuilder: $3.MonitoredResource.create) + ..m<$core.String, $core.String>(3, 'labels', + entryClassName: 'WriteLogEntriesRequest.LabelsEntry', + keyFieldType: $pb.PbFieldType.OS, + valueFieldType: $pb.PbFieldType.OS, + packageName: const $pb.PackageName('google.logging.v2')) + ..pc<$4.LogEntry>(4, 'entries', $pb.PbFieldType.PM, + subBuilder: $4.LogEntry.create) ..aOB(5, 'partialSuccess') ..aOB(6, 'dryRun') ..hasRequiredFields = false; @@ -89,50 +92,72 @@ class WriteLogEntriesRequest extends $pb.GeneratedMessage { WriteLogEntriesRequest createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static WriteLogEntriesRequest getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static WriteLogEntriesRequest getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static WriteLogEntriesRequest _defaultInstance; - $core.String get logName => $_getS(0, ''); + @$pb.TagNumber(1) + $core.String get logName => $_getSZ(0); + @$pb.TagNumber(1) set logName($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) $core.bool hasLogName() => $_has(0); + @$pb.TagNumber(1) void clearLogName() => clearField(1); - $2.MonitoredResource get resource => $_getN(1); - set resource($2.MonitoredResource v) { + @$pb.TagNumber(2) + $3.MonitoredResource get resource => $_getN(1); + @$pb.TagNumber(2) + set resource($3.MonitoredResource v) { setField(2, v); } + @$pb.TagNumber(2) $core.bool hasResource() => $_has(1); + @$pb.TagNumber(2) void clearResource() => clearField(2); + @$pb.TagNumber(2) + $3.MonitoredResource ensureResource() => $_ensure(1); + @$pb.TagNumber(3) $core.Map<$core.String, $core.String> get labels => $_getMap(2); - $core.List<$3.LogEntry> get entries => $_getList(3); + @$pb.TagNumber(4) + $core.List<$4.LogEntry> get entries => $_getList(3); - $core.bool get partialSuccess => $_get(4, false); + @$pb.TagNumber(5) + $core.bool get partialSuccess => $_getBF(4); + @$pb.TagNumber(5) set partialSuccess($core.bool v) { $_setBool(4, v); } + @$pb.TagNumber(5) $core.bool hasPartialSuccess() => $_has(4); + @$pb.TagNumber(5) void clearPartialSuccess() => clearField(5); - $core.bool get dryRun => $_get(5, false); + @$pb.TagNumber(6) + $core.bool get dryRun => $_getBF(5); + @$pb.TagNumber(6) set dryRun($core.bool v) { $_setBool(5, v); } + @$pb.TagNumber(6) $core.bool hasDryRun() => $_has(5); + @$pb.TagNumber(6) void clearDryRun() => clearField(6); } class WriteLogEntriesResponse extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('WriteLogEntriesResponse', - package: const $pb.PackageName('google.logging.v2')) + package: const $pb.PackageName('google.logging.v2'), + createEmptyInstance: create) ..hasRequiredFields = false; WriteLogEntriesResponse._() : super(); @@ -154,25 +179,23 @@ class WriteLogEntriesResponse extends $pb.GeneratedMessage { WriteLogEntriesResponse createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static WriteLogEntriesResponse getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static WriteLogEntriesResponse getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static WriteLogEntriesResponse _defaultInstance; } class WriteLogEntriesPartialErrors extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo( 'WriteLogEntriesPartialErrors', - package: const $pb.PackageName('google.logging.v2')) - ..m<$core.int, $4.Status>( - 1, - 'logEntryErrors', - 'WriteLogEntriesPartialErrors.LogEntryErrorsEntry', - $pb.PbFieldType.O3, - $pb.PbFieldType.OM, - $4.Status.create, - null, - null, - const $pb.PackageName('google.logging.v2')) + package: const $pb.PackageName('google.logging.v2'), + createEmptyInstance: create) + ..m<$core.int, $5.Status>(1, 'logEntryErrors', + entryClassName: 'WriteLogEntriesPartialErrors.LogEntryErrorsEntry', + keyFieldType: $pb.PbFieldType.O3, + valueFieldType: $pb.PbFieldType.OM, + valueCreator: $5.Status.create, + packageName: const $pb.PackageName('google.logging.v2')) ..hasRequiredFields = false; WriteLogEntriesPartialErrors._() : super(); @@ -196,17 +219,19 @@ class WriteLogEntriesPartialErrors extends $pb.GeneratedMessage { WriteLogEntriesPartialErrors createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static WriteLogEntriesPartialErrors getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static WriteLogEntriesPartialErrors getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static WriteLogEntriesPartialErrors _defaultInstance; - $core.Map<$core.int, $4.Status> get logEntryErrors => $_getMap(0); + @$pb.TagNumber(1) + $core.Map<$core.int, $5.Status> get logEntryErrors => $_getMap(0); } class ListLogEntriesRequest extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('ListLogEntriesRequest', - package: const $pb.PackageName('google.logging.v2')) - ..pPS(1, 'projectIds') + package: const $pb.PackageName('google.logging.v2'), + createEmptyInstance: create) ..aOS(2, 'filter') ..aOS(3, 'orderBy') ..a<$core.int>(4, 'pageSize', $pb.PbFieldType.O3) @@ -233,52 +258,69 @@ class ListLogEntriesRequest extends $pb.GeneratedMessage { ListLogEntriesRequest createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static ListLogEntriesRequest getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static ListLogEntriesRequest getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static ListLogEntriesRequest _defaultInstance; - @$core.Deprecated('This field is deprecated.') - $core.List<$core.String> get projectIds => $_getList(0); - - $core.String get filter => $_getS(1, ''); + @$pb.TagNumber(2) + $core.String get filter => $_getSZ(0); + @$pb.TagNumber(2) set filter($core.String v) { - $_setString(1, v); + $_setString(0, v); } - $core.bool hasFilter() => $_has(1); + @$pb.TagNumber(2) + $core.bool hasFilter() => $_has(0); + @$pb.TagNumber(2) void clearFilter() => clearField(2); - $core.String get orderBy => $_getS(2, ''); + @$pb.TagNumber(3) + $core.String get orderBy => $_getSZ(1); + @$pb.TagNumber(3) set orderBy($core.String v) { - $_setString(2, v); + $_setString(1, v); } - $core.bool hasOrderBy() => $_has(2); + @$pb.TagNumber(3) + $core.bool hasOrderBy() => $_has(1); + @$pb.TagNumber(3) void clearOrderBy() => clearField(3); - $core.int get pageSize => $_get(3, 0); + @$pb.TagNumber(4) + $core.int get pageSize => $_getIZ(2); + @$pb.TagNumber(4) set pageSize($core.int v) { - $_setSignedInt32(3, v); + $_setSignedInt32(2, v); } - $core.bool hasPageSize() => $_has(3); + @$pb.TagNumber(4) + $core.bool hasPageSize() => $_has(2); + @$pb.TagNumber(4) void clearPageSize() => clearField(4); - $core.String get pageToken => $_getS(4, ''); + @$pb.TagNumber(5) + $core.String get pageToken => $_getSZ(3); + @$pb.TagNumber(5) set pageToken($core.String v) { - $_setString(4, v); + $_setString(3, v); } - $core.bool hasPageToken() => $_has(4); + @$pb.TagNumber(5) + $core.bool hasPageToken() => $_has(3); + @$pb.TagNumber(5) void clearPageToken() => clearField(5); - $core.List<$core.String> get resourceNames => $_getList(5); + @$pb.TagNumber(8) + $core.List<$core.String> get resourceNames => $_getList(4); } class ListLogEntriesResponse extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('ListLogEntriesResponse', - package: const $pb.PackageName('google.logging.v2')) - ..pc<$3.LogEntry>(1, 'entries', $pb.PbFieldType.PM, $3.LogEntry.create) + package: const $pb.PackageName('google.logging.v2'), + createEmptyInstance: create) + ..pc<$4.LogEntry>(1, 'entries', $pb.PbFieldType.PM, + subBuilder: $4.LogEntry.create) ..aOS(2, 'nextPageToken') ..hasRequiredFields = false; @@ -301,25 +343,32 @@ class ListLogEntriesResponse extends $pb.GeneratedMessage { ListLogEntriesResponse createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static ListLogEntriesResponse getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static ListLogEntriesResponse getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static ListLogEntriesResponse _defaultInstance; - $core.List<$3.LogEntry> get entries => $_getList(0); + @$pb.TagNumber(1) + $core.List<$4.LogEntry> get entries => $_getList(0); - $core.String get nextPageToken => $_getS(1, ''); + @$pb.TagNumber(2) + $core.String get nextPageToken => $_getSZ(1); + @$pb.TagNumber(2) set nextPageToken($core.String v) { $_setString(1, v); } + @$pb.TagNumber(2) $core.bool hasNextPageToken() => $_has(1); + @$pb.TagNumber(2) void clearNextPageToken() => clearField(2); } class ListMonitoredResourceDescriptorsRequest extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo( 'ListMonitoredResourceDescriptorsRequest', - package: const $pb.PackageName('google.logging.v2')) + package: const $pb.PackageName('google.logging.v2'), + createEmptyInstance: create) ..a<$core.int>(1, 'pageSize', $pb.PbFieldType.O3) ..aOS(2, 'pageToken') ..hasRequiredFields = false; @@ -346,33 +395,45 @@ class ListMonitoredResourceDescriptorsRequest extends $pb.GeneratedMessage { ListMonitoredResourceDescriptorsRequest createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') static ListMonitoredResourceDescriptorsRequest getDefault() => - _defaultInstance ??= create()..freeze(); + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor< + ListMonitoredResourceDescriptorsRequest>(create); static ListMonitoredResourceDescriptorsRequest _defaultInstance; - $core.int get pageSize => $_get(0, 0); + @$pb.TagNumber(1) + $core.int get pageSize => $_getIZ(0); + @$pb.TagNumber(1) set pageSize($core.int v) { $_setSignedInt32(0, v); } + @$pb.TagNumber(1) $core.bool hasPageSize() => $_has(0); + @$pb.TagNumber(1) void clearPageSize() => clearField(1); - $core.String get pageToken => $_getS(1, ''); + @$pb.TagNumber(2) + $core.String get pageToken => $_getSZ(1); + @$pb.TagNumber(2) set pageToken($core.String v) { $_setString(1, v); } + @$pb.TagNumber(2) $core.bool hasPageToken() => $_has(1); + @$pb.TagNumber(2) void clearPageToken() => clearField(2); } class ListMonitoredResourceDescriptorsResponse extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo( 'ListMonitoredResourceDescriptorsResponse', - package: const $pb.PackageName('google.logging.v2')) - ..pc<$2.MonitoredResourceDescriptor>(1, 'resourceDescriptors', - $pb.PbFieldType.PM, $2.MonitoredResourceDescriptor.create) + package: const $pb.PackageName('google.logging.v2'), + createEmptyInstance: create) + ..pc<$3.MonitoredResourceDescriptor>( + 1, 'resourceDescriptors', $pb.PbFieldType.PM, + subBuilder: $3.MonitoredResourceDescriptor.create) ..aOS(2, 'nextPageToken') ..hasRequiredFields = false; @@ -399,25 +460,33 @@ class ListMonitoredResourceDescriptorsResponse extends $pb.GeneratedMessage { static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') static ListMonitoredResourceDescriptorsResponse getDefault() => - _defaultInstance ??= create()..freeze(); + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor< + ListMonitoredResourceDescriptorsResponse>(create); static ListMonitoredResourceDescriptorsResponse _defaultInstance; - $core.List<$2.MonitoredResourceDescriptor> get resourceDescriptors => + @$pb.TagNumber(1) + $core.List<$3.MonitoredResourceDescriptor> get resourceDescriptors => $_getList(0); - $core.String get nextPageToken => $_getS(1, ''); + @$pb.TagNumber(2) + $core.String get nextPageToken => $_getSZ(1); + @$pb.TagNumber(2) set nextPageToken($core.String v) { $_setString(1, v); } + @$pb.TagNumber(2) $core.bool hasNextPageToken() => $_has(1); + @$pb.TagNumber(2) void clearNextPageToken() => clearField(2); } class ListLogsRequest extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('ListLogsRequest', - package: const $pb.PackageName('google.logging.v2')) + package: const $pb.PackageName('google.logging.v2'), + createEmptyInstance: create) ..aOS(1, 'parent') ..a<$core.int>(2, 'pageSize', $pb.PbFieldType.O3) ..aOS(3, 'pageToken') @@ -440,38 +509,52 @@ class ListLogsRequest extends $pb.GeneratedMessage { ListLogsRequest createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static ListLogsRequest getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static ListLogsRequest getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static ListLogsRequest _defaultInstance; - $core.String get parent => $_getS(0, ''); + @$pb.TagNumber(1) + $core.String get parent => $_getSZ(0); + @$pb.TagNumber(1) set parent($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) $core.bool hasParent() => $_has(0); + @$pb.TagNumber(1) void clearParent() => clearField(1); - $core.int get pageSize => $_get(1, 0); + @$pb.TagNumber(2) + $core.int get pageSize => $_getIZ(1); + @$pb.TagNumber(2) set pageSize($core.int v) { $_setSignedInt32(1, v); } + @$pb.TagNumber(2) $core.bool hasPageSize() => $_has(1); + @$pb.TagNumber(2) void clearPageSize() => clearField(2); - $core.String get pageToken => $_getS(2, ''); + @$pb.TagNumber(3) + $core.String get pageToken => $_getSZ(2); + @$pb.TagNumber(3) set pageToken($core.String v) { $_setString(2, v); } + @$pb.TagNumber(3) $core.bool hasPageToken() => $_has(2); + @$pb.TagNumber(3) void clearPageToken() => clearField(3); } class ListLogsResponse extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('ListLogsResponse', - package: const $pb.PackageName('google.logging.v2')) + package: const $pb.PackageName('google.logging.v2'), + createEmptyInstance: create) ..aOS(2, 'nextPageToken') ..pPS(3, 'logNames') ..hasRequiredFields = false; @@ -493,17 +576,23 @@ class ListLogsResponse extends $pb.GeneratedMessage { ListLogsResponse createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static ListLogsResponse getDefault() => - _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static ListLogsResponse getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); static ListLogsResponse _defaultInstance; - $core.String get nextPageToken => $_getS(0, ''); + @$pb.TagNumber(2) + $core.String get nextPageToken => $_getSZ(0); + @$pb.TagNumber(2) set nextPageToken($core.String v) { $_setString(0, v); } + @$pb.TagNumber(2) $core.bool hasNextPageToken() => $_has(0); + @$pb.TagNumber(2) void clearNextPageToken() => clearField(2); + @$pb.TagNumber(3) $core.List<$core.String> get logNames => $_getList(1); } diff --git a/example/googleapis/lib/src/generated/google/logging/v2/logging.pbenum.dart b/example/googleapis/lib/src/generated/google/logging/v2/logging.pbenum.dart index ebedfd6c..2c166196 100644 --- a/example/googleapis/lib/src/generated/google/logging/v2/logging.pbenum.dart +++ b/example/googleapis/lib/src/generated/google/logging/v2/logging.pbenum.dart @@ -1,5 +1,6 @@ /// // Generated code. Do not modify. // source: google/logging/v2/logging.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type diff --git a/example/googleapis/lib/src/generated/google/logging/v2/logging.pbgrpc.dart b/example/googleapis/lib/src/generated/google/logging/v2/logging.pbgrpc.dart index 51cc3013..583d03f9 100644 --- a/example/googleapis/lib/src/generated/google/logging/v2/logging.pbgrpc.dart +++ b/example/googleapis/lib/src/generated/google/logging/v2/logging.pbgrpc.dart @@ -1,63 +1,64 @@ /// // Generated code. Do not modify. // source: google/logging/v2/logging.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type import 'dart:async' as $async; -import 'dart:core' as $core show int, String, List; +import 'dart:core' as $core; import 'package:grpc/service_api.dart' as $grpc; -import 'logging.pb.dart' as $0; +import 'logging.pb.dart' as $2; import '../../protobuf/empty.pb.dart' as $1; export 'logging.pb.dart'; class LoggingServiceV2Client extends $grpc.Client { - static final _$deleteLog = $grpc.ClientMethod<$0.DeleteLogRequest, $1.Empty>( + static final _$deleteLog = $grpc.ClientMethod<$2.DeleteLogRequest, $1.Empty>( '/google.logging.v2.LoggingServiceV2/DeleteLog', - ($0.DeleteLogRequest value) => value.writeToBuffer(), + ($2.DeleteLogRequest value) => value.writeToBuffer(), ($core.List<$core.int> value) => $1.Empty.fromBuffer(value)); static final _$writeLogEntries = - $grpc.ClientMethod<$0.WriteLogEntriesRequest, $0.WriteLogEntriesResponse>( + $grpc.ClientMethod<$2.WriteLogEntriesRequest, $2.WriteLogEntriesResponse>( '/google.logging.v2.LoggingServiceV2/WriteLogEntries', - ($0.WriteLogEntriesRequest value) => value.writeToBuffer(), + ($2.WriteLogEntriesRequest value) => value.writeToBuffer(), ($core.List<$core.int> value) => - $0.WriteLogEntriesResponse.fromBuffer(value)); + $2.WriteLogEntriesResponse.fromBuffer(value)); static final _$listLogEntries = - $grpc.ClientMethod<$0.ListLogEntriesRequest, $0.ListLogEntriesResponse>( + $grpc.ClientMethod<$2.ListLogEntriesRequest, $2.ListLogEntriesResponse>( '/google.logging.v2.LoggingServiceV2/ListLogEntries', - ($0.ListLogEntriesRequest value) => value.writeToBuffer(), + ($2.ListLogEntriesRequest value) => value.writeToBuffer(), ($core.List<$core.int> value) => - $0.ListLogEntriesResponse.fromBuffer(value)); + $2.ListLogEntriesResponse.fromBuffer(value)); static final _$listMonitoredResourceDescriptors = $grpc.ClientMethod< - $0.ListMonitoredResourceDescriptorsRequest, - $0.ListMonitoredResourceDescriptorsResponse>( + $2.ListMonitoredResourceDescriptorsRequest, + $2.ListMonitoredResourceDescriptorsResponse>( '/google.logging.v2.LoggingServiceV2/ListMonitoredResourceDescriptors', - ($0.ListMonitoredResourceDescriptorsRequest value) => + ($2.ListMonitoredResourceDescriptorsRequest value) => value.writeToBuffer(), ($core.List<$core.int> value) => - $0.ListMonitoredResourceDescriptorsResponse.fromBuffer(value)); + $2.ListMonitoredResourceDescriptorsResponse.fromBuffer(value)); static final _$listLogs = - $grpc.ClientMethod<$0.ListLogsRequest, $0.ListLogsResponse>( + $grpc.ClientMethod<$2.ListLogsRequest, $2.ListLogsResponse>( '/google.logging.v2.LoggingServiceV2/ListLogs', - ($0.ListLogsRequest value) => value.writeToBuffer(), + ($2.ListLogsRequest value) => value.writeToBuffer(), ($core.List<$core.int> value) => - $0.ListLogsResponse.fromBuffer(value)); + $2.ListLogsResponse.fromBuffer(value)); LoggingServiceV2Client($grpc.ClientChannel channel, {$grpc.CallOptions options}) : super(channel, options: options); - $grpc.ResponseFuture<$1.Empty> deleteLog($0.DeleteLogRequest request, + $grpc.ResponseFuture<$1.Empty> deleteLog($2.DeleteLogRequest request, {$grpc.CallOptions options}) { final call = $createCall(_$deleteLog, $async.Stream.fromIterable([request]), options: options); return $grpc.ResponseFuture(call); } - $grpc.ResponseFuture<$0.WriteLogEntriesResponse> writeLogEntries( - $0.WriteLogEntriesRequest request, + $grpc.ResponseFuture<$2.WriteLogEntriesResponse> writeLogEntries( + $2.WriteLogEntriesRequest request, {$grpc.CallOptions options}) { final call = $createCall( _$writeLogEntries, $async.Stream.fromIterable([request]), @@ -65,8 +66,8 @@ class LoggingServiceV2Client extends $grpc.Client { return $grpc.ResponseFuture(call); } - $grpc.ResponseFuture<$0.ListLogEntriesResponse> listLogEntries( - $0.ListLogEntriesRequest request, + $grpc.ResponseFuture<$2.ListLogEntriesResponse> listLogEntries( + $2.ListLogEntriesRequest request, {$grpc.CallOptions options}) { final call = $createCall( _$listLogEntries, $async.Stream.fromIterable([request]), @@ -74,9 +75,9 @@ class LoggingServiceV2Client extends $grpc.Client { return $grpc.ResponseFuture(call); } - $grpc.ResponseFuture<$0.ListMonitoredResourceDescriptorsResponse> + $grpc.ResponseFuture<$2.ListMonitoredResourceDescriptorsResponse> listMonitoredResourceDescriptors( - $0.ListMonitoredResourceDescriptorsRequest request, + $2.ListMonitoredResourceDescriptorsRequest request, {$grpc.CallOptions options}) { final call = $createCall(_$listMonitoredResourceDescriptors, $async.Stream.fromIterable([request]), @@ -84,7 +85,7 @@ class LoggingServiceV2Client extends $grpc.Client { return $grpc.ResponseFuture(call); } - $grpc.ResponseFuture<$0.ListLogsResponse> listLogs($0.ListLogsRequest request, + $grpc.ResponseFuture<$2.ListLogsResponse> listLogs($2.ListLogsRequest request, {$grpc.CallOptions options}) { final call = $createCall(_$listLogs, $async.Stream.fromIterable([request]), options: options); @@ -96,85 +97,89 @@ abstract class LoggingServiceV2ServiceBase extends $grpc.Service { $core.String get $name => 'google.logging.v2.LoggingServiceV2'; LoggingServiceV2ServiceBase() { - $addMethod($grpc.ServiceMethod<$0.DeleteLogRequest, $1.Empty>( + $addMethod($grpc.ServiceMethod<$2.DeleteLogRequest, $1.Empty>( 'DeleteLog', deleteLog_Pre, false, false, - ($core.List<$core.int> value) => $0.DeleteLogRequest.fromBuffer(value), + ($core.List<$core.int> value) => $2.DeleteLogRequest.fromBuffer(value), ($1.Empty value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.WriteLogEntriesRequest, - $0.WriteLogEntriesResponse>( + $addMethod($grpc.ServiceMethod<$2.WriteLogEntriesRequest, + $2.WriteLogEntriesResponse>( 'WriteLogEntries', writeLogEntries_Pre, false, false, ($core.List<$core.int> value) => - $0.WriteLogEntriesRequest.fromBuffer(value), - ($0.WriteLogEntriesResponse value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.ListLogEntriesRequest, - $0.ListLogEntriesResponse>( + $2.WriteLogEntriesRequest.fromBuffer(value), + ($2.WriteLogEntriesResponse value) => value.writeToBuffer())); + $addMethod($grpc.ServiceMethod<$2.ListLogEntriesRequest, + $2.ListLogEntriesResponse>( 'ListLogEntries', listLogEntries_Pre, false, false, ($core.List<$core.int> value) => - $0.ListLogEntriesRequest.fromBuffer(value), - ($0.ListLogEntriesResponse value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.ListMonitoredResourceDescriptorsRequest, - $0.ListMonitoredResourceDescriptorsResponse>( + $2.ListLogEntriesRequest.fromBuffer(value), + ($2.ListLogEntriesResponse value) => value.writeToBuffer())); + $addMethod($grpc.ServiceMethod<$2.ListMonitoredResourceDescriptorsRequest, + $2.ListMonitoredResourceDescriptorsResponse>( 'ListMonitoredResourceDescriptors', listMonitoredResourceDescriptors_Pre, false, false, ($core.List<$core.int> value) => - $0.ListMonitoredResourceDescriptorsRequest.fromBuffer(value), - ($0.ListMonitoredResourceDescriptorsResponse value) => + $2.ListMonitoredResourceDescriptorsRequest.fromBuffer(value), + ($2.ListMonitoredResourceDescriptorsResponse value) => value.writeToBuffer())); - $addMethod($grpc.ServiceMethod<$0.ListLogsRequest, $0.ListLogsResponse>( + $addMethod($grpc.ServiceMethod<$2.ListLogsRequest, $2.ListLogsResponse>( 'ListLogs', listLogs_Pre, false, false, - ($core.List<$core.int> value) => $0.ListLogsRequest.fromBuffer(value), - ($0.ListLogsResponse value) => value.writeToBuffer())); + ($core.List<$core.int> value) => $2.ListLogsRequest.fromBuffer(value), + ($2.ListLogsResponse value) => value.writeToBuffer())); } - $async.Future<$1.Empty> deleteLog_Pre( - $grpc.ServiceCall call, $async.Future request) async { + $async.Future<$1.Empty> deleteLog_Pre($grpc.ServiceCall call, + $async.Future<$2.DeleteLogRequest> request) async { return deleteLog(call, await request); } - $async.Future<$0.WriteLogEntriesResponse> writeLogEntries_Pre( - $grpc.ServiceCall call, $async.Future request) async { + $async.Future<$2.WriteLogEntriesResponse> writeLogEntries_Pre( + $grpc.ServiceCall call, + $async.Future<$2.WriteLogEntriesRequest> request) async { return writeLogEntries(call, await request); } - $async.Future<$0.ListLogEntriesResponse> listLogEntries_Pre( - $grpc.ServiceCall call, $async.Future request) async { + $async.Future<$2.ListLogEntriesResponse> listLogEntries_Pre( + $grpc.ServiceCall call, + $async.Future<$2.ListLogEntriesRequest> request) async { return listLogEntries(call, await request); } - $async.Future<$0.ListMonitoredResourceDescriptorsResponse> + $async.Future<$2.ListMonitoredResourceDescriptorsResponse> listMonitoredResourceDescriptors_Pre( - $grpc.ServiceCall call, $async.Future request) async { + $grpc.ServiceCall call, + $async.Future<$2.ListMonitoredResourceDescriptorsRequest> + request) async { return listMonitoredResourceDescriptors(call, await request); } - $async.Future<$0.ListLogsResponse> listLogs_Pre( - $grpc.ServiceCall call, $async.Future request) async { + $async.Future<$2.ListLogsResponse> listLogs_Pre( + $grpc.ServiceCall call, $async.Future<$2.ListLogsRequest> request) async { return listLogs(call, await request); } $async.Future<$1.Empty> deleteLog( - $grpc.ServiceCall call, $0.DeleteLogRequest request); - $async.Future<$0.WriteLogEntriesResponse> writeLogEntries( - $grpc.ServiceCall call, $0.WriteLogEntriesRequest request); - $async.Future<$0.ListLogEntriesResponse> listLogEntries( - $grpc.ServiceCall call, $0.ListLogEntriesRequest request); - $async.Future<$0.ListMonitoredResourceDescriptorsResponse> + $grpc.ServiceCall call, $2.DeleteLogRequest request); + $async.Future<$2.WriteLogEntriesResponse> writeLogEntries( + $grpc.ServiceCall call, $2.WriteLogEntriesRequest request); + $async.Future<$2.ListLogEntriesResponse> listLogEntries( + $grpc.ServiceCall call, $2.ListLogEntriesRequest request); + $async.Future<$2.ListMonitoredResourceDescriptorsResponse> listMonitoredResourceDescriptors($grpc.ServiceCall call, - $0.ListMonitoredResourceDescriptorsRequest request); - $async.Future<$0.ListLogsResponse> listLogs( - $grpc.ServiceCall call, $0.ListLogsRequest request); + $2.ListMonitoredResourceDescriptorsRequest request); + $async.Future<$2.ListLogsResponse> listLogs( + $grpc.ServiceCall call, $2.ListLogsRequest request); } diff --git a/example/googleapis/lib/src/generated/google/logging/v2/logging.pbjson.dart b/example/googleapis/lib/src/generated/google/logging/v2/logging.pbjson.dart index 8e0ccb5f..c8bd7b75 100644 --- a/example/googleapis/lib/src/generated/google/logging/v2/logging.pbjson.dart +++ b/example/googleapis/lib/src/generated/google/logging/v2/logging.pbjson.dart @@ -1,67 +1,99 @@ /// // Generated code. Do not modify. // source: google/logging/v2/logging.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -const DeleteLogRequest$json = { +const DeleteLogRequest$json = const { '1': 'DeleteLogRequest', - '2': [ - {'1': 'log_name', '3': 1, '4': 1, '5': 9, '10': 'logName'}, + '2': const [ + const { + '1': 'log_name', + '3': 1, + '4': 1, + '5': 9, + '8': const {}, + '10': 'logName' + }, ], }; -const WriteLogEntriesRequest$json = { +const WriteLogEntriesRequest$json = const { '1': 'WriteLogEntriesRequest', - '2': [ - {'1': 'log_name', '3': 1, '4': 1, '5': 9, '10': 'logName'}, - { + '2': const [ + const { + '1': 'log_name', + '3': 1, + '4': 1, + '5': 9, + '8': const {}, + '10': 'logName' + }, + const { '1': 'resource', '3': 2, '4': 1, '5': 11, '6': '.google.api.MonitoredResource', + '8': const {}, '10': 'resource' }, - { + const { '1': 'labels', '3': 3, '4': 3, '5': 11, '6': '.google.logging.v2.WriteLogEntriesRequest.LabelsEntry', + '8': const {}, '10': 'labels' }, - { + const { '1': 'entries', '3': 4, '4': 3, '5': 11, '6': '.google.logging.v2.LogEntry', + '8': const {}, '10': 'entries' }, - {'1': 'partial_success', '3': 5, '4': 1, '5': 8, '10': 'partialSuccess'}, - {'1': 'dry_run', '3': 6, '4': 1, '5': 8, '10': 'dryRun'}, + const { + '1': 'partial_success', + '3': 5, + '4': 1, + '5': 8, + '8': const {}, + '10': 'partialSuccess' + }, + const { + '1': 'dry_run', + '3': 6, + '4': 1, + '5': 8, + '8': const {}, + '10': 'dryRun' + }, ], - '3': [WriteLogEntriesRequest_LabelsEntry$json], + '3': const [WriteLogEntriesRequest_LabelsEntry$json], }; -const WriteLogEntriesRequest_LabelsEntry$json = { +const WriteLogEntriesRequest_LabelsEntry$json = const { '1': 'LabelsEntry', - '2': [ - {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, - {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'}, + '2': const [ + const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, + const {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'}, ], - '7': {'7': true}, + '7': const {'7': true}, }; -const WriteLogEntriesResponse$json = { +const WriteLogEntriesResponse$json = const { '1': 'WriteLogEntriesResponse', }; -const WriteLogEntriesPartialErrors$json = { +const WriteLogEntriesPartialErrors$json = const { '1': 'WriteLogEntriesPartialErrors', - '2': [ - { + '2': const [ + const { '1': 'log_entry_errors', '3': 1, '4': 3, @@ -71,14 +103,14 @@ const WriteLogEntriesPartialErrors$json = { '10': 'logEntryErrors' }, ], - '3': [WriteLogEntriesPartialErrors_LogEntryErrorsEntry$json], + '3': const [WriteLogEntriesPartialErrors_LogEntryErrorsEntry$json], }; -const WriteLogEntriesPartialErrors_LogEntryErrorsEntry$json = { +const WriteLogEntriesPartialErrors_LogEntryErrorsEntry$json = const { '1': 'LogEntryErrorsEntry', - '2': [ - {'1': 'key', '3': 1, '4': 1, '5': 5, '10': 'key'}, - { + '2': const [ + const {'1': 'key', '3': 1, '4': 1, '5': 5, '10': 'key'}, + const { '1': 'value', '3': 2, '4': 1, @@ -87,32 +119,59 @@ const WriteLogEntriesPartialErrors_LogEntryErrorsEntry$json = { '10': 'value' }, ], - '7': {'7': true}, + '7': const {'7': true}, }; -const ListLogEntriesRequest$json = { +const ListLogEntriesRequest$json = const { '1': 'ListLogEntriesRequest', - '2': [ - { - '1': 'project_ids', - '3': 1, + '2': const [ + const { + '1': 'resource_names', + '3': 8, '4': 3, '5': 9, - '8': {'3': true}, - '10': 'projectIds', - }, - {'1': 'resource_names', '3': 8, '4': 3, '5': 9, '10': 'resourceNames'}, - {'1': 'filter', '3': 2, '4': 1, '5': 9, '10': 'filter'}, - {'1': 'order_by', '3': 3, '4': 1, '5': 9, '10': 'orderBy'}, - {'1': 'page_size', '3': 4, '4': 1, '5': 5, '10': 'pageSize'}, - {'1': 'page_token', '3': 5, '4': 1, '5': 9, '10': 'pageToken'}, + '8': const {}, + '10': 'resourceNames' + }, + const { + '1': 'filter', + '3': 2, + '4': 1, + '5': 9, + '8': const {}, + '10': 'filter' + }, + const { + '1': 'order_by', + '3': 3, + '4': 1, + '5': 9, + '8': const {}, + '10': 'orderBy' + }, + const { + '1': 'page_size', + '3': 4, + '4': 1, + '5': 5, + '8': const {}, + '10': 'pageSize' + }, + const { + '1': 'page_token', + '3': 5, + '4': 1, + '5': 9, + '8': const {}, + '10': 'pageToken' + }, ], }; -const ListLogEntriesResponse$json = { +const ListLogEntriesResponse$json = const { '1': 'ListLogEntriesResponse', - '2': [ - { + '2': const [ + const { '1': 'entries', '3': 1, '4': 3, @@ -120,22 +179,42 @@ const ListLogEntriesResponse$json = { '6': '.google.logging.v2.LogEntry', '10': 'entries' }, - {'1': 'next_page_token', '3': 2, '4': 1, '5': 9, '10': 'nextPageToken'}, + const { + '1': 'next_page_token', + '3': 2, + '4': 1, + '5': 9, + '10': 'nextPageToken' + }, ], }; -const ListMonitoredResourceDescriptorsRequest$json = { +const ListMonitoredResourceDescriptorsRequest$json = const { '1': 'ListMonitoredResourceDescriptorsRequest', - '2': [ - {'1': 'page_size', '3': 1, '4': 1, '5': 5, '10': 'pageSize'}, - {'1': 'page_token', '3': 2, '4': 1, '5': 9, '10': 'pageToken'}, + '2': const [ + const { + '1': 'page_size', + '3': 1, + '4': 1, + '5': 5, + '8': const {}, + '10': 'pageSize' + }, + const { + '1': 'page_token', + '3': 2, + '4': 1, + '5': 9, + '8': const {}, + '10': 'pageToken' + }, ], }; -const ListMonitoredResourceDescriptorsResponse$json = { +const ListMonitoredResourceDescriptorsResponse$json = const { '1': 'ListMonitoredResourceDescriptorsResponse', - '2': [ - { + '2': const [ + const { '1': 'resource_descriptors', '3': 1, '4': 3, @@ -143,23 +222,56 @@ const ListMonitoredResourceDescriptorsResponse$json = { '6': '.google.api.MonitoredResourceDescriptor', '10': 'resourceDescriptors' }, - {'1': 'next_page_token', '3': 2, '4': 1, '5': 9, '10': 'nextPageToken'}, + const { + '1': 'next_page_token', + '3': 2, + '4': 1, + '5': 9, + '10': 'nextPageToken' + }, ], }; -const ListLogsRequest$json = { +const ListLogsRequest$json = const { '1': 'ListLogsRequest', - '2': [ - {'1': 'parent', '3': 1, '4': 1, '5': 9, '10': 'parent'}, - {'1': 'page_size', '3': 2, '4': 1, '5': 5, '10': 'pageSize'}, - {'1': 'page_token', '3': 3, '4': 1, '5': 9, '10': 'pageToken'}, + '2': const [ + const { + '1': 'parent', + '3': 1, + '4': 1, + '5': 9, + '8': const {}, + '10': 'parent' + }, + const { + '1': 'page_size', + '3': 2, + '4': 1, + '5': 5, + '8': const {}, + '10': 'pageSize' + }, + const { + '1': 'page_token', + '3': 3, + '4': 1, + '5': 9, + '8': const {}, + '10': 'pageToken' + }, ], }; -const ListLogsResponse$json = { +const ListLogsResponse$json = const { '1': 'ListLogsResponse', - '2': [ - {'1': 'log_names', '3': 3, '4': 3, '5': 9, '10': 'logNames'}, - {'1': 'next_page_token', '3': 2, '4': 1, '5': 9, '10': 'nextPageToken'}, + '2': const [ + const {'1': 'log_names', '3': 3, '4': 3, '5': 9, '10': 'logNames'}, + const { + '1': 'next_page_token', + '3': 2, + '4': 1, + '5': 9, + '10': 'nextPageToken' + }, ], }; diff --git a/example/googleapis/lib/src/generated/google/protobuf/any.pb.dart b/example/googleapis/lib/src/generated/google/protobuf/any.pb.dart index 11c9936d..806956f6 100644 --- a/example/googleapis/lib/src/generated/google/protobuf/any.pb.dart +++ b/example/googleapis/lib/src/generated/google/protobuf/any.pb.dart @@ -1,20 +1,25 @@ /// // Generated code. Do not modify. // source: google/protobuf/any.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; -class Any extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = - $pb.BuilderInfo('Any', package: const $pb.PackageName('google.protobuf')) - ..aOS(1, 'typeUrl') - ..a<$core.List<$core.int>>(2, 'value', $pb.PbFieldType.OY) - ..hasRequiredFields = false; +import 'package:protobuf/src/protobuf/mixins/well_known.dart' as $mixin; + +class Any extends $pb.GeneratedMessage with $mixin.AnyMixin { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('Any', + package: const $pb.PackageName('google.protobuf'), + createEmptyInstance: create, + toProto3Json: $mixin.AnyMixin.toProto3JsonHelper, + fromProto3Json: $mixin.AnyMixin.fromProto3JsonHelper) + ..aOS(1, 'typeUrl') + ..a<$core.List<$core.int>>(2, 'value', $pb.PbFieldType.OY) + ..hasRequiredFields = false; Any._() : super(); factory Any() => create(); @@ -32,56 +37,43 @@ class Any extends $pb.GeneratedMessage { static Any create() => Any._(); Any createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static Any getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static Any getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); static Any _defaultInstance; - $core.String get typeUrl => $_getS(0, ''); + @$pb.TagNumber(1) + $core.String get typeUrl => $_getSZ(0); + @$pb.TagNumber(1) set typeUrl($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) $core.bool hasTypeUrl() => $_has(0); + @$pb.TagNumber(1) void clearTypeUrl() => clearField(1); + @$pb.TagNumber(2) $core.List<$core.int> get value => $_getN(1); + @$pb.TagNumber(2) set value($core.List<$core.int> v) { $_setBytes(1, v); } + @$pb.TagNumber(2) $core.bool hasValue() => $_has(1); + @$pb.TagNumber(2) void clearValue() => clearField(2); - /// Unpacks the message in [value] into [instance]. - /// - /// Throws a [InvalidProtocolBufferException] if [typeUrl] does not correspond - /// to the type of [instance]. - /// - /// A typical usage would be `any.unpackInto(Message())`. - /// - /// Returns [instance]. - T unpackInto(T instance, - {$pb.ExtensionRegistry extensionRegistry = $pb.ExtensionRegistry.EMPTY}) { - $pb.unpackIntoHelper(value, instance, typeUrl, - extensionRegistry: extensionRegistry); - return instance; - } - - /// Returns `true` if the encoded message matches the type of [instance]. - /// - /// Can be used with a default instance: - /// `any.canUnpackInto(Message.getDefault())` - $core.bool canUnpackInto($pb.GeneratedMessage instance) { - return $pb.canUnpackIntoHelper(instance, typeUrl); - } - /// Creates a new [Any] encoding [message]. /// /// The [typeUrl] will be [typeUrlPrefix]/`fullName` where `fullName` is /// the fully qualified name of the type of [message]. static Any pack($pb.GeneratedMessage message, {$core.String typeUrlPrefix = 'type.googleapis.com'}) { - return Any() - ..value = message.writeToBuffer() - ..typeUrl = '${typeUrlPrefix}/${message.info_.qualifiedMessageName}'; + final result = create(); + $mixin.AnyMixin.packIntoAny(result, message, typeUrlPrefix: typeUrlPrefix); + return result; } } diff --git a/example/googleapis/lib/src/generated/google/protobuf/any.pbenum.dart b/example/googleapis/lib/src/generated/google/protobuf/any.pbenum.dart index d3319524..ed3dc035 100644 --- a/example/googleapis/lib/src/generated/google/protobuf/any.pbenum.dart +++ b/example/googleapis/lib/src/generated/google/protobuf/any.pbenum.dart @@ -1,5 +1,6 @@ /// // Generated code. Do not modify. // source: google/protobuf/any.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type diff --git a/example/googleapis/lib/src/generated/google/protobuf/any.pbjson.dart b/example/googleapis/lib/src/generated/google/protobuf/any.pbjson.dart index a7996b6b..8e0463ea 100644 --- a/example/googleapis/lib/src/generated/google/protobuf/any.pbjson.dart +++ b/example/googleapis/lib/src/generated/google/protobuf/any.pbjson.dart @@ -1,13 +1,14 @@ /// // Generated code. Do not modify. // source: google/protobuf/any.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -const Any$json = { +const Any$json = const { '1': 'Any', - '2': [ - {'1': 'type_url', '3': 1, '4': 1, '5': 9, '10': 'typeUrl'}, - {'1': 'value', '3': 2, '4': 1, '5': 12, '10': 'value'}, + '2': const [ + const {'1': 'type_url', '3': 1, '4': 1, '5': 9, '10': 'typeUrl'}, + const {'1': 'value', '3': 2, '4': 1, '5': 12, '10': 'value'}, ], }; diff --git a/example/googleapis/lib/src/generated/google/protobuf/duration.pb.dart b/example/googleapis/lib/src/generated/google/protobuf/duration.pb.dart index 3c22a51c..c612a3e5 100644 --- a/example/googleapis/lib/src/generated/google/protobuf/duration.pb.dart +++ b/example/googleapis/lib/src/generated/google/protobuf/duration.pb.dart @@ -1,18 +1,23 @@ /// // Generated code. Do not modify. // source: google/protobuf/duration.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; -import 'package:fixnum/fixnum.dart'; +import 'package:fixnum/fixnum.dart' as $fixnum; import 'package:protobuf/protobuf.dart' as $pb; -class Duration extends $pb.GeneratedMessage { +import 'package:protobuf/src/protobuf/mixins/well_known.dart' as $mixin; + +class Duration extends $pb.GeneratedMessage with $mixin.DurationMixin { static final $pb.BuilderInfo _i = $pb.BuilderInfo('Duration', - package: const $pb.PackageName('google.protobuf')) + package: const $pb.PackageName('google.protobuf'), + createEmptyInstance: create, + toProto3Json: $mixin.DurationMixin.toProto3JsonHelper, + fromProto3Json: $mixin.DurationMixin.fromProto3JsonHelper) ..aInt64(1, 'seconds') ..a<$core.int>(2, 'nanos', $pb.PbFieldType.O3) ..hasRequiredFields = false; @@ -33,22 +38,32 @@ class Duration extends $pb.GeneratedMessage { static Duration create() => Duration._(); Duration createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static Duration getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static Duration getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); static Duration _defaultInstance; - Int64 get seconds => $_getI64(0); - set seconds(Int64 v) { + @$pb.TagNumber(1) + $fixnum.Int64 get seconds => $_getI64(0); + @$pb.TagNumber(1) + set seconds($fixnum.Int64 v) { $_setInt64(0, v); } + @$pb.TagNumber(1) $core.bool hasSeconds() => $_has(0); + @$pb.TagNumber(1) void clearSeconds() => clearField(1); - $core.int get nanos => $_get(1, 0); + @$pb.TagNumber(2) + $core.int get nanos => $_getIZ(1); + @$pb.TagNumber(2) set nanos($core.int v) { $_setSignedInt32(1, v); } + @$pb.TagNumber(2) $core.bool hasNanos() => $_has(1); + @$pb.TagNumber(2) void clearNanos() => clearField(2); } diff --git a/example/googleapis/lib/src/generated/google/protobuf/duration.pbenum.dart b/example/googleapis/lib/src/generated/google/protobuf/duration.pbenum.dart index 799bf270..9cfc0031 100644 --- a/example/googleapis/lib/src/generated/google/protobuf/duration.pbenum.dart +++ b/example/googleapis/lib/src/generated/google/protobuf/duration.pbenum.dart @@ -1,5 +1,6 @@ /// // Generated code. Do not modify. // source: google/protobuf/duration.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type diff --git a/example/googleapis/lib/src/generated/google/protobuf/duration.pbjson.dart b/example/googleapis/lib/src/generated/google/protobuf/duration.pbjson.dart index dad238b3..7a83954e 100644 --- a/example/googleapis/lib/src/generated/google/protobuf/duration.pbjson.dart +++ b/example/googleapis/lib/src/generated/google/protobuf/duration.pbjson.dart @@ -1,13 +1,14 @@ /// // Generated code. Do not modify. // source: google/protobuf/duration.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -const Duration$json = { +const Duration$json = const { '1': 'Duration', - '2': [ - {'1': 'seconds', '3': 1, '4': 1, '5': 3, '10': 'seconds'}, - {'1': 'nanos', '3': 2, '4': 1, '5': 5, '10': 'nanos'}, + '2': const [ + const {'1': 'seconds', '3': 1, '4': 1, '5': 3, '10': 'seconds'}, + const {'1': 'nanos', '3': 2, '4': 1, '5': 5, '10': 'nanos'}, ], }; diff --git a/example/googleapis/lib/src/generated/google/protobuf/empty.pb.dart b/example/googleapis/lib/src/generated/google/protobuf/empty.pb.dart index d7063e51..bc2a0998 100644 --- a/example/googleapis/lib/src/generated/google/protobuf/empty.pb.dart +++ b/example/googleapis/lib/src/generated/google/protobuf/empty.pb.dart @@ -1,17 +1,18 @@ /// // Generated code. Do not modify. // source: google/protobuf/empty.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; class Empty extends $pb.GeneratedMessage { static final $pb.BuilderInfo _i = $pb.BuilderInfo('Empty', - package: const $pb.PackageName('google.protobuf')) + package: const $pb.PackageName('google.protobuf'), + createEmptyInstance: create) ..hasRequiredFields = false; Empty._() : super(); @@ -30,6 +31,8 @@ class Empty extends $pb.GeneratedMessage { static Empty create() => Empty._(); Empty createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static Empty getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static Empty getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); static Empty _defaultInstance; } diff --git a/example/googleapis/lib/src/generated/google/protobuf/empty.pbenum.dart b/example/googleapis/lib/src/generated/google/protobuf/empty.pbenum.dart index 71070e5c..0fb3ebb8 100644 --- a/example/googleapis/lib/src/generated/google/protobuf/empty.pbenum.dart +++ b/example/googleapis/lib/src/generated/google/protobuf/empty.pbenum.dart @@ -1,5 +1,6 @@ /// // Generated code. Do not modify. // source: google/protobuf/empty.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type diff --git a/example/googleapis/lib/src/generated/google/protobuf/empty.pbjson.dart b/example/googleapis/lib/src/generated/google/protobuf/empty.pbjson.dart index ed330350..588c6a03 100644 --- a/example/googleapis/lib/src/generated/google/protobuf/empty.pbjson.dart +++ b/example/googleapis/lib/src/generated/google/protobuf/empty.pbjson.dart @@ -1,9 +1,10 @@ /// // Generated code. Do not modify. // source: google/protobuf/empty.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -const Empty$json = { +const Empty$json = const { '1': 'Empty', }; diff --git a/example/googleapis/lib/src/generated/google/protobuf/struct.pb.dart b/example/googleapis/lib/src/generated/google/protobuf/struct.pb.dart index 254b230f..a47e29bb 100644 --- a/example/googleapis/lib/src/generated/google/protobuf/struct.pb.dart +++ b/example/googleapis/lib/src/generated/google/protobuf/struct.pb.dart @@ -1,31 +1,32 @@ /// // Generated code. Do not modify. // source: google/protobuf/struct.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; +import 'package:protobuf/src/protobuf/mixins/well_known.dart' as $mixin; + import 'struct.pbenum.dart'; export 'struct.pbenum.dart'; -class Struct extends $pb.GeneratedMessage { +class Struct extends $pb.GeneratedMessage with $mixin.StructMixin { static final $pb.BuilderInfo _i = $pb.BuilderInfo('Struct', - package: const $pb.PackageName('google.protobuf')) - ..m<$core.String, Value>( - 1, - 'fields', - 'Struct.FieldsEntry', - $pb.PbFieldType.OS, - $pb.PbFieldType.OM, - Value.create, - null, - null, - const $pb.PackageName('google.protobuf')) + package: const $pb.PackageName('google.protobuf'), + createEmptyInstance: create, + toProto3Json: $mixin.StructMixin.toProto3JsonHelper, + fromProto3Json: $mixin.StructMixin.fromProto3JsonHelper) + ..m<$core.String, Value>(1, 'fields', + entryClassName: 'Struct.FieldsEntry', + keyFieldType: $pb.PbFieldType.OS, + valueFieldType: $pb.PbFieldType.OM, + valueCreator: Value.create, + packageName: const $pb.PackageName('google.protobuf')) ..hasRequiredFields = false; Struct._() : super(); @@ -44,9 +45,12 @@ class Struct extends $pb.GeneratedMessage { static Struct create() => Struct._(); Struct createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static Struct getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static Struct getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); static Struct _defaultInstance; + @$pb.TagNumber(1) $core.Map<$core.String, Value> get fields => $_getMap(0); } @@ -60,7 +64,7 @@ enum Value_Kind { notSet } -class Value extends $pb.GeneratedMessage { +class Value extends $pb.GeneratedMessage with $mixin.ValueMixin { static const $core.Map<$core.int, Value_Kind> _Value_KindByTag = { 1: Value_Kind.nullValue, 2: Value_Kind.numberValue, @@ -71,17 +75,20 @@ class Value extends $pb.GeneratedMessage { 0: Value_Kind.notSet }; static final $pb.BuilderInfo _i = $pb.BuilderInfo('Value', - package: const $pb.PackageName('google.protobuf')) + package: const $pb.PackageName('google.protobuf'), + createEmptyInstance: create, + toProto3Json: $mixin.ValueMixin.toProto3JsonHelper, + fromProto3Json: $mixin.ValueMixin.fromProto3JsonHelper) ..oo(0, [1, 2, 3, 4, 5, 6]) - ..e(1, 'nullValue', $pb.PbFieldType.OE, NullValue.NULL_VALUE, - NullValue.valueOf, NullValue.values) + ..e(1, 'nullValue', $pb.PbFieldType.OE, + defaultOrMaker: NullValue.NULL_VALUE, + valueOf: NullValue.valueOf, + enumValues: NullValue.values) ..a<$core.double>(2, 'numberValue', $pb.PbFieldType.OD) ..aOS(3, 'stringValue') ..aOB(4, 'boolValue') - ..a( - 5, 'structValue', $pb.PbFieldType.OM, Struct.getDefault, Struct.create) - ..a(6, 'listValue', $pb.PbFieldType.OM, ListValue.getDefault, - ListValue.create) + ..aOM(5, 'structValue', subBuilder: Struct.create) + ..aOM(6, 'listValue', subBuilder: ListValue.create) ..hasRequiredFields = false; Value._() : super(); @@ -100,65 +107,98 @@ class Value extends $pb.GeneratedMessage { static Value create() => Value._(); Value createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static Value getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static Value getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); static Value _defaultInstance; Value_Kind whichKind() => _Value_KindByTag[$_whichOneof(0)]; void clearKind() => clearField($_whichOneof(0)); + @$pb.TagNumber(1) NullValue get nullValue => $_getN(0); + @$pb.TagNumber(1) set nullValue(NullValue v) { setField(1, v); } + @$pb.TagNumber(1) $core.bool hasNullValue() => $_has(0); + @$pb.TagNumber(1) void clearNullValue() => clearField(1); + @$pb.TagNumber(2) $core.double get numberValue => $_getN(1); + @$pb.TagNumber(2) set numberValue($core.double v) { $_setDouble(1, v); } + @$pb.TagNumber(2) $core.bool hasNumberValue() => $_has(1); + @$pb.TagNumber(2) void clearNumberValue() => clearField(2); - $core.String get stringValue => $_getS(2, ''); + @$pb.TagNumber(3) + $core.String get stringValue => $_getSZ(2); + @$pb.TagNumber(3) set stringValue($core.String v) { $_setString(2, v); } + @$pb.TagNumber(3) $core.bool hasStringValue() => $_has(2); + @$pb.TagNumber(3) void clearStringValue() => clearField(3); - $core.bool get boolValue => $_get(3, false); + @$pb.TagNumber(4) + $core.bool get boolValue => $_getBF(3); + @$pb.TagNumber(4) set boolValue($core.bool v) { $_setBool(3, v); } + @$pb.TagNumber(4) $core.bool hasBoolValue() => $_has(3); + @$pb.TagNumber(4) void clearBoolValue() => clearField(4); + @$pb.TagNumber(5) Struct get structValue => $_getN(4); + @$pb.TagNumber(5) set structValue(Struct v) { setField(5, v); } + @$pb.TagNumber(5) $core.bool hasStructValue() => $_has(4); + @$pb.TagNumber(5) void clearStructValue() => clearField(5); + @$pb.TagNumber(5) + Struct ensureStructValue() => $_ensure(4); + @$pb.TagNumber(6) ListValue get listValue => $_getN(5); + @$pb.TagNumber(6) set listValue(ListValue v) { setField(6, v); } + @$pb.TagNumber(6) $core.bool hasListValue() => $_has(5); + @$pb.TagNumber(6) void clearListValue() => clearField(6); + @$pb.TagNumber(6) + ListValue ensureListValue() => $_ensure(5); } -class ListValue extends $pb.GeneratedMessage { +class ListValue extends $pb.GeneratedMessage with $mixin.ListValueMixin { static final $pb.BuilderInfo _i = $pb.BuilderInfo('ListValue', - package: const $pb.PackageName('google.protobuf')) - ..pc(1, 'values', $pb.PbFieldType.PM, Value.create) + package: const $pb.PackageName('google.protobuf'), + createEmptyInstance: create, + toProto3Json: $mixin.ListValueMixin.toProto3JsonHelper, + fromProto3Json: $mixin.ListValueMixin.fromProto3JsonHelper) + ..pc(1, 'values', $pb.PbFieldType.PM, subBuilder: Value.create) ..hasRequiredFields = false; ListValue._() : super(); @@ -177,8 +217,11 @@ class ListValue extends $pb.GeneratedMessage { static ListValue create() => ListValue._(); ListValue createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static ListValue getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static ListValue getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); static ListValue _defaultInstance; + @$pb.TagNumber(1) $core.List get values => $_getList(0); } diff --git a/example/googleapis/lib/src/generated/google/protobuf/struct.pbenum.dart b/example/googleapis/lib/src/generated/google/protobuf/struct.pbenum.dart index 4edc77bd..c70b13b6 100644 --- a/example/googleapis/lib/src/generated/google/protobuf/struct.pbenum.dart +++ b/example/googleapis/lib/src/generated/google/protobuf/struct.pbenum.dart @@ -1,11 +1,12 @@ /// // Generated code. Do not modify. // source: google/protobuf/struct.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type // ignore_for_file: UNDEFINED_SHOWN_NAME,UNUSED_SHOWN_NAME -import 'dart:core' as $core show int, dynamic, String, List, Map; +import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; class NullValue extends $pb.ProtobufEnum { diff --git a/example/googleapis/lib/src/generated/google/protobuf/struct.pbjson.dart b/example/googleapis/lib/src/generated/google/protobuf/struct.pbjson.dart index 688f6be5..185e47cb 100644 --- a/example/googleapis/lib/src/generated/google/protobuf/struct.pbjson.dart +++ b/example/googleapis/lib/src/generated/google/protobuf/struct.pbjson.dart @@ -1,20 +1,21 @@ /// // Generated code. Do not modify. // source: google/protobuf/struct.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -const NullValue$json = { +const NullValue$json = const { '1': 'NullValue', - '2': [ - {'1': 'NULL_VALUE', '2': 0}, + '2': const [ + const {'1': 'NULL_VALUE', '2': 0}, ], }; -const Struct$json = { +const Struct$json = const { '1': 'Struct', - '2': [ - { + '2': const [ + const { '1': 'fields', '3': 1, '4': 3, @@ -23,14 +24,14 @@ const Struct$json = { '10': 'fields' }, ], - '3': [Struct_FieldsEntry$json], + '3': const [Struct_FieldsEntry$json], }; -const Struct_FieldsEntry$json = { +const Struct_FieldsEntry$json = const { '1': 'FieldsEntry', - '2': [ - {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, - { + '2': const [ + const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, + const { '1': 'value', '3': 2, '4': 1, @@ -39,13 +40,13 @@ const Struct_FieldsEntry$json = { '10': 'value' }, ], - '7': {'7': true}, + '7': const {'7': true}, }; -const Value$json = { +const Value$json = const { '1': 'Value', - '2': [ - { + '2': const [ + const { '1': 'null_value', '3': 1, '4': 1, @@ -54,10 +55,31 @@ const Value$json = { '9': 0, '10': 'nullValue' }, - {'1': 'number_value', '3': 2, '4': 1, '5': 1, '9': 0, '10': 'numberValue'}, - {'1': 'string_value', '3': 3, '4': 1, '5': 9, '9': 0, '10': 'stringValue'}, - {'1': 'bool_value', '3': 4, '4': 1, '5': 8, '9': 0, '10': 'boolValue'}, - { + const { + '1': 'number_value', + '3': 2, + '4': 1, + '5': 1, + '9': 0, + '10': 'numberValue' + }, + const { + '1': 'string_value', + '3': 3, + '4': 1, + '5': 9, + '9': 0, + '10': 'stringValue' + }, + const { + '1': 'bool_value', + '3': 4, + '4': 1, + '5': 8, + '9': 0, + '10': 'boolValue' + }, + const { '1': 'struct_value', '3': 5, '4': 1, @@ -66,7 +88,7 @@ const Value$json = { '9': 0, '10': 'structValue' }, - { + const { '1': 'list_value', '3': 6, '4': 1, @@ -76,15 +98,15 @@ const Value$json = { '10': 'listValue' }, ], - '8': [ - {'1': 'kind'}, + '8': const [ + const {'1': 'kind'}, ], }; -const ListValue$json = { +const ListValue$json = const { '1': 'ListValue', - '2': [ - { + '2': const [ + const { '1': 'values', '3': 1, '4': 3, diff --git a/example/googleapis/lib/src/generated/google/protobuf/timestamp.pb.dart b/example/googleapis/lib/src/generated/google/protobuf/timestamp.pb.dart index ac581639..99f37230 100644 --- a/example/googleapis/lib/src/generated/google/protobuf/timestamp.pb.dart +++ b/example/googleapis/lib/src/generated/google/protobuf/timestamp.pb.dart @@ -1,20 +1,23 @@ /// // Generated code. Do not modify. // source: google/protobuf/timestamp.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; -import 'package:fixnum/fixnum.dart'; +import 'package:fixnum/fixnum.dart' as $fixnum; import 'package:protobuf/protobuf.dart' as $pb; -import 'dart:core' as $core show DateTime, Duration; +import 'package:protobuf/src/protobuf/mixins/well_known.dart' as $mixin; -class Timestamp extends $pb.GeneratedMessage { +class Timestamp extends $pb.GeneratedMessage with $mixin.TimestampMixin { static final $pb.BuilderInfo _i = $pb.BuilderInfo('Timestamp', - package: const $pb.PackageName('google.protobuf')) + package: const $pb.PackageName('google.protobuf'), + createEmptyInstance: create, + toProto3Json: $mixin.TimestampMixin.toProto3JsonHelper, + fromProto3Json: $mixin.TimestampMixin.fromProto3JsonHelper) ..aInt64(1, 'seconds') ..a<$core.int>(2, 'nanos', $pb.PbFieldType.O3) ..hasRequiredFields = false; @@ -35,40 +38,41 @@ class Timestamp extends $pb.GeneratedMessage { static Timestamp create() => Timestamp._(); Timestamp createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static Timestamp getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static Timestamp getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); static Timestamp _defaultInstance; - Int64 get seconds => $_getI64(0); - set seconds(Int64 v) { + @$pb.TagNumber(1) + $fixnum.Int64 get seconds => $_getI64(0); + @$pb.TagNumber(1) + set seconds($fixnum.Int64 v) { $_setInt64(0, v); } + @$pb.TagNumber(1) $core.bool hasSeconds() => $_has(0); + @$pb.TagNumber(1) void clearSeconds() => clearField(1); - $core.int get nanos => $_get(1, 0); + @$pb.TagNumber(2) + $core.int get nanos => $_getIZ(1); + @$pb.TagNumber(2) set nanos($core.int v) { $_setSignedInt32(1, v); } + @$pb.TagNumber(2) $core.bool hasNanos() => $_has(1); + @$pb.TagNumber(2) void clearNanos() => clearField(2); - /// Converts an instance to [DateTime]. - /// - /// The result is in UTC time zone and has microsecond precision, as - /// [DateTime] does not support nanosecond precision. - $core.DateTime toDateTime() => $core.DateTime.fromMicrosecondsSinceEpoch( - seconds.toInt() * $core.Duration.microsecondsPerSecond + nanos ~/ 1000, - isUtc: true); - /// Creates a new instance from [dateTime]. /// /// Time zone information will not be preserved. static Timestamp fromDateTime($core.DateTime dateTime) { - $core.int micros = dateTime.microsecondsSinceEpoch; - return Timestamp() - ..seconds = Int64(micros ~/ $core.Duration.microsecondsPerSecond) - ..nanos = (micros % $core.Duration.microsecondsPerSecond).toInt() * 1000; + final result = create(); + $mixin.TimestampMixin.setFromDateTime(result, dateTime); + return result; } } diff --git a/example/googleapis/lib/src/generated/google/protobuf/timestamp.pbenum.dart b/example/googleapis/lib/src/generated/google/protobuf/timestamp.pbenum.dart index 2cc673b9..feb30f11 100644 --- a/example/googleapis/lib/src/generated/google/protobuf/timestamp.pbenum.dart +++ b/example/googleapis/lib/src/generated/google/protobuf/timestamp.pbenum.dart @@ -1,5 +1,6 @@ /// // Generated code. Do not modify. // source: google/protobuf/timestamp.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type diff --git a/example/googleapis/lib/src/generated/google/protobuf/timestamp.pbjson.dart b/example/googleapis/lib/src/generated/google/protobuf/timestamp.pbjson.dart index 061cf484..d319827c 100644 --- a/example/googleapis/lib/src/generated/google/protobuf/timestamp.pbjson.dart +++ b/example/googleapis/lib/src/generated/google/protobuf/timestamp.pbjson.dart @@ -1,13 +1,14 @@ /// // Generated code. Do not modify. // source: google/protobuf/timestamp.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -const Timestamp$json = { +const Timestamp$json = const { '1': 'Timestamp', - '2': [ - {'1': 'seconds', '3': 1, '4': 1, '5': 3, '10': 'seconds'}, - {'1': 'nanos', '3': 2, '4': 1, '5': 5, '10': 'nanos'}, + '2': const [ + const {'1': 'seconds', '3': 1, '4': 1, '5': 3, '10': 'seconds'}, + const {'1': 'nanos', '3': 2, '4': 1, '5': 5, '10': 'nanos'}, ], }; diff --git a/example/googleapis/lib/src/generated/google/rpc/status.pb.dart b/example/googleapis/lib/src/generated/google/rpc/status.pb.dart index 3c2c4c55..2e0370f6 100644 --- a/example/googleapis/lib/src/generated/google/rpc/status.pb.dart +++ b/example/googleapis/lib/src/generated/google/rpc/status.pb.dart @@ -1,23 +1,23 @@ /// // Generated code. Do not modify. // source: google/rpc/status.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -import 'dart:core' as $core - show bool, Deprecated, double, int, List, Map, override, pragma, String; +import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; import '../protobuf/any.pb.dart' as $0; class Status extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = - $pb.BuilderInfo('Status', package: const $pb.PackageName('google.rpc')) - ..a<$core.int>(1, 'code', $pb.PbFieldType.O3) - ..aOS(2, 'message') - ..pc<$0.Any>(3, 'details', $pb.PbFieldType.PM, $0.Any.create) - ..hasRequiredFields = false; + static final $pb.BuilderInfo _i = $pb.BuilderInfo('Status', + package: const $pb.PackageName('google.rpc'), createEmptyInstance: create) + ..a<$core.int>(1, 'code', $pb.PbFieldType.O3) + ..aOS(2, 'message') + ..pc<$0.Any>(3, 'details', $pb.PbFieldType.PM, subBuilder: $0.Any.create) + ..hasRequiredFields = false; Status._() : super(); factory Status() => create(); @@ -35,24 +35,35 @@ class Status extends $pb.GeneratedMessage { static Status create() => Status._(); Status createEmptyInstance() => create(); static $pb.PbList createRepeated() => $pb.PbList(); - static Status getDefault() => _defaultInstance ??= create()..freeze(); + @$core.pragma('dart2js:noInline') + static Status getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); static Status _defaultInstance; - $core.int get code => $_get(0, 0); + @$pb.TagNumber(1) + $core.int get code => $_getIZ(0); + @$pb.TagNumber(1) set code($core.int v) { $_setSignedInt32(0, v); } + @$pb.TagNumber(1) $core.bool hasCode() => $_has(0); + @$pb.TagNumber(1) void clearCode() => clearField(1); - $core.String get message => $_getS(1, ''); + @$pb.TagNumber(2) + $core.String get message => $_getSZ(1); + @$pb.TagNumber(2) set message($core.String v) { $_setString(1, v); } + @$pb.TagNumber(2) $core.bool hasMessage() => $_has(1); + @$pb.TagNumber(2) void clearMessage() => clearField(2); + @$pb.TagNumber(3) $core.List<$0.Any> get details => $_getList(2); } diff --git a/example/googleapis/lib/src/generated/google/rpc/status.pbenum.dart b/example/googleapis/lib/src/generated/google/rpc/status.pbenum.dart index 3872b584..3c022b46 100644 --- a/example/googleapis/lib/src/generated/google/rpc/status.pbenum.dart +++ b/example/googleapis/lib/src/generated/google/rpc/status.pbenum.dart @@ -1,5 +1,6 @@ /// // Generated code. Do not modify. // source: google/rpc/status.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type diff --git a/example/googleapis/lib/src/generated/google/rpc/status.pbjson.dart b/example/googleapis/lib/src/generated/google/rpc/status.pbjson.dart index 6c868704..cbb32ac9 100644 --- a/example/googleapis/lib/src/generated/google/rpc/status.pbjson.dart +++ b/example/googleapis/lib/src/generated/google/rpc/status.pbjson.dart @@ -1,15 +1,16 @@ /// // Generated code. Do not modify. // source: google/rpc/status.proto -/// -// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name +// +// @dart = 2.3 +// ignore_for_file: camel_case_types,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type -const Status$json = { +const Status$json = const { '1': 'Status', - '2': [ - {'1': 'code', '3': 1, '4': 1, '5': 5, '10': 'code'}, - {'1': 'message', '3': 2, '4': 1, '5': 9, '10': 'message'}, - { + '2': const [ + const {'1': 'code', '3': 1, '4': 1, '5': 5, '10': 'code'}, + const {'1': 'message', '3': 2, '4': 1, '5': 9, '10': 'message'}, + const { '1': 'details', '3': 3, '4': 3, From f06943da4086a5d892f83ab27fbea61d9bd55740 Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Thu, 17 Sep 2020 14:08:25 -0400 Subject: [PATCH 12/21] Added unit tests for extracting error details from grpc-status-details-bin --- lib/src/client/call.dart | 28 +++++--- test/client_tests/client_test.dart | 107 +++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 10 deletions(-) diff --git a/lib/src/client/call.dart b/lib/src/client/call.dart index f056c0d1..7b9d8c46 100644 --- a/lib/src/client/call.dart +++ b/lib/src/client/call.dart @@ -255,7 +255,7 @@ class ClientCall implements Response { _responseError(GrpcError.custom( statusCode, message, - _decodeStatusDetails(metadata['grpc-status-details-bin']), + decodeStatusDetails(metadata['grpc-status-details-bin']), )); } } @@ -302,7 +302,7 @@ class ClientCall implements Response { _responseError(GrpcError.custom( statusCode, message, - _decodeStatusDetails(_headerMetadata['grpc-status-details-bin']), + decodeStatusDetails(_headerMetadata['grpc-status-details-bin']), )); } } @@ -368,14 +368,22 @@ class ClientCall implements Response { } } -List _decodeStatusDetails(String data) { - /// Parse details out of message. Length must be an even multiple of 4 so we pad it if needed. - var details = data ?? ''; - while (details.length % 4 != 0) { - details += '='; +/// Given a string, ensure the length is a multiple of 4, adding padding if needed. +String padBase64Multiple4(String input) { + var data = input ?? ''; + while (data.length % 4 != 0) { + data += '='; } + return data; +} - /// Parse each Any type into the correct GeneratedMessage - final parsedStatus = Status.fromBuffer(base64Url.decode(details)); - return parsedStatus.details.map((e) => parseGeneratedMessage(e)).toList(); +List decodeStatusDetails(String data) { + try { + /// Parse each Any type into the correct GeneratedMessage + final parsedStatus = + Status.fromBuffer(base64Url.decode(padBase64Multiple4(data))); + return parsedStatus.details.map((e) => parseGeneratedMessage(e)).toList(); + } catch (e) { + return []; + } } diff --git a/test/client_tests/client_test.dart b/test/client_tests/client_test.dart index 70480df6..f9ed0ba2 100644 --- a/test/client_tests/client_test.dart +++ b/test/client_tests/client_test.dart @@ -14,10 +14,15 @@ // limitations under the License. import 'dart:async'; +import 'dart:convert'; import 'package:grpc/grpc.dart'; +import 'package:grpc/src/client/call.dart'; import 'package:grpc/src/client/http2_connection.dart'; +import 'package:grpc/src/generated/google/rpc/status.pb.dart'; +import 'package:grpc/src/shared/status.dart'; import 'package:http2/transport.dart'; +import 'package:protobuf/protobuf.dart'; import 'package:test/test.dart'; import '../src/client_utils.dart'; @@ -399,4 +404,106 @@ void main() { expect(Http2ClientConnection('localhost', null, channelOptions).authority, 'myauthority.com'); }); + + test( + 'padBase64Multiple4 should pad a string that is not a length multiple of 4', + () { + final str = '111'; + final padded = padBase64Multiple4(str); + expect(padded, '111='); + }); + + test( + 'padBase64Multiple4 should return the original string if it is a multiple of 4', + () { + final str = '1111'; + final padded = padBase64Multiple4(str); + expect(padded, '1111'); + }); + + test('padBase64Multiple4 should handle empty string', () { + final str = ''; + final padded = padBase64Multiple4(str); + expect(padded, ''); + }); + + test('padBase64Multiple4 should handle null string', () { + final str = null; + final padded = padBase64Multiple4(str); + expect(padded, ''); + }); + + test( + 'decodeStatusDetails should decode details into a List if base64 present', + () { + final decodedDetails = decodeStatusDetails( + 'CAMSEGFtb3VudCB0b28gc21hbGwafgopdHlwZS5nb29nbGVhcGlzLmNvbS9nb29nbGUucnBjLkJhZFJlcXVlc3QSUQpPCgZhbW91bnQSRVRoZSByZXF1aXJlZCBjdXJyZW5jeSBjb252ZXJzaW9uIHdvdWxkIHJlc3VsdCBpbiBhIHplcm8gdmFsdWUgcGF5bWVudA'); + expect(decodedDetails, isA>()); + expect(decodedDetails.length, 1); + }); + + test( + 'decodeStatusDetails should decode details into an empty list for an invalid base64 string', + () { + final decodedDetails = decodeStatusDetails('xxxxxxxxxxxxxxxxxxxxxx'); + expect(decodedDetails, isA>()); + expect(decodedDetails.length, 0); + }); + + test('decodeStatusDetails should handle a null input', () { + final decodedDetails = decodeStatusDetails(null); + expect(decodedDetails, isA>()); + expect(decodedDetails.length, 0); + }); + + test('parseGeneratedMessage should parse out a valid Any type', () { + final status = Status.fromBuffer(base64Url.decode( + 'CAMSEGFtb3VudCB0b28gc21hbGwafgopdHlwZS5nb29nbGVhcGlzLmNvbS9nb29nbGUucnBjLkJhZFJlcXVlc3QSUQpPCgZhbW91bnQSRVRoZSByZXF1aXJlZCBjdXJyZW5jeSBjb252ZXJzaW9uIHdvdWxkIHJlc3VsdCBpbiBhIHplcm8gdmFsdWUgcGF5bWVudA==')); + expect(status.details, isNotEmpty); + + final detailItem = status.details.first; + final parsedResult = parseGeneratedMessage(detailItem); + expect(parsedResult, isA()); + + final castedResult = parsedResult as BadRequest; + expect(castedResult.fieldViolations, isNotEmpty); + expect(castedResult.fieldViolations.first.field_1, 'amount'); + expect(castedResult.fieldViolations.first.description, + 'The required currency conversion would result in a zero value payment'); + }); + + test('getStatusCodeValue should return the right status code', () { + expect(getStatusCodeValue(1), 'CANCELLED'); + }); + + test('getStatusCodeValue should return UNKNOWN for an invalid status code', + () { + expect(getStatusCodeValue(99), 'UNKNOWN'); + }); + + test('Call should throw details embedded in the headers', () async { + final code = StatusCode.invalidArgument; + final message = 'amount too small'; + final details = + 'CAMSEGFtb3VudCB0b28gc21hbGwafgopdHlwZS5nb29nbGVhcGlzLmNvbS9nb29nbGUucnBjLkJhZFJlcXVlc3QSUQpPCgZhbW91bnQSRVRoZSByZXF1aXJlZCBjdXJyZW5jeSBjb252ZXJzaW9uIHdvdWxkIHJlc3VsdCBpbiBhIHplcm8gdmFsdWUgcGF5bWVudA'; + + void handleRequest(_) { + harness.toClient.add(HeadersStreamMessage([ + Header.ascii('grpc-status', code.toString()), + Header.ascii('grpc-message', message), + Header.ascii('grpc-status-details-bin', details), + ], endStream: true)); + harness.toClient.close(); + } + + await harness.runFailureTest( + clientCall: harness.client.unary(dummyValue), + expectedException: GrpcError.custom( + code, + message, + decodeStatusDetails(details), + ), + serverHandlers: [handleRequest], + ); + }); } From a72916d1c05708ca89c7bbb5f8d43aebeefbf768 Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Thu, 17 Sep 2020 15:12:31 -0400 Subject: [PATCH 13/21] Bumped version and added changelog entry --- CHANGELOG.md | 3 +++ pubspec.yaml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c7f46ce..b90ae969 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2.3.0 +* Added parsing of response error details from `grpc-status-details-bin` to provide access to all provided exception details in the `GrpcError` thrown in Dart, via [#349](https://github.com/grpc/grpc-dart/pull/349). + ## 2.2.0+1 * Relax `crypto` version dependency constraint from `^2.1.5` to `^2.1.4`. diff --git a/pubspec.yaml b/pubspec.yaml index f981f674..5d033e2b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: grpc description: Dart implementation of gRPC, a high performance, open-source universal RPC framework. -version: 2.2.0+1 +version: 2.3.0 author: Dart Team homepage: https://github.com/dart-lang/grpc-dart From 9b94792a0bdcca7a558950038e43680010264e28 Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Mon, 21 Sep 2020 09:29:04 -0400 Subject: [PATCH 14/21] Updated readme to include how to use the regenerate.sh script to update protobuf definitions. Moved the regenerate script to the project root tool/ directory. --- README.md | 3 +++ lib/src/tool/regenerate.sh | 6 ------ tool/regenerate.sh | 6 ++++++ 3 files changed, 9 insertions(+), 6 deletions(-) delete mode 100755 lib/src/tool/regenerate.sh create mode 100755 tool/regenerate.sh diff --git a/README.md b/README.md index 2724ba49..94a84246 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,6 @@ For complete documentation, see [Dart gRPC](https://grpc.io/docs/languages/dart) If you experience problems or have feature requests, [open an issue](https://github.com/dart-lang/grpc-dart/issues/new). Note that we have limited bandwidth to accept PRs, and that all PRs require signing the [EasyCLA](https://lfcla.com). + +## Updating protobuf definitions +Sometimes we might need to update the generated dart files from the protos included in `lib/src/protos`. To do this, run the script `tool/regenerate.sh` from the project root and it will update the generated dart files in `lib/src/geneerated`. \ No newline at end of file diff --git a/lib/src/tool/regenerate.sh b/lib/src/tool/regenerate.sh deleted file mode 100755 index 41934210..00000000 --- a/lib/src/tool/regenerate.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -mkdir -p generated -protoc --dart_out=grpc:generated -Iprotos/ $(find protos -iname "*.proto") -rm generated/*.pbjson.dart -rm generated/{empty,test}.pbenum.dart -dartfmt -w generated diff --git a/tool/regenerate.sh b/tool/regenerate.sh new file mode 100755 index 00000000..84177e48 --- /dev/null +++ b/tool/regenerate.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +mkdir -p lib/src/generated +protoc --dart_out=grpc:lib/src/generated --proto_path lib/src/protos $(find lib/src/protos -iname "*.proto") +rm lib/src/generated/*.pbjson.dart +rm lib/src/generated/{empty,test}.pbenum.dart +dartfmt -w lib/src/generated From 977f2fcab83edb58ebbf85e28d67f83c8776c79a Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Mon, 21 Sep 2020 09:31:20 -0400 Subject: [PATCH 15/21] Removed todos related to parsing headers --- lib/src/client/call.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/src/client/call.dart b/lib/src/client/call.dart index 7b9d8c46..31021109 100644 --- a/lib/src/client/call.dart +++ b/lib/src/client/call.dart @@ -231,7 +231,6 @@ class ClientCall implements Response { _hasReceivedResponses = true; } else if (data is GrpcMetadata) { if (!_headers.isCompleted) { - // TODO(jakobr): Parse, and extract common headers. _headerMetadata = data.metadata; _headers.complete(_headerMetadata); return; @@ -242,7 +241,6 @@ class ClientCall implements Response { } final metadata = data.metadata; _trailers.complete(metadata); - // TODO(jakobr): Parse more! if (metadata.containsKey('grpc-status')) { final status = metadata['grpc-status']; final statusCode = status != null ? int.parse(status) : 0; From cd197160a01b0b1ac641eccd433d5b4f55f20f9c Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Mon, 21 Sep 2020 12:03:55 -0400 Subject: [PATCH 16/21] More code review fixes --- lib/src/client/call.dart | 69 ++++++++++++------------------ lib/src/shared/status.dart | 58 ++++++++++++------------- test/client_tests/client_test.dart | 39 +---------------- 3 files changed, 56 insertions(+), 110 deletions(-) diff --git a/lib/src/client/call.dart b/lib/src/client/call.dart index 31021109..b3d582b7 100644 --- a/lib/src/client/call.dart +++ b/lib/src/client/call.dart @@ -215,6 +215,24 @@ class ClientCall implements Response { _stream.terminate(); } + /// If there's an error status then process it as a response error + void _checkForErrorStatus(Map metadata) { + final status = metadata['grpc-status']; + final statusCode = int.parse(status ?? '0'); + + if (statusCode != 0) { + final message = metadata['grpc-message'] == null + ? null + : Uri.decodeFull(metadata['grpc-message']); + + _responseError(GrpcError.custom( + statusCode, + message, + decodeStatusDetails(metadata['grpc-status-details-bin']), + )); + } + } + /// Data handler for responses coming from the server. Handles header/trailer /// metadata, and forwards response objects to [_responses]. void _onResponseData(GrpcMessage data) { @@ -241,22 +259,9 @@ class ClientCall implements Response { } final metadata = data.metadata; _trailers.complete(metadata); - if (metadata.containsKey('grpc-status')) { - final status = metadata['grpc-status']; - final statusCode = status != null ? int.parse(status) : 0; - - if (statusCode != 0) { - final message = metadata['grpc-message'] == null - ? null - : Uri.decodeFull(metadata['grpc-message']); - - _responseError(GrpcError.custom( - statusCode, - message, - decodeStatusDetails(metadata['grpc-status-details-bin']), - )); - } - } + + /// Process status error if necessary + _checkForErrorStatus(metadata); } else { _responseError(GrpcError.unimplemented('Unexpected frame received')); } @@ -289,20 +294,9 @@ class ClientCall implements Response { // Only received a header frame and no data frames, so the header // should contain "trailers" as well (Trailers-Only). _trailers.complete(_headerMetadata); - final status = _headerMetadata['grpc-status']; - final statusCode = status != null ? int.parse(status) : 0; - - if (statusCode != 0) { - final message = _headerMetadata['grpc-message'] == null - ? null - : Uri.decodeFull(_headerMetadata['grpc-message']); - - _responseError(GrpcError.custom( - statusCode, - message, - decodeStatusDetails(_headerMetadata['grpc-status-details-bin']), - )); - } + + /// Process status error if necessary + _checkForErrorStatus(_headerMetadata); } _timeoutTimer?.cancel(); _responses.close(); @@ -366,21 +360,12 @@ class ClientCall implements Response { } } -/// Given a string, ensure the length is a multiple of 4, adding padding if needed. -String padBase64Multiple4(String input) { - var data = input ?? ''; - while (data.length % 4 != 0) { - data += '='; - } - return data; -} - List decodeStatusDetails(String data) { try { /// Parse each Any type into the correct GeneratedMessage - final parsedStatus = - Status.fromBuffer(base64Url.decode(padBase64Multiple4(data))); - return parsedStatus.details.map((e) => parseGeneratedMessage(e)).toList(); + final parsedStatus = Status.fromBuffer( + base64Url.decode(data.padRight((data.length + 3) & ~3, '='))); + return parsedStatus.details.map(parseErrorDetailsFromAny).toList(); } catch (e) { return []; } diff --git a/lib/src/shared/status.dart b/lib/src/shared/status.dart index 1374f88c..3326fb45 100644 --- a/lib/src/shared/status.dart +++ b/lib/src/shared/status.dart @@ -16,6 +16,7 @@ import 'package:grpc/src/generated/google/protobuf/any.pb.dart'; import 'package:grpc/src/generated/google/rpc/code.pbenum.dart'; import 'package:grpc/src/generated/google/rpc/error_details.pb.dart'; +import 'package:meta/meta.dart'; import 'package:protobuf/protobuf.dart'; class StatusCode { @@ -130,17 +131,17 @@ class GrpcError implements Exception { /// Custom error code. GrpcError.custom(this.code, [this.message, this.details]) - : codeName = getStatusCodeValue(code); + : codeName = _getStatusCodeValue(code); /// The operation completed successfully. GrpcError.ok([this.message, this.details]) : code = StatusCode.ok, - codeName = getStatusCodeValue(StatusCode.ok); + codeName = _getStatusCodeValue(StatusCode.ok); /// The operation was cancelled (typically by the caller). GrpcError.cancelled([this.message, this.details]) : code = StatusCode.cancelled, - codeName = getStatusCodeValue(StatusCode.cancelled); + codeName = _getStatusCodeValue(StatusCode.cancelled); /// Unknown error. An example of where this error may be returned is if a /// Status value received from another address space belongs to an error-space @@ -148,7 +149,7 @@ class GrpcError implements Exception { /// do not return enough error information may be converted to this error. GrpcError.unknown([this.message, this.details]) : code = StatusCode.unknown, - codeName = getStatusCodeValue(StatusCode.unknown); + codeName = _getStatusCodeValue(StatusCode.unknown); /// Client specified an invalid argument. Note that this differs from /// [failedPrecondition]. [invalidArgument] indicates arguments that are @@ -156,7 +157,7 @@ class GrpcError implements Exception { /// name). GrpcError.invalidArgument([this.message, this.details]) : code = StatusCode.invalidArgument, - codeName = getStatusCodeValue(StatusCode.invalidArgument); + codeName = _getStatusCodeValue(StatusCode.invalidArgument); /// Deadline expired before operation could complete. For operations that /// change the state of the system, this error may be returned even if the @@ -165,18 +166,18 @@ class GrpcError implements Exception { /// expire. GrpcError.deadlineExceeded([this.message, this.details]) : code = StatusCode.deadlineExceeded, - codeName = getStatusCodeValue(StatusCode.deadlineExceeded); + codeName = _getStatusCodeValue(StatusCode.deadlineExceeded); /// Some requested entity (e.g., file or directory) was not found. GrpcError.notFound([this.message, this.details]) : code = StatusCode.notFound, - codeName = getStatusCodeValue(StatusCode.notFound); + codeName = _getStatusCodeValue(StatusCode.notFound); /// Some entity that we attempted to create (e.g., file or directory) already /// exists. GrpcError.alreadyExists([this.message, this.details]) : code = StatusCode.alreadyExists, - codeName = getStatusCodeValue(StatusCode.alreadyExists); + codeName = _getStatusCodeValue(StatusCode.alreadyExists); /// The caller does not have permission to execute the specified operation. /// [permissionDenied] must not be used for rejections caused by exhausting @@ -185,13 +186,13 @@ class GrpcError implements Exception { /// (use [unauthenticated] instead for those errors). GrpcError.permissionDenied([this.message, this.details]) : code = StatusCode.permissionDenied, - codeName = getStatusCodeValue(StatusCode.permissionDenied); + codeName = _getStatusCodeValue(StatusCode.permissionDenied); /// Some resource has been exhausted, perhaps a per-user quota, or perhaps the /// entire file system is out of space. GrpcError.resourceExhausted([this.message, this.details]) : code = StatusCode.resourceExhausted, - codeName = getStatusCodeValue(StatusCode.resourceExhausted); + codeName = _getStatusCodeValue(StatusCode.resourceExhausted); /// Operation was rejected because the system is not in a state required for /// the operation's execution. For example, directory to be deleted may be @@ -209,7 +210,7 @@ class GrpcError implements Exception { /// fixed up the directory by deleting files from it. GrpcError.failedPrecondition([this.message, this.details]) : code = StatusCode.failedPrecondition, - codeName = getStatusCodeValue(StatusCode.failedPrecondition); + codeName = _getStatusCodeValue(StatusCode.failedPrecondition); /// The operation was aborted, typically due to a concurrency issue like /// sequencer check failures, transaction aborts, etc. @@ -218,7 +219,7 @@ class GrpcError implements Exception { /// [aborted], and [unavailable]. GrpcError.aborted([this.message, this.details]) : code = StatusCode.aborted, - codeName = getStatusCodeValue(StatusCode.aborted); + codeName = _getStatusCodeValue(StatusCode.aborted); /// Operation was attempted past the valid range. E.g., seeking or reading /// past end of file. @@ -235,19 +236,19 @@ class GrpcError implements Exception { /// easily look for an [outOfRange] error to detect when they are done. GrpcError.outOfRange([this.message, this.details]) : code = StatusCode.outOfRange, - codeName = getStatusCodeValue(StatusCode.outOfRange); + codeName = _getStatusCodeValue(StatusCode.outOfRange); /// Operation is not implemented or not supported/enabled in this service. GrpcError.unimplemented([this.message, this.details]) : code = StatusCode.unimplemented, - codeName = getStatusCodeValue(StatusCode.unimplemented); + codeName = _getStatusCodeValue(StatusCode.unimplemented); /// Internal errors. Means some invariants expected by underlying system has /// been broken. If you see one of these errors, something is very broken. // TODO(sigurdm): This should probably not be an [Exception]. GrpcError.internal([this.message, this.details]) : code = StatusCode.internal, - codeName = getStatusCodeValue(StatusCode.internal); + codeName = _getStatusCodeValue(StatusCode.internal); /// The service is currently unavailable. This is a most likely a transient /// condition and may be corrected by retrying with a backoff. @@ -256,18 +257,18 @@ class GrpcError implements Exception { /// [aborted], and [unavailable]. GrpcError.unavailable([this.message, this.details]) : code = StatusCode.unavailable, - codeName = getStatusCodeValue(StatusCode.unavailable); + codeName = _getStatusCodeValue(StatusCode.unavailable); /// Unrecoverable data loss or corruption. GrpcError.dataLoss([this.message, this.details]) : code = StatusCode.dataLoss, - codeName = getStatusCodeValue(StatusCode.dataLoss); + codeName = _getStatusCodeValue(StatusCode.dataLoss); /// The request does not have valid authentication credentials for the /// operation. GrpcError.unauthenticated([this.message, this.details]) : code = StatusCode.unauthenticated, - codeName = getStatusCodeValue(StatusCode.unauthenticated); + codeName = _getStatusCodeValue(StatusCode.unauthenticated); @override bool operator ==(other) { @@ -284,18 +285,15 @@ class GrpcError implements Exception { } /// Given a status code, return the name -String getStatusCodeValue(int code) { - if (code > Code.values.length - 1) { - return Code.UNKNOWN.name; - } else { - return Code.values - .firstWhere((e) => e.value == code, orElse: () => Code.UNKNOWN) - .name; - } -} - -/// Parse error details into the right kind of GeneratedMessage. -GeneratedMessage parseGeneratedMessage(Any any) { +String _getStatusCodeValue(int code) => + (Code.valueOf(code) ?? Code.UNKNOWN).name; + +/// Parse error details `Any` object into the right kind of `GeneratedMessage`. +/// +/// This list comes from `error_details.proto`. If any new error detail types are +/// added to the protbuf definition, this function should be updated accordingly to +/// support them. +GeneratedMessage parseErrorDetailsFromAny(Any any) { switch (any.typeUrl) { case 'type.googleapis.com/google.rpc.RetryInfo': return RetryInfo.fromBuffer(any.value); diff --git a/test/client_tests/client_test.dart b/test/client_tests/client_test.dart index f9ed0ba2..0cd3c6de 100644 --- a/test/client_tests/client_test.dart +++ b/test/client_tests/client_test.dart @@ -405,34 +405,6 @@ void main() { 'myauthority.com'); }); - test( - 'padBase64Multiple4 should pad a string that is not a length multiple of 4', - () { - final str = '111'; - final padded = padBase64Multiple4(str); - expect(padded, '111='); - }); - - test( - 'padBase64Multiple4 should return the original string if it is a multiple of 4', - () { - final str = '1111'; - final padded = padBase64Multiple4(str); - expect(padded, '1111'); - }); - - test('padBase64Multiple4 should handle empty string', () { - final str = ''; - final padded = padBase64Multiple4(str); - expect(padded, ''); - }); - - test('padBase64Multiple4 should handle null string', () { - final str = null; - final padded = padBase64Multiple4(str); - expect(padded, ''); - }); - test( 'decodeStatusDetails should decode details into a List if base64 present', () { @@ -462,7 +434,7 @@ void main() { expect(status.details, isNotEmpty); final detailItem = status.details.first; - final parsedResult = parseGeneratedMessage(detailItem); + final parsedResult = parseErrorDetailsFromAny(detailItem); expect(parsedResult, isA()); final castedResult = parsedResult as BadRequest; @@ -472,15 +444,6 @@ void main() { 'The required currency conversion would result in a zero value payment'); }); - test('getStatusCodeValue should return the right status code', () { - expect(getStatusCodeValue(1), 'CANCELLED'); - }); - - test('getStatusCodeValue should return UNKNOWN for an invalid status code', - () { - expect(getStatusCodeValue(99), 'UNKNOWN'); - }); - test('Call should throw details embedded in the headers', () async { final code = StatusCode.invalidArgument; final message = 'amount too small'; From 058303ae7919ac4da3b39714a91d694d5c4ecad6 Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Tue, 22 Sep 2020 08:00:20 -0400 Subject: [PATCH 17/21] Fixes for code review --- CONTRIBUTING.md | 3 +++ README.md | 5 +---- lib/src/client/call.dart | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b87c68ff..5d966794 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,3 +63,6 @@ early on. - Exceptions to the rules can be made if there's a compelling reason for doing so. + +## Updating protobuf definitions +Sometimes we might need to update the generated dart files from the protos included in `lib/src/protos`. To do this, run the script `tool/regenerate.sh` from the project root and it will update the generated dart files in `lib/src/geneerated`. \ No newline at end of file diff --git a/README.md b/README.md index 94a84246..d3d94348 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,4 @@ For complete documentation, see [Dart gRPC](https://grpc.io/docs/languages/dart) If you experience problems or have feature requests, [open an issue](https://github.com/dart-lang/grpc-dart/issues/new). -Note that we have limited bandwidth to accept PRs, and that all PRs require signing the [EasyCLA](https://lfcla.com). - -## Updating protobuf definitions -Sometimes we might need to update the generated dart files from the protos included in `lib/src/protos`. To do this, run the script `tool/regenerate.sh` from the project root and it will update the generated dart files in `lib/src/geneerated`. \ No newline at end of file +Note that we have limited bandwidth to accept PRs, and that all PRs require signing the [EasyCLA](https://lfcla.com). \ No newline at end of file diff --git a/lib/src/client/call.dart b/lib/src/client/call.dart index b3d582b7..5e30d411 100644 --- a/lib/src/client/call.dart +++ b/lib/src/client/call.dart @@ -17,6 +17,7 @@ import 'dart:async'; import 'dart:convert'; import 'package:grpc/src/generated/google/rpc/status.pb.dart'; +import 'package:meta/meta.dart'; import 'package:protobuf/protobuf.dart'; import '../shared/message.dart'; @@ -360,6 +361,7 @@ class ClientCall implements Response { } } +@visibleForTesting List decodeStatusDetails(String data) { try { /// Parse each Any type into the correct GeneratedMessage From b8ffd5059d34e36f5e0ece961b6ac5e852955182 Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Wed, 23 Sep 2020 08:42:33 -0400 Subject: [PATCH 18/21] Add return carriage to last line of readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d3d94348..2724ba49 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,4 @@ For complete documentation, see [Dart gRPC](https://grpc.io/docs/languages/dart) If you experience problems or have feature requests, [open an issue](https://github.com/dart-lang/grpc-dart/issues/new). -Note that we have limited bandwidth to accept PRs, and that all PRs require signing the [EasyCLA](https://lfcla.com). \ No newline at end of file +Note that we have limited bandwidth to accept PRs, and that all PRs require signing the [EasyCLA](https://lfcla.com). From 150268e6e7766db7ae324ae82fa64b73034532ff Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Wed, 23 Sep 2020 08:49:34 -0400 Subject: [PATCH 19/21] Improve comment for decodeStatusDetails --- lib/src/client/call.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/src/client/call.dart b/lib/src/client/call.dart index 5e30d411..1d95983e 100644 --- a/lib/src/client/call.dart +++ b/lib/src/client/call.dart @@ -361,10 +361,18 @@ class ClientCall implements Response { } } +/// Given a string of base64url data, attempt to parse a Status object from it. +/// Once parsed, it will then map each detail item and attempt to parse it into +/// its respective GeneratedMessage type, returning the list of parsed detail items +/// as a `List`. +/// +/// Prior to creating the Status object we pad the data to ensure its length is +/// an even multiple of 4, which is a requirement in Dart when decoding base64url data. +/// +/// If any errors are thrown during decoding/parsing, it will return an empty list. @visibleForTesting List decodeStatusDetails(String data) { try { - /// Parse each Any type into the correct GeneratedMessage final parsedStatus = Status.fromBuffer( base64Url.decode(data.padRight((data.length + 3) & ~3, '='))); return parsedStatus.details.map(parseErrorDetailsFromAny).toList(); From d5db7930eab2b1452374da03140cd1dbfe551e51 Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Wed, 23 Sep 2020 10:15:10 -0400 Subject: [PATCH 20/21] Bump pubspec version --- pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 5d033e2b..66109d1f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,13 +1,13 @@ name: grpc description: Dart implementation of gRPC, a high performance, open-source universal RPC framework. -version: 2.3.0 +version: 2.4.0 author: Dart Team homepage: https://github.com/dart-lang/grpc-dart environment: - sdk: '>=2.2.0 <3.0.0' + sdk: ">=2.2.0 <3.0.0" dependencies: async: ^2.2.0 From 97fa8991e102c3c1ef7ceca398b5df233821c031 Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Mon, 26 Oct 2020 10:43:57 -0400 Subject: [PATCH 21/21] Bump version and add DS_Store to gitignore --- .gitignore | 3 +++ CHANGELOG.md | 2 +- pubspec.yaml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4fb07239..cbc3e2a5 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ doc/api/ # Directory created by WebStorm .idea/ + +# Macos +.DS_Store \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index cc40598c..8895f007 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 2.4.0 +## 2.7.0 * Added decoding/parsing of `grpc-status-details-bin` to pass all response exception details to the `GrpcError` thrown in Dart, via [#349](https://github.com/grpc/grpc-dart/pull/349). diff --git a/pubspec.yaml b/pubspec.yaml index 66109d1f..3bc1d5d5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: grpc description: Dart implementation of gRPC, a high performance, open-source universal RPC framework. -version: 2.4.0 +version: 2.7.0 author: Dart Team homepage: https://github.com/dart-lang/grpc-dart