Skip to content

Commit

Permalink
feat(bazel): map operation_metadata.proto to common_proto (#77)
Browse files Browse the repository at this point in the history
* feat(bazel): map operation_metadata.proto to common_proto

* fix import matching string

* add extra protos for nodejs pkg

* add longrunning with common metadata
  • Loading branch information
noahdietz committed Sep 29, 2021
1 parent 3eb22bc commit f078303
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ nodejs_gapic_assembly_pkg(
name = "{{assembly_name}}-{{version}}-nodejs",
deps = [
":{{name}}_nodejs_gapic",
":{{name}}_proto",
":{{name}}_proto",{{extra_protos_nodejs}}
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class BazelBuildFileView {
tokens.put("version", bp.getVersion());
tokens.put("package", bp.getProtoPackage());

Set<String> extraProtosNodeJS = new TreeSet<>();
Set<String> extraImports = new TreeSet<>();
extraImports.add(COMMON_RESOURCES_PROTO);
tokens.put("extra_imports", joinSetWithIndentation(extraImports));
Expand All @@ -58,12 +59,16 @@ class BazelBuildFileView {
String actualImport = imp.replace(".proto", "_proto");
if (actualImport.startsWith("google/protobuf/")) {
actualImport = actualImport.replace("google/protobuf/", "@com_google_protobuf//:");
} else if (actualImport.equals("google/cloud/common/operation_metadata_proto")) {
actualImport = "//google/cloud/common:common_proto";
extraProtosNodeJS.add(actualImport);
} else {
actualImport = convertPathToLabel("", actualImport);
}
actualImports.add(actualImport);
}
tokens.put("proto_deps", joinSetWithIndentation(actualImports));
tokens.put("extra_protos_nodejs", joinSetWithIndentationNl(extraProtosNodeJS));
tokens.put("go_proto_importpath", bp.getLangProtoPackages().get("go").split(";")[0]);
tokens.put("go_proto_deps", joinSetWithIndentation(mapGoProtoDeps(actualImports)));

Expand Down Expand Up @@ -241,6 +246,8 @@ private Set<String> mapJavaGapicDeps(Set<String> protoImports) {
} else if (protoImport.endsWith(":location_proto")) {
javaImports.add("//google/cloud/location:location_java_proto");
javaImports.add("//google/cloud/location:location_java_grpc");
} else if (protoImport.endsWith(":common_proto")) {
javaImports.add(replaceLabelName(protoImport, ":common_java_proto"));
}
}
return javaImports;
Expand Down Expand Up @@ -348,6 +355,8 @@ private Set<String> mapGoGapicDeps(Set<String> protoImports) {
goImports.add(replaceLabelName(protoImport, ":metric_go_proto"));
} else if (protoImport.endsWith(":location_proto")) {
goImports.add(replaceLabelName(protoImport, ":location_go_proto"));
} else if (protoImport.endsWith(":common_proto")) {
goImports.add(replaceLabelName(protoImport, ":common_go_proto"));
}
}
return goImports;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ proto_library(
"//google/api:field_behavior_proto",
"//google/api:httpbody_proto",
"//google/api:resource_proto",
"//google/cloud/common:common_proto",
"//google/longrunning:operations_proto",
"@com_google_protobuf//:empty_proto",
],
)
Expand Down Expand Up @@ -77,6 +79,7 @@ java_gapic_library(
deps = [
":library_java_proto",
"//google/api:api_java_proto",
"//google/cloud/common:common_java_proto",
"//google/cloud/location:location_java_grpc",
"//google/cloud/location:location_java_proto",
],
Expand Down Expand Up @@ -123,6 +126,8 @@ go_proto_library(
deps = [
"//google/api:annotations_go_proto",
"//google/api:httpbody_go_proto",
"//google/cloud/common:common_go_proto",
"//google/longrunning:longrunning_go_proto",
],
)

Expand All @@ -136,8 +141,12 @@ go_gapic_library(
deps = [
":library_go_proto",
"//google/api:httpbody_go_proto",
"//google/cloud/common:common_go_proto",
"//google/cloud/location:location_go_proto",
"//google/iam/v1:iam_go_proto",
"//google/longrunning:longrunning_go_proto",
"@com_google_cloud_go//longrunning/autogen:go_default_library",
"@com_google_cloud_go//longrunning:go_default_library",
],
)

Expand Down Expand Up @@ -250,6 +259,7 @@ nodejs_gapic_assembly_pkg(
deps = [
":library_nodejs_gapic",
":library_proto",
"//google/cloud/common:common_proto",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/api/httpbody.proto";
import "google/cloud/common/operation_metadata.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/empty.proto";

option go_package = "google.golang.org/genproto/googleapis/example/library/v1;library";
Expand All @@ -47,6 +49,16 @@ service LibraryService {
};
option (google.api.method_signature) = "shelf";
}

rpc DeleteShelf(DeleteShelfRequest) returns (google.longrunning.Operation) {
option (google.api.http) = {
delete: "/v1/{name=shelves/*}"
};
option (google.longrunning.operation_info) = {
response_type: "google.protobuf.Empty"
metadata_type: "google.cloud.common.OperationMetadata"
};
}
}

// A Shelf contains a collection of books with a theme.
Expand All @@ -73,3 +85,9 @@ message CreateShelfRequest {
// The shelf to create.
Shelf shelf = 1 [(google.api.field_behavior) = REQUIRED];
}

// Request message for LibraryService.DeleteShelf.
message DeleteShelfRequest {
// The shelf to delete.
string name = 1;
}

0 comments on commit f078303

Please sign in to comment.