Refactor the vendored protos (#1000)
diff --git a/.gitignore b/.gitignore index 5b83f42..a189518 100644 --- a/.gitignore +++ b/.gitignore
@@ -1,7 +1,4 @@ -.children .dart_tool/ -.idea -.packages .pub build/ pubspec.lock
diff --git a/benchmarks/.gitignore b/benchmarks/.gitignore index c766086..a6779a9 100644 --- a/benchmarks/.gitignore +++ b/benchmarks/.gitignore
@@ -1,2 +1,5 @@ +# Generated by pub +.dart_tool/ +pubspec.lock + lib/generated/ -out/
diff --git a/protoc_plugin/.gitignore b/protoc_plugin/.gitignore index 40fd954..1f4e744 100644 --- a/protoc_plugin/.gitignore +++ b/protoc_plugin/.gitignore
@@ -1,12 +1,6 @@ # Generated by pub .dart_tool/ -.packages pubspec.lock # Other generated files -benchmark/data/pubspec.link.yaml -benchmark/data/pubspec.link.lock -benchmark/data/hostname.txt -benchmark/data/latest_vm.pb.json -benchmark/lib/generated out/
diff --git a/protoc_plugin/Makefile b/protoc_plugin/Makefile index 9b68b43..c7379fb 100644 --- a/protoc_plugin/Makefile +++ b/protoc_plugin/Makefile
@@ -77,38 +77,36 @@ TEST_PROTO_SRCS=$(foreach proto, $(TEST_PROTO_LIST), \ $(TEST_PROTO_SRC_DIR)/$(proto).proto) -PREGENERATED_SRCS=protos/descriptor.proto protos/client.proto protos/plugin.proto protos/dart_options.proto +PREGENERATED_SRCS := $(shell find protos -name '*.proto') $(TEST_PROTO_LIBS): $(PLUGIN_SRC) $(TEST_PROTO_SRCS) mkdir -p $(TEST_PROTO_DIR) protoc\ - --experimental_allow_proto3_optional\ --dart_out="disable_constructor_args:$(TEST_PROTO_DIR)"\ - -Iprotos\ -I$(TEST_PROTO_SRC_DIR)\ + -Iprotos\ --plugin=protoc-gen-dart=$(realpath $(PLUGIN_PATH))\ $(TEST_PROTO_SRCS) mkdir -p $(TEST_PROTO_DIR)/constructor_args protoc\ - --experimental_allow_proto3_optional\ --dart_out="$(TEST_PROTO_DIR)/constructor_args"\ - -Iprotos\ -I$(TEST_PROTO_SRC_DIR)\ + -Iprotos\ --plugin=protoc-gen-dart=$(realpath $(PLUGIN_PATH))\ $(TEST_PROTO_SRCS) dart format $(TEST_PROTO_DIR) update-pregenerated: $(PLUGIN_PATH) $(PREGENERATED_SRCS) - protoc --dart_out=lib/src/generated -Iprotos --plugin=protoc-gen-dart=$(realpath $(PLUGIN_PATH)) $(PREGENERATED_SRCS) - rm lib/src/generated/client.pb{json,server}.dart - rm lib/src/generated/descriptor.pb{json,server}.dart - rm lib/src/generated/dart_options.pb{enum,json,server}.dart - rm lib/src/generated/plugin.pb{json,server}.dart - dart format lib/src/generated + protoc --dart_out=lib/src/gen \ + -Iprotos \ + --plugin=protoc-gen-dart=$(realpath $(PLUGIN_PATH)) $(PREGENERATED_SRCS) + find lib/src/gen -name '*.pbjson.dart' -delete + find lib/src/gen -name '*.pbserver.dart' -delete + dart format lib/src/gen protos: $(PLUGIN_PATH) $(TEST_PROTO_LIBS)
diff --git a/protoc_plugin/lib/indenting_writer.dart b/protoc_plugin/lib/indenting_writer.dart index 307b785..641cc0a 100644 --- a/protoc_plugin/lib/indenting_writer.dart +++ b/protoc_plugin/lib/indenting_writer.dart
@@ -4,7 +4,7 @@ import 'dart:collection'; -import 'src/generated/descriptor.pb.dart'; +import 'src/gen/google/protobuf/descriptor.pb.dart'; /// Specifies code locations where metadata annotations should be attached and /// where they should point to in the original proto. @@ -184,6 +184,9 @@ _packageExports.isNotEmpty || _fileExports.isNotEmpty; + bool get hasSrcImport => + _packageImports.any((item) => item.contains('/src/')); + /// Add an import with an optional import prefix. void addImport(String url, {String? prefix}) { final directive =
diff --git a/protoc_plugin/lib/names.dart b/protoc_plugin/lib/names.dart index 99d666a..52460c4 100644 --- a/protoc_plugin/lib/names.dart +++ b/protoc_plugin/lib/names.dart
@@ -6,8 +6,8 @@ import 'package:protobuf/meta.dart'; -import 'src/generated/dart_options.pb.dart'; -import 'src/generated/descriptor.pb.dart'; +import 'src/gen/dart_options.pb.dart'; +import 'src/gen/google/protobuf/descriptor.pb.dart'; class MemberNames { List<FieldNames> fieldNames;
diff --git a/protoc_plugin/lib/protoc.dart b/protoc_plugin/lib/protoc.dart index 8020405..424a4a0 100644 --- a/protoc_plugin/lib/protoc.dart +++ b/protoc_plugin/lib/protoc.dart
@@ -7,10 +7,10 @@ import 'mixins.dart'; import 'names.dart'; import 'src/code_generator.dart'; -import 'src/generated/client.pb.dart'; -import 'src/generated/dart_options.pb.dart'; -import 'src/generated/descriptor.pb.dart'; -import 'src/generated/plugin.pb.dart'; +import 'src/gen/dart_options.pb.dart'; +import 'src/gen/google/api/client.pb.dart'; +import 'src/gen/google/protobuf/compiler/plugin.pb.dart'; +import 'src/gen/google/protobuf/descriptor.pb.dart'; import 'src/linker.dart'; import 'src/options.dart'; import 'src/output_config.dart';
diff --git a/protoc_plugin/lib/src/code_generator.dart b/protoc_plugin/lib/src/code_generator.dart index 45cfe55..7e15cd0 100644 --- a/protoc_plugin/lib/src/code_generator.dart +++ b/protoc_plugin/lib/src/code_generator.dart
@@ -11,9 +11,9 @@ import '../names.dart' show lowerCaseFirstLetter; import '../protoc.dart' show FileGenerator; -import 'generated/client.pb.dart'; -import 'generated/dart_options.pb.dart'; -import 'generated/plugin.pb.dart'; +import 'gen/dart_options.pb.dart'; +import 'gen/google/api/client.pb.dart'; +import 'gen/google/protobuf/compiler/plugin.pb.dart'; import 'linker.dart'; import 'options.dart'; import 'output_config.dart';
diff --git a/protoc_plugin/lib/src/file_generator.dart b/protoc_plugin/lib/src/file_generator.dart index cb06ca0..40306aa 100644 --- a/protoc_plugin/lib/src/file_generator.dart +++ b/protoc_plugin/lib/src/file_generator.dart
@@ -303,8 +303,6 @@ /// Writes the header and imports for the .pb.dart file. void writeMainHeader(IndentingWriter out, [OutputConfiguration config = const DefaultOutputConfiguration()]) { - _writeHeading(out); - final importWriter = ImportWriter(); // We only add the dart:async import if there are generic client API @@ -356,6 +354,14 @@ importWriter.addExport(url.toString()); } + // The well-known-types mixins create src/ refs into package:protobuf; we + // should likely refactor this so they're regular (non-src/) references. + // + // For now, we surpress the analysis warning. + _writeHeading(out, extraIgnores: { + if (importWriter.hasSrcImport) 'implementation_imports', + }); + out.println(importWriter.emit()); }
diff --git a/protoc_plugin/lib/src/generated/dart_options.pb.dart b/protoc_plugin/lib/src/gen/dart_options.pb.dart similarity index 100% rename from protoc_plugin/lib/src/generated/dart_options.pb.dart rename to protoc_plugin/lib/src/gen/dart_options.pb.dart
diff --git a/protoc_plugin/lib/src/gen/dart_options.pbenum.dart b/protoc_plugin/lib/src/gen/dart_options.pbenum.dart new file mode 100644 index 0000000..ab0e780 --- /dev/null +++ b/protoc_plugin/lib/src/gen/dart_options.pbenum.dart
@@ -0,0 +1,10 @@ +// +// Generated code. Do not modify. +// source: dart_options.proto +// +// @dart = 3.3 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import
diff --git a/protoc_plugin/lib/src/generated/client.pb.dart b/protoc_plugin/lib/src/gen/google/api/client.pb.dart similarity index 69% rename from protoc_plugin/lib/src/generated/client.pb.dart rename to protoc_plugin/lib/src/gen/google/api/client.pb.dart index dfccc2d..3aa47fc 100644 --- a/protoc_plugin/lib/src/generated/client.pb.dart +++ b/protoc_plugin/lib/src/gen/google/api/client.pb.dart
@@ -1,6 +1,6 @@ // // Generated code. Do not modify. -// source: client.proto +// source: google/api/client.proto // // @dart = 3.3 @@ -13,7 +13,9 @@ import 'package:protobuf/protobuf.dart' as $pb; +import '../protobuf/duration.pb.dart' as $0; import 'client.pbenum.dart'; +import 'launch_stage.pbenum.dart' as $1; export 'package:protobuf/protobuf.dart' show GeneratedMessageGenericExtensions; @@ -123,11 +125,284 @@ SelectiveGapicGeneration ensureSelectiveGapicGeneration() => $_ensure(2); } +/// Details about how and where to publish client libraries. +class ClientLibrarySettings extends $pb.GeneratedMessage { + factory ClientLibrarySettings({ + $core.String? version, + $1.LaunchStage? launchStage, + $core.bool? restNumericEnums, + JavaSettings? javaSettings, + CppSettings? cppSettings, + PhpSettings? phpSettings, + PythonSettings? pythonSettings, + NodeSettings? nodeSettings, + DotnetSettings? dotnetSettings, + RubySettings? rubySettings, + GoSettings? goSettings, + }) { + final $result = create(); + if (version != null) { + $result.version = version; + } + if (launchStage != null) { + $result.launchStage = launchStage; + } + if (restNumericEnums != null) { + $result.restNumericEnums = restNumericEnums; + } + if (javaSettings != null) { + $result.javaSettings = javaSettings; + } + if (cppSettings != null) { + $result.cppSettings = cppSettings; + } + if (phpSettings != null) { + $result.phpSettings = phpSettings; + } + if (pythonSettings != null) { + $result.pythonSettings = pythonSettings; + } + if (nodeSettings != null) { + $result.nodeSettings = nodeSettings; + } + if (dotnetSettings != null) { + $result.dotnetSettings = dotnetSettings; + } + if (rubySettings != null) { + $result.rubySettings = rubySettings; + } + if (goSettings != null) { + $result.goSettings = goSettings; + } + return $result; + } + ClientLibrarySettings._() : super(); + factory ClientLibrarySettings.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory ClientLibrarySettings.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'ClientLibrarySettings', + package: const $pb.PackageName(_omitMessageNames ? '' : 'google.api'), + createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'version') + ..e<$1.LaunchStage>( + 2, _omitFieldNames ? '' : 'launchStage', $pb.PbFieldType.OE, + defaultOrMaker: $1.LaunchStage.LAUNCH_STAGE_UNSPECIFIED, + valueOf: $1.LaunchStage.valueOf, + enumValues: $1.LaunchStage.values) + ..aOB(3, _omitFieldNames ? '' : 'restNumericEnums') + ..aOM<JavaSettings>(21, _omitFieldNames ? '' : 'javaSettings', + subBuilder: JavaSettings.create) + ..aOM<CppSettings>(22, _omitFieldNames ? '' : 'cppSettings', + subBuilder: CppSettings.create) + ..aOM<PhpSettings>(23, _omitFieldNames ? '' : 'phpSettings', + subBuilder: PhpSettings.create) + ..aOM<PythonSettings>(24, _omitFieldNames ? '' : 'pythonSettings', + subBuilder: PythonSettings.create) + ..aOM<NodeSettings>(25, _omitFieldNames ? '' : 'nodeSettings', + subBuilder: NodeSettings.create) + ..aOM<DotnetSettings>(26, _omitFieldNames ? '' : 'dotnetSettings', + subBuilder: DotnetSettings.create) + ..aOM<RubySettings>(27, _omitFieldNames ? '' : 'rubySettings', + subBuilder: RubySettings.create) + ..aOM<GoSettings>(28, _omitFieldNames ? '' : 'goSettings', + subBuilder: GoSettings.create) + ..hasRequiredFields = false; + + @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') + ClientLibrarySettings clone() => + ClientLibrarySettings()..mergeFromMessage(this); + @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') + ClientLibrarySettings copyWith( + void Function(ClientLibrarySettings) updates) => + super.copyWith((message) => updates(message as ClientLibrarySettings)) + as ClientLibrarySettings; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static ClientLibrarySettings create() => ClientLibrarySettings._(); + ClientLibrarySettings createEmptyInstance() => create(); + static $pb.PbList<ClientLibrarySettings> createRepeated() => + $pb.PbList<ClientLibrarySettings>(); + @$core.pragma('dart2js:noInline') + static ClientLibrarySettings getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor<ClientLibrarySettings>(create); + static ClientLibrarySettings? _defaultInstance; + + /// Version of the API to apply these settings to. This is the full protobuf + /// package for the API, ending in the version element. + /// Examples: "google.cloud.speech.v1" and "google.spanner.admin.database.v1". + @$pb.TagNumber(1) + $core.String get version => $_getSZ(0); + @$pb.TagNumber(1) + set version($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasVersion() => $_has(0); + @$pb.TagNumber(1) + void clearVersion() => $_clearField(1); + + /// Launch stage of this version of the API. + @$pb.TagNumber(2) + $1.LaunchStage get launchStage => $_getN(1); + @$pb.TagNumber(2) + set launchStage($1.LaunchStage v) { + $_setField(2, v); + } + + @$pb.TagNumber(2) + $core.bool hasLaunchStage() => $_has(1); + @$pb.TagNumber(2) + void clearLaunchStage() => $_clearField(2); + + /// When using transport=rest, the client request will encode enums as + /// numbers rather than strings. + @$pb.TagNumber(3) + $core.bool get restNumericEnums => $_getBF(2); + @$pb.TagNumber(3) + set restNumericEnums($core.bool v) { + $_setBool(2, v); + } + + @$pb.TagNumber(3) + $core.bool hasRestNumericEnums() => $_has(2); + @$pb.TagNumber(3) + void clearRestNumericEnums() => $_clearField(3); + + /// Settings for legacy Java features, supported in the Service YAML. + @$pb.TagNumber(21) + JavaSettings get javaSettings => $_getN(3); + @$pb.TagNumber(21) + set javaSettings(JavaSettings v) { + $_setField(21, v); + } + + @$pb.TagNumber(21) + $core.bool hasJavaSettings() => $_has(3); + @$pb.TagNumber(21) + void clearJavaSettings() => $_clearField(21); + @$pb.TagNumber(21) + JavaSettings ensureJavaSettings() => $_ensure(3); + + /// Settings for C++ client libraries. + @$pb.TagNumber(22) + CppSettings get cppSettings => $_getN(4); + @$pb.TagNumber(22) + set cppSettings(CppSettings v) { + $_setField(22, v); + } + + @$pb.TagNumber(22) + $core.bool hasCppSettings() => $_has(4); + @$pb.TagNumber(22) + void clearCppSettings() => $_clearField(22); + @$pb.TagNumber(22) + CppSettings ensureCppSettings() => $_ensure(4); + + /// Settings for PHP client libraries. + @$pb.TagNumber(23) + PhpSettings get phpSettings => $_getN(5); + @$pb.TagNumber(23) + set phpSettings(PhpSettings v) { + $_setField(23, v); + } + + @$pb.TagNumber(23) + $core.bool hasPhpSettings() => $_has(5); + @$pb.TagNumber(23) + void clearPhpSettings() => $_clearField(23); + @$pb.TagNumber(23) + PhpSettings ensurePhpSettings() => $_ensure(5); + + /// Settings for Python client libraries. + @$pb.TagNumber(24) + PythonSettings get pythonSettings => $_getN(6); + @$pb.TagNumber(24) + set pythonSettings(PythonSettings v) { + $_setField(24, v); + } + + @$pb.TagNumber(24) + $core.bool hasPythonSettings() => $_has(6); + @$pb.TagNumber(24) + void clearPythonSettings() => $_clearField(24); + @$pb.TagNumber(24) + PythonSettings ensurePythonSettings() => $_ensure(6); + + /// Settings for Node client libraries. + @$pb.TagNumber(25) + NodeSettings get nodeSettings => $_getN(7); + @$pb.TagNumber(25) + set nodeSettings(NodeSettings v) { + $_setField(25, v); + } + + @$pb.TagNumber(25) + $core.bool hasNodeSettings() => $_has(7); + @$pb.TagNumber(25) + void clearNodeSettings() => $_clearField(25); + @$pb.TagNumber(25) + NodeSettings ensureNodeSettings() => $_ensure(7); + + /// Settings for .NET client libraries. + @$pb.TagNumber(26) + DotnetSettings get dotnetSettings => $_getN(8); + @$pb.TagNumber(26) + set dotnetSettings(DotnetSettings v) { + $_setField(26, v); + } + + @$pb.TagNumber(26) + $core.bool hasDotnetSettings() => $_has(8); + @$pb.TagNumber(26) + void clearDotnetSettings() => $_clearField(26); + @$pb.TagNumber(26) + DotnetSettings ensureDotnetSettings() => $_ensure(8); + + /// Settings for Ruby client libraries. + @$pb.TagNumber(27) + RubySettings get rubySettings => $_getN(9); + @$pb.TagNumber(27) + set rubySettings(RubySettings v) { + $_setField(27, v); + } + + @$pb.TagNumber(27) + $core.bool hasRubySettings() => $_has(9); + @$pb.TagNumber(27) + void clearRubySettings() => $_clearField(27); + @$pb.TagNumber(27) + RubySettings ensureRubySettings() => $_ensure(9); + + /// Settings for Go client libraries. + @$pb.TagNumber(28) + GoSettings get goSettings => $_getN(10); + @$pb.TagNumber(28) + set goSettings(GoSettings v) { + $_setField(28, v); + } + + @$pb.TagNumber(28) + $core.bool hasGoSettings() => $_has(10); + @$pb.TagNumber(28) + void clearGoSettings() => $_clearField(28); + @$pb.TagNumber(28) + GoSettings ensureGoSettings() => $_ensure(10); +} + /// This message configures the settings for publishing [Google Cloud Client /// libraries](https://cloud.google.com/apis/docs/cloud-client-libraries) /// generated from the service config. class Publishing extends $pb.GeneratedMessage { factory Publishing({ + $core.Iterable<MethodSettings>? methodSettings, $core.String? newIssueUri, $core.String? documentationUri, $core.String? apiShortName, @@ -135,10 +410,14 @@ $core.Iterable<$core.String>? codeownerGithubTeams, $core.String? docTagPrefix, ClientLibraryOrganization? organization, + $core.Iterable<ClientLibrarySettings>? librarySettings, $core.String? protoReferenceDocumentationUri, $core.String? restReferenceDocumentationUri, }) { final $result = create(); + if (methodSettings != null) { + $result.methodSettings.addAll(methodSettings); + } if (newIssueUri != null) { $result.newIssueUri = newIssueUri; } @@ -160,6 +439,9 @@ if (organization != null) { $result.organization = organization; } + if (librarySettings != null) { + $result.librarySettings.addAll(librarySettings); + } if (protoReferenceDocumentationUri != null) { $result.protoReferenceDocumentationUri = protoReferenceDocumentationUri; } @@ -180,6 +462,9 @@ _omitMessageNames ? '' : 'Publishing', package: const $pb.PackageName(_omitMessageNames ? '' : 'google.api'), createEmptyInstance: create) + ..pc<MethodSettings>( + 2, _omitFieldNames ? '' : 'methodSettings', $pb.PbFieldType.PM, + subBuilder: MethodSettings.create) ..aOS(101, _omitFieldNames ? '' : 'newIssueUri') ..aOS(102, _omitFieldNames ? '' : 'documentationUri') ..aOS(103, _omitFieldNames ? '' : 'apiShortName') @@ -192,6 +477,9 @@ ClientLibraryOrganization.CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED, valueOf: ClientLibraryOrganization.valueOf, enumValues: ClientLibraryOrganization.values) + ..pc<ClientLibrarySettings>( + 109, _omitFieldNames ? '' : 'librarySettings', $pb.PbFieldType.PM, + subBuilder: ClientLibrarySettings.create) ..aOS(110, _omitFieldNames ? '' : 'protoReferenceDocumentationUri') ..aOS(111, _omitFieldNames ? '' : 'restReferenceDocumentationUri') ..hasRequiredFields = false; @@ -213,31 +501,36 @@ $pb.GeneratedMessage.$_defaultFor<Publishing>(create); static Publishing? _defaultInstance; + /// A list of API method settings, e.g. the behavior for methods that use the + /// long-running operation pattern. + @$pb.TagNumber(2) + $pb.PbList<MethodSettings> get methodSettings => $_getList(0); + /// Link to a *public* URI where users can report issues. Example: /// https://issuetracker.google.com/issues/new?component=190865&template=1161103 @$pb.TagNumber(101) - $core.String get newIssueUri => $_getSZ(0); + $core.String get newIssueUri => $_getSZ(1); @$pb.TagNumber(101) set newIssueUri($core.String v) { - $_setString(0, v); + $_setString(1, v); } @$pb.TagNumber(101) - $core.bool hasNewIssueUri() => $_has(0); + $core.bool hasNewIssueUri() => $_has(1); @$pb.TagNumber(101) void clearNewIssueUri() => $_clearField(101); /// Link to product home page. Example: /// https://cloud.google.com/asset-inventory/docs/overview @$pb.TagNumber(102) - $core.String get documentationUri => $_getSZ(1); + $core.String get documentationUri => $_getSZ(2); @$pb.TagNumber(102) set documentationUri($core.String v) { - $_setString(1, v); + $_setString(2, v); } @$pb.TagNumber(102) - $core.bool hasDocumentationUri() => $_has(1); + $core.bool hasDocumentationUri() => $_has(2); @$pb.TagNumber(102) void clearDocumentationUri() => $_clearField(102); @@ -245,87 +538,93 @@ /// relations artifacts like docs, packages delivered to package managers, /// etc. Example: "speech". @$pb.TagNumber(103) - $core.String get apiShortName => $_getSZ(2); + $core.String get apiShortName => $_getSZ(3); @$pb.TagNumber(103) set apiShortName($core.String v) { - $_setString(2, v); + $_setString(3, v); } @$pb.TagNumber(103) - $core.bool hasApiShortName() => $_has(2); + $core.bool hasApiShortName() => $_has(3); @$pb.TagNumber(103) void clearApiShortName() => $_clearField(103); /// GitHub label to apply to issues and pull requests opened for this API. @$pb.TagNumber(104) - $core.String get githubLabel => $_getSZ(3); + $core.String get githubLabel => $_getSZ(4); @$pb.TagNumber(104) set githubLabel($core.String v) { - $_setString(3, v); + $_setString(4, v); } @$pb.TagNumber(104) - $core.bool hasGithubLabel() => $_has(3); + $core.bool hasGithubLabel() => $_has(4); @$pb.TagNumber(104) void clearGithubLabel() => $_clearField(104); /// GitHub teams to be added to CODEOWNERS in the directory in GitHub /// containing source code for the client libraries for this API. @$pb.TagNumber(105) - $pb.PbList<$core.String> get codeownerGithubTeams => $_getList(4); + $pb.PbList<$core.String> get codeownerGithubTeams => $_getList(5); /// A prefix used in sample code when demarking regions to be included in /// documentation. @$pb.TagNumber(106) - $core.String get docTagPrefix => $_getSZ(5); + $core.String get docTagPrefix => $_getSZ(6); @$pb.TagNumber(106) set docTagPrefix($core.String v) { - $_setString(5, v); + $_setString(6, v); } @$pb.TagNumber(106) - $core.bool hasDocTagPrefix() => $_has(5); + $core.bool hasDocTagPrefix() => $_has(6); @$pb.TagNumber(106) void clearDocTagPrefix() => $_clearField(106); /// For whom the client library is being published. @$pb.TagNumber(107) - ClientLibraryOrganization get organization => $_getN(6); + ClientLibraryOrganization get organization => $_getN(7); @$pb.TagNumber(107) set organization(ClientLibraryOrganization v) { $_setField(107, v); } @$pb.TagNumber(107) - $core.bool hasOrganization() => $_has(6); + $core.bool hasOrganization() => $_has(7); @$pb.TagNumber(107) void clearOrganization() => $_clearField(107); + /// Client library settings. If the same version string appears multiple + /// times in this list, then the last one wins. Settings from earlier + /// settings with the same version string are discarded. + @$pb.TagNumber(109) + $pb.PbList<ClientLibrarySettings> get librarySettings => $_getList(8); + /// Optional link to proto reference documentation. Example: /// https://cloud.google.com/pubsub/lite/docs/reference/rpc @$pb.TagNumber(110) - $core.String get protoReferenceDocumentationUri => $_getSZ(7); + $core.String get protoReferenceDocumentationUri => $_getSZ(9); @$pb.TagNumber(110) set protoReferenceDocumentationUri($core.String v) { - $_setString(7, v); + $_setString(9, v); } @$pb.TagNumber(110) - $core.bool hasProtoReferenceDocumentationUri() => $_has(7); + $core.bool hasProtoReferenceDocumentationUri() => $_has(9); @$pb.TagNumber(110) void clearProtoReferenceDocumentationUri() => $_clearField(110); /// Optional link to REST reference documentation. Example: /// https://cloud.google.com/pubsub/lite/docs/reference/rest @$pb.TagNumber(111) - $core.String get restReferenceDocumentationUri => $_getSZ(8); + $core.String get restReferenceDocumentationUri => $_getSZ(10); @$pb.TagNumber(111) set restReferenceDocumentationUri($core.String v) { - $_setString(8, v); + $_setString(10, v); } @$pb.TagNumber(111) - $core.bool hasRestReferenceDocumentationUri() => $_has(8); + $core.bool hasRestReferenceDocumentationUri() => $_has(10); @$pb.TagNumber(111) void clearRestReferenceDocumentationUri() => $_clearField(111); } @@ -1103,6 +1402,261 @@ $pb.PbMap<$core.String, $core.String> get renamedServices => $_getMap(1); } +/// Describes settings to use when generating API methods that use the +/// long-running operation pattern. +/// All default values below are from those used in the client library +/// generators (e.g. +/// [Java](https://github.com/googleapis/gapic-generator-java/blob/04c2faa191a9b5a10b92392fe8482279c4404803/src/main/java/com/google/api/generator/gapic/composer/common/RetrySettingsComposer.java)). +class MethodSettings_LongRunning extends $pb.GeneratedMessage { + factory MethodSettings_LongRunning({ + $0.Duration? initialPollDelay, + $core.double? pollDelayMultiplier, + $0.Duration? maxPollDelay, + $0.Duration? totalPollTimeout, + }) { + final $result = create(); + if (initialPollDelay != null) { + $result.initialPollDelay = initialPollDelay; + } + if (pollDelayMultiplier != null) { + $result.pollDelayMultiplier = pollDelayMultiplier; + } + if (maxPollDelay != null) { + $result.maxPollDelay = maxPollDelay; + } + if (totalPollTimeout != null) { + $result.totalPollTimeout = totalPollTimeout; + } + return $result; + } + MethodSettings_LongRunning._() : super(); + factory MethodSettings_LongRunning.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory MethodSettings_LongRunning.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'MethodSettings.LongRunning', + package: const $pb.PackageName(_omitMessageNames ? '' : 'google.api'), + createEmptyInstance: create) + ..aOM<$0.Duration>(1, _omitFieldNames ? '' : 'initialPollDelay', + subBuilder: $0.Duration.create) + ..a<$core.double>( + 2, _omitFieldNames ? '' : 'pollDelayMultiplier', $pb.PbFieldType.OF) + ..aOM<$0.Duration>(3, _omitFieldNames ? '' : 'maxPollDelay', + subBuilder: $0.Duration.create) + ..aOM<$0.Duration>(4, _omitFieldNames ? '' : 'totalPollTimeout', + subBuilder: $0.Duration.create) + ..hasRequiredFields = false; + + @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') + MethodSettings_LongRunning clone() => + MethodSettings_LongRunning()..mergeFromMessage(this); + @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') + MethodSettings_LongRunning copyWith( + void Function(MethodSettings_LongRunning) updates) => + super.copyWith( + (message) => updates(message as MethodSettings_LongRunning)) + as MethodSettings_LongRunning; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static MethodSettings_LongRunning create() => MethodSettings_LongRunning._(); + MethodSettings_LongRunning createEmptyInstance() => create(); + static $pb.PbList<MethodSettings_LongRunning> createRepeated() => + $pb.PbList<MethodSettings_LongRunning>(); + @$core.pragma('dart2js:noInline') + static MethodSettings_LongRunning getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor<MethodSettings_LongRunning>(create); + static MethodSettings_LongRunning? _defaultInstance; + + /// Initial delay after which the first poll request will be made. + /// Default value: 5 seconds. + @$pb.TagNumber(1) + $0.Duration get initialPollDelay => $_getN(0); + @$pb.TagNumber(1) + set initialPollDelay($0.Duration v) { + $_setField(1, v); + } + + @$pb.TagNumber(1) + $core.bool hasInitialPollDelay() => $_has(0); + @$pb.TagNumber(1) + void clearInitialPollDelay() => $_clearField(1); + @$pb.TagNumber(1) + $0.Duration ensureInitialPollDelay() => $_ensure(0); + + /// Multiplier to gradually increase delay between subsequent polls until it + /// reaches max_poll_delay. + /// Default value: 1.5. + @$pb.TagNumber(2) + $core.double get pollDelayMultiplier => $_getN(1); + @$pb.TagNumber(2) + set pollDelayMultiplier($core.double v) { + $_setFloat(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasPollDelayMultiplier() => $_has(1); + @$pb.TagNumber(2) + void clearPollDelayMultiplier() => $_clearField(2); + + /// Maximum time between two subsequent poll requests. + /// Default value: 45 seconds. + @$pb.TagNumber(3) + $0.Duration get maxPollDelay => $_getN(2); + @$pb.TagNumber(3) + set maxPollDelay($0.Duration v) { + $_setField(3, v); + } + + @$pb.TagNumber(3) + $core.bool hasMaxPollDelay() => $_has(2); + @$pb.TagNumber(3) + void clearMaxPollDelay() => $_clearField(3); + @$pb.TagNumber(3) + $0.Duration ensureMaxPollDelay() => $_ensure(2); + + /// Total polling timeout. + /// Default value: 5 minutes. + @$pb.TagNumber(4) + $0.Duration get totalPollTimeout => $_getN(3); + @$pb.TagNumber(4) + set totalPollTimeout($0.Duration v) { + $_setField(4, v); + } + + @$pb.TagNumber(4) + $core.bool hasTotalPollTimeout() => $_has(3); + @$pb.TagNumber(4) + void clearTotalPollTimeout() => $_clearField(4); + @$pb.TagNumber(4) + $0.Duration ensureTotalPollTimeout() => $_ensure(3); +} + +/// Describes the generator configuration for a method. +class MethodSettings extends $pb.GeneratedMessage { + factory MethodSettings({ + $core.String? selector, + MethodSettings_LongRunning? longRunning, + $core.Iterable<$core.String>? autoPopulatedFields, + }) { + final $result = create(); + if (selector != null) { + $result.selector = selector; + } + if (longRunning != null) { + $result.longRunning = longRunning; + } + if (autoPopulatedFields != null) { + $result.autoPopulatedFields.addAll(autoPopulatedFields); + } + return $result; + } + MethodSettings._() : super(); + factory MethodSettings.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory MethodSettings.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'MethodSettings', + package: const $pb.PackageName(_omitMessageNames ? '' : 'google.api'), + createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'selector') + ..aOM<MethodSettings_LongRunning>(2, _omitFieldNames ? '' : 'longRunning', + subBuilder: MethodSettings_LongRunning.create) + ..pPS(3, _omitFieldNames ? '' : 'autoPopulatedFields') + ..hasRequiredFields = false; + + @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') + MethodSettings clone() => MethodSettings()..mergeFromMessage(this); + @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') + MethodSettings copyWith(void Function(MethodSettings) updates) => + super.copyWith((message) => updates(message as MethodSettings)) + as MethodSettings; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static MethodSettings create() => MethodSettings._(); + MethodSettings createEmptyInstance() => create(); + static $pb.PbList<MethodSettings> createRepeated() => + $pb.PbList<MethodSettings>(); + @$core.pragma('dart2js:noInline') + static MethodSettings getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor<MethodSettings>(create); + static MethodSettings? _defaultInstance; + + /// The fully qualified name of the method, for which the options below apply. + /// This is used to find the method to apply the options. + /// + /// Example: + /// + /// publishing: + /// method_settings: + /// - selector: google.storage.control.v2.StorageControl.CreateFolder + /// # method settings for CreateFolder... + @$pb.TagNumber(1) + $core.String get selector => $_getSZ(0); + @$pb.TagNumber(1) + set selector($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasSelector() => $_has(0); + @$pb.TagNumber(1) + void clearSelector() => $_clearField(1); + + /// Describes settings to use for long-running operations when generating + /// API methods for RPCs. Complements RPCs that use the annotations in + /// google/longrunning/operations.proto. + /// + /// Example of a YAML configuration:: + /// + /// publishing: + /// method_settings: + /// - selector: google.cloud.speech.v2.Speech.BatchRecognize + /// long_running: + /// initial_poll_delay: 60s # 1 minute + /// poll_delay_multiplier: 1.5 + /// max_poll_delay: 360s # 6 minutes + /// total_poll_timeout: 54000s # 90 minutes + @$pb.TagNumber(2) + MethodSettings_LongRunning get longRunning => $_getN(1); + @$pb.TagNumber(2) + set longRunning(MethodSettings_LongRunning v) { + $_setField(2, v); + } + + @$pb.TagNumber(2) + $core.bool hasLongRunning() => $_has(1); + @$pb.TagNumber(2) + void clearLongRunning() => $_clearField(2); + @$pb.TagNumber(2) + MethodSettings_LongRunning ensureLongRunning() => $_ensure(1); + + /// List of top-level fields of the request message, that should be + /// automatically populated by the client libraries based on their + /// (google.api.field_info).format. Currently supported format: UUID4. + /// + /// Example of a YAML configuration: + /// + /// publishing: + /// method_settings: + /// - selector: google.example.v1.ExampleService.CreateExample + /// auto_populated_fields: + /// - request_id + @$pb.TagNumber(3) + $pb.PbList<$core.String> get autoPopulatedFields => $_getList(2); +} + /// This message is used to configure the generation of a subset of the RPCs in /// a service for client libraries. class SelectiveGapicGeneration extends $pb.GeneratedMessage {
diff --git a/protoc_plugin/lib/src/generated/client.pbenum.dart b/protoc_plugin/lib/src/gen/google/api/client.pbenum.dart similarity index 98% rename from protoc_plugin/lib/src/generated/client.pbenum.dart rename to protoc_plugin/lib/src/gen/google/api/client.pbenum.dart index bc568da..97f4568 100644 --- a/protoc_plugin/lib/src/generated/client.pbenum.dart +++ b/protoc_plugin/lib/src/gen/google/api/client.pbenum.dart
@@ -1,6 +1,6 @@ // // Generated code. Do not modify. -// source: client.proto +// source: google/api/client.proto // // @dart = 3.3
diff --git a/protoc_plugin/lib/src/gen/google/api/http.pb.dart b/protoc_plugin/lib/src/gen/google/api/http.pb.dart new file mode 100644 index 0000000..ca989fa --- /dev/null +++ b/protoc_plugin/lib/src/gen/google/api/http.pb.dart
@@ -0,0 +1,685 @@ +// +// Generated code. Do not modify. +// source: google/api/http.proto +// +// @dart = 3.3 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +import 'dart:core' as $core; + +import 'package:protobuf/protobuf.dart' as $pb; + +export 'package:protobuf/protobuf.dart' show GeneratedMessageGenericExtensions; + +/// Defines the HTTP configuration for an API service. It contains a list of +/// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method +/// to one or more HTTP REST API methods. +class Http extends $pb.GeneratedMessage { + factory Http({ + $core.Iterable<HttpRule>? rules, + $core.bool? fullyDecodeReservedExpansion, + }) { + final $result = create(); + if (rules != null) { + $result.rules.addAll(rules); + } + if (fullyDecodeReservedExpansion != null) { + $result.fullyDecodeReservedExpansion = fullyDecodeReservedExpansion; + } + return $result; + } + Http._() : super(); + factory Http.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Http.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Http', + package: const $pb.PackageName(_omitMessageNames ? '' : 'google.api'), + createEmptyInstance: create) + ..pc<HttpRule>(1, _omitFieldNames ? '' : 'rules', $pb.PbFieldType.PM, + subBuilder: HttpRule.create) + ..aOB(2, _omitFieldNames ? '' : 'fullyDecodeReservedExpansion') + ..hasRequiredFields = false; + + @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') + Http clone() => Http()..mergeFromMessage(this); + @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') + Http copyWith(void Function(Http) updates) => + super.copyWith((message) => updates(message as Http)) as Http; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Http create() => Http._(); + Http createEmptyInstance() => create(); + static $pb.PbList<Http> createRepeated() => $pb.PbList<Http>(); + @$core.pragma('dart2js:noInline') + static Http getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Http>(create); + static Http? _defaultInstance; + + /// A list of HTTP configuration rules that apply to individual API methods. + /// + /// **NOTE:** All service configuration rules follow "last one wins" order. + @$pb.TagNumber(1) + $pb.PbList<HttpRule> get rules => $_getList(0); + + /// When set to true, URL path parameters will be fully URI-decoded except in + /// cases of single segment matches in reserved expansion, where "%2F" will be + /// left encoded. + /// + /// The default behavior is to not decode RFC 6570 reserved characters in multi + /// segment matches. + @$pb.TagNumber(2) + $core.bool get fullyDecodeReservedExpansion => $_getBF(1); + @$pb.TagNumber(2) + set fullyDecodeReservedExpansion($core.bool v) { + $_setBool(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasFullyDecodeReservedExpansion() => $_has(1); + @$pb.TagNumber(2) + void clearFullyDecodeReservedExpansion() => $_clearField(2); +} + +enum HttpRule_Pattern { get, put, post, delete, patch, custom, notSet } + +/// gRPC Transcoding +/// +/// gRPC Transcoding is a feature for mapping between a gRPC method and one or +/// more HTTP REST endpoints. It allows developers to build a single API service +/// that supports both gRPC APIs and REST APIs. Many systems, including [Google +/// APIs](https://github.com/googleapis/googleapis), +/// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC +/// Gateway](https://github.com/grpc-ecosystem/grpc-gateway), +/// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature +/// and use it for large scale production services. +/// +/// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies +/// how different portions of the gRPC request message are mapped to the URL +/// path, URL query parameters, and HTTP request body. It also controls how the +/// gRPC response message is mapped to the HTTP response body. `HttpRule` is +/// typically specified as an `google.api.http` annotation on the gRPC method. +/// +/// Each mapping specifies a URL path template and an HTTP method. The path +/// template may refer to one or more fields in the gRPC request message, as long +/// as each field is a non-repeated field with a primitive (non-message) type. +/// The path template controls how fields of the request message are mapped to +/// the URL path. +/// +/// Example: +/// +/// service Messaging { +/// rpc GetMessage(GetMessageRequest) returns (Message) { +/// option (google.api.http) = { +/// get: "/v1/{name=messages/*}" +/// }; +/// } +/// } +/// message GetMessageRequest { +/// string name = 1; // Mapped to URL path. +/// } +/// message Message { +/// string text = 1; // The resource content. +/// } +/// +/// This enables an HTTP REST to gRPC mapping as below: +/// +/// - HTTP: `GET /v1/messages/123456` +/// - gRPC: `GetMessage(name: "messages/123456")` +/// +/// Any fields in the request message which are not bound by the path template +/// automatically become HTTP query parameters if there is no HTTP request body. +/// For example: +/// +/// service Messaging { +/// rpc GetMessage(GetMessageRequest) returns (Message) { +/// option (google.api.http) = { +/// get:"/v1/messages/{message_id}" +/// }; +/// } +/// } +/// message GetMessageRequest { +/// message SubMessage { +/// string subfield = 1; +/// } +/// string message_id = 1; // Mapped to URL path. +/// int64 revision = 2; // Mapped to URL query parameter `revision`. +/// SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`. +/// } +/// +/// This enables a HTTP JSON to RPC mapping as below: +/// +/// - HTTP: `GET /v1/messages/123456?revision=2&sub.subfield=foo` +/// - gRPC: `GetMessage(message_id: "123456" revision: 2 sub: +/// SubMessage(subfield: "foo"))` +/// +/// Note that fields which are mapped to URL query parameters must have a +/// primitive type or a repeated primitive type or a non-repeated message type. +/// In the case of a repeated type, the parameter can be repeated in the URL +/// as `...?param=A¶m=B`. In the case of a message type, each field of the +/// message is mapped to a separate parameter, such as +/// `...?foo.a=A&foo.b=B&foo.c=C`. +/// +/// For HTTP methods that allow a request body, the `body` field +/// specifies the mapping. Consider a REST update method on the +/// message resource collection: +/// +/// service Messaging { +/// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { +/// option (google.api.http) = { +/// patch: "/v1/messages/{message_id}" +/// body: "message" +/// }; +/// } +/// } +/// message UpdateMessageRequest { +/// string message_id = 1; // mapped to the URL +/// Message message = 2; // mapped to the body +/// } +/// +/// The following HTTP JSON to RPC mapping is enabled, where the +/// representation of the JSON in the request body is determined by +/// protos JSON encoding: +/// +/// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }` +/// - gRPC: `UpdateMessage(message_id: "123456" message { text: "Hi!" })` +/// +/// The special name `*` can be used in the body mapping to define that +/// every field not bound by the path template should be mapped to the +/// request body. This enables the following alternative definition of +/// the update method: +/// +/// service Messaging { +/// rpc UpdateMessage(Message) returns (Message) { +/// option (google.api.http) = { +/// patch: "/v1/messages/{message_id}" +/// body: "*" +/// }; +/// } +/// } +/// message Message { +/// string message_id = 1; +/// string text = 2; +/// } +/// +/// +/// The following HTTP JSON to RPC mapping is enabled: +/// +/// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }` +/// - gRPC: `UpdateMessage(message_id: "123456" text: "Hi!")` +/// +/// Note that when using `*` in the body mapping, it is not possible to +/// have HTTP parameters, as all fields not bound by the path end in +/// the body. This makes this option more rarely used in practice when +/// defining REST APIs. The common usage of `*` is in custom methods +/// which don't use the URL at all for transferring data. +/// +/// It is possible to define multiple HTTP methods for one RPC by using +/// the `additional_bindings` option. Example: +/// +/// service Messaging { +/// rpc GetMessage(GetMessageRequest) returns (Message) { +/// option (google.api.http) = { +/// get: "/v1/messages/{message_id}" +/// additional_bindings { +/// get: "/v1/users/{user_id}/messages/{message_id}" +/// } +/// }; +/// } +/// } +/// message GetMessageRequest { +/// string message_id = 1; +/// string user_id = 2; +/// } +/// +/// This enables the following two alternative HTTP JSON to RPC mappings: +/// +/// - HTTP: `GET /v1/messages/123456` +/// - gRPC: `GetMessage(message_id: "123456")` +/// +/// - HTTP: `GET /v1/users/me/messages/123456` +/// - gRPC: `GetMessage(user_id: "me" message_id: "123456")` +/// +/// Rules for HTTP mapping +/// +/// 1. Leaf request fields (recursive expansion nested messages in the request +/// message) are classified into three categories: +/// - Fields referred by the path template. They are passed via the URL path. +/// - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They +/// are passed via the HTTP +/// request body. +/// - All other fields are passed via the URL query parameters, and the +/// parameter name is the field path in the request message. A repeated +/// field can be represented as multiple query parameters under the same +/// name. +/// 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL +/// query parameter, all fields +/// are passed via URL path and HTTP request body. +/// 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP +/// request body, all +/// fields are passed via URL path and URL query parameters. +/// +/// Path template syntax +/// +/// Template = "/" Segments [ Verb ] ; +/// Segments = Segment { "/" Segment } ; +/// Segment = "*" | "**" | LITERAL | Variable ; +/// Variable = "{" FieldPath [ "=" Segments ] "}" ; +/// FieldPath = IDENT { "." IDENT } ; +/// Verb = ":" LITERAL ; +/// +/// The syntax `*` matches a single URL path segment. The syntax `**` matches +/// zero or more URL path segments, which must be the last part of the URL path +/// except the `Verb`. +/// +/// The syntax `Variable` matches part of the URL path as specified by its +/// template. A variable template must not contain other variables. If a variable +/// matches a single path segment, its template may be omitted, e.g. `{var}` +/// is equivalent to `{var=*}`. +/// +/// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL` +/// contains any reserved character, such characters should be percent-encoded +/// before the matching. +/// +/// If a variable contains exactly one path segment, such as `"{var}"` or +/// `"{var=*}"`, when such a variable is expanded into a URL path on the client +/// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The +/// server side does the reverse decoding. Such variables show up in the +/// [Discovery +/// Document](https://developers.google.com/discovery/v1/reference/apis) as +/// `{var}`. +/// +/// If a variable contains multiple path segments, such as `"{var=foo/*}"` +/// or `"{var=**}"`, when such a variable is expanded into a URL path on the +/// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. +/// The server side does the reverse decoding, except "%2F" and "%2f" are left +/// unchanged. Such variables show up in the +/// [Discovery +/// Document](https://developers.google.com/discovery/v1/reference/apis) as +/// `{+var}`. +/// +/// Using gRPC API Service Configuration +/// +/// gRPC API Service Configuration (service config) is a configuration language +/// for configuring a gRPC service to become a user-facing product. The +/// service config is simply the YAML representation of the `google.api.Service` +/// proto message. +/// +/// As an alternative to annotating your proto file, you can configure gRPC +/// transcoding in your service config YAML files. You do this by specifying a +/// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same +/// effect as the proto annotation. This can be particularly useful if you +/// have a proto that is reused in multiple services. Note that any transcoding +/// specified in the service config will override any matching transcoding +/// configuration in the proto. +/// +/// The following example selects a gRPC method and applies an `HttpRule` to it: +/// +/// http: +/// rules: +/// - selector: example.v1.Messaging.GetMessage +/// get: /v1/messages/{message_id}/{sub.subfield} +/// +/// Special notes +/// +/// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the +/// proto to JSON conversion must follow the [proto3 +/// specification](https://developers.google.com/protocol-buffers/docs/proto3#json). +/// +/// While the single segment variable follows the semantics of +/// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String +/// Expansion, the multi segment variable **does not** follow RFC 6570 Section +/// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion +/// does not expand special characters like `?` and `#`, which would lead +/// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding +/// for multi segment variables. +/// +/// The path variables **must not** refer to any repeated or mapped field, +/// because client libraries are not capable of handling such variable expansion. +/// +/// The path variables **must not** capture the leading "/" character. The reason +/// is that the most common use case "{var}" does not capture the leading "/" +/// character. For consistency, all path variables must share the same behavior. +/// +/// Repeated message fields must not be mapped to URL query parameters, because +/// no client library can support such complicated mapping. +/// +/// If an API needs to use a JSON array for request or response body, it can map +/// the request or response body to a repeated field. However, some gRPC +/// Transcoding implementations may not support this feature. +class HttpRule extends $pb.GeneratedMessage { + factory HttpRule({ + $core.String? selector, + $core.String? get, + $core.String? put, + $core.String? post, + $core.String? delete, + $core.String? patch, + $core.String? body, + CustomHttpPattern? custom, + $core.Iterable<HttpRule>? additionalBindings, + $core.String? responseBody, + }) { + final $result = create(); + if (selector != null) { + $result.selector = selector; + } + if (get != null) { + $result.get = get; + } + if (put != null) { + $result.put = put; + } + if (post != null) { + $result.post = post; + } + if (delete != null) { + $result.delete = delete; + } + if (patch != null) { + $result.patch = patch; + } + if (body != null) { + $result.body = body; + } + if (custom != null) { + $result.custom = custom; + } + if (additionalBindings != null) { + $result.additionalBindings.addAll(additionalBindings); + } + if (responseBody != null) { + $result.responseBody = responseBody; + } + return $result; + } + HttpRule._() : super(); + factory HttpRule.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory HttpRule.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static const $core.Map<$core.int, HttpRule_Pattern> _HttpRule_PatternByTag = { + 2: HttpRule_Pattern.get, + 3: HttpRule_Pattern.put, + 4: HttpRule_Pattern.post, + 5: HttpRule_Pattern.delete, + 6: HttpRule_Pattern.patch, + 8: HttpRule_Pattern.custom, + 0: HttpRule_Pattern.notSet + }; + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'HttpRule', + package: const $pb.PackageName(_omitMessageNames ? '' : 'google.api'), + createEmptyInstance: create) + ..oo(0, [2, 3, 4, 5, 6, 8]) + ..aOS(1, _omitFieldNames ? '' : 'selector') + ..aOS(2, _omitFieldNames ? '' : 'get') + ..aOS(3, _omitFieldNames ? '' : 'put') + ..aOS(4, _omitFieldNames ? '' : 'post') + ..aOS(5, _omitFieldNames ? '' : 'delete') + ..aOS(6, _omitFieldNames ? '' : 'patch') + ..aOS(7, _omitFieldNames ? '' : 'body') + ..aOM<CustomHttpPattern>(8, _omitFieldNames ? '' : 'custom', + subBuilder: CustomHttpPattern.create) + ..pc<HttpRule>( + 11, _omitFieldNames ? '' : 'additionalBindings', $pb.PbFieldType.PM, + subBuilder: HttpRule.create) + ..aOS(12, _omitFieldNames ? '' : 'responseBody') + ..hasRequiredFields = false; + + @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') + HttpRule clone() => HttpRule()..mergeFromMessage(this); + @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') + HttpRule copyWith(void Function(HttpRule) updates) => + super.copyWith((message) => updates(message as HttpRule)) as HttpRule; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static HttpRule create() => HttpRule._(); + HttpRule createEmptyInstance() => create(); + static $pb.PbList<HttpRule> createRepeated() => $pb.PbList<HttpRule>(); + @$core.pragma('dart2js:noInline') + static HttpRule getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<HttpRule>(create); + static HttpRule? _defaultInstance; + + HttpRule_Pattern whichPattern() => _HttpRule_PatternByTag[$_whichOneof(0)]!; + void clearPattern() => $_clearField($_whichOneof(0)); + + /// Selects a method to which this rule applies. + /// + /// Refer to [selector][google.api.DocumentationRule.selector] for syntax + /// details. + @$pb.TagNumber(1) + $core.String get selector => $_getSZ(0); + @$pb.TagNumber(1) + set selector($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasSelector() => $_has(0); + @$pb.TagNumber(1) + void clearSelector() => $_clearField(1); + + /// Maps to HTTP GET. Used for listing and getting information about + /// resources. + @$pb.TagNumber(2) + $core.String get get => $_getSZ(1); + @$pb.TagNumber(2) + set get($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasGet() => $_has(1); + @$pb.TagNumber(2) + void clearGet() => $_clearField(2); + + /// Maps to HTTP PUT. Used for replacing a resource. + @$pb.TagNumber(3) + $core.String get put => $_getSZ(2); + @$pb.TagNumber(3) + set put($core.String v) { + $_setString(2, v); + } + + @$pb.TagNumber(3) + $core.bool hasPut() => $_has(2); + @$pb.TagNumber(3) + void clearPut() => $_clearField(3); + + /// Maps to HTTP POST. Used for creating a resource or performing an action. + @$pb.TagNumber(4) + $core.String get post => $_getSZ(3); + @$pb.TagNumber(4) + set post($core.String v) { + $_setString(3, v); + } + + @$pb.TagNumber(4) + $core.bool hasPost() => $_has(3); + @$pb.TagNumber(4) + void clearPost() => $_clearField(4); + + /// Maps to HTTP DELETE. Used for deleting a resource. + @$pb.TagNumber(5) + $core.String get delete => $_getSZ(4); + @$pb.TagNumber(5) + set delete($core.String v) { + $_setString(4, v); + } + + @$pb.TagNumber(5) + $core.bool hasDelete() => $_has(4); + @$pb.TagNumber(5) + void clearDelete() => $_clearField(5); + + /// Maps to HTTP PATCH. Used for updating a resource. + @$pb.TagNumber(6) + $core.String get patch => $_getSZ(5); + @$pb.TagNumber(6) + set patch($core.String v) { + $_setString(5, v); + } + + @$pb.TagNumber(6) + $core.bool hasPatch() => $_has(5); + @$pb.TagNumber(6) + void clearPatch() => $_clearField(6); + + /// The name of the request field whose value is mapped to the HTTP request + /// body, or `*` for mapping all request fields not captured by the path + /// pattern to the HTTP body, or omitted for not having any HTTP request body. + /// + /// NOTE: the referred field must be present at the top-level of the request + /// message type. + @$pb.TagNumber(7) + $core.String get body => $_getSZ(6); + @$pb.TagNumber(7) + set body($core.String v) { + $_setString(6, v); + } + + @$pb.TagNumber(7) + $core.bool hasBody() => $_has(6); + @$pb.TagNumber(7) + void clearBody() => $_clearField(7); + + /// The custom pattern is used for specifying an HTTP method that is not + /// included in the `pattern` field, such as HEAD, or "*" to leave the + /// HTTP method unspecified for this rule. The wild-card rule is useful + /// for services that provide content to Web (HTML) clients. + @$pb.TagNumber(8) + CustomHttpPattern get custom => $_getN(7); + @$pb.TagNumber(8) + set custom(CustomHttpPattern v) { + $_setField(8, v); + } + + @$pb.TagNumber(8) + $core.bool hasCustom() => $_has(7); + @$pb.TagNumber(8) + void clearCustom() => $_clearField(8); + @$pb.TagNumber(8) + CustomHttpPattern ensureCustom() => $_ensure(7); + + /// Additional HTTP bindings for the selector. Nested bindings must + /// not contain an `additional_bindings` field themselves (that is, + /// the nesting may only be one level deep). + @$pb.TagNumber(11) + $pb.PbList<HttpRule> get additionalBindings => $_getList(8); + + /// Optional. The name of the response field whose value is mapped to the HTTP + /// response body. When omitted, the entire response message will be used + /// as the HTTP response body. + /// + /// NOTE: The referred field must be present at the top-level of the response + /// message type. + @$pb.TagNumber(12) + $core.String get responseBody => $_getSZ(9); + @$pb.TagNumber(12) + set responseBody($core.String v) { + $_setString(9, v); + } + + @$pb.TagNumber(12) + $core.bool hasResponseBody() => $_has(9); + @$pb.TagNumber(12) + void clearResponseBody() => $_clearField(12); +} + +/// A custom pattern is used for defining custom HTTP verb. +class CustomHttpPattern extends $pb.GeneratedMessage { + factory CustomHttpPattern({ + $core.String? kind, + $core.String? path, + }) { + final $result = create(); + if (kind != null) { + $result.kind = kind; + } + if (path != null) { + $result.path = path; + } + return $result; + } + CustomHttpPattern._() : super(); + factory CustomHttpPattern.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory CustomHttpPattern.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'CustomHttpPattern', + package: const $pb.PackageName(_omitMessageNames ? '' : 'google.api'), + createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'kind') + ..aOS(2, _omitFieldNames ? '' : 'path') + ..hasRequiredFields = false; + + @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') + CustomHttpPattern clone() => CustomHttpPattern()..mergeFromMessage(this); + @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') + CustomHttpPattern copyWith(void Function(CustomHttpPattern) updates) => + super.copyWith((message) => updates(message as CustomHttpPattern)) + as CustomHttpPattern; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static CustomHttpPattern create() => CustomHttpPattern._(); + CustomHttpPattern createEmptyInstance() => create(); + static $pb.PbList<CustomHttpPattern> createRepeated() => + $pb.PbList<CustomHttpPattern>(); + @$core.pragma('dart2js:noInline') + static CustomHttpPattern getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor<CustomHttpPattern>(create); + static CustomHttpPattern? _defaultInstance; + + /// The name of this custom HTTP verb. + @$pb.TagNumber(1) + $core.String get kind => $_getSZ(0); + @$pb.TagNumber(1) + set kind($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasKind() => $_has(0); + @$pb.TagNumber(1) + void clearKind() => $_clearField(1); + + /// The path matched by this custom verb. + @$pb.TagNumber(2) + $core.String get path => $_getSZ(1); + @$pb.TagNumber(2) + set path($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasPath() => $_has(1); + @$pb.TagNumber(2) + void clearPath() => $_clearField(2); +} + +const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names'); +const _omitMessageNames = + $core.bool.fromEnvironment('protobuf.omit_message_names');
diff --git a/protoc_plugin/lib/src/gen/google/api/http.pbenum.dart b/protoc_plugin/lib/src/gen/google/api/http.pbenum.dart new file mode 100644 index 0000000..4824393 --- /dev/null +++ b/protoc_plugin/lib/src/gen/google/api/http.pbenum.dart
@@ -0,0 +1,10 @@ +// +// Generated code. Do not modify. +// source: google/api/http.proto +// +// @dart = 3.3 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import
diff --git a/protoc_plugin/lib/src/gen/google/api/launch_stage.pb.dart b/protoc_plugin/lib/src/gen/google/api/launch_stage.pb.dart new file mode 100644 index 0000000..4373372 --- /dev/null +++ b/protoc_plugin/lib/src/gen/google/api/launch_stage.pb.dart
@@ -0,0 +1,16 @@ +// +// Generated code. Do not modify. +// source: google/api/launch_stage.proto +// +// @dart = 3.3 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +import 'dart:core' as $core; + +export 'package:protobuf/protobuf.dart' show GeneratedMessageGenericExtensions; + +export 'launch_stage.pbenum.dart';
diff --git a/protoc_plugin/lib/src/gen/google/api/launch_stage.pbenum.dart b/protoc_plugin/lib/src/gen/google/api/launch_stage.pbenum.dart new file mode 100644 index 0000000..1cb6b62 --- /dev/null +++ b/protoc_plugin/lib/src/gen/google/api/launch_stage.pbenum.dart
@@ -0,0 +1,90 @@ +// +// Generated code. Do not modify. +// source: google/api/launch_stage.proto +// +// @dart = 3.3 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +import 'dart:core' as $core; + +import 'package:protobuf/protobuf.dart' as $pb; + +/// The launch stage as defined by [Google Cloud Platform +/// Launch Stages](https://cloud.google.com/terms/launch-stages). +class LaunchStage extends $pb.ProtobufEnum { + /// Do not use this default value. + static const LaunchStage LAUNCH_STAGE_UNSPECIFIED = + LaunchStage._(0, _omitEnumNames ? '' : 'LAUNCH_STAGE_UNSPECIFIED'); + + /// The feature is not yet implemented. Users can not use it. + static const LaunchStage UNIMPLEMENTED = + LaunchStage._(6, _omitEnumNames ? '' : 'UNIMPLEMENTED'); + + /// Prelaunch features are hidden from users and are only visible internally. + static const LaunchStage PRELAUNCH = + LaunchStage._(7, _omitEnumNames ? '' : 'PRELAUNCH'); + + /// Early Access features are limited to a closed group of testers. To use + /// these features, you must sign up in advance and sign a Trusted Tester + /// agreement (which includes confidentiality provisions). These features may + /// be unstable, changed in backward-incompatible ways, and are not + /// guaranteed to be released. + static const LaunchStage EARLY_ACCESS = + LaunchStage._(1, _omitEnumNames ? '' : 'EARLY_ACCESS'); + + /// Alpha is a limited availability test for releases before they are cleared + /// for widespread use. By Alpha, all significant design issues are resolved + /// and we are in the process of verifying functionality. Alpha customers + /// need to apply for access, agree to applicable terms, and have their + /// projects allowlisted. Alpha releases don't have to be feature complete, + /// no SLAs are provided, and there are no technical support obligations, but + /// they will be far enough along that customers can actually use them in + /// test environments or for limited-use tests -- just like they would in + /// normal production cases. + static const LaunchStage ALPHA = + LaunchStage._(2, _omitEnumNames ? '' : 'ALPHA'); + + /// Beta is the point at which we are ready to open a release for any + /// customer to use. There are no SLA or technical support obligations in a + /// Beta release. Products will be complete from a feature perspective, but + /// may have some open outstanding issues. Beta releases are suitable for + /// limited production use cases. + static const LaunchStage BETA = + LaunchStage._(3, _omitEnumNames ? '' : 'BETA'); + + /// GA features are open to all developers and are considered stable and + /// fully qualified for production use. + static const LaunchStage GA = LaunchStage._(4, _omitEnumNames ? '' : 'GA'); + + /// Deprecated features are scheduled to be shut down and removed. For more + /// information, see the "Deprecation Policy" section of our [Terms of + /// Service](https://cloud.google.com/terms/) + /// and the [Google Cloud Platform Subject to the Deprecation + /// Policy](https://cloud.google.com/terms/deprecation) documentation. + static const LaunchStage DEPRECATED = + LaunchStage._(5, _omitEnumNames ? '' : 'DEPRECATED'); + + static const $core.List<LaunchStage> values = <LaunchStage>[ + LAUNCH_STAGE_UNSPECIFIED, + UNIMPLEMENTED, + PRELAUNCH, + EARLY_ACCESS, + ALPHA, + BETA, + GA, + DEPRECATED, + ]; + + static final $core.List<LaunchStage?> _byValue = + $pb.ProtobufEnum.$_initByValueList(values, 7); + static LaunchStage? valueOf($core.int value) => + value < 0 || value >= _byValue.length ? null : _byValue[value]; + + const LaunchStage._(super.v, super.n); +} + +const _omitEnumNames = $core.bool.fromEnvironment('protobuf.omit_enum_names');
diff --git a/protoc_plugin/lib/src/generated/plugin.pb.dart b/protoc_plugin/lib/src/gen/google/protobuf/compiler/plugin.pb.dart similarity index 96% rename from protoc_plugin/lib/src/generated/plugin.pb.dart rename to protoc_plugin/lib/src/gen/google/protobuf/compiler/plugin.pb.dart index 2b23ada..07da1c3 100644 --- a/protoc_plugin/lib/src/generated/plugin.pb.dart +++ b/protoc_plugin/lib/src/gen/google/protobuf/compiler/plugin.pb.dart
@@ -1,6 +1,6 @@ // // Generated code. Do not modify. -// source: plugin.proto +// source: google/protobuf/compiler/plugin.proto // // @dart = 3.3 @@ -14,7 +14,7 @@ import 'package:fixnum/fixnum.dart' as $fixnum; import 'package:protobuf/protobuf.dart' as $pb; -import 'descriptor.pb.dart' as $0; +import '../descriptor.pb.dart' as $2; export 'package:protobuf/protobuf.dart' show GeneratedMessageGenericExtensions; @@ -136,7 +136,7 @@ $core.Iterable<$core.String>? fileToGenerate, $core.String? parameter, Version? compilerVersion, - $core.Iterable<$0.FileDescriptorProto>? protoFile, + $core.Iterable<$2.FileDescriptorProto>? protoFile, }) { final $result = create(); if (fileToGenerate != null) { @@ -170,9 +170,9 @@ ..aOS(2, _omitFieldNames ? '' : 'parameter') ..aOM<Version>(3, _omitFieldNames ? '' : 'compilerVersion', subBuilder: Version.create) - ..pc<$0.FileDescriptorProto>( + ..pc<$2.FileDescriptorProto>( 15, _omitFieldNames ? '' : 'protoFile', $pb.PbFieldType.PM, - subBuilder: $0.FileDescriptorProto.create); + subBuilder: $2.FileDescriptorProto.create); @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') CodeGeneratorRequest clone() => @@ -243,7 +243,7 @@ /// Type names of fields and extensions in the FileDescriptorProto are always /// fully qualified. @$pb.TagNumber(15) - $pb.PbList<$0.FileDescriptorProto> get protoFile => $_getList(3); + $pb.PbList<$2.FileDescriptorProto> get protoFile => $_getList(3); } /// Represents a single generated file. @@ -252,7 +252,7 @@ $core.String? name, $core.String? insertionPoint, $core.String? content, - $0.GeneratedCodeInfo? generatedCodeInfo, + $2.GeneratedCodeInfo? generatedCodeInfo, }) { final $result = create(); if (name != null) { @@ -285,8 +285,8 @@ ..aOS(1, _omitFieldNames ? '' : 'name') ..aOS(2, _omitFieldNames ? '' : 'insertionPoint') ..aOS(15, _omitFieldNames ? '' : 'content') - ..aOM<$0.GeneratedCodeInfo>(16, _omitFieldNames ? '' : 'generatedCodeInfo', - subBuilder: $0.GeneratedCodeInfo.create) + ..aOM<$2.GeneratedCodeInfo>(16, _omitFieldNames ? '' : 'generatedCodeInfo', + subBuilder: $2.GeneratedCodeInfo.create) ..hasRequiredFields = false; @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') @@ -400,9 +400,9 @@ /// point is used, this information will be appropriately offset and inserted /// into the code generation metadata for the generated files. @$pb.TagNumber(16) - $0.GeneratedCodeInfo get generatedCodeInfo => $_getN(3); + $2.GeneratedCodeInfo get generatedCodeInfo => $_getN(3); @$pb.TagNumber(16) - set generatedCodeInfo($0.GeneratedCodeInfo v) { + set generatedCodeInfo($2.GeneratedCodeInfo v) { $_setField(16, v); } @@ -411,7 +411,7 @@ @$pb.TagNumber(16) void clearGeneratedCodeInfo() => $_clearField(16); @$pb.TagNumber(16) - $0.GeneratedCodeInfo ensureGeneratedCodeInfo() => $_ensure(3); + $2.GeneratedCodeInfo ensureGeneratedCodeInfo() => $_ensure(3); } /// The plugin writes an encoded CodeGeneratorResponse to stdout.
diff --git a/protoc_plugin/lib/src/generated/plugin.pbenum.dart b/protoc_plugin/lib/src/gen/google/protobuf/compiler/plugin.pbenum.dart similarity index 96% rename from protoc_plugin/lib/src/generated/plugin.pbenum.dart rename to protoc_plugin/lib/src/gen/google/protobuf/compiler/plugin.pbenum.dart index 2f427c9..c4ef32e 100644 --- a/protoc_plugin/lib/src/generated/plugin.pbenum.dart +++ b/protoc_plugin/lib/src/gen/google/protobuf/compiler/plugin.pbenum.dart
@@ -1,6 +1,6 @@ // // Generated code. Do not modify. -// source: plugin.proto +// source: google/protobuf/compiler/plugin.proto // // @dart = 3.3
diff --git a/protoc_plugin/lib/src/generated/descriptor.pb.dart b/protoc_plugin/lib/src/gen/google/protobuf/descriptor.pb.dart similarity index 99% rename from protoc_plugin/lib/src/generated/descriptor.pb.dart rename to protoc_plugin/lib/src/gen/google/protobuf/descriptor.pb.dart index 316c81a..45f178a 100644 --- a/protoc_plugin/lib/src/generated/descriptor.pb.dart +++ b/protoc_plugin/lib/src/gen/google/protobuf/descriptor.pb.dart
@@ -1,6 +1,6 @@ // // Generated code. Do not modify. -// source: descriptor.proto +// source: google/protobuf/descriptor.proto // // @dart = 3.3
diff --git a/protoc_plugin/lib/src/generated/descriptor.pbenum.dart b/protoc_plugin/lib/src/gen/google/protobuf/descriptor.pbenum.dart similarity index 99% rename from protoc_plugin/lib/src/generated/descriptor.pbenum.dart rename to protoc_plugin/lib/src/gen/google/protobuf/descriptor.pbenum.dart index 15909ed..f7ca7b8 100644 --- a/protoc_plugin/lib/src/generated/descriptor.pbenum.dart +++ b/protoc_plugin/lib/src/gen/google/protobuf/descriptor.pbenum.dart
@@ -1,6 +1,6 @@ // // Generated code. Do not modify. -// source: descriptor.proto +// source: google/protobuf/descriptor.proto // // @dart = 3.3
diff --git a/protoc_plugin/lib/src/gen/google/protobuf/duration.pb.dart b/protoc_plugin/lib/src/gen/google/protobuf/duration.pb.dart new file mode 100644 index 0000000..5f8439b --- /dev/null +++ b/protoc_plugin/lib/src/gen/google/protobuf/duration.pb.dart
@@ -0,0 +1,180 @@ +// +// Generated code. Do not modify. +// source: google/protobuf/duration.proto +// +// @dart = 3.3 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, implementation_imports +// ignore_for_file: library_prefixes, non_constant_identifier_names +// ignore_for_file: prefer_final_fields, unnecessary_import, unnecessary_this +// ignore_for_file: unused_import + +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; + +export 'package:protobuf/protobuf.dart' show GeneratedMessageGenericExtensions; + +/// 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". +class Duration extends $pb.GeneratedMessage with $mixin.DurationMixin { + factory Duration({ + $fixnum.Int64? seconds, + $core.int? nanos, + }) { + final $result = create(); + if (seconds != null) { + $result.seconds = seconds; + } + if (nanos != null) { + $result.nanos = nanos; + } + return $result; + } + Duration._() : super(); + 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); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Duration', + package: + const $pb.PackageName(_omitMessageNames ? '' : 'google.protobuf'), + createEmptyInstance: create, + toProto3Json: $mixin.DurationMixin.toProto3JsonHelper, + fromProto3Json: $mixin.DurationMixin.fromProto3JsonHelper) + ..aInt64(1, _omitFieldNames ? '' : 'seconds') + ..a<$core.int>(2, _omitFieldNames ? '' : 'nanos', $pb.PbFieldType.O3) + ..hasRequiredFields = false; + + @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') + Duration clone() => Duration()..mergeFromMessage(this); + @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.') + Duration copyWith(void Function(Duration) updates) => + super.copyWith((message) => updates(message as Duration)) as Duration; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Duration create() => Duration._(); + Duration createEmptyInstance() => create(); + static $pb.PbList<Duration> createRepeated() => $pb.PbList<Duration>(); + @$core.pragma('dart2js:noInline') + static Duration getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Duration>(create); + static Duration? _defaultInstance; + + /// 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 + @$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); + + /// 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. + @$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 the [Duration] to [$core.Duration]. + /// + /// This is a lossy conversion, as [$core.Duration] is limited to [int] + /// microseconds and also does not support nanosecond precision. + $core.Duration toDart() => $core.Duration( + seconds: seconds.toInt(), + microseconds: nanos ~/ 1000, + ); + + /// Creates a new instance from [$core.Duration]. + static Duration fromDart($core.Duration duration) => Duration() + ..seconds = $fixnum.Int64(duration.inSeconds) + ..nanos = + (duration.inMicroseconds % $core.Duration.microsecondsPerSecond) * 1000; +} + +const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names'); +const _omitMessageNames = + $core.bool.fromEnvironment('protobuf.omit_message_names');
diff --git a/protoc_plugin/lib/src/gen/google/protobuf/duration.pbenum.dart b/protoc_plugin/lib/src/gen/google/protobuf/duration.pbenum.dart new file mode 100644 index 0000000..431da01 --- /dev/null +++ b/protoc_plugin/lib/src/gen/google/protobuf/duration.pbenum.dart
@@ -0,0 +1,10 @@ +// +// Generated code. Do not modify. +// source: google/protobuf/duration.proto +// +// @dart = 3.3 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import
diff --git a/protoc_plugin/lib/src/options.dart b/protoc_plugin/lib/src/options.dart index 25b960b..a923373 100644 --- a/protoc_plugin/lib/src/options.dart +++ b/protoc_plugin/lib/src/options.dart
@@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'generated/plugin.pb.dart'; +import 'gen/google/protobuf/compiler/plugin.pb.dart'; typedef OnError = void Function(String details);
diff --git a/protoc_plugin/lib/src/shared.dart b/protoc_plugin/lib/src/shared.dart index c2c729d..89fa1d1 100644 --- a/protoc_plugin/lib/src/shared.dart +++ b/protoc_plugin/lib/src/shared.dart
@@ -6,7 +6,7 @@ import 'dart:io'; import '../protoc.dart'; -import '../src/generated/descriptor.pb.dart'; +import '../src/gen/google/protobuf/descriptor.pb.dart'; const protobufImportPrefix = r'$pb'; const asyncImportPrefix = r'$async';
diff --git a/protoc_plugin/protos/README.md b/protoc_plugin/protos/README.md new file mode 100644 index 0000000..1b430fc --- /dev/null +++ b/protoc_plugin/protos/README.md
@@ -0,0 +1,29 @@ +## What's this? + +These are core protos that are used in the protoc_plugin generator. They allow +us to read generation requests from the protoc tool as well as parse extensions +from protos for things like gRPC generation parameter and other config +information. + +## Regenerating + +To regenerate the Dart code from the current protos, run: + +``` +make update-pregenerated +``` + +This will generate the associated Dart code in `lib/src/gen/`. + +## Updating the protos + +The protos are currently updated by hand. We should create a shell script to +update from the source repos at specific SHAs. In the meantime: + +The contents of `google/protobuf/` can be found at +https://github.com/protocolbuffers/protobuf/tree/main/src/google/protobuf. + +All other 'google' protos can be found at +https://github.com/googleapis/googleapis/tree/master/google. + +`dart_options.proto` is hand-maintained.
diff --git a/protoc_plugin/protos/dart_options.proto b/protoc_plugin/protos/dart_options.proto index 507c7f3..cdb49d4 100644 --- a/protoc_plugin/protos/dart_options.proto +++ b/protoc_plugin/protos/dart_options.proto
@@ -3,12 +3,12 @@ package dart_options; -// This file must be modified for Google internal use, -// because custom options only work when the package name -// agrees with the version of protoc we are using. -// (The import statement and "google.protobuf." prefix need to be changed.) +// This file must be modified for Google internal use, because custom options +// only work when the package name agrees with the version of protoc we are +// using (the import statement and "google.protobuf." prefix need to be +// changed). -import "descriptor.proto"; +import "google/protobuf/descriptor.proto"; // A mixin that can be used in the 'with' clause of the generated Dart class // for a proto message. @@ -28,7 +28,6 @@ // Defines additional Dart imports to be used with messages in this file. message Imports { - // Mixins to be used on messages in this file. // These mixins are in addition to internally defined mixins (e.g PbMapMixin) // and may override them. @@ -41,7 +40,6 @@ } extend google.protobuf.FileOptions { - optional Imports imports = 28125061; // Applies the named mixin to all messages in this file. @@ -51,7 +49,6 @@ } extend google.protobuf.MessageOptions { - // Applies the named mixin. // For now, "PbMapMixin" is the only available mixin. // The empty string can be used to turn off mixins for this message.
diff --git a/protoc_plugin/protos/client.proto b/protoc_plugin/protos/google/api/client.proto similarity index 75% rename from protoc_plugin/protos/client.proto rename to protoc_plugin/protos/google/api/client.proto index 0991b2d..3d69256 100644 --- a/protoc_plugin/protos/client.proto +++ b/protoc_plugin/protos/google/api/client.proto
@@ -16,7 +16,9 @@ package google.api; -import "descriptor.proto"; +import "google/api/launch_stage.proto"; +import "google/protobuf/descriptor.proto"; +import "google/protobuf/duration.proto"; option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; option java_multiple_files = true; @@ -127,10 +129,53 @@ SelectiveGapicGeneration selective_gapic_generation = 3; } +// Details about how and where to publish client libraries. +message ClientLibrarySettings { + // Version of the API to apply these settings to. This is the full protobuf + // package for the API, ending in the version element. + // Examples: "google.cloud.speech.v1" and "google.spanner.admin.database.v1". + string version = 1; + + // Launch stage of this version of the API. + LaunchStage launch_stage = 2; + + // When using transport=rest, the client request will encode enums as + // numbers rather than strings. + bool rest_numeric_enums = 3; + + // Settings for legacy Java features, supported in the Service YAML. + JavaSettings java_settings = 21; + + // Settings for C++ client libraries. + CppSettings cpp_settings = 22; + + // Settings for PHP client libraries. + PhpSettings php_settings = 23; + + // Settings for Python client libraries. + PythonSettings python_settings = 24; + + // Settings for Node client libraries. + NodeSettings node_settings = 25; + + // Settings for .NET client libraries. + DotnetSettings dotnet_settings = 26; + + // Settings for Ruby client libraries. + RubySettings ruby_settings = 27; + + // Settings for Go client libraries. + GoSettings go_settings = 28; +} + // This message configures the settings for publishing [Google Cloud Client // libraries](https://cloud.google.com/apis/docs/cloud-client-libraries) // generated from the service config. message Publishing { + // A list of API method settings, e.g. the behavior for methods that use the + // long-running operation pattern. + repeated MethodSettings method_settings = 2; + // Link to a *public* URI where users can report issues. Example: // https://issuetracker.google.com/issues/new?component=190865&template=1161103 string new_issue_uri = 101; @@ -158,6 +203,11 @@ // For whom the client library is being published. ClientLibraryOrganization organization = 107; + // Client library settings. If the same version string appears multiple + // times in this list, then the last one wins. Settings from earlier + // settings with the same version string are discarded. + repeated ClientLibrarySettings library_settings = 109; + // Optional link to proto reference documentation. Example: // https://cloud.google.com/pubsub/lite/docs/reference/rpc string proto_reference_documentation_uri = 110; @@ -310,6 +360,73 @@ map<string, string> renamed_services = 2; } +// Describes the generator configuration for a method. +message MethodSettings { + // Describes settings to use when generating API methods that use the + // long-running operation pattern. + // All default values below are from those used in the client library + // generators (e.g. + // [Java](https://github.com/googleapis/gapic-generator-java/blob/04c2faa191a9b5a10b92392fe8482279c4404803/src/main/java/com/google/api/generator/gapic/composer/common/RetrySettingsComposer.java)). + message LongRunning { + // Initial delay after which the first poll request will be made. + // Default value: 5 seconds. + google.protobuf.Duration initial_poll_delay = 1; + + // Multiplier to gradually increase delay between subsequent polls until it + // reaches max_poll_delay. + // Default value: 1.5. + float poll_delay_multiplier = 2; + + // Maximum time between two subsequent poll requests. + // Default value: 45 seconds. + google.protobuf.Duration max_poll_delay = 3; + + // Total polling timeout. + // Default value: 5 minutes. + google.protobuf.Duration total_poll_timeout = 4; + } + + // The fully qualified name of the method, for which the options below apply. + // This is used to find the method to apply the options. + // + // Example: + // + // publishing: + // method_settings: + // - selector: google.storage.control.v2.StorageControl.CreateFolder + // # method settings for CreateFolder... + string selector = 1; + + // Describes settings to use for long-running operations when generating + // API methods for RPCs. Complements RPCs that use the annotations in + // google/longrunning/operations.proto. + // + // Example of a YAML configuration:: + // + // publishing: + // method_settings: + // - selector: google.cloud.speech.v2.Speech.BatchRecognize + // long_running: + // initial_poll_delay: 60s # 1 minute + // poll_delay_multiplier: 1.5 + // max_poll_delay: 360s # 6 minutes + // total_poll_timeout: 54000s # 90 minutes + LongRunning long_running = 2; + + // List of top-level fields of the request message, that should be + // automatically populated by the client libraries based on their + // (google.api.field_info).format. Currently supported format: UUID4. + // + // Example of a YAML configuration: + // + // publishing: + // method_settings: + // - selector: google.example.v1.ExampleService.CreateExample + // auto_populated_fields: + // - request_id + repeated string auto_populated_fields = 3; +} + // The organization for which the client libraries are being published. // Affects the url where generated docs are published, etc. enum ClientLibraryOrganization {
diff --git a/protoc_plugin/protos/google/api/http.proto b/protoc_plugin/protos/google/api/http.proto new file mode 100644 index 0000000..57621b5 --- /dev/null +++ b/protoc_plugin/protos/google/api/http.proto
@@ -0,0 +1,370 @@ +// Copyright 2025 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.api; + +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "HttpProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +// Defines the HTTP configuration for an API service. It contains a list of +// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method +// to one or more HTTP REST API methods. +message Http { + // A list of HTTP configuration rules that apply to individual API methods. + // + // **NOTE:** All service configuration rules follow "last one wins" order. + repeated HttpRule rules = 1; + + // When set to true, URL path parameters will be fully URI-decoded except in + // cases of single segment matches in reserved expansion, where "%2F" will be + // left encoded. + // + // The default behavior is to not decode RFC 6570 reserved characters in multi + // segment matches. + bool fully_decode_reserved_expansion = 2; +} + +// gRPC Transcoding +// +// gRPC Transcoding is a feature for mapping between a gRPC method and one or +// more HTTP REST endpoints. It allows developers to build a single API service +// that supports both gRPC APIs and REST APIs. Many systems, including [Google +// APIs](https://github.com/googleapis/googleapis), +// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC +// Gateway](https://github.com/grpc-ecosystem/grpc-gateway), +// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature +// and use it for large scale production services. +// +// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies +// how different portions of the gRPC request message are mapped to the URL +// path, URL query parameters, and HTTP request body. It also controls how the +// gRPC response message is mapped to the HTTP response body. `HttpRule` is +// typically specified as an `google.api.http` annotation on the gRPC method. +// +// Each mapping specifies a URL path template and an HTTP method. The path +// template may refer to one or more fields in the gRPC request message, as long +// as each field is a non-repeated field with a primitive (non-message) type. +// The path template controls how fields of the request message are mapped to +// the URL path. +// +// Example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get: "/v1/{name=messages/*}" +// }; +// } +// } +// message GetMessageRequest { +// string name = 1; // Mapped to URL path. +// } +// message Message { +// string text = 1; // The resource content. +// } +// +// This enables an HTTP REST to gRPC mapping as below: +// +// - HTTP: `GET /v1/messages/123456` +// - gRPC: `GetMessage(name: "messages/123456")` +// +// Any fields in the request message which are not bound by the path template +// automatically become HTTP query parameters if there is no HTTP request body. +// For example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get:"/v1/messages/{message_id}" +// }; +// } +// } +// message GetMessageRequest { +// message SubMessage { +// string subfield = 1; +// } +// string message_id = 1; // Mapped to URL path. +// int64 revision = 2; // Mapped to URL query parameter `revision`. +// SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`. +// } +// +// This enables a HTTP JSON to RPC mapping as below: +// +// - HTTP: `GET /v1/messages/123456?revision=2&sub.subfield=foo` +// - gRPC: `GetMessage(message_id: "123456" revision: 2 sub: +// SubMessage(subfield: "foo"))` +// +// Note that fields which are mapped to URL query parameters must have a +// primitive type or a repeated primitive type or a non-repeated message type. +// In the case of a repeated type, the parameter can be repeated in the URL +// as `...?param=A¶m=B`. In the case of a message type, each field of the +// message is mapped to a separate parameter, such as +// `...?foo.a=A&foo.b=B&foo.c=C`. +// +// For HTTP methods that allow a request body, the `body` field +// specifies the mapping. Consider a REST update method on the +// message resource collection: +// +// service Messaging { +// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { +// option (google.api.http) = { +// patch: "/v1/messages/{message_id}" +// body: "message" +// }; +// } +// } +// message UpdateMessageRequest { +// string message_id = 1; // mapped to the URL +// Message message = 2; // mapped to the body +// } +// +// The following HTTP JSON to RPC mapping is enabled, where the +// representation of the JSON in the request body is determined by +// protos JSON encoding: +// +// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }` +// - gRPC: `UpdateMessage(message_id: "123456" message { text: "Hi!" })` +// +// The special name `*` can be used in the body mapping to define that +// every field not bound by the path template should be mapped to the +// request body. This enables the following alternative definition of +// the update method: +// +// service Messaging { +// rpc UpdateMessage(Message) returns (Message) { +// option (google.api.http) = { +// patch: "/v1/messages/{message_id}" +// body: "*" +// }; +// } +// } +// message Message { +// string message_id = 1; +// string text = 2; +// } +// +// +// The following HTTP JSON to RPC mapping is enabled: +// +// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }` +// - gRPC: `UpdateMessage(message_id: "123456" text: "Hi!")` +// +// Note that when using `*` in the body mapping, it is not possible to +// have HTTP parameters, as all fields not bound by the path end in +// the body. This makes this option more rarely used in practice when +// defining REST APIs. The common usage of `*` is in custom methods +// which don't use the URL at all for transferring data. +// +// It is possible to define multiple HTTP methods for one RPC by using +// the `additional_bindings` option. Example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get: "/v1/messages/{message_id}" +// additional_bindings { +// get: "/v1/users/{user_id}/messages/{message_id}" +// } +// }; +// } +// } +// message GetMessageRequest { +// string message_id = 1; +// string user_id = 2; +// } +// +// This enables the following two alternative HTTP JSON to RPC mappings: +// +// - HTTP: `GET /v1/messages/123456` +// - gRPC: `GetMessage(message_id: "123456")` +// +// - HTTP: `GET /v1/users/me/messages/123456` +// - gRPC: `GetMessage(user_id: "me" message_id: "123456")` +// +// Rules for HTTP mapping +// +// 1. Leaf request fields (recursive expansion nested messages in the request +// message) are classified into three categories: +// - Fields referred by the path template. They are passed via the URL path. +// - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They +// are passed via the HTTP +// request body. +// - All other fields are passed via the URL query parameters, and the +// parameter name is the field path in the request message. A repeated +// field can be represented as multiple query parameters under the same +// name. +// 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL +// query parameter, all fields +// are passed via URL path and HTTP request body. +// 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP +// request body, all +// fields are passed via URL path and URL query parameters. +// +// Path template syntax +// +// Template = "/" Segments [ Verb ] ; +// Segments = Segment { "/" Segment } ; +// Segment = "*" | "**" | LITERAL | Variable ; +// Variable = "{" FieldPath [ "=" Segments ] "}" ; +// FieldPath = IDENT { "." IDENT } ; +// Verb = ":" LITERAL ; +// +// The syntax `*` matches a single URL path segment. The syntax `**` matches +// zero or more URL path segments, which must be the last part of the URL path +// except the `Verb`. +// +// The syntax `Variable` matches part of the URL path as specified by its +// template. A variable template must not contain other variables. If a variable +// matches a single path segment, its template may be omitted, e.g. `{var}` +// is equivalent to `{var=*}`. +// +// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL` +// contains any reserved character, such characters should be percent-encoded +// before the matching. +// +// If a variable contains exactly one path segment, such as `"{var}"` or +// `"{var=*}"`, when such a variable is expanded into a URL path on the client +// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The +// server side does the reverse decoding. Such variables show up in the +// [Discovery +// Document](https://developers.google.com/discovery/v1/reference/apis) as +// `{var}`. +// +// If a variable contains multiple path segments, such as `"{var=foo/*}"` +// or `"{var=**}"`, when such a variable is expanded into a URL path on the +// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. +// The server side does the reverse decoding, except "%2F" and "%2f" are left +// unchanged. Such variables show up in the +// [Discovery +// Document](https://developers.google.com/discovery/v1/reference/apis) as +// `{+var}`. +// +// Using gRPC API Service Configuration +// +// gRPC API Service Configuration (service config) is a configuration language +// for configuring a gRPC service to become a user-facing product. The +// service config is simply the YAML representation of the `google.api.Service` +// proto message. +// +// As an alternative to annotating your proto file, you can configure gRPC +// transcoding in your service config YAML files. You do this by specifying a +// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same +// effect as the proto annotation. This can be particularly useful if you +// have a proto that is reused in multiple services. Note that any transcoding +// specified in the service config will override any matching transcoding +// configuration in the proto. +// +// The following example selects a gRPC method and applies an `HttpRule` to it: +// +// http: +// rules: +// - selector: example.v1.Messaging.GetMessage +// get: /v1/messages/{message_id}/{sub.subfield} +// +// Special notes +// +// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the +// proto to JSON conversion must follow the [proto3 +// specification](https://developers.google.com/protocol-buffers/docs/proto3#json). +// +// While the single segment variable follows the semantics of +// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String +// Expansion, the multi segment variable **does not** follow RFC 6570 Section +// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion +// does not expand special characters like `?` and `#`, which would lead +// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding +// for multi segment variables. +// +// The path variables **must not** refer to any repeated or mapped field, +// because client libraries are not capable of handling such variable expansion. +// +// The path variables **must not** capture the leading "/" character. The reason +// is that the most common use case "{var}" does not capture the leading "/" +// character. For consistency, all path variables must share the same behavior. +// +// Repeated message fields must not be mapped to URL query parameters, because +// no client library can support such complicated mapping. +// +// If an API needs to use a JSON array for request or response body, it can map +// the request or response body to a repeated field. However, some gRPC +// Transcoding implementations may not support this feature. +message HttpRule { + // Selects a method to which this rule applies. + // + // Refer to [selector][google.api.DocumentationRule.selector] for syntax + // details. + string selector = 1; + + // Determines the URL pattern is matched by this rules. This pattern can be + // used with any of the {get|put|post|delete|patch} methods. A custom method + // can be defined using the 'custom' field. + oneof pattern { + // Maps to HTTP GET. Used for listing and getting information about + // resources. + string get = 2; + + // Maps to HTTP PUT. Used for replacing a resource. + string put = 3; + + // Maps to HTTP POST. Used for creating a resource or performing an action. + string post = 4; + + // Maps to HTTP DELETE. Used for deleting a resource. + string delete = 5; + + // Maps to HTTP PATCH. Used for updating a resource. + string patch = 6; + + // The custom pattern is used for specifying an HTTP method that is not + // included in the `pattern` field, such as HEAD, or "*" to leave the + // HTTP method unspecified for this rule. The wild-card rule is useful + // for services that provide content to Web (HTML) clients. + CustomHttpPattern custom = 8; + } + + // The name of the request field whose value is mapped to the HTTP request + // body, or `*` for mapping all request fields not captured by the path + // pattern to the HTTP body, or omitted for not having any HTTP request body. + // + // NOTE: the referred field must be present at the top-level of the request + // message type. + string body = 7; + + // Optional. The name of the response field whose value is mapped to the HTTP + // response body. When omitted, the entire response message will be used + // as the HTTP response body. + // + // NOTE: The referred field must be present at the top-level of the response + // message type. + string response_body = 12; + + // Additional HTTP bindings for the selector. Nested bindings must + // not contain an `additional_bindings` field themselves (that is, + // the nesting may only be one level deep). + repeated HttpRule additional_bindings = 11; +} + +// A custom pattern is used for defining custom HTTP verb. +message CustomHttpPattern { + // The name of this custom HTTP verb. + string kind = 1; + + // The path matched by this custom verb. + string path = 2; +}
diff --git a/protoc_plugin/protos/google/api/launch_stage.proto b/protoc_plugin/protos/google/api/launch_stage.proto new file mode 100644 index 0000000..1e86c1a --- /dev/null +++ b/protoc_plugin/protos/google/api/launch_stage.proto
@@ -0,0 +1,72 @@ +// Copyright 2025 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.api; + +option go_package = "google.golang.org/genproto/googleapis/api;api"; +option java_multiple_files = true; +option java_outer_classname = "LaunchStageProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +// The launch stage as defined by [Google Cloud Platform +// Launch Stages](https://cloud.google.com/terms/launch-stages). +enum LaunchStage { + // Do not use this default value. + LAUNCH_STAGE_UNSPECIFIED = 0; + + // The feature is not yet implemented. Users can not use it. + UNIMPLEMENTED = 6; + + // Prelaunch features are hidden from users and are only visible internally. + PRELAUNCH = 7; + + // Early Access features are limited to a closed group of testers. To use + // these features, you must sign up in advance and sign a Trusted Tester + // agreement (which includes confidentiality provisions). These features may + // be unstable, changed in backward-incompatible ways, and are not + // guaranteed to be released. + EARLY_ACCESS = 1; + + // Alpha is a limited availability test for releases before they are cleared + // for widespread use. By Alpha, all significant design issues are resolved + // and we are in the process of verifying functionality. Alpha customers + // need to apply for access, agree to applicable terms, and have their + // projects allowlisted. Alpha releases don't have to be feature complete, + // no SLAs are provided, and there are no technical support obligations, but + // they will be far enough along that customers can actually use them in + // test environments or for limited-use tests -- just like they would in + // normal production cases. + ALPHA = 2; + + // Beta is the point at which we are ready to open a release for any + // customer to use. There are no SLA or technical support obligations in a + // Beta release. Products will be complete from a feature perspective, but + // may have some open outstanding issues. Beta releases are suitable for + // limited production use cases. + BETA = 3; + + // GA features are open to all developers and are considered stable and + // fully qualified for production use. + GA = 4; + + // Deprecated features are scheduled to be shut down and removed. For more + // information, see the "Deprecation Policy" section of our [Terms of + // Service](https://cloud.google.com/terms/) + // and the [Google Cloud Platform Subject to the Deprecation + // Policy](https://cloud.google.com/terms/deprecation) documentation. + DEPRECATED = 5; +}
diff --git a/protoc_plugin/protos/plugin.proto b/protoc_plugin/protos/google/protobuf/compiler/plugin.proto similarity index 99% rename from protoc_plugin/protos/plugin.proto rename to protoc_plugin/protos/google/protobuf/compiler/plugin.proto index 7880c93..9242aac 100644 --- a/protoc_plugin/protos/plugin.proto +++ b/protoc_plugin/protos/google/protobuf/compiler/plugin.proto
@@ -52,7 +52,7 @@ option go_package = "google.golang.org/protobuf/types/pluginpb"; -import "descriptor.proto"; +import "google/protobuf/descriptor.proto"; // The version number of protocol compiler. message Version {
diff --git a/protoc_plugin/protos/descriptor.proto b/protoc_plugin/protos/google/protobuf/descriptor.proto similarity index 100% rename from protoc_plugin/protos/descriptor.proto rename to protoc_plugin/protos/google/protobuf/descriptor.proto
diff --git a/protoc_plugin/protos/google/protobuf/duration.proto b/protoc_plugin/protos/google/protobuf/duration.proto new file mode 100644 index 0000000..41f40c2 --- /dev/null +++ b/protoc_plugin/protos/google/protobuf/duration.proto
@@ -0,0 +1,115 @@ +// 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 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"; +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; + +// 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; +}
diff --git a/protoc_plugin/test/descriptor_test.dart b/protoc_plugin/test/descriptor_test.dart index 34085cf..c066bf8 100644 --- a/protoc_plugin/test/descriptor_test.dart +++ b/protoc_plugin/test/descriptor_test.dart
@@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:protobuf/protobuf.dart'; -import 'package:protoc_plugin/src/generated/descriptor.pb.dart'; +import 'package:protoc_plugin/src/gen/google/protobuf/descriptor.pb.dart'; import 'package:test/test.dart'; import '../out/protos/custom_option.pb.dart';
diff --git a/protoc_plugin/test/enum_generator_test.dart b/protoc_plugin/test/enum_generator_test.dart index e171e6f..4f5ec37 100644 --- a/protoc_plugin/test/enum_generator_test.dart +++ b/protoc_plugin/test/enum_generator_test.dart
@@ -4,7 +4,7 @@ import 'package:protoc_plugin/indenting_writer.dart'; import 'package:protoc_plugin/protoc.dart'; -import 'package:protoc_plugin/src/generated/descriptor.pb.dart'; +import 'package:protoc_plugin/src/gen/google/protobuf/descriptor.pb.dart'; import 'package:protoc_plugin/src/options.dart'; import 'package:test/test.dart';
diff --git a/protoc_plugin/test/extension_generator_test.dart b/protoc_plugin/test/extension_generator_test.dart index 8770eae..57cd2b9 100644 --- a/protoc_plugin/test/extension_generator_test.dart +++ b/protoc_plugin/test/extension_generator_test.dart
@@ -4,8 +4,9 @@ import 'package:protoc_plugin/indenting_writer.dart'; import 'package:protoc_plugin/protoc.dart'; -import 'package:protoc_plugin/src/generated/descriptor.pb.dart' as pb; -import 'package:protoc_plugin/src/generated/plugin.pb.dart' as pb; +import 'package:protoc_plugin/src/gen/google/protobuf/compiler/plugin.pb.dart' + as pb; +import 'package:protoc_plugin/src/gen/google/protobuf/descriptor.pb.dart' as pb; import 'package:protoc_plugin/src/linker.dart'; import 'package:protoc_plugin/src/options.dart'; import 'package:test/test.dart';
diff --git a/protoc_plugin/test/file_generator_test.dart b/protoc_plugin/test/file_generator_test.dart index 26a297d..3a22888 100644 --- a/protoc_plugin/test/file_generator_test.dart +++ b/protoc_plugin/test/file_generator_test.dart
@@ -4,9 +4,9 @@ import 'package:protoc_plugin/indenting_writer.dart'; import 'package:protoc_plugin/protoc.dart'; -import 'package:protoc_plugin/src/generated/client.pb.dart'; -import 'package:protoc_plugin/src/generated/descriptor.pb.dart'; -import 'package:protoc_plugin/src/generated/plugin.pb.dart'; +import 'package:protoc_plugin/src/gen/google/api/client.pb.dart'; +import 'package:protoc_plugin/src/gen/google/protobuf/compiler/plugin.pb.dart'; +import 'package:protoc_plugin/src/gen/google/protobuf/descriptor.pb.dart'; import 'package:protoc_plugin/src/linker.dart'; import 'package:protoc_plugin/src/options.dart'; import 'package:test/test.dart';
diff --git a/protoc_plugin/test/indenting_writer_test.dart b/protoc_plugin/test/indenting_writer_test.dart index 81ec9fe..6af4797 100644 --- a/protoc_plugin/test/indenting_writer_test.dart +++ b/protoc_plugin/test/indenting_writer_test.dart
@@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:protoc_plugin/indenting_writer.dart'; -import 'package:protoc_plugin/src/generated/descriptor.pb.dart'; +import 'package:protoc_plugin/src/gen/google/protobuf/descriptor.pb.dart'; import 'package:test/test.dart'; void main() {
diff --git a/protoc_plugin/test/message_generator_test.dart b/protoc_plugin/test/message_generator_test.dart index c25fa0e..c4cadda 100644 --- a/protoc_plugin/test/message_generator_test.dart +++ b/protoc_plugin/test/message_generator_test.dart
@@ -7,8 +7,8 @@ import 'package:collection/collection.dart'; import 'package:protoc_plugin/indenting_writer.dart'; import 'package:protoc_plugin/protoc.dart'; -import 'package:protoc_plugin/src/generated/descriptor.pb.dart'; -import 'package:protoc_plugin/src/generated/plugin.pb.dart'; +import 'package:protoc_plugin/src/gen/google/protobuf/compiler/plugin.pb.dart'; +import 'package:protoc_plugin/src/gen/google/protobuf/descriptor.pb.dart'; import 'package:protoc_plugin/src/linker.dart'; import 'package:protoc_plugin/src/options.dart'; import 'package:test/test.dart';
diff --git a/protoc_plugin/test/message_test.dart b/protoc_plugin/test/message_test.dart index 9064721..d1d6806 100644 --- a/protoc_plugin/test/message_test.dart +++ b/protoc_plugin/test/message_test.dart
@@ -4,7 +4,7 @@ // ignore_for_file: deprecated_member_use_from_same_package -import 'package:protoc_plugin/src/generated/descriptor.pb.dart' +import 'package:protoc_plugin/src/gen/google/protobuf/descriptor.pb.dart' show DescriptorProto; import 'package:test/test.dart';
diff --git a/protoc_plugin/test/names_test.dart b/protoc_plugin/test/names_test.dart index ae83b38..9cbece6 100644 --- a/protoc_plugin/test/names_test.dart +++ b/protoc_plugin/test/names_test.dart
@@ -3,8 +3,8 @@ // BSD-style license that can be found in the LICENSE file. import 'package:protoc_plugin/names.dart' as names; -import 'package:protoc_plugin/src/generated/dart_options.pb.dart'; -import 'package:protoc_plugin/src/generated/descriptor.pb.dart'; +import 'package:protoc_plugin/src/gen/dart_options.pb.dart'; +import 'package:protoc_plugin/src/gen/google/protobuf/descriptor.pb.dart'; import 'package:test/test.dart'; import '../out/protos/dart_name.pb.dart' as pb;
diff --git a/protoc_plugin/test/protoc_options_test.dart b/protoc_plugin/test/protoc_options_test.dart index fd64bbf..78bac76 100644 --- a/protoc_plugin/test/protoc_options_test.dart +++ b/protoc_plugin/test/protoc_options_test.dart
@@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:protoc_plugin/src/generated/plugin.pb.dart'; +import 'package:protoc_plugin/src/gen/google/protobuf/compiler/plugin.pb.dart'; import 'package:protoc_plugin/src/options.dart'; import 'package:test/test.dart';
diff --git a/protoc_plugin/test/protos/custom_option.proto b/protoc_plugin/test/protos/custom_option.proto index cb4fc2e..57e31fb 100644 --- a/protoc_plugin/test/protos/custom_option.proto +++ b/protoc_plugin/test/protos/custom_option.proto
@@ -6,7 +6,7 @@ package custom_option; -import "descriptor.proto"; +import "google/protobuf/descriptor.proto"; extend google.protobuf.MessageOptions { optional string my_option = 51234;
diff --git a/protoc_plugin/test/service_test.dart b/protoc_plugin/test/service_test.dart index 51e9d92..04cab34 100644 --- a/protoc_plugin/test/service_test.dart +++ b/protoc_plugin/test/service_test.dart
@@ -1,5 +1,5 @@ import 'package:protobuf/protobuf.dart'; -import 'package:protoc_plugin/src/generated/descriptor.pb.dart' +import 'package:protoc_plugin/src/gen/google/protobuf/descriptor.pb.dart' show DescriptorProto, ServiceDescriptorProto; import 'package:test/test.dart';
diff --git a/protoc_plugin/test/service_util.dart b/protoc_plugin/test/service_util.dart index b26e1e6..627254f 100644 --- a/protoc_plugin/test/service_util.dart +++ b/protoc_plugin/test/service_util.dart
@@ -2,7 +2,7 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:protoc_plugin/src/generated/descriptor.pb.dart'; +import 'package:protoc_plugin/src/gen/google/protobuf/descriptor.pb.dart'; ServiceDescriptorProto buildServiceDescriptor() { final sd = ServiceDescriptorProto()