diff --git a/proto/prost/private/protoc_wrapper.rs b/proto/prost/private/protoc_wrapper.rs index 38a19196c4..817faac9b0 100644 --- a/proto/prost/private/protoc_wrapper.rs +++ b/proto/prost/private/protoc_wrapper.rs @@ -30,6 +30,7 @@ fn find_generated_rust_files(out_dir: &Path) -> BTreeSet { all_rs_files.insert(path); } } else if let Some(name) = path.file_name() { + // The filename is set to `_` when the package name is empty. if name == "_" { let rs_name = path.parent().expect("Failed to get parent").join("_.rs"); fs::rename(&path, &rs_name).unwrap_or_else(|err| { diff --git a/proto/prost/private/tests/bazel_remote_apis/BUILD.bazel b/proto/prost/private/tests/bazel_remote_apis/BUILD.bazel new file mode 100644 index 0000000000..e763e1d530 --- /dev/null +++ b/proto/prost/private/tests/bazel_remote_apis/BUILD.bazel @@ -0,0 +1,32 @@ +load("@rules_rust//proto/prost:defs.bzl", "rust_prost_library", "rust_tonic_library") +load("//rust:defs.bzl", "rust_test") + +rust_tonic_library( + name = "remote_execution_rs_proto", + proto = "@bazel_remote_apis//build/bazel/remote/execution/v2:remote_execution_proto", + visibility = ["//visibility:public"], +) + +rust_test( + name = "remote_execution_test", + srcs = ["remote_execution_test.rs"], + edition = "2021", + deps = [ + ":remote_execution_rs_proto", + ], +) + +rust_prost_library( + name = "semver_rs_proto", + proto = "@bazel_remote_apis//build/bazel/semver:semver_proto", + visibility = ["//visibility:public"], +) + +rust_test( + name = "semver_test", + srcs = ["semver_test.rs"], + edition = "2021", + deps = [ + ":semver_rs_proto", + ], +) diff --git a/proto/prost/private/tests/complex_imports/remote-apis/build/bazel/remote/execution/v2/remoteexecution_test.rs b/proto/prost/private/tests/bazel_remote_apis/remote_execution_test.rs similarity index 74% rename from proto/prost/private/tests/complex_imports/remote-apis/build/bazel/remote/execution/v2/remoteexecution_test.rs rename to proto/prost/private/tests/bazel_remote_apis/remote_execution_test.rs index a582e7ad6d..c0e2608abb 100644 --- a/proto/prost/private/tests/complex_imports/remote-apis/build/bazel/remote/execution/v2/remoteexecution_test.rs +++ b/proto/prost/private/tests/bazel_remote_apis/remote_execution_test.rs @@ -1,6 +1,6 @@ //! Tests the remote execution protos. -use remoteexecution_proto::build::bazel::remote::execution::v2::Digest; +use remote_execution_proto::build::bazel::remote::execution::v2::Digest; #[test] fn test_remote_execution() { diff --git a/proto/prost/private/tests/complex_imports/remote-apis/build/bazel/semver/semver_test.rs b/proto/prost/private/tests/bazel_remote_apis/semver_test.rs similarity index 100% rename from proto/prost/private/tests/complex_imports/remote-apis/build/bazel/semver/semver_test.rs rename to proto/prost/private/tests/bazel_remote_apis/semver_test.rs diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/api/BUILD.bazel b/proto/prost/private/tests/complex_imports/googleapis/google/api/BUILD.bazel deleted file mode 100644 index 5202016fe0..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/api/BUILD.bazel +++ /dev/null @@ -1,32 +0,0 @@ -load("@rules_proto//proto:defs.bzl", "proto_library") -load("//proto:defs.bzl", "rust_prost_library") -load("//rust:defs.bzl", "rust_test") - -proto_library( - name = "annotations_proto", - srcs = [ - "annotations.proto", - "client.proto", - "field_behavior.proto", - "http.proto", - ], - strip_import_prefix = "/proto/prost/private/tests/complex_imports/googleapis", - visibility = ["//visibility:public"], - deps = [ - "@com_google_protobuf//:descriptor_proto", - ], -) - -rust_prost_library( - name = "annotations_rs_proto", - proto = ":annotations_proto", -) - -rust_test( - name = "annotations_test", - srcs = ["annotations_test.rs"], - edition = "2021", - deps = [ - ":annotations_rs_proto", - ], -) diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/api/annotations.proto b/proto/prost/private/tests/complex_imports/googleapis/google/api/annotations.proto deleted file mode 100644 index efdab3db6c..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/api/annotations.proto +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 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; - -import "google/api/http.proto"; -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "AnnotationsProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.MethodOptions { - // See `HttpRule`. - HttpRule http = 72295728; -} diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/api/annotations_test.rs b/proto/prost/private/tests/complex_imports/googleapis/google/api/annotations_test.rs deleted file mode 100644 index af6ee4fdd6..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/api/annotations_test.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! Tests the annotations protos. - -use annotations_proto::google::api::http_rule::Pattern; -use annotations_proto::google::api::HttpRule; - -#[test] -fn test_annotations() { - let http_rule = HttpRule { - pattern: Some(Pattern::Get("/v1/{name=shelves/*}/books".to_string())), - ..HttpRule::default() - }; - - assert_eq!( - http_rule.pattern, - Some(Pattern::Get("/v1/{name=shelves/*}/books".to_string())) - ); -} diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/api/client.proto b/proto/prost/private/tests/complex_imports/googleapis/google/api/client.proto deleted file mode 100644 index 3b3fd0c401..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/api/client.proto +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2018 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; - -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "ClientProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.MethodOptions { - // A definition of a client library method signature. - // - // In client libraries, each proto RPC corresponds to one or more methods - // which the end user is able to call, and calls the underlying RPC. - // Normally, this method receives a single argument (a struct or instance - // corresponding to the RPC request object). Defining this field will - // add one or more overloads providing flattened or simpler method signatures - // in some languages. - // - // The fields on the method signature are provided as a comma-separated - // string. - // - // For example, the proto RPC and annotation: - // - // rpc CreateSubscription(CreateSubscriptionRequest) - // returns (Subscription) { - // option (google.api.method_signature) = "name,topic"; - // } - // - // Would add the following Java overload (in addition to the method accepting - // the request object): - // - // public final Subscription createSubscription(String name, String topic) - // - // The following backwards-compatibility guidelines apply: - // - // * Adding this annotation to an unannotated method is backwards - // compatible. - // * Adding this annotation to a method which already has existing - // method signature annotations is backwards compatible if and only if - // the new method signature annotation is last in the sequence. - // * Modifying or removing an existing method signature annotation is - // a breaking change. - // * Re-ordering existing method signature annotations is a breaking - // change. - repeated string method_signature = 1051; -} - -extend google.protobuf.ServiceOptions { - // The hostname for this service. - // This should be specified with no prefix or protocol. - // - // Example: - // - // service Foo { - // option (google.api.default_host) = "foo.googleapi.com"; - // ... - // } - string default_host = 1049; - - // OAuth scopes needed for the client. - // - // Example: - // - // service Foo { - // option (google.api.oauth_scopes) = \ - // "https://www.googleapis.com/auth/cloud-platform"; - // ... - // } - // - // If there is more than one scope, use a comma-separated string: - // - // Example: - // - // service Foo { - // option (google.api.oauth_scopes) = \ - // "https://www.googleapis.com/auth/cloud-platform," - // "https://www.googleapis.com/auth/monitoring"; - // ... - // } - string oauth_scopes = 1050; -} diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/api/field_behavior.proto b/proto/prost/private/tests/complex_imports/googleapis/google/api/field_behavior.proto deleted file mode 100644 index c4abe3b670..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/api/field_behavior.proto +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2018 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; - -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "FieldBehaviorProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.FieldOptions { - // A designation of a specific field behavior (required, output only, etc.) - // in protobuf messages. - // - // Examples: - // - // string name = 1 [(google.api.field_behavior) = REQUIRED]; - // State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - // google.protobuf.Duration ttl = 1 - // [(google.api.field_behavior) = INPUT_ONLY]; - // google.protobuf.Timestamp expire_time = 1 - // [(google.api.field_behavior) = OUTPUT_ONLY, - // (google.api.field_behavior) = IMMUTABLE]; - repeated google.api.FieldBehavior field_behavior = 1052; -} - -// An indicator of the behavior of a given field (for example, that a field -// is required in requests, or given as output but ignored as input). -// This **does not** change the behavior in protocol buffers itself; it only -// denotes the behavior and may affect how API tooling handles the field. -// -// Note: This enum **may** receive new values in the future. -enum FieldBehavior { - // Conventional default for enums. Do not use this. - FIELD_BEHAVIOR_UNSPECIFIED = 0; - - // Specifically denotes a field as optional. - // While all fields in protocol buffers are optional, this may be specified - // for emphasis if appropriate. - OPTIONAL = 1; - - // Denotes a field as required. - // This indicates that the field **must** be provided as part of the request, - // and failure to do so will cause an error (usually `INVALID_ARGUMENT`). - REQUIRED = 2; - - // Denotes a field as output only. - // This indicates that the field is provided in responses, but including the - // field in a request does nothing (the server *must* ignore it and - // *must not* throw an error as a result of the field's presence). - OUTPUT_ONLY = 3; - - // Denotes a field as input only. - // This indicates that the field is provided in requests, and the - // corresponding field is not included in output. - INPUT_ONLY = 4; - - // Denotes a field as immutable. - // This indicates that the field may be set once in a request to create a - // resource, but may not be changed thereafter. - IMMUTABLE = 5; - - // Denotes that a (repeated) field is an unordered list. - // This indicates that the service may provide the elements of the list - // in any arbitrary order, rather than the order the user originally - // provided. Additionally, the list's order may or may not be stable. - UNORDERED_LIST = 6; - - // Denotes that this field returns a non-empty default value if not set. - // This indicates that if the user provides the empty value in a request, - // a non-empty value will be returned. The user will not be aware of what - // non-empty value to expect. - NON_EMPTY_DEFAULT = 7; -} diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/api/http.proto b/proto/prost/private/tests/complex_imports/googleapis/google/api/http.proto deleted file mode 100644 index 113fa936a0..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/api/http.proto +++ /dev/null @@ -1,375 +0,0 @@ -// Copyright 2015 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 cc_enable_arenas = true; -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 | gRPC -// -----|----- -// `GET /v1/messages/123456` | `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 | gRPC -// -----|----- -// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | -// `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 | gRPC -// -----|----- -// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `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 | gRPC -// -----|----- -// `PATCH /v1/messages/123456 { "text": "Hi!" }` | `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 | gRPC -// -----|----- -// `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` -// `GET /v1/users/me/messages/123456` | `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. -// -// Example: -// -// http: -// rules: -// # Selects a gRPC method and applies HttpRule to it. -// - 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/proto/prost/private/tests/complex_imports/googleapis/google/bytestream/BUILD.bazel b/proto/prost/private/tests/complex_imports/googleapis/google/bytestream/BUILD.bazel deleted file mode 100644 index 1188906701..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/bytestream/BUILD.bazel +++ /dev/null @@ -1,23 +0,0 @@ -load("@rules_proto//proto:defs.bzl", "proto_library") -load("//proto:defs.bzl", "rust_tonic_library") -load("//rust:defs.bzl", "rust_test") - -proto_library( - name = "bytestream_proto", - srcs = ["bytestream.proto"], - visibility = ["//visibility:public"], -) - -rust_tonic_library( - name = "bytestream_rs_proto", - proto = ":bytestream_proto", -) - -rust_test( - name = "bytestream_test", - srcs = ["bytestream_test.rs"], - edition = "2021", - deps = [ - ":bytestream_rs_proto", - ], -) diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/bytestream/bytestream.proto b/proto/prost/private/tests/complex_imports/googleapis/google/bytestream/bytestream.proto deleted file mode 100644 index 2974601b76..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/bytestream/bytestream.proto +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright 2016 Google Inc. -// -// 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.bytestream; - -option go_package = "google.golang.org/genproto/googleapis/bytestream;bytestream"; -option java_outer_classname = "ByteStreamProto"; -option java_package = "com.google.bytestream"; - -// #### Introduction -// -// The Byte Stream API enables a client to read and write a stream of bytes to -// and from a resource. Resources have names, and these names are supplied in -// the API calls below to identify the resource that is being read from or -// written to. -// -// All implementations of the Byte Stream API export the interface defined here: -// -// * `Read()`: Reads the contents of a resource. -// -// * `Write()`: Writes the contents of a resource. The client can call `Write()` -// multiple times with the same resource and can check the status of the write -// by calling `QueryWriteStatus()`. -// -// #### Service parameters and metadata -// -// The ByteStream API provides no direct way to access/modify any metadata -// associated with the resource. -// -// #### Errors -// -// The errors returned by the service are in the Google canonical error space. -service ByteStream { - // `Read()` is used to retrieve the contents of a resource as a sequence - // of bytes. The bytes are returned in a sequence of responses, and the - // responses are delivered as the results of a server-side streaming RPC. - rpc Read(ReadRequest) returns (stream ReadResponse); - - // `Write()` is used to send the contents of a resource as a sequence of - // bytes. The bytes are sent in a sequence of request protos of a client-side - // streaming RPC. - // - // A `Write()` action is resumable. If there is an error or the connection is - // broken during the `Write()`, the client should check the status of the - // `Write()` by calling `QueryWriteStatus()` and continue writing from the - // returned `committed_size`. This may be less than the amount of data the - // client previously sent. - // - // Calling `Write()` on a resource name that was previously written and - // finalized could cause an error, depending on whether the underlying service - // allows over-writing of previously written resources. - // - // When the client closes the request channel, the service will respond with - // a `WriteResponse`. The service will not view the resource as `complete` - // until the client has sent a `WriteRequest` with `finish_write` set to - // `true`. Sending any requests on a stream after sending a request with - // `finish_write` set to `true` will cause an error. The client **should** - // check the `WriteResponse` it receives to determine how much data the - // service was able to commit and whether the service views the resource as - // `complete` or not. - rpc Write(stream WriteRequest) returns (WriteResponse); - - // `QueryWriteStatus()` is used to find the `committed_size` for a resource - // that is being written, which can then be used as the `write_offset` for - // the next `Write()` call. - // - // If the resource does not exist (i.e., the resource has been deleted, or the - // first `Write()` has not yet reached the service), this method returns the - // error `NOT_FOUND`. - // - // The client **may** call `QueryWriteStatus()` at any time to determine how - // much data has been processed for this resource. This is useful if the - // client is buffering data and needs to know which data can be safely - // evicted. For any sequence of `QueryWriteStatus()` calls for a given - // resource name, the sequence of returned `committed_size` values will be - // non-decreasing. - rpc QueryWriteStatus(QueryWriteStatusRequest) - returns (QueryWriteStatusResponse); -} - -// Request object for ByteStream.Read. -message ReadRequest { - // The name of the resource to read. - string resource_name = 1; - - // The offset for the first byte to return in the read, relative to the start - // of the resource. - // - // A `read_offset` that is negative or greater than the size of the resource - // will cause an `OUT_OF_RANGE` error. - int64 read_offset = 2; - - // The maximum number of `data` bytes the server is allowed to return in the - // sum of all `ReadResponse` messages. A `read_limit` of zero indicates that - // there is no limit, and a negative `read_limit` will cause an error. - // - // If the stream returns fewer bytes than allowed by the `read_limit` and no - // error occurred, the stream includes all data from the `read_offset` to the - // end of the resource. - int64 read_limit = 3; -} - -// Response object for ByteStream.Read. -message ReadResponse { - // A portion of the data for the resource. The service **may** leave `data` - // empty for any given `ReadResponse`. This enables the service to inform the - // client that the request is still live while it is running an operation to - // generate more data. - bytes data = 10; -} - -// Request object for ByteStream.Write. -message WriteRequest { - // The name of the resource to write. This **must** be set on the first - // `WriteRequest` of each `Write()` action. If it is set on subsequent calls, - // it **must** match the value of the first request. - string resource_name = 1; - - // The offset from the beginning of the resource at which the data should be - // written. It is required on all `WriteRequest`s. - // - // In the first `WriteRequest` of a `Write()` action, it indicates - // the initial offset for the `Write()` call. The value **must** be equal to - // the `committed_size` that a call to `QueryWriteStatus()` would return. - // - // On subsequent calls, this value **must** be set and **must** be equal to - // the sum of the first `write_offset` and the sizes of all `data` bundles - // sent previously on this stream. - // - // An incorrect value will cause an error. - int64 write_offset = 2; - - // If `true`, this indicates that the write is complete. Sending any - // `WriteRequest`s subsequent to one in which `finish_write` is `true` will - // cause an error. - bool finish_write = 3; - - // A portion of the data for the resource. The client **may** leave `data` - // empty for any given `WriteRequest`. This enables the client to inform the - // service that the request is still live while it is running an operation to - // generate more data. - bytes data = 10; -} - -// Response object for ByteStream.Write. -message WriteResponse { - // The number of bytes that have been processed for the given resource. - int64 committed_size = 1; -} - -// Request object for ByteStream.QueryWriteStatus. -message QueryWriteStatusRequest { - // The name of the resource whose write status is being requested. - string resource_name = 1; -} - -// Response object for ByteStream.QueryWriteStatus. -message QueryWriteStatusResponse { - // The number of bytes that have been processed for the given resource. - int64 committed_size = 1; - - // `complete` is `true` only if the client has sent a `WriteRequest` with - // `finish_write` set to true, and the server has processed that request. - bool complete = 2; -} diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/bytestream/bytestream_test.rs b/proto/prost/private/tests/complex_imports/googleapis/google/bytestream/bytestream_test.rs deleted file mode 100644 index 16e38fe976..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/bytestream/bytestream_test.rs +++ /dev/null @@ -1,15 +0,0 @@ -//! Tests the bytestream protos. - -use bytestream_proto::google::bytestream::WriteRequest; - -#[test] -fn test_bytestream() { - let write_request = WriteRequest { - resource_name: "resource_name".to_string(), - write_offset: 0, - finish_write: false, - data: vec![0, 1, 2, 3], - }; - - assert_eq!(write_request.resource_name, "resource_name") -} diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/longrunning/BUILD.bazel b/proto/prost/private/tests/complex_imports/googleapis/google/longrunning/BUILD.bazel deleted file mode 100644 index 25ffd4a221..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/longrunning/BUILD.bazel +++ /dev/null @@ -1,32 +0,0 @@ -load("@rules_proto//proto:defs.bzl", "proto_library") -load("//proto:defs.bzl", "rust_tonic_library") -load("//rust:defs.bzl", "rust_test") - -proto_library( - name = "longrunning_proto", - srcs = ["operations.proto"], - strip_import_prefix = "/proto/prost/private/tests/complex_imports/googleapis", - visibility = ["//visibility:public"], - deps = [ - "//proto/prost/private/tests/complex_imports/googleapis/google/api:annotations_proto", - "//proto/prost/private/tests/complex_imports/googleapis/google/rpc:status_proto", - "@com_google_protobuf//:any_proto", - "@com_google_protobuf//:descriptor_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:empty_proto", - ], -) - -rust_tonic_library( - name = "longrunning_rs_proto", - proto = ":longrunning_proto", -) - -rust_test( - name = "longrunning_test", - srcs = ["longrunning_test.rs"], - edition = "2021", - deps = [ - ":longrunning_rs_proto", - ], -) diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/longrunning/longrunning_test.rs b/proto/prost/private/tests/complex_imports/googleapis/google/longrunning/longrunning_test.rs deleted file mode 100644 index e3414a20e4..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/longrunning/longrunning_test.rs +++ /dev/null @@ -1,12 +0,0 @@ -//! Tests the longrunning protos. - -use longrunning_proto::google::longrunning::GetOperationRequest; - -#[test] -fn test_longrunning() { - let get_operation_request = GetOperationRequest { - name: "name".to_string(), - }; - - assert_eq!(get_operation_request.name, "name") -} diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/longrunning/operations.proto b/proto/prost/private/tests/complex_imports/googleapis/google/longrunning/operations.proto deleted file mode 100644 index c1fdc6f529..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/longrunning/operations.proto +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.longrunning; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/protobuf/any.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/empty.proto"; -import "google/rpc/status.proto"; -import "google/protobuf/descriptor.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "Google.LongRunning"; -option go_package = "google.golang.org/genproto/googleapis/longrunning;longrunning"; -option java_multiple_files = true; -option java_outer_classname = "OperationsProto"; -option java_package = "com.google.longrunning"; -option php_namespace = "Google\\LongRunning"; - -extend google.protobuf.MethodOptions { - // Additional information regarding long-running operations. - // In particular, this specifies the types that are returned from - // long-running operations. - // - // Required for methods that return `google.longrunning.Operation`; invalid - // otherwise. - google.longrunning.OperationInfo operation_info = 1049; -} - -// Manages long-running operations with an API service. -// -// When an API method normally takes long time to complete, it can be designed -// to return [Operation][google.longrunning.Operation] to the client, and the client can use this -// interface to receive the real response asynchronously by polling the -// operation resource, or pass the operation resource to another API (such as -// Google Cloud Pub/Sub API) to receive the response. Any API service that -// returns long-running operations should implement the `Operations` interface -// so developers can have a consistent client experience. -service Operations { - option (google.api.default_host) = "longrunning.googleapis.com"; - - // Lists operations that match the specified filter in the request. If the - // server doesn't support this method, it returns `UNIMPLEMENTED`. - // - // NOTE: the `name` binding allows API services to override the binding - // to use different resource name schemes, such as `users/*/operations`. To - // override the binding, API services can add a binding such as - // `"/v1/{name=users/*}/operations"` to their service configuration. - // For backwards compatibility, the default name includes the operations - // collection id, however overriding users must ensure the name binding - // is the parent resource, without the operations collection id. - rpc ListOperations(ListOperationsRequest) returns (ListOperationsResponse) { - option (google.api.http) = { - get: "/v1/{name=operations}" - }; - option (google.api.method_signature) = "name,filter"; - } - - // Gets the latest state of a long-running operation. Clients can use this - // method to poll the operation result at intervals as recommended by the API - // service. - rpc GetOperation(GetOperationRequest) returns (Operation) { - option (google.api.http) = { - get: "/v1/{name=operations/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Deletes a long-running operation. This method indicates that the client is - // no longer interested in the operation result. It does not cancel the - // operation. If the server doesn't support this method, it returns - // `google.rpc.Code.UNIMPLEMENTED`. - rpc DeleteOperation(DeleteOperationRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=operations/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Starts asynchronous cancellation on a long-running operation. The server - // makes a best effort to cancel the operation, but success is not - // guaranteed. If the server doesn't support this method, it returns - // `google.rpc.Code.UNIMPLEMENTED`. Clients can use - // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or - // other methods to check whether the cancellation succeeded or whether the - // operation completed despite cancellation. On successful cancellation, - // the operation is not deleted; instead, it becomes an operation with - // an [Operation.error][google.longrunning.Operation.error] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1, - // corresponding to `Code.CANCELLED`. - rpc CancelOperation(CancelOperationRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/{name=operations/**}:cancel" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Waits until the specified long-running operation is done or reaches at most - // a specified timeout, returning the latest state. If the operation is - // already done, the latest state is immediately returned. If the timeout - // specified is greater than the default HTTP/RPC timeout, the HTTP/RPC - // timeout is used. If the server does not support this method, it returns - // `google.rpc.Code.UNIMPLEMENTED`. - // Note that this method is on a best-effort basis. It may return the latest - // state before the specified timeout (including immediately), meaning even an - // immediate response is no guarantee that the operation is done. - rpc WaitOperation(WaitOperationRequest) returns (Operation) { - } -} - -// This resource represents a long-running operation that is the result of a -// network API call. -message Operation { - // The server-assigned name, which is only unique within the same service that - // originally returns it. If you use the default HTTP mapping, the - // `name` should be a resource name ending with `operations/{unique_id}`. - string name = 1; - - // Service-specific metadata associated with the operation. It typically - // contains progress information and common metadata such as create time. - // Some services might not provide such metadata. Any method that returns a - // long-running operation should document the metadata type, if any. - google.protobuf.Any metadata = 2; - - // If the value is `false`, it means the operation is still in progress. - // If `true`, the operation is completed, and either `error` or `response` is - // available. - bool done = 3; - - // The operation result, which can be either an `error` or a valid `response`. - // If `done` == `false`, neither `error` nor `response` is set. - // If `done` == `true`, exactly one of `error` or `response` is set. - oneof result { - // The error result of the operation in case of failure or cancellation. - google.rpc.Status error = 4; - - // The normal response of the operation in case of success. If the original - // method returns no data on success, such as `Delete`, the response is - // `google.protobuf.Empty`. If the original method is standard - // `Get`/`Create`/`Update`, the response should be the resource. For other - // methods, the response should have the type `XxxResponse`, where `Xxx` - // is the original method name. For example, if the original method name - // is `TakeSnapshot()`, the inferred response type is - // `TakeSnapshotResponse`. - google.protobuf.Any response = 5; - } -} - -// The request message for [Operations.GetOperation][google.longrunning.Operations.GetOperation]. -message GetOperationRequest { - // The name of the operation resource. - string name = 1; -} - -// The request message for [Operations.ListOperations][google.longrunning.Operations.ListOperations]. -message ListOperationsRequest { - // The name of the operation's parent resource. - string name = 4; - - // The standard list filter. - string filter = 1; - - // The standard list page size. - int32 page_size = 2; - - // The standard list page token. - string page_token = 3; -} - -// The response message for [Operations.ListOperations][google.longrunning.Operations.ListOperations]. -message ListOperationsResponse { - // A list of operations that matches the specified filter in the request. - repeated Operation operations = 1; - - // The standard List next-page token. - string next_page_token = 2; -} - -// The request message for [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]. -message CancelOperationRequest { - // The name of the operation resource to be cancelled. - string name = 1; -} - -// The request message for [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation]. -message DeleteOperationRequest { - // The name of the operation resource to be deleted. - string name = 1; -} - -// The request message for [Operations.WaitOperation][google.longrunning.Operations.WaitOperation]. -message WaitOperationRequest { - // The name of the operation resource to wait on. - string name = 1; - - // The maximum duration to wait before timing out. If left blank, the wait - // will be at most the time permitted by the underlying HTTP/RPC protocol. - // If RPC context deadline is also specified, the shorter one will be used. - google.protobuf.Duration timeout = 2; -} - -// A message representing the message types used by a long-running operation. -// -// Example: -// -// rpc LongRunningRecognize(LongRunningRecognizeRequest) -// returns (google.longrunning.Operation) { -// option (google.longrunning.operation_info) = { -// response_type: "LongRunningRecognizeResponse" -// metadata_type: "LongRunningRecognizeMetadata" -// }; -// } -message OperationInfo { - // Required. The message name of the primary return type for this - // long-running operation. - // This type will be used to deserialize the LRO's response. - // - // If the response is in a different package from the rpc, a fully-qualified - // message name must be used (e.g. `google.protobuf.Struct`). - // - // Note: Altering this value constitutes a breaking change. - string response_type = 1; - - // Required. The message name of the metadata type for this long-running - // operation. - // - // If the response is in a different package from the rpc, a fully-qualified - // message name must be used (e.g. `google.protobuf.Struct`). - // - // Note: Altering this value constitutes a breaking change. - string metadata_type = 2; -} diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/rpc/BUILD.bazel b/proto/prost/private/tests/complex_imports/googleapis/google/rpc/BUILD.bazel deleted file mode 100644 index 8f38b4d9a1..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/rpc/BUILD.bazel +++ /dev/null @@ -1,62 +0,0 @@ -load("@rules_proto//proto:defs.bzl", "proto_library") -load("//proto:defs.bzl", "rust_prost_library") -load("//rust:defs.bzl", "rust_test") - -proto_library( - name = "code_proto", - srcs = [ - "code.proto", - ], - strip_import_prefix = "/proto/prost/private/tests/complex_imports/googleapis", - visibility = ["//visibility:public"], -) - -proto_library( - name = "error_details_proto", - srcs = [ - "error_details.proto", - ], - strip_import_prefix = "/proto/prost/private/tests/complex_imports/googleapis", - visibility = ["//visibility:public"], - deps = [ - "@com_google_protobuf//:duration_proto", - ], -) - -proto_library( - name = "status_proto", - srcs = [ - "status.proto", - ], - strip_import_prefix = "/proto/prost/private/tests/complex_imports/googleapis", - visibility = ["//visibility:public"], - deps = [ - "@com_google_protobuf//:any_proto", - ], -) - -rust_prost_library( - name = "code_rs_proto", - proto = ":code_proto", -) - -rust_prost_library( - name = "error_details_rs_proto", - proto = ":error_details_proto", -) - -rust_prost_library( - name = "status_rs_proto", - proto = ":status_proto", -) - -rust_test( - name = "rpc_test", - srcs = ["rpc_test.rs"], - edition = "2021", - deps = [ - ":code_rs_proto", - ":error_details_rs_proto", - ":status_rs_proto", - ], -) diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/rpc/code.proto b/proto/prost/private/tests/complex_imports/googleapis/google/rpc/code.proto deleted file mode 100644 index 98ae0ac18f..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/rpc/code.proto +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.rpc; - -option go_package = "google.golang.org/genproto/googleapis/rpc/code;code"; -option java_multiple_files = true; -option java_outer_classname = "CodeProto"; -option java_package = "com.google.rpc"; -option objc_class_prefix = "RPC"; - -// The canonical error codes for gRPC APIs. -// -// -// Sometimes multiple error codes may apply. Services should return -// the most specific error code that applies. For example, prefer -// `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply. -// Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`. -enum Code { - // Not an error; returned on success - // - // HTTP Mapping: 200 OK - OK = 0; - - // The operation was cancelled, typically by the caller. - // - // HTTP Mapping: 499 Client Closed Request - CANCELLED = 1; - - // Unknown error. For example, this error may be returned when - // a `Status` value received from another address space belongs to - // an error space that is not known in this address space. Also - // errors raised by APIs that do not return enough error information - // may be converted to this error. - // - // HTTP Mapping: 500 Internal Server Error - UNKNOWN = 2; - - // The client specified an invalid argument. Note that this differs - // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments - // that are problematic regardless of the state of the system - // (e.g., a malformed file name). - // - // HTTP Mapping: 400 Bad Request - INVALID_ARGUMENT = 3; - - // The deadline expired before the operation could complete. For operations - // that change the state of the system, this error may be returned - // even if the operation has completed successfully. For example, a - // successful response from a server could have been delayed long - // enough for the deadline to expire. - // - // HTTP Mapping: 504 Gateway Timeout - DEADLINE_EXCEEDED = 4; - - // Some requested entity (e.g., file or directory) was not found. - // - // Note to server developers: if a request is denied for an entire class - // of users, such as gradual feature rollout or undocumented whitelist, - // `NOT_FOUND` may be used. If a request is denied for some users within - // a class of users, such as user-based access control, `PERMISSION_DENIED` - // must be used. - // - // HTTP Mapping: 404 Not Found - NOT_FOUND = 5; - - // The entity that a client attempted to create (e.g., file or directory) - // already exists. - // - // HTTP Mapping: 409 Conflict - ALREADY_EXISTS = 6; - - // The caller does not have permission to execute the specified - // operation. `PERMISSION_DENIED` must not be used for rejections - // caused by exhausting some resource (use `RESOURCE_EXHAUSTED` - // instead for those errors). `PERMISSION_DENIED` must not be - // used if the caller can not be identified (use `UNAUTHENTICATED` - // instead for those errors). This error code does not imply the - // request is valid or the requested entity exists or satisfies - // other pre-conditions. - // - // HTTP Mapping: 403 Forbidden - PERMISSION_DENIED = 7; - - // The request does not have valid authentication credentials for the - // operation. - // - // HTTP Mapping: 401 Unauthorized - UNAUTHENTICATED = 16; - - // Some resource has been exhausted, perhaps a per-user quota, or - // perhaps the entire file system is out of space. - // - // HTTP Mapping: 429 Too Many Requests - RESOURCE_EXHAUSTED = 8; - - // The operation was rejected because the system is not in a state - // required for the operation's execution. For example, the directory - // to be deleted is non-empty, an rmdir operation is applied to - // a non-directory, etc. - // - // Service implementors can use the following guidelines to decide - // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`: - // (a) Use `UNAVAILABLE` if the client can retry just the failing call. - // (b) Use `ABORTED` if the client should retry at a higher level - // (e.g., when a client-specified test-and-set fails, indicating the - // client should restart a read-modify-write sequence). - // (c) Use `FAILED_PRECONDITION` if the client should not retry until - // the system state has been explicitly fixed. E.g., if an "rmdir" - // fails because the directory is non-empty, `FAILED_PRECONDITION` - // should be returned since the client should not retry unless - // the files are deleted from the directory. - // - // HTTP Mapping: 400 Bad Request - FAILED_PRECONDITION = 9; - - // The operation was aborted, typically due to a concurrency issue such as - // a sequencer check failure or transaction abort. - // - // See the guidelines above for deciding between `FAILED_PRECONDITION`, - // `ABORTED`, and `UNAVAILABLE`. - // - // HTTP Mapping: 409 Conflict - ABORTED = 10; - - // The operation was attempted past the valid range. E.g., seeking or - // reading past end-of-file. - // - // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may - // be fixed if the system state changes. For example, a 32-bit file - // system will generate `INVALID_ARGUMENT` if asked to read at an - // offset that is not in the range [0,2^32-1], but it will generate - // `OUT_OF_RANGE` if asked to read from an offset past the current - // file size. - // - // There is a fair bit of overlap between `FAILED_PRECONDITION` and - // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific - // error) when it applies so that callers who are iterating through - // a space can easily look for an `OUT_OF_RANGE` error to detect when - // they are done. - // - // HTTP Mapping: 400 Bad Request - OUT_OF_RANGE = 11; - - // The operation is not implemented or is not supported/enabled in this - // service. - // - // HTTP Mapping: 501 Not Implemented - UNIMPLEMENTED = 12; - - // Internal errors. This means that some invariants expected by the - // underlying system have been broken. This error code is reserved - // for serious errors. - // - // HTTP Mapping: 500 Internal Server Error - INTERNAL = 13; - - // The service is currently unavailable. This is most likely a - // transient condition, which can be corrected by retrying with - // a backoff. Note that it is not always safe to retry - // non-idempotent operations. - // - // See the guidelines above for deciding between `FAILED_PRECONDITION`, - // `ABORTED`, and `UNAVAILABLE`. - // - // HTTP Mapping: 503 Service Unavailable - UNAVAILABLE = 14; - - // Unrecoverable data loss or corruption. - // - // HTTP Mapping: 500 Internal Server Error - DATA_LOSS = 15; -} diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/rpc/error_details.proto b/proto/prost/private/tests/complex_imports/googleapis/google/rpc/error_details.proto deleted file mode 100644 index c4d6c4b78c..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/rpc/error_details.proto +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.rpc; - -import "google/protobuf/duration.proto"; - -option go_package = "google.golang.org/genproto/googleapis/rpc/errdetails;errdetails"; -option java_multiple_files = true; -option java_outer_classname = "ErrorDetailsProto"; -option java_package = "com.google.rpc"; -option objc_class_prefix = "RPC"; - -// Describes when the clients can retry a failed request. Clients could ignore -// the recommendation here or retry when this information is missing from error -// responses. -// -// It's always recommended that clients should use exponential backoff when -// retrying. -// -// Clients should wait until `retry_delay` amount of time has passed since -// receiving the error response before retrying. If retrying requests also -// fail, clients should use an exponential backoff scheme to gradually increase -// the delay between retries based on `retry_delay`, until either a maximum -// number of retries have been reached or a maximum retry delay cap has been -// reached. -message RetryInfo { - // Clients should wait at least this long between retrying the same request. - google.protobuf.Duration retry_delay = 1; -} - -// Describes additional debugging info. -message DebugInfo { - // The stack trace entries indicating where the error occurred. - repeated string stack_entries = 1; - - // Additional debugging information provided by the server. - string detail = 2; -} - -// Describes how a quota check failed. -// -// For example if a daily limit was exceeded for the calling project, -// a service could respond with a QuotaFailure detail containing the project -// id and the description of the quota limit that was exceeded. If the -// calling project hasn't enabled the service in the developer console, then -// a service could respond with the project id and set `service_disabled` -// to true. -// -// Also see RetryInfo and Help types for other details about handling a -// quota failure. -message QuotaFailure { - // A message type used to describe a single quota violation. For example, a - // daily quota or a custom quota that was exceeded. - message Violation { - // The subject on which the quota check failed. - // For example, "clientip:" or "project:". - string subject = 1; - - // A description of how the quota check failed. Clients can use this - // description to find more about the quota configuration in the service's - // public documentation, or find the relevant quota limit to adjust through - // developer console. - // - // For example: "Service disabled" or "Daily Limit for read operations - // exceeded". - string description = 2; - } - - // Describes all quota violations. - repeated Violation violations = 1; -} - -// Describes the cause of the error with structured details. -// -// Example of an error when contacting the "pubsub.googleapis.com" API when it -// is not enabled: -// -// { "reason": "API_DISABLED" -// "domain": "googleapis.com" -// "metadata": { -// "resource": "projects/123", -// "service": "pubsub.googleapis.com" -// } -// } -// -// This response indicates that the pubsub.googleapis.com API is not enabled. -// -// Example of an error that is returned when attempting to create a Spanner -// instance in a region that is out of stock: -// -// { "reason": "STOCKOUT" -// "domain": "spanner.googleapis.com", -// "metadata": { -// "availableRegions": "us-central1,us-east2" -// } -// } -message ErrorInfo { - // The reason of the error. This is a constant value that identifies the - // proximate cause of the error. Error reasons are unique within a particular - // domain of errors. This should be at most 63 characters and match - // /[A-Z0-9_]+/. - string reason = 1; - - // The logical grouping to which the "reason" belongs. The error domain - // is typically the registered service name of the tool or product that - // generates the error. Example: "pubsub.googleapis.com". If the error is - // generated by some common infrastructure, the error domain must be a - // globally unique value that identifies the infrastructure. For Google API - // infrastructure, the error domain is "googleapis.com". - string domain = 2; - - // Additional structured details about this error. - // - // Keys should match /[a-zA-Z0-9-_]/ and be limited to 64 characters in - // length. When identifying the current value of an exceeded limit, the units - // should be contained in the key, not the value. For example, rather than - // {"instanceLimit": "100/request"}, should be returned as, - // {"instanceLimitPerRequest": "100"}, if the client exceeds the number of - // instances that can be created in a single (batch) request. - map metadata = 3; -} - -// Describes what preconditions have failed. -// -// For example, if an RPC failed because it required the Terms of Service to be -// acknowledged, it could list the terms of service violation in the -// PreconditionFailure message. -message PreconditionFailure { - // A message type used to describe a single precondition failure. - message Violation { - // The type of PreconditionFailure. We recommend using a service-specific - // enum type to define the supported precondition violation subjects. For - // example, "TOS" for "Terms of Service violation". - string type = 1; - - // The subject, relative to the type, that failed. - // For example, "google.com/cloud" relative to the "TOS" type would indicate - // which terms of service is being referenced. - string subject = 2; - - // A description of how the precondition failed. Developers can use this - // description to understand how to fix the failure. - // - // For example: "Terms of service not accepted". - string description = 3; - } - - // Describes all precondition violations. - repeated Violation violations = 1; -} - -// Describes violations in a client request. This error type focuses on the -// syntactic aspects of the request. -message BadRequest { - // A message type used to describe a single bad request field. - message FieldViolation { - // A path leading to a field in the request body. The value will be a - // sequence of dot-separated identifiers that identify a protocol buffer - // field. E.g., "field_violations.field" would identify this field. - string field = 1; - - // A description of why the request element is bad. - string description = 2; - } - - // Describes all violations in a client request. - repeated FieldViolation field_violations = 1; -} - -// Contains metadata about the request that clients can attach when filing a bug -// or providing other forms of feedback. -message RequestInfo { - // An opaque string that should only be interpreted by the service generating - // it. For example, it can be used to identify requests in the service's logs. - string request_id = 1; - - // Any data that was used to serve this request. For example, an encrypted - // stack trace that can be sent back to the service provider for debugging. - string serving_data = 2; -} - -// Describes the resource that is being accessed. -message ResourceInfo { - // A name for the type of resource being accessed, e.g. "sql table", - // "cloud storage bucket", "file", "Google calendar"; or the type URL - // of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic". - string resource_type = 1; - - // The name of the resource being accessed. For example, a shared calendar - // name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current - // error is [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED]. - string resource_name = 2; - - // The owner of the resource (optional). - // For example, "user:" or "project:". - string owner = 3; - - // Describes what error is encountered when accessing this resource. - // For example, updating a cloud project may require the `writer` permission - // on the developer console project. - string description = 4; -} - -// Provides links to documentation or for performing an out of band action. -// -// For example, if a quota check failed with an error indicating the calling -// project hasn't enabled the accessed service, this can contain a URL pointing -// directly to the right place in the developer console to flip the bit. -message Help { - // Describes a URL link. - message Link { - // Describes what the link offers. - string description = 1; - - // The URL of the link. - string url = 2; - } - - // URL(s) pointing to additional information on handling the current error. - repeated Link links = 1; -} - -// Provides a localized error message that is safe to return to the user -// which can be attached to an RPC error. -message LocalizedMessage { - // The locale used following the specification defined at - // http://www.rfc-editor.org/rfc/bcp/bcp47.txt. - // Examples are: "en-US", "fr-CH", "es-MX" - string locale = 1; - - // The localized error message in the above locale. - string message = 2; -} diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/rpc/rpc_test.rs b/proto/prost/private/tests/complex_imports/googleapis/google/rpc/rpc_test.rs deleted file mode 100644 index 21f1702cad..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/rpc/rpc_test.rs +++ /dev/null @@ -1,31 +0,0 @@ -//! Tests the rpc protos. - -use code_proto::google::rpc::Code; -use duration_proto::google::protobuf::Duration; -use error_details_proto::google::rpc::RetryInfo; -use status_proto::google::rpc::Status; - -#[test] -fn test_rpc() { - let retry_info = RetryInfo { - retry_delay: Some(Duration { - seconds: 1, - nanos: 2, - }), - }; - assert_eq!( - retry_info.retry_delay, - Some(Duration { - seconds: 1, - nanos: 2, - }) - ); - - let status = Status { - code: Code::Ok.into(), - message: "message".to_string(), - details: vec![], - }; - - assert_eq!(status.code, Code::Ok.into()); -} diff --git a/proto/prost/private/tests/complex_imports/googleapis/google/rpc/status.proto b/proto/prost/private/tests/complex_imports/googleapis/google/rpc/status.proto deleted file mode 100644 index 3b1f7a932f..0000000000 --- a/proto/prost/private/tests/complex_imports/googleapis/google/rpc/status.proto +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.rpc; - -import "google/protobuf/any.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/rpc/status;status"; -option java_multiple_files = true; -option java_outer_classname = "StatusProto"; -option java_package = "com.google.rpc"; -option objc_class_prefix = "RPC"; - -// The `Status` type defines a logical error model that is suitable for -// different programming environments, including REST APIs and RPC APIs. It is -// used by [gRPC](https://github.com/grpc). Each `Status` message contains -// three pieces of data: error code, error message, and error details. -// -// You can find out more about this error model and how to work with it in the -// [API Design Guide](https://cloud.google.com/apis/design/errors). -message Status { - // The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. - int32 code = 1; - - // A developer-facing error message, which should be in English. Any - // user-facing error message should be localized and sent in the - // [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client. - string message = 2; - - // A list of messages that carry the error details. There is a common set of - // message types for APIs to use. - repeated google.protobuf.Any details = 3; -} diff --git a/proto/prost/private/tests/complex_imports/remote-apis/build/bazel/remote/execution/v2/BUILD.bazel b/proto/prost/private/tests/complex_imports/remote-apis/build/bazel/remote/execution/v2/BUILD.bazel deleted file mode 100644 index 858efc3009..0000000000 --- a/proto/prost/private/tests/complex_imports/remote-apis/build/bazel/remote/execution/v2/BUILD.bazel +++ /dev/null @@ -1,36 +0,0 @@ -load("@rules_proto//proto:defs.bzl", "proto_library") -load("@rules_rust//proto/prost:defs.bzl", "rust_tonic_library") -load("@rules_rust//rust:defs.bzl", "rust_test") - -proto_library( - name = "remoteexecution_proto", - srcs = ["remote_execution.proto"], - strip_import_prefix = "/proto/prost/private/tests/complex_imports/remote-apis", - visibility = ["//visibility:public"], - deps = [ - "//proto/prost/private/tests/complex_imports/googleapis/google/api:annotations_proto", - "//proto/prost/private/tests/complex_imports/googleapis/google/longrunning:longrunning_proto", - "//proto/prost/private/tests/complex_imports/googleapis/google/rpc:status_proto", - "//proto/prost/private/tests/complex_imports/remote-apis/build/bazel/semver:semver_proto", - "@com_google_protobuf//:any_proto", - "@com_google_protobuf//:duration_proto", - "@com_google_protobuf//:empty_proto", - "@com_google_protobuf//:timestamp_proto", - "@com_google_protobuf//:wrappers_proto", - ], -) - -rust_tonic_library( - name = "remoteexecution_rs_proto", - proto = ":remoteexecution_proto", - visibility = ["//visibility:public"], -) - -rust_test( - name = "remoteexecution_test", - srcs = ["remoteexecution_test.rs"], - edition = "2021", - deps = [ - ":remoteexecution_rs_proto", - ], -) diff --git a/proto/prost/private/tests/complex_imports/remote-apis/build/bazel/remote/execution/v2/remote_execution.proto b/proto/prost/private/tests/complex_imports/remote-apis/build/bazel/remote/execution/v2/remote_execution.proto deleted file mode 100644 index 6f7cdde25a..0000000000 --- a/proto/prost/private/tests/complex_imports/remote-apis/build/bazel/remote/execution/v2/remote_execution.proto +++ /dev/null @@ -1,1795 +0,0 @@ -// Copyright 2018 The Bazel Authors. -// -// 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 build.bazel.remote.execution.v2; - -import "build/bazel/semver/semver.proto"; -import "google/api/annotations.proto"; -import "google/longrunning/operations.proto"; -import "google/protobuf/any.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; -import "google/rpc/status.proto"; - -option csharp_namespace = "Build.Bazel.Remote.Execution.V2"; -option go_package = "remoteexecution"; -option java_multiple_files = true; -option java_outer_classname = "RemoteExecutionProto"; -option java_package = "build.bazel.remote.execution.v2"; -option objc_class_prefix = "REX"; - - -// The Remote Execution API is used to execute an -// [Action][build.bazel.remote.execution.v2.Action] on the remote -// workers. -// -// As with other services in the Remote Execution API, any call may return an -// error with a [RetryInfo][google.rpc.RetryInfo] error detail providing -// information about when the client should retry the request; clients SHOULD -// respect the information provided. -service Execution { - // Execute an action remotely. - // - // In order to execute an action, the client must first upload all of the - // inputs, the - // [Command][build.bazel.remote.execution.v2.Command] to run, and the - // [Action][build.bazel.remote.execution.v2.Action] into the - // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. - // It then calls `Execute` with an `action_digest` referring to them. The - // server will run the action and eventually return the result. - // - // The input `Action`'s fields MUST meet the various canonicalization - // requirements specified in the documentation for their types so that it has - // the same digest as other logically equivalent `Action`s. The server MAY - // enforce the requirements and return errors if a non-canonical input is - // received. It MAY also proceed without verifying some or all of the - // requirements, such as for performance reasons. If the server does not - // verify the requirement, then it will treat the `Action` as distinct from - // another logically equivalent action if they hash differently. - // - // Returns a stream of - // [google.longrunning.Operation][google.longrunning.Operation] messages - // describing the resulting execution, with eventual `response` - // [ExecuteResponse][build.bazel.remote.execution.v2.ExecuteResponse]. The - // `metadata` on the operation is of type - // [ExecuteOperationMetadata][build.bazel.remote.execution.v2.ExecuteOperationMetadata]. - // - // If the client remains connected after the first response is returned after - // the server, then updates are streamed as if the client had called - // [WaitExecution][build.bazel.remote.execution.v2.Execution.WaitExecution] - // until the execution completes or the request reaches an error. The - // operation can also be queried using [Operations - // API][google.longrunning.Operations.GetOperation]. - // - // The server NEED NOT implement other methods or functionality of the - // Operations API. - // - // Errors discovered during creation of the `Operation` will be reported - // as gRPC Status errors, while errors that occurred while running the - // action will be reported in the `status` field of the `ExecuteResponse`. The - // server MUST NOT set the `error` field of the `Operation` proto. - // The possible errors include: - // - // * `INVALID_ARGUMENT`: One or more arguments are invalid. - // * `FAILED_PRECONDITION`: One or more errors occurred in setting up the - // action requested, such as a missing input or command or no worker being - // available. The client may be able to fix the errors and retry. - // * `RESOURCE_EXHAUSTED`: There is insufficient quota of some resource to run - // the action. - // * `UNAVAILABLE`: Due to a transient condition, such as all workers being - // occupied (and the server does not support a queue), the action could not - // be started. The client should retry. - // * `INTERNAL`: An internal error occurred in the execution engine or the - // worker. - // * `DEADLINE_EXCEEDED`: The execution timed out. - // * `CANCELLED`: The operation was cancelled by the client. This status is - // only possible if the server implements the Operations API CancelOperation - // method, and it was called for the current execution. - // - // In the case of a missing input or command, the server SHOULD additionally - // send a [PreconditionFailure][google.rpc.PreconditionFailure] error detail - // where, for each requested blob not present in the CAS, there is a - // `Violation` with a `type` of `MISSING` and a `subject` of - // `"blobs/{hash}/{size}"` indicating the digest of the missing blob. - // - // The server does not need to guarantee that a call to this method leads to - // at most one execution of the action. The server MAY execute the action - // multiple times, potentially in parallel. These redundant executions MAY - // continue to run, even if the operation is completed. - rpc Execute(ExecuteRequest) returns (stream google.longrunning.Operation) { - option (google.api.http) = { post: "/v2/{instance_name=**}/actions:execute" body: "*" }; - } - - // Wait for an execution operation to complete. When the client initially - // makes the request, the server immediately responds with the current status - // of the execution. The server will leave the request stream open until the - // operation completes, and then respond with the completed operation. The - // server MAY choose to stream additional updates as execution progresses, - // such as to provide an update as to the state of the execution. - rpc WaitExecution(WaitExecutionRequest) returns (stream google.longrunning.Operation) { - option (google.api.http) = { post: "/v2/{name=operations/**}:waitExecution" body: "*" }; - } -} - -// The action cache API is used to query whether a given action has already been -// performed and, if so, retrieve its result. Unlike the -// [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage], -// which addresses blobs by their own content, the action cache addresses the -// [ActionResult][build.bazel.remote.execution.v2.ActionResult] by a -// digest of the encoded [Action][build.bazel.remote.execution.v2.Action] -// which produced them. -// -// The lifetime of entries in the action cache is implementation-specific, but -// the server SHOULD assume that more recently used entries are more likely to -// be used again. -// -// As with other services in the Remote Execution API, any call may return an -// error with a [RetryInfo][google.rpc.RetryInfo] error detail providing -// information about when the client should retry the request; clients SHOULD -// respect the information provided. -service ActionCache { - // Retrieve a cached execution result. - // - // Implementations SHOULD ensure that any blobs referenced from the - // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage] - // are available at the time of returning the - // [ActionResult][build.bazel.remote.execution.v2.ActionResult] and will be - // for some period of time afterwards. The lifetimes of the referenced blobs SHOULD be increased - // if necessary and applicable. - // - // Errors: - // - // * `NOT_FOUND`: The requested `ActionResult` is not in the cache. - rpc GetActionResult(GetActionResultRequest) returns (ActionResult) { - option (google.api.http) = { get: "/v2/{instance_name=**}/actionResults/{action_digest.hash}/{action_digest.size_bytes}" }; - } - - // Upload a new execution result. - // - // In order to allow the server to perform access control based on the type of - // action, and to assist with client debugging, the client MUST first upload - // the [Action][build.bazel.remote.execution.v2.Execution] that produced the - // result, along with its - // [Command][build.bazel.remote.execution.v2.Command], into the - // `ContentAddressableStorage`. - // - // Server implementations MAY modify the - // `UpdateActionResultRequest.action_result` and return an equivalent value. - // - // Errors: - // - // * `INVALID_ARGUMENT`: One or more arguments are invalid. - // * `FAILED_PRECONDITION`: One or more errors occurred in updating the - // action result, such as a missing command or action. - // * `RESOURCE_EXHAUSTED`: There is insufficient storage space to add the - // entry to the cache. - rpc UpdateActionResult(UpdateActionResultRequest) returns (ActionResult) { - option (google.api.http) = { put: "/v2/{instance_name=**}/actionResults/{action_digest.hash}/{action_digest.size_bytes}" body: "action_result" }; - } -} - -// The CAS (content-addressable storage) is used to store the inputs to and -// outputs from the execution service. Each piece of content is addressed by the -// digest of its binary data. -// -// Most of the binary data stored in the CAS is opaque to the execution engine, -// and is only used as a communication medium. In order to build an -// [Action][build.bazel.remote.execution.v2.Action], -// however, the client will need to also upload the -// [Command][build.bazel.remote.execution.v2.Command] and input root -// [Directory][build.bazel.remote.execution.v2.Directory] for the Action. -// The Command and Directory messages must be marshalled to wire format and then -// uploaded under the hash as with any other piece of content. In practice, the -// input root directory is likely to refer to other Directories in its -// hierarchy, which must also each be uploaded on their own. -// -// For small file uploads the client should group them together and call -// [BatchUpdateBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchUpdateBlobs]. -// -// For large uploads, the client must use the -// [Write method][google.bytestream.ByteStream.Write] of the ByteStream API. -// -// For uncompressed data, The `WriteRequest.resource_name` is of the following form: -// `{instance_name}/uploads/{uuid}/blobs/{hash}/{size}{/optional_metadata}` -// -// Where: -// * `instance_name` is an identifier, possibly containing multiple path -// segments, used to distinguish between the various instances on the server, -// in a manner defined by the server. If it is the empty path, the leading -// slash is omitted, so that the `resource_name` becomes -// `uploads/{uuid}/blobs/{hash}/{size}{/optional_metadata}`. -// To simplify parsing, a path segment cannot equal any of the following -// keywords: `blobs`, `uploads`, `actions`, `actionResults`, `operations`, -// `capabilities` or `compressed-blobs`. -// * `uuid` is a version 4 UUID generated by the client, used to avoid -// collisions between concurrent uploads of the same data. Clients MAY -// reuse the same `uuid` for uploading different blobs. -// * `hash` and `size` refer to the [Digest][build.bazel.remote.execution.v2.Digest] -// of the data being uploaded. -// * `optional_metadata` is implementation specific data, which clients MAY omit. -// Servers MAY ignore this metadata. -// -// Data can alternatively be uploaded in compressed form, with the following -// `WriteRequest.resource_name` form: -// `{instance_name}/uploads/{uuid}/compressed-blobs/{compressor}/{uncompressed_hash}/{uncompressed_size}{/optional_metadata}` -// -// Where: -// * `instance_name`, `uuid` and `optional_metadata` are defined as above. -// * `compressor` is a lowercase string form of a `Compressor.Value` enum -// other than `identity`, which is supported by the server and advertised in -// [CacheCapabilities.supported_compressor][build.bazel.remote.execution.v2.CacheCapabilities.supported_compressor]. -// * `uncompressed_hash` and `uncompressed_size` refer to the -// [Digest][build.bazel.remote.execution.v2.Digest] of the data being -// uploaded, once uncompressed. Servers MUST verify that these match -// the uploaded data once uncompressed, and MUST return an -// `INVALID_ARGUMENT` error in the case of mismatch. -// -// Note that when writing compressed blobs, the `WriteRequest.write_offset` in -// the initial request in a stream refers to the offset in the uncompressed form -// of the blob. In subsequent requests, `WriteRequest.write_offset` MUST be the -// sum of the first request's 'WriteRequest.write_offset' and the total size of -// all the compressed data bundles in the previous requests. -// Note that this mixes an uncompressed offset with a compressed byte length, -// which is nonsensical, but it is done to fit the semantics of the existing -// ByteStream protocol. -// -// Uploads of the same data MAY occur concurrently in any form, compressed or -// uncompressed. -// -// Clients SHOULD NOT use gRPC-level compression for ByteStream API `Write` -// calls of compressed blobs, since this would compress already-compressed data. -// -// When attempting an upload, if another client has already completed the upload -// (which may occur in the middle of a single upload if another client uploads -// the same blob concurrently), the request will terminate immediately with -// a response whose `committed_size` is the full size of the uploaded file -// (regardless of how much data was transmitted by the client). If the client -// completes the upload but the -// [Digest][build.bazel.remote.execution.v2.Digest] does not match, an -// `INVALID_ARGUMENT` error will be returned. In either case, the client should -// not attempt to retry the upload. -// -// Small downloads can be grouped and requested in a batch via -// [BatchReadBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchReadBlobs]. -// -// For large downloads, the client must use the -// [Read method][google.bytestream.ByteStream.Read] of the ByteStream API. -// -// For uncompressed data, The `ReadRequest.resource_name` is of the following form: -// `{instance_name}/blobs/{hash}/{size}` -// Where `instance_name`, `hash` and `size` are defined as for uploads. -// -// Data can alternatively be downloaded in compressed form, with the following -// `ReadRequest.resource_name` form: -// `{instance_name}/compressed-blobs/{compressor}/{uncompressed_hash}/{uncompressed_size}` -// -// Where: -// * `instance_name` and `compressor` are defined as for uploads. -// * `uncompressed_hash` and `uncompressed_size` refer to the -// [Digest][build.bazel.remote.execution.v2.Digest] of the data being -// downloaded, once uncompressed. Clients MUST verify that these match -// the downloaded data once uncompressed, and take appropriate steps in -// the case of failure such as retrying a limited number of times or -// surfacing an error to the user. -// -// When downloading compressed blobs: -// * `ReadRequest.read_offset` refers to the offset in the uncompressed form -// of the blob. -// * Servers MUST return `INVALID_ARGUMENT` if `ReadRequest.read_limit` is -// non-zero. -// * Servers MAY use any compression level they choose, including different -// levels for different blobs (e.g. choosing a level designed for maximum -// speed for data known to be incompressible). -// * Clients SHOULD NOT use gRPC-level compression, since this would compress -// already-compressed data. -// -// Servers MUST be able to provide data for all recently advertised blobs in -// each of the compression formats that the server supports, as well as in -// uncompressed form. -// -// The lifetime of entries in the CAS is implementation specific, but it SHOULD -// be long enough to allow for newly-added and recently looked-up entries to be -// used in subsequent calls (e.g. to -// [Execute][build.bazel.remote.execution.v2.Execution.Execute]). -// -// Servers MUST behave as though empty blobs are always available, even if they -// have not been uploaded. Clients MAY optimize away the uploading or -// downloading of empty blobs. -// -// As with other services in the Remote Execution API, any call may return an -// error with a [RetryInfo][google.rpc.RetryInfo] error detail providing -// information about when the client should retry the request; clients SHOULD -// respect the information provided. -service ContentAddressableStorage { - // Determine if blobs are present in the CAS. - // - // Clients can use this API before uploading blobs to determine which ones are - // already present in the CAS and do not need to be uploaded again. - // - // Servers SHOULD increase the lifetimes of the referenced blobs if necessary and - // applicable. - // - // There are no method-specific errors. - rpc FindMissingBlobs(FindMissingBlobsRequest) returns (FindMissingBlobsResponse) { - option (google.api.http) = { post: "/v2/{instance_name=**}/blobs:findMissing" body: "*" }; - } - - // Upload many blobs at once. - // - // The server may enforce a limit of the combined total size of blobs - // to be uploaded using this API. This limit may be obtained using the - // [Capabilities][build.bazel.remote.execution.v2.Capabilities] API. - // Requests exceeding the limit should either be split into smaller - // chunks or uploaded using the - // [ByteStream API][google.bytestream.ByteStream], as appropriate. - // - // This request is equivalent to calling a Bytestream `Write` request - // on each individual blob, in parallel. The requests may succeed or fail - // independently. - // - // Errors: - // - // * `INVALID_ARGUMENT`: The client attempted to upload more than the - // server supported limit. - // - // Individual requests may return the following errors, additionally: - // - // * `RESOURCE_EXHAUSTED`: There is insufficient disk quota to store the blob. - // * `INVALID_ARGUMENT`: The - // [Digest][build.bazel.remote.execution.v2.Digest] does not match the - // provided data. - rpc BatchUpdateBlobs(BatchUpdateBlobsRequest) returns (BatchUpdateBlobsResponse) { - option (google.api.http) = { post: "/v2/{instance_name=**}/blobs:batchUpdate" body: "*" }; - } - - // Download many blobs at once. - // - // The server may enforce a limit of the combined total size of blobs - // to be downloaded using this API. This limit may be obtained using the - // [Capabilities][build.bazel.remote.execution.v2.Capabilities] API. - // Requests exceeding the limit should either be split into smaller - // chunks or downloaded using the - // [ByteStream API][google.bytestream.ByteStream], as appropriate. - // - // This request is equivalent to calling a Bytestream `Read` request - // on each individual blob, in parallel. The requests may succeed or fail - // independently. - // - // Errors: - // - // * `INVALID_ARGUMENT`: The client attempted to read more than the - // server supported limit. - // - // Every error on individual read will be returned in the corresponding digest - // status. - rpc BatchReadBlobs(BatchReadBlobsRequest) returns (BatchReadBlobsResponse) { - option (google.api.http) = { post: "/v2/{instance_name=**}/blobs:batchRead" body: "*" }; - } - - // Fetch the entire directory tree rooted at a node. - // - // This request must be targeted at a - // [Directory][build.bazel.remote.execution.v2.Directory] stored in the - // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage] - // (CAS). The server will enumerate the `Directory` tree recursively and - // return every node descended from the root. - // - // The GetTreeRequest.page_token parameter can be used to skip ahead in - // the stream (e.g. when retrying a partially completed and aborted request), - // by setting it to a value taken from GetTreeResponse.next_page_token of the - // last successfully processed GetTreeResponse). - // - // The exact traversal order is unspecified and, unless retrieving subsequent - // pages from an earlier request, is not guaranteed to be stable across - // multiple invocations of `GetTree`. - // - // If part of the tree is missing from the CAS, the server will return the - // portion present and omit the rest. - // - // Errors: - // - // * `NOT_FOUND`: The requested tree root is not present in the CAS. - rpc GetTree(GetTreeRequest) returns (stream GetTreeResponse) { - option (google.api.http) = { get: "/v2/{instance_name=**}/blobs/{root_digest.hash}/{root_digest.size_bytes}:getTree" }; - } -} - -// The Capabilities service may be used by remote execution clients to query -// various server properties, in order to self-configure or return meaningful -// error messages. -// -// The query may include a particular `instance_name`, in which case the values -// returned will pertain to that instance. -service Capabilities { - // GetCapabilities returns the server capabilities configuration of the - // remote endpoint. - // Only the capabilities of the services supported by the endpoint will - // be returned: - // * Execution + CAS + Action Cache endpoints should return both - // CacheCapabilities and ExecutionCapabilities. - // * Execution only endpoints should return ExecutionCapabilities. - // * CAS + Action Cache only endpoints should return CacheCapabilities. - rpc GetCapabilities(GetCapabilitiesRequest) returns (ServerCapabilities) { - option (google.api.http) = { - get: "/v2/{instance_name=**}/capabilities" - }; - } -} - -// An `Action` captures all the information about an execution which is required -// to reproduce it. -// -// `Action`s are the core component of the [Execution] service. A single -// `Action` represents a repeatable action that can be performed by the -// execution service. `Action`s can be succinctly identified by the digest of -// their wire format encoding and, once an `Action` has been executed, will be -// cached in the action cache. Future requests can then use the cached result -// rather than needing to run afresh. -// -// When a server completes execution of an -// [Action][build.bazel.remote.execution.v2.Action], it MAY choose to -// cache the [result][build.bazel.remote.execution.v2.ActionResult] in -// the [ActionCache][build.bazel.remote.execution.v2.ActionCache] unless -// `do_not_cache` is `true`. Clients SHOULD expect the server to do so. By -// default, future calls to -// [Execute][build.bazel.remote.execution.v2.Execution.Execute] the same -// `Action` will also serve their results from the cache. Clients must take care -// to understand the caching behaviour. Ideally, all `Action`s will be -// reproducible so that serving a result from cache is always desirable and -// correct. -message Action { - // The digest of the [Command][build.bazel.remote.execution.v2.Command] - // to run, which MUST be present in the - // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. - Digest command_digest = 1; - - // The digest of the root - // [Directory][build.bazel.remote.execution.v2.Directory] for the input - // files. The files in the directory tree are available in the correct - // location on the build machine before the command is executed. The root - // directory, as well as every subdirectory and content blob referred to, MUST - // be in the - // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. - Digest input_root_digest = 2; - - reserved 3 to 5; // Used for fields moved to [Command][build.bazel.remote.execution.v2.Command]. - - // A timeout after which the execution should be killed. If the timeout is - // absent, then the client is specifying that the execution should continue - // as long as the server will let it. The server SHOULD impose a timeout if - // the client does not specify one, however, if the client does specify a - // timeout that is longer than the server's maximum timeout, the server MUST - // reject the request. - // - // The timeout is a part of the - // [Action][build.bazel.remote.execution.v2.Action] message, and - // therefore two `Actions` with different timeouts are different, even if they - // are otherwise identical. This is because, if they were not, running an - // `Action` with a lower timeout than is required might result in a cache hit - // from an execution run with a longer timeout, hiding the fact that the - // timeout is too short. By encoding it directly in the `Action`, a lower - // timeout will result in a cache miss and the execution timeout will fail - // immediately, rather than whenever the cache entry gets evicted. - google.protobuf.Duration timeout = 6; - - // If true, then the `Action`'s result cannot be cached, and in-flight - // requests for the same `Action` may not be merged. - bool do_not_cache = 7; - - reserved 8; // Used for field moved to [Command][build.bazel.remote.execution.v2.Command]. - - // An optional additional salt value used to place this `Action` into a - // separate cache namespace from other instances having the same field - // contents. This salt typically comes from operational configuration - // specific to sources such as repo and service configuration, - // and allows disowning an entire set of ActionResults that might have been - // poisoned by buggy software or tool failures. - bytes salt = 9; - - // The optional platform requirements for the execution environment. The - // server MAY choose to execute the action on any worker satisfying the - // requirements, so the client SHOULD ensure that running the action on any - // such worker will have the same result. A detailed lexicon for this can be - // found in the accompanying platform.md. - // New in version 2.2: clients SHOULD set these platform properties as well - // as those in the [Command][build.bazel.remote.execution.v2.Command]. Servers - // SHOULD prefer those set here. - Platform platform = 10; -} - -// A `Command` is the actual command executed by a worker running an -// [Action][build.bazel.remote.execution.v2.Action] and specifications of its -// environment. -// -// Except as otherwise required, the environment (such as which system -// libraries or binaries are available, and what filesystems are mounted where) -// is defined by and specific to the implementation of the remote execution API. -message Command { - // An `EnvironmentVariable` is one variable to set in the running program's - // environment. - message EnvironmentVariable { - // The variable name. - string name = 1; - - // The variable value. - string value = 2; - } - - // The arguments to the command. The first argument must be the path to the - // executable, which must be either a relative path, in which case it is - // evaluated with respect to the input root, or an absolute path. - repeated string arguments = 1; - - // The environment variables to set when running the program. The worker may - // provide its own default environment variables; these defaults can be - // overridden using this field. Additional variables can also be specified. - // - // In order to ensure that equivalent - // [Command][build.bazel.remote.execution.v2.Command]s always hash to the same - // value, the environment variables MUST be lexicographically sorted by name. - // Sorting of strings is done by code point, equivalently, by the UTF-8 bytes. - repeated EnvironmentVariable environment_variables = 2; - - // A list of the output files that the client expects to retrieve from the - // action. Only the listed files, as well as directories listed in - // `output_directories`, will be returned to the client as output. - // Other files or directories that may be created during command execution - // are discarded. - // - // The paths are relative to the working directory of the action execution. - // The paths are specified using a single forward slash (`/`) as a path - // separator, even if the execution platform natively uses a different - // separator. The path MUST NOT include a trailing slash, nor a leading slash, - // being a relative path. - // - // In order to ensure consistent hashing of the same Action, the output paths - // MUST be sorted lexicographically by code point (or, equivalently, by UTF-8 - // bytes). - // - // An output file cannot be duplicated, be a parent of another output file, or - // have the same path as any of the listed output directories. - // - // Directories leading up to the output files are created by the worker prior - // to execution, even if they are not explicitly part of the input root. - // - // DEPRECATED since v2.1: Use `output_paths` instead. - repeated string output_files = 3; - - // A list of the output directories that the client expects to retrieve from - // the action. Only the listed directories will be returned (an entire - // directory structure will be returned as a - // [Tree][build.bazel.remote.execution.v2.Tree] message digest, see - // [OutputDirectory][build.bazel.remote.execution.v2.OutputDirectory]), as - // well as files listed in `output_files`. Other files or directories that - // may be created during command execution are discarded. - // - // The paths are relative to the working directory of the action execution. - // The paths are specified using a single forward slash (`/`) as a path - // separator, even if the execution platform natively uses a different - // separator. The path MUST NOT include a trailing slash, nor a leading slash, - // being a relative path. The special value of empty string is allowed, - // although not recommended, and can be used to capture the entire working - // directory tree, including inputs. - // - // In order to ensure consistent hashing of the same Action, the output paths - // MUST be sorted lexicographically by code point (or, equivalently, by UTF-8 - // bytes). - // - // An output directory cannot be duplicated or have the same path as any of - // the listed output files. An output directory is allowed to be a parent of - // another output directory. - // - // Directories leading up to the output directories (but not the output - // directories themselves) are created by the worker prior to execution, even - // if they are not explicitly part of the input root. - // - // DEPRECATED since 2.1: Use `output_paths` instead. - repeated string output_directories = 4; - - // A list of the output paths that the client expects to retrieve from the - // action. Only the listed paths will be returned to the client as output. - // The type of the output (file or directory) is not specified, and will be - // determined by the server after action execution. If the resulting path is - // a file, it will be returned in an - // [OutputFile][build.bazel.remote.execution.v2.OutputFile]) typed field. - // If the path is a directory, the entire directory structure will be returned - // as a [Tree][build.bazel.remote.execution.v2.Tree] message digest, see - // [OutputDirectory][build.bazel.remote.execution.v2.OutputDirectory]) - // Other files or directories that may be created during command execution - // are discarded. - // - // The paths are relative to the working directory of the action execution. - // The paths are specified using a single forward slash (`/`) as a path - // separator, even if the execution platform natively uses a different - // separator. The path MUST NOT include a trailing slash, nor a leading slash, - // being a relative path. - // - // In order to ensure consistent hashing of the same Action, the output paths - // MUST be deduplicated and sorted lexicographically by code point (or, - // equivalently, by UTF-8 bytes). - // - // Directories leading up to the output paths are created by the worker prior - // to execution, even if they are not explicitly part of the input root. - // - // New in v2.1: this field supersedes the DEPRECATED `output_files` and - // `output_directories` fields. If `output_paths` is used, `output_files` and - // `output_directories` will be ignored! - repeated string output_paths = 7; - - // The platform requirements for the execution environment. The server MAY - // choose to execute the action on any worker satisfying the requirements, so - // the client SHOULD ensure that running the action on any such worker will - // have the same result. A detailed lexicon for this can be found in the - // accompanying platform.md. - // DEPRECATED as of v2.2: platform properties are now specified directly in - // the action. See documentation note in the - // [Action][build.bazel.remote.execution.v2.Action] for migration. - Platform platform = 5; - - // The working directory, relative to the input root, for the command to run - // in. It must be a directory which exists in the input tree. If it is left - // empty, then the action is run in the input root. - string working_directory = 6; - - // A list of keys for node properties the client expects to retrieve for - // output files and directories. Keys are either names of string-based - // [NodeProperty][build.bazel.remote.execution.v2.NodeProperty] or - // names of fields in [NodeProperties][build.bazel.remote.execution.v2.NodeProperties]. - // In order to ensure that equivalent `Action`s always hash to the same - // value, the node properties MUST be lexicographically sorted by name. - // Sorting of strings is done by code point, equivalently, by the UTF-8 bytes. - // - // The interpretation of string-based properties is server-dependent. If a - // property is not recognized by the server, the server will return an - // `INVALID_ARGUMENT`. - repeated string output_node_properties = 8; -} - -// A `Platform` is a set of requirements, such as hardware, operating system, or -// compiler toolchain, for an -// [Action][build.bazel.remote.execution.v2.Action]'s execution -// environment. A `Platform` is represented as a series of key-value pairs -// representing the properties that are required of the platform. -message Platform { - // A single property for the environment. The server is responsible for - // specifying the property `name`s that it accepts. If an unknown `name` is - // provided in the requirements for an - // [Action][build.bazel.remote.execution.v2.Action], the server SHOULD - // reject the execution request. If permitted by the server, the same `name` - // may occur multiple times. - // - // The server is also responsible for specifying the interpretation of - // property `value`s. For instance, a property describing how much RAM must be - // available may be interpreted as allowing a worker with 16GB to fulfill a - // request for 8GB, while a property describing the OS environment on which - // the action must be performed may require an exact match with the worker's - // OS. - // - // The server MAY use the `value` of one or more properties to determine how - // it sets up the execution environment, such as by making specific system - // files available to the worker. - // - // Both names and values are typically case-sensitive. Note that the platform - // is implicitly part of the action digest, so even tiny changes in the names - // or values (like changing case) may result in different action cache - // entries. - message Property { - // The property name. - string name = 1; - - // The property value. - string value = 2; - } - - // The properties that make up this platform. In order to ensure that - // equivalent `Platform`s always hash to the same value, the properties MUST - // be lexicographically sorted by name, and then by value. Sorting of strings - // is done by code point, equivalently, by the UTF-8 bytes. - repeated Property properties = 1; -} - -// A `Directory` represents a directory node in a file tree, containing zero or -// more children [FileNodes][build.bazel.remote.execution.v2.FileNode], -// [DirectoryNodes][build.bazel.remote.execution.v2.DirectoryNode] and -// [SymlinkNodes][build.bazel.remote.execution.v2.SymlinkNode]. -// Each `Node` contains its name in the directory, either the digest of its -// content (either a file blob or a `Directory` proto) or a symlink target, as -// well as possibly some metadata about the file or directory. -// -// In order to ensure that two equivalent directory trees hash to the same -// value, the following restrictions MUST be obeyed when constructing a -// a `Directory`: -// -// * Every child in the directory must have a path of exactly one segment. -// Multiple levels of directory hierarchy may not be collapsed. -// * Each child in the directory must have a unique path segment (file name). -// Note that while the API itself is case-sensitive, the environment where -// the Action is executed may or may not be case-sensitive. That is, it is -// legal to call the API with a Directory that has both "Foo" and "foo" as -// children, but the Action may be rejected by the remote system upon -// execution. -// * The files, directories and symlinks in the directory must each be sorted -// in lexicographical order by path. The path strings must be sorted by code -// point, equivalently, by UTF-8 bytes. -// * The [NodeProperties][build.bazel.remote.execution.v2.NodeProperty] of files, -// directories, and symlinks must be sorted in lexicographical order by -// property name. -// -// A `Directory` that obeys the restrictions is said to be in canonical form. -// -// As an example, the following could be used for a file named `bar` and a -// directory named `foo` with an executable file named `baz` (hashes shortened -// for readability): -// -// ```json -// // (Directory proto) -// { -// files: [ -// { -// name: "bar", -// digest: { -// hash: "4a73bc9d03...", -// size: 65534 -// }, -// node_properties: [ -// { -// "name": "MTime", -// "value": "2017-01-15T01:30:15.01Z" -// } -// ] -// } -// ], -// directories: [ -// { -// name: "foo", -// digest: { -// hash: "4cf2eda940...", -// size: 43 -// } -// } -// ] -// } -// -// // (Directory proto with hash "4cf2eda940..." and size 43) -// { -// files: [ -// { -// name: "baz", -// digest: { -// hash: "b2c941073e...", -// size: 1294, -// }, -// is_executable: true -// } -// ] -// } -// ``` -message Directory { - // The files in the directory. - repeated FileNode files = 1; - - // The subdirectories in the directory. - repeated DirectoryNode directories = 2; - - // The symlinks in the directory. - repeated SymlinkNode symlinks = 3; - - // The node properties of the Directory. - reserved 4; - NodeProperties node_properties = 5; -} - -// A single property for [FileNodes][build.bazel.remote.execution.v2.FileNode], -// [DirectoryNodes][build.bazel.remote.execution.v2.DirectoryNode], and -// [SymlinkNodes][build.bazel.remote.execution.v2.SymlinkNode]. The server is -// responsible for specifying the property `name`s that it accepts. If -// permitted by the server, the same `name` may occur multiple times. -message NodeProperty { - // The property name. - string name = 1; - - // The property value. - string value = 2; -} - -// Node properties for [FileNodes][build.bazel.remote.execution.v2.FileNode], -// [DirectoryNodes][build.bazel.remote.execution.v2.DirectoryNode], and -// [SymlinkNodes][build.bazel.remote.execution.v2.SymlinkNode]. The server is -// responsible for specifying the properties that it accepts. -// -message NodeProperties { - // A list of string-based - // [NodeProperties][build.bazel.remote.execution.v2.NodeProperty]. - repeated NodeProperty properties = 1; - - // The file's last modification timestamp. - google.protobuf.Timestamp mtime = 2; - - // The UNIX file mode, e.g., 0755. - google.protobuf.UInt32Value unix_mode = 3; -} - -// A `FileNode` represents a single file and associated metadata. -message FileNode { - // The name of the file. - string name = 1; - - // The digest of the file's content. - Digest digest = 2; - - reserved 3; // Reserved to ensure wire-compatibility with `OutputFile`. - - // True if file is executable, false otherwise. - bool is_executable = 4; - - // The node properties of the FileNode. - reserved 5; - NodeProperties node_properties = 6; -} - -// A `DirectoryNode` represents a child of a -// [Directory][build.bazel.remote.execution.v2.Directory] which is itself -// a `Directory` and its associated metadata. -message DirectoryNode { - // The name of the directory. - string name = 1; - - // The digest of the - // [Directory][build.bazel.remote.execution.v2.Directory] object - // represented. See [Digest][build.bazel.remote.execution.v2.Digest] - // for information about how to take the digest of a proto message. - Digest digest = 2; -} - -// A `SymlinkNode` represents a symbolic link. -message SymlinkNode { - // The name of the symlink. - string name = 1; - - // The target path of the symlink. The path separator is a forward slash `/`. - // The target path can be relative to the parent directory of the symlink or - // it can be an absolute path starting with `/`. Support for absolute paths - // can be checked using the [Capabilities][build.bazel.remote.execution.v2.Capabilities] - // API. `..` components are allowed anywhere in the target path as logical - // canonicalization may lead to different behavior in the presence of - // directory symlinks (e.g. `foo/../bar` may not be the same as `bar`). - // To reduce potential cache misses, canonicalization is still recommended - // where this is possible without impacting correctness. - string target = 2; - - // The node properties of the SymlinkNode. - reserved 3; - NodeProperties node_properties = 4; -} - -// A content digest. A digest for a given blob consists of the size of the blob -// and its hash. The hash algorithm to use is defined by the server. -// -// The size is considered to be an integral part of the digest and cannot be -// separated. That is, even if the `hash` field is correctly specified but -// `size_bytes` is not, the server MUST reject the request. -// -// The reason for including the size in the digest is as follows: in a great -// many cases, the server needs to know the size of the blob it is about to work -// with prior to starting an operation with it, such as flattening Merkle tree -// structures or streaming it to a worker. Technically, the server could -// implement a separate metadata store, but this results in a significantly more -// complicated implementation as opposed to having the client specify the size -// up-front (or storing the size along with the digest in every message where -// digests are embedded). This does mean that the API leaks some implementation -// details of (what we consider to be) a reasonable server implementation, but -// we consider this to be a worthwhile tradeoff. -// -// When a `Digest` is used to refer to a proto message, it always refers to the -// message in binary encoded form. To ensure consistent hashing, clients and -// servers MUST ensure that they serialize messages according to the following -// rules, even if there are alternate valid encodings for the same message: -// -// * Fields are serialized in tag order. -// * There are no unknown fields. -// * There are no duplicate fields. -// * Fields are serialized according to the default semantics for their type. -// -// Most protocol buffer implementations will always follow these rules when -// serializing, but care should be taken to avoid shortcuts. For instance, -// concatenating two messages to merge them may produce duplicate fields. -message Digest { - // The hash. In the case of SHA-256, it will always be a lowercase hex string - // exactly 64 characters long. - string hash = 1; - - // The size of the blob, in bytes. - int64 size_bytes = 2; -} - -// ExecutedActionMetadata contains details about a completed execution. -message ExecutedActionMetadata { - // The name of the worker which ran the execution. - string worker = 1; - - // When was the action added to the queue. - google.protobuf.Timestamp queued_timestamp = 2; - - // When the worker received the action. - google.protobuf.Timestamp worker_start_timestamp = 3; - - // When the worker completed the action, including all stages. - google.protobuf.Timestamp worker_completed_timestamp = 4; - - // When the worker started fetching action inputs. - google.protobuf.Timestamp input_fetch_start_timestamp = 5; - - // When the worker finished fetching action inputs. - google.protobuf.Timestamp input_fetch_completed_timestamp = 6; - - // When the worker started executing the action command. - google.protobuf.Timestamp execution_start_timestamp = 7; - - // When the worker completed executing the action command. - google.protobuf.Timestamp execution_completed_timestamp = 8; - - // When the worker started uploading action outputs. - google.protobuf.Timestamp output_upload_start_timestamp = 9; - - // When the worker finished uploading action outputs. - google.protobuf.Timestamp output_upload_completed_timestamp = 10; - - // Details that are specific to the kind of worker used. For example, - // on POSIX-like systems this could contain a message with - // getrusage(2) statistics. - repeated google.protobuf.Any auxiliary_metadata = 11; -} - -// An ActionResult represents the result of an -// [Action][build.bazel.remote.execution.v2.Action] being run. -// -// It is advised that at least one field (for example -// `ActionResult.execution_metadata.Worker`) have a non-default value, to -// ensure that the serialized value is non-empty, which can then be used -// as a basic data sanity check. -message ActionResult { - reserved 1; // Reserved for use as the resource name. - - // The output files of the action. For each output file requested in the - // `output_files` or `output_paths` field of the Action, if the corresponding - // file existed after the action completed, a single entry will be present - // either in this field, or the `output_file_symlinks` field if the file was - // a symbolic link to another file (`output_symlinks` field after v2.1). - // - // If an output listed in `output_files` was found, but was a directory rather - // than a regular file, the server will return a FAILED_PRECONDITION. - // If the action does not produce the requested output, then that output - // will be omitted from the list. The server is free to arrange the output - // list as desired; clients MUST NOT assume that the output list is sorted. - repeated OutputFile output_files = 2; - - // The output files of the action that are symbolic links to other files. Those - // may be links to other output files, or input files, or even absolute paths - // outside of the working directory, if the server supports - // [SymlinkAbsolutePathStrategy.ALLOWED][build.bazel.remote.execution.v2.CacheCapabilities.SymlinkAbsolutePathStrategy]. - // For each output file requested in the `output_files` or `output_paths` - // field of the Action, if the corresponding file existed after - // the action completed, a single entry will be present either in this field, - // or in the `output_files` field, if the file was not a symbolic link. - // - // If an output symbolic link of the same name as listed in `output_files` of - // the Command was found, but its target type was not a regular file, the - // server will return a FAILED_PRECONDITION. - // If the action does not produce the requested output, then that output - // will be omitted from the list. The server is free to arrange the output - // list as desired; clients MUST NOT assume that the output list is sorted. - // - // DEPRECATED as of v2.1. Servers that wish to be compatible with v2.0 API - // should still populate this field in addition to `output_symlinks`. - repeated OutputSymlink output_file_symlinks = 10; - - // New in v2.1: this field will only be populated if the command - // `output_paths` field was used, and not the pre v2.1 `output_files` or - // `output_directories` fields. - // The output paths of the action that are symbolic links to other paths. Those - // may be links to other outputs, or inputs, or even absolute paths - // outside of the working directory, if the server supports - // [SymlinkAbsolutePathStrategy.ALLOWED][build.bazel.remote.execution.v2.CacheCapabilities.SymlinkAbsolutePathStrategy]. - // A single entry for each output requested in `output_paths` - // field of the Action, if the corresponding path existed after - // the action completed and was a symbolic link. - // - // If the action does not produce a requested output, then that output - // will be omitted from the list. The server is free to arrange the output - // list as desired; clients MUST NOT assume that the output list is sorted. - repeated OutputSymlink output_symlinks = 12; - - // The output directories of the action. For each output directory requested - // in the `output_directories` or `output_paths` field of the Action, if the - // corresponding directory existed after the action completed, a single entry - // will be present in the output list, which will contain the digest of a - // [Tree][build.bazel.remote.execution.v2.Tree] message containing the - // directory tree, and the path equal exactly to the corresponding Action - // output_directories member. - // - // As an example, suppose the Action had an output directory `a/b/dir` and the - // execution produced the following contents in `a/b/dir`: a file named `bar` - // and a directory named `foo` with an executable file named `baz`. Then, - // output_directory will contain (hashes shortened for readability): - // - // ```json - // // OutputDirectory proto: - // { - // path: "a/b/dir" - // tree_digest: { - // hash: "4a73bc9d03...", - // size: 55 - // } - // } - // // Tree proto with hash "4a73bc9d03..." and size 55: - // { - // root: { - // files: [ - // { - // name: "bar", - // digest: { - // hash: "4a73bc9d03...", - // size: 65534 - // } - // } - // ], - // directories: [ - // { - // name: "foo", - // digest: { - // hash: "4cf2eda940...", - // size: 43 - // } - // } - // ] - // } - // children : { - // // (Directory proto with hash "4cf2eda940..." and size 43) - // files: [ - // { - // name: "baz", - // digest: { - // hash: "b2c941073e...", - // size: 1294, - // }, - // is_executable: true - // } - // ] - // } - // } - // ``` - // If an output of the same name as listed in `output_files` of - // the Command was found in `output_directories`, but was not a directory, the - // server will return a FAILED_PRECONDITION. - repeated OutputDirectory output_directories = 3; - - // The output directories of the action that are symbolic links to other - // directories. Those may be links to other output directories, or input - // directories, or even absolute paths outside of the working directory, - // if the server supports - // [SymlinkAbsolutePathStrategy.ALLOWED][build.bazel.remote.execution.v2.CacheCapabilities.SymlinkAbsolutePathStrategy]. - // For each output directory requested in the `output_directories` field of - // the Action, if the directory existed after the action completed, a - // single entry will be present either in this field, or in the - // `output_directories` field, if the directory was not a symbolic link. - // - // If an output of the same name was found, but was a symbolic link to a file - // instead of a directory, the server will return a FAILED_PRECONDITION. - // If the action does not produce the requested output, then that output - // will be omitted from the list. The server is free to arrange the output - // list as desired; clients MUST NOT assume that the output list is sorted. - // - // DEPRECATED as of v2.1. Servers that wish to be compatible with v2.0 API - // should still populate this field in addition to `output_symlinks`. - repeated OutputSymlink output_directory_symlinks = 11; - - // The exit code of the command. - int32 exit_code = 4; - - // The standard output buffer of the action. The server SHOULD NOT inline - // stdout unless requested by the client in the - // [GetActionResultRequest][build.bazel.remote.execution.v2.GetActionResultRequest] - // message. The server MAY omit inlining, even if requested, and MUST do so if inlining - // would cause the response to exceed message size limits. - bytes stdout_raw = 5; - - // The digest for a blob containing the standard output of the action, which - // can be retrieved from the - // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. - Digest stdout_digest = 6; - - // The standard error buffer of the action. The server SHOULD NOT inline - // stderr unless requested by the client in the - // [GetActionResultRequest][build.bazel.remote.execution.v2.GetActionResultRequest] - // message. The server MAY omit inlining, even if requested, and MUST do so if inlining - // would cause the response to exceed message size limits. - bytes stderr_raw = 7; - - // The digest for a blob containing the standard error of the action, which - // can be retrieved from the - // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. - Digest stderr_digest = 8; - - // The details of the execution that originally produced this result. - ExecutedActionMetadata execution_metadata = 9; -} - -// An `OutputFile` is similar to a -// [FileNode][build.bazel.remote.execution.v2.FileNode], but it is used as an -// output in an `ActionResult`. It allows a full file path rather than -// only a name. -message OutputFile { - // The full path of the file relative to the working directory, including the - // filename. The path separator is a forward slash `/`. Since this is a - // relative path, it MUST NOT begin with a leading forward slash. - string path = 1; - - // The digest of the file's content. - Digest digest = 2; - - reserved 3; // Used for a removed field in an earlier version of the API. - - // True if file is executable, false otherwise. - bool is_executable = 4; - - // The contents of the file if inlining was requested. The server SHOULD NOT inline - // file contents unless requested by the client in the - // [GetActionResultRequest][build.bazel.remote.execution.v2.GetActionResultRequest] - // message. The server MAY omit inlining, even if requested, and MUST do so if inlining - // would cause the response to exceed message size limits. - bytes contents = 5; - - // The supported node properties of the OutputFile, if requested by the Action. - reserved 6; - NodeProperties node_properties = 7; -} - -// A `Tree` contains all the -// [Directory][build.bazel.remote.execution.v2.Directory] protos in a -// single directory Merkle tree, compressed into one message. -message Tree { - // The root directory in the tree. - Directory root = 1; - - // All the child directories: the directories referred to by the root and, - // recursively, all its children. In order to reconstruct the directory tree, - // the client must take the digests of each of the child directories and then - // build up a tree starting from the `root`. - repeated Directory children = 2; -} - -// An `OutputDirectory` is the output in an `ActionResult` corresponding to a -// directory's full contents rather than a single file. -message OutputDirectory { - // The full path of the directory relative to the working directory. The path - // separator is a forward slash `/`. Since this is a relative path, it MUST - // NOT begin with a leading forward slash. The empty string value is allowed, - // and it denotes the entire working directory. - string path = 1; - - reserved 2; // Used for a removed field in an earlier version of the API. - - // The digest of the encoded - // [Tree][build.bazel.remote.execution.v2.Tree] proto containing the - // directory's contents. - Digest tree_digest = 3; -} - -// An `OutputSymlink` is similar to a -// [Symlink][build.bazel.remote.execution.v2.SymlinkNode], but it is used as an -// output in an `ActionResult`. -// -// `OutputSymlink` is binary-compatible with `SymlinkNode`. -message OutputSymlink { - // The full path of the symlink relative to the working directory, including the - // filename. The path separator is a forward slash `/`. Since this is a - // relative path, it MUST NOT begin with a leading forward slash. - string path = 1; - - // The target path of the symlink. The path separator is a forward slash `/`. - // The target path can be relative to the parent directory of the symlink or - // it can be an absolute path starting with `/`. Support for absolute paths - // can be checked using the [Capabilities][build.bazel.remote.execution.v2.Capabilities] - // API. `..` components are allowed anywhere in the target path. - string target = 2; - - // The supported node properties of the OutputSymlink, if requested by the - // Action. - reserved 3; - NodeProperties node_properties = 4; -} - -// An `ExecutionPolicy` can be used to control the scheduling of the action. -message ExecutionPolicy { - // The priority (relative importance) of this action. Generally, a lower value - // means that the action should be run sooner than actions having a greater - // priority value, but the interpretation of a given value is server- - // dependent. A priority of 0 means the *default* priority. Priorities may be - // positive or negative, and such actions should run later or sooner than - // actions having the default priority, respectively. The particular semantics - // of this field is up to the server. In particular, every server will have - // their own supported range of priorities, and will decide how these map into - // scheduling policy. - int32 priority = 1; -} - -// A `ResultsCachePolicy` is used for fine-grained control over how action -// outputs are stored in the CAS and Action Cache. -message ResultsCachePolicy { - // The priority (relative importance) of this content in the overall cache. - // Generally, a lower value means a longer retention time or other advantage, - // but the interpretation of a given value is server-dependent. A priority of - // 0 means a *default* value, decided by the server. - // - // The particular semantics of this field is up to the server. In particular, - // every server will have their own supported range of priorities, and will - // decide how these map into retention/eviction policy. - int32 priority = 1; -} - -// A request message for -// [Execution.Execute][build.bazel.remote.execution.v2.Execution.Execute]. -message ExecuteRequest { - // The instance of the execution system to operate against. A server may - // support multiple instances of the execution system (with their own workers, - // storage, caches, etc.). The server MAY require use of this field to select - // between them in an implementation-defined fashion, otherwise it can be - // omitted. - string instance_name = 1; - - // If true, the action will be executed even if its result is already - // present in the [ActionCache][build.bazel.remote.execution.v2.ActionCache]. - // The execution is still allowed to be merged with other in-flight executions - // of the same action, however - semantically, the service MUST only guarantee - // that the results of an execution with this field set were not visible - // before the corresponding execution request was sent. - // Note that actions from execution requests setting this field set are still - // eligible to be entered into the action cache upon completion, and services - // SHOULD overwrite any existing entries that may exist. This allows - // skip_cache_lookup requests to be used as a mechanism for replacing action - // cache entries that reference outputs no longer available or that are - // poisoned in any way. - // If false, the result may be served from the action cache. - bool skip_cache_lookup = 3; - - reserved 2, 4, 5; // Used for removed fields in an earlier version of the API. - - // The digest of the [Action][build.bazel.remote.execution.v2.Action] to - // execute. - Digest action_digest = 6; - - // An optional policy for execution of the action. - // The server will have a default policy if this is not provided. - ExecutionPolicy execution_policy = 7; - - // An optional policy for the results of this execution in the remote cache. - // The server will have a default policy if this is not provided. - // This may be applied to both the ActionResult and the associated blobs. - ResultsCachePolicy results_cache_policy = 8; -} - -// A `LogFile` is a log stored in the CAS. -message LogFile { - // The digest of the log contents. - Digest digest = 1; - - // This is a hint as to the purpose of the log, and is set to true if the log - // is human-readable text that can be usefully displayed to a user, and false - // otherwise. For instance, if a command-line client wishes to print the - // server logs to the terminal for a failed action, this allows it to avoid - // displaying a binary file. - bool human_readable = 2; -} - -// The response message for -// [Execution.Execute][build.bazel.remote.execution.v2.Execution.Execute], -// which will be contained in the [response -// field][google.longrunning.Operation.response] of the -// [Operation][google.longrunning.Operation]. -message ExecuteResponse { - // The result of the action. - ActionResult result = 1; - - // True if the result was served from cache, false if it was executed. - bool cached_result = 2; - - // If the status has a code other than `OK`, it indicates that the action did - // not finish execution. For example, if the operation times out during - // execution, the status will have a `DEADLINE_EXCEEDED` code. Servers MUST - // use this field for errors in execution, rather than the error field on the - // `Operation` object. - // - // If the status code is other than `OK`, then the result MUST NOT be cached. - // For an error status, the `result` field is optional; the server may - // populate the output-, stdout-, and stderr-related fields if it has any - // information available, such as the stdout and stderr of a timed-out action. - google.rpc.Status status = 3; - - // An optional list of additional log outputs the server wishes to provide. A - // server can use this to return execution-specific logs however it wishes. - // This is intended primarily to make it easier for users to debug issues that - // may be outside of the actual job execution, such as by identifying the - // worker executing the action or by providing logs from the worker's setup - // phase. The keys SHOULD be human readable so that a client can display them - // to a user. - map server_logs = 4; - - // Freeform informational message with details on the execution of the action - // that may be displayed to the user upon failure or when requested explicitly. - string message = 5; -} - -// The current stage of action execution. -message ExecutionStage { - enum Value { - // Invalid value. - UNKNOWN = 0; - - // Checking the result against the cache. - CACHE_CHECK = 1; - - // Currently idle, awaiting a free machine to execute. - QUEUED = 2; - - // Currently being executed by a worker. - EXECUTING = 3; - - // Finished execution. - COMPLETED = 4; - } -} - -// Metadata about an ongoing -// [execution][build.bazel.remote.execution.v2.Execution.Execute], which -// will be contained in the [metadata -// field][google.longrunning.Operation.response] of the -// [Operation][google.longrunning.Operation]. -message ExecuteOperationMetadata { - // The current stage of execution. - ExecutionStage.Value stage = 1; - - // The digest of the [Action][build.bazel.remote.execution.v2.Action] - // being executed. - Digest action_digest = 2; - - // If set, the client can use this resource name with - // [ByteStream.Read][google.bytestream.ByteStream.Read] to stream the - // standard output from the endpoint hosting streamed responses. - string stdout_stream_name = 3; - - // If set, the client can use this resource name with - // [ByteStream.Read][google.bytestream.ByteStream.Read] to stream the - // standard error from the endpoint hosting streamed responses. - string stderr_stream_name = 4; -} - -// A request message for -// [WaitExecution][build.bazel.remote.execution.v2.Execution.WaitExecution]. -message WaitExecutionRequest { - // The name of the [Operation][google.longrunning.Operation] - // returned by [Execute][build.bazel.remote.execution.v2.Execution.Execute]. - string name = 1; -} - -// A request message for -// [ActionCache.GetActionResult][build.bazel.remote.execution.v2.ActionCache.GetActionResult]. -message GetActionResultRequest { - // The instance of the execution system to operate against. A server may - // support multiple instances of the execution system (with their own workers, - // storage, caches, etc.). The server MAY require use of this field to select - // between them in an implementation-defined fashion, otherwise it can be - // omitted. - string instance_name = 1; - - // The digest of the [Action][build.bazel.remote.execution.v2.Action] - // whose result is requested. - Digest action_digest = 2; - - // A hint to the server to request inlining stdout in the - // [ActionResult][build.bazel.remote.execution.v2.ActionResult] message. - bool inline_stdout = 3; - - // A hint to the server to request inlining stderr in the - // [ActionResult][build.bazel.remote.execution.v2.ActionResult] message. - bool inline_stderr = 4; - - // A hint to the server to inline the contents of the listed output files. - // Each path needs to exactly match one file path in either `output_paths` or - // `output_files` (DEPRECATED since v2.1) in the - // [Command][build.bazel.remote.execution.v2.Command] message. - repeated string inline_output_files = 5; -} - -// A request message for -// [ActionCache.UpdateActionResult][build.bazel.remote.execution.v2.ActionCache.UpdateActionResult]. -message UpdateActionResultRequest { - // The instance of the execution system to operate against. A server may - // support multiple instances of the execution system (with their own workers, - // storage, caches, etc.). The server MAY require use of this field to select - // between them in an implementation-defined fashion, otherwise it can be - // omitted. - string instance_name = 1; - - // The digest of the [Action][build.bazel.remote.execution.v2.Action] - // whose result is being uploaded. - Digest action_digest = 2; - - // The [ActionResult][build.bazel.remote.execution.v2.ActionResult] - // to store in the cache. - ActionResult action_result = 3; - - // An optional policy for the results of this execution in the remote cache. - // The server will have a default policy if this is not provided. - // This may be applied to both the ActionResult and the associated blobs. - ResultsCachePolicy results_cache_policy = 4; -} - -// A request message for -// [ContentAddressableStorage.FindMissingBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.FindMissingBlobs]. -message FindMissingBlobsRequest { - // The instance of the execution system to operate against. A server may - // support multiple instances of the execution system (with their own workers, - // storage, caches, etc.). The server MAY require use of this field to select - // between them in an implementation-defined fashion, otherwise it can be - // omitted. - string instance_name = 1; - - // A list of the blobs to check. - repeated Digest blob_digests = 2; -} - -// A response message for -// [ContentAddressableStorage.FindMissingBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.FindMissingBlobs]. -message FindMissingBlobsResponse { - // A list of the blobs requested *not* present in the storage. - repeated Digest missing_blob_digests = 2; -} - -// A request message for -// [ContentAddressableStorage.BatchUpdateBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchUpdateBlobs]. -message BatchUpdateBlobsRequest { - // A request corresponding to a single blob that the client wants to upload. - message Request { - // The digest of the blob. This MUST be the digest of `data`. - Digest digest = 1; - - // The raw binary data. - bytes data = 2; - } - - // The instance of the execution system to operate against. A server may - // support multiple instances of the execution system (with their own workers, - // storage, caches, etc.). The server MAY require use of this field to select - // between them in an implementation-defined fashion, otherwise it can be - // omitted. - string instance_name = 1; - - // The individual upload requests. - repeated Request requests = 2; -} - -// A response message for -// [ContentAddressableStorage.BatchUpdateBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchUpdateBlobs]. -message BatchUpdateBlobsResponse { - // A response corresponding to a single blob that the client tried to upload. - message Response { - // The blob digest to which this response corresponds. - Digest digest = 1; - - // The result of attempting to upload that blob. - google.rpc.Status status = 2; - } - - // The responses to the requests. - repeated Response responses = 1; -} - -// A request message for -// [ContentAddressableStorage.BatchReadBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchReadBlobs]. -message BatchReadBlobsRequest { - // The instance of the execution system to operate against. A server may - // support multiple instances of the execution system (with their own workers, - // storage, caches, etc.). The server MAY require use of this field to select - // between them in an implementation-defined fashion, otherwise it can be - // omitted. - string instance_name = 1; - - // The individual blob digests. - repeated Digest digests = 2; -} - -// A response message for -// [ContentAddressableStorage.BatchReadBlobs][build.bazel.remote.execution.v2.ContentAddressableStorage.BatchReadBlobs]. -message BatchReadBlobsResponse { - // A response corresponding to a single blob that the client tried to download. - message Response { - // The digest to which this response corresponds. - Digest digest = 1; - - // The raw binary data. - bytes data = 2; - - // The result of attempting to download that blob. - google.rpc.Status status = 3; - } - - // The responses to the requests. - repeated Response responses = 1; -} - -// A request message for -// [ContentAddressableStorage.GetTree][build.bazel.remote.execution.v2.ContentAddressableStorage.GetTree]. -message GetTreeRequest { - // The instance of the execution system to operate against. A server may - // support multiple instances of the execution system (with their own workers, - // storage, caches, etc.). The server MAY require use of this field to select - // between them in an implementation-defined fashion, otherwise it can be - // omitted. - string instance_name = 1; - - // The digest of the root, which must be an encoded - // [Directory][build.bazel.remote.execution.v2.Directory] message - // stored in the - // [ContentAddressableStorage][build.bazel.remote.execution.v2.ContentAddressableStorage]. - Digest root_digest = 2; - - // A maximum page size to request. If present, the server will request no more - // than this many items. Regardless of whether a page size is specified, the - // server may place its own limit on the number of items to be returned and - // require the client to retrieve more items using a subsequent request. - int32 page_size = 3; - - // A page token, which must be a value received in a previous - // [GetTreeResponse][build.bazel.remote.execution.v2.GetTreeResponse]. - // If present, the server will use that token as an offset, returning only - // that page and the ones that succeed it. - string page_token = 4; -} - -// A response message for -// [ContentAddressableStorage.GetTree][build.bazel.remote.execution.v2.ContentAddressableStorage.GetTree]. -message GetTreeResponse { - // The directories descended from the requested root. - repeated Directory directories = 1; - - // If present, signifies that there are more results which the client can - // retrieve by passing this as the page_token in a subsequent - // [request][build.bazel.remote.execution.v2.GetTreeRequest]. - // If empty, signifies that this is the last page of results. - string next_page_token = 2; -} - -// A request message for -// [Capabilities.GetCapabilities][build.bazel.remote.execution.v2.Capabilities.GetCapabilities]. -message GetCapabilitiesRequest { - // The instance of the execution system to operate against. A server may - // support multiple instances of the execution system (with their own workers, - // storage, caches, etc.). The server MAY require use of this field to select - // between them in an implementation-defined fashion, otherwise it can be - // omitted. - string instance_name = 1; -} - -// A response message for -// [Capabilities.GetCapabilities][build.bazel.remote.execution.v2.Capabilities.GetCapabilities]. -message ServerCapabilities { - // Capabilities of the remote cache system. - CacheCapabilities cache_capabilities = 1; - - // Capabilities of the remote execution system. - ExecutionCapabilities execution_capabilities = 2; - - // Earliest RE API version supported, including deprecated versions. - build.bazel.semver.SemVer deprecated_api_version = 3; - - // Earliest non-deprecated RE API version supported. - build.bazel.semver.SemVer low_api_version = 4; - - // Latest RE API version supported. - build.bazel.semver.SemVer high_api_version = 5; -} - -// The digest function used for converting values into keys for CAS and Action -// Cache. -message DigestFunction { - enum Value { - // It is an error for the server to return this value. - UNKNOWN = 0; - - // The SHA-256 digest function. - SHA256 = 1; - - // The SHA-1 digest function. - SHA1 = 2; - - // The MD5 digest function. - MD5 = 3; - - // The Microsoft "VSO-Hash" paged SHA256 digest function. - // See https://github.com/microsoft/BuildXL/blob/master/Documentation/Specs/PagedHash.md . - VSO = 4; - - // The SHA-384 digest function. - SHA384 = 5; - - // The SHA-512 digest function. - SHA512 = 6; - - // Murmur3 128-bit digest function, x64 variant. Note that this is not a - // cryptographic hash function and its collision properties are not strongly guaranteed. - // See https://github.com/aappleby/smhasher/wiki/MurmurHash3 . - MURMUR3 = 7; - } -} - -// Describes the server/instance capabilities for updating the action cache. -message ActionCacheUpdateCapabilities { - bool update_enabled = 1; -} - -// Allowed values for priority in -// [ResultsCachePolicy][build.bazel.remoteexecution.v2.ResultsCachePolicy] and -// [ExecutionPolicy][build.bazel.remoteexecution.v2.ResultsCachePolicy] -// Used for querying both cache and execution valid priority ranges. -message PriorityCapabilities { - // Supported range of priorities, including boundaries. - message PriorityRange { - // The minimum numeric value for this priority range, which represents the - // most urgent task or longest retained item. - int32 min_priority = 1; - // The maximum numeric value for this priority range, which represents the - // least urgent task or shortest retained item. - int32 max_priority = 2; - } - repeated PriorityRange priorities = 1; -} - -// Describes how the server treats absolute symlink targets. -message SymlinkAbsolutePathStrategy { - enum Value { - // Invalid value. - UNKNOWN = 0; - - // Server will return an `INVALID_ARGUMENT` on input symlinks with absolute - // targets. - // If an action tries to create an output symlink with an absolute target, a - // `FAILED_PRECONDITION` will be returned. - DISALLOWED = 1; - - // Server will allow symlink targets to escape the input root tree, possibly - // resulting in non-hermetic builds. - ALLOWED = 2; - } -} - -// Compression formats which may be supported. -message Compressor { - enum Value { - // No compression. Servers and clients MUST always support this, and do - // not need to advertise it. - IDENTITY = 0; - - // Zstandard compression. - ZSTD = 1; - - // RFC 1951 Deflate. This format is identical to what is used by ZIP - // files. Headers such as the one generated by gzip are not - // included. - // - // It is advised to use algorithms such as Zstandard instead, as - // those are faster and/or provide a better compression ratio. - DEFLATE = 2; - } -} - -// Capabilities of the remote cache system. -message CacheCapabilities { - // All the digest functions supported by the remote cache. - // Remote cache may support multiple digest functions simultaneously. - repeated DigestFunction.Value digest_function = 1; - - // Capabilities for updating the action cache. - ActionCacheUpdateCapabilities action_cache_update_capabilities = 2; - - // Supported cache priority range for both CAS and ActionCache. - PriorityCapabilities cache_priority_capabilities = 3; - - // Maximum total size of blobs to be uploaded/downloaded using - // batch methods. A value of 0 means no limit is set, although - // in practice there will always be a message size limitation - // of the protocol in use, e.g. GRPC. - int64 max_batch_total_size_bytes = 4; - - // Whether absolute symlink targets are supported. - SymlinkAbsolutePathStrategy.Value symlink_absolute_path_strategy = 5; - - // Compressors supported by the "compressed-blobs" bytestream resources. - // Servers MUST support identity/no-compression, even if it is not listed - // here. - // - // Note that this does not imply which if any compressors are supported by - // the server at the gRPC level. - repeated Compressor.Value supported_compressor = 6; -} - -// Capabilities of the remote execution system. -message ExecutionCapabilities { - // Remote execution may only support a single digest function. - DigestFunction.Value digest_function = 1; - - // Whether remote execution is enabled for the particular server/instance. - bool exec_enabled = 2; - - // Supported execution priority range. - PriorityCapabilities execution_priority_capabilities = 3; - - // Supported node properties. - repeated string supported_node_properties = 4; -} - -// Details for the tool used to call the API. -message ToolDetails { - // Name of the tool, e.g. bazel. - string tool_name = 1; - - // Version of the tool used for the request, e.g. 5.0.3. - string tool_version = 2; -} - -// An optional Metadata to attach to any RPC request to tell the server about an -// external context of the request. The server may use this for logging or other -// purposes. To use it, the client attaches the header to the call using the -// canonical proto serialization: -// -// * name: `build.bazel.remote.execution.v2.requestmetadata-bin` -// * contents: the base64 encoded binary `RequestMetadata` message. -// Note: the gRPC library serializes binary headers encoded in base 64 by -// default (https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests). -// Therefore, if the gRPC library is used to pass/retrieve this -// metadata, the user may ignore the base64 encoding and assume it is simply -// serialized as a binary message. -message RequestMetadata { - // The details for the tool invoking the requests. - ToolDetails tool_details = 1; - - // An identifier that ties multiple requests to the same action. - // For example, multiple requests to the CAS, Action Cache, and Execution - // API are used in order to compile foo.cc. - string action_id = 2; - - // An identifier that ties multiple actions together to a final result. - // For example, multiple actions are required to build and run foo_test. - string tool_invocation_id = 3; - - // An identifier to tie multiple tool invocations together. For example, - // runs of foo_test, bar_test and baz_test on a post-submit of a given patch. - string correlated_invocations_id = 4; - - // A brief description of the kind of action, for example, CppCompile or GoLink. - // There is no standard agreed set of values for this, and they are expected to vary between different client tools. - string action_mnemonic = 5; - - // An identifier for the target which produced this action. - // No guarantees are made around how many actions may relate to a single target. - string target_id = 6; - - // An identifier for the configuration in which the target was built, - // e.g. for differentiating building host tools or different target platforms. - // There is no expectation that this value will have any particular structure, - // or equality across invocations, though some client tools may offer these guarantees. - string configuration_id = 7; -} diff --git a/proto/prost/private/tests/complex_imports/remote-apis/build/bazel/semver/BUILD.bazel b/proto/prost/private/tests/complex_imports/remote-apis/build/bazel/semver/BUILD.bazel deleted file mode 100644 index 22624417f5..0000000000 --- a/proto/prost/private/tests/complex_imports/remote-apis/build/bazel/semver/BUILD.bazel +++ /dev/null @@ -1,25 +0,0 @@ -load("@rules_proto//proto:defs.bzl", "proto_library") -load("@rules_rust//proto/prost:defs.bzl", "rust_prost_library") -load("//rust:defs.bzl", "rust_test") - -proto_library( - name = "semver_proto", - srcs = ["semver.proto"], - strip_import_prefix = "/proto/prost/private/tests/complex_imports/remote-apis", - visibility = ["//visibility:public"], -) - -rust_prost_library( - name = "semver_rs_proto", - proto = ":semver_proto", - visibility = ["//visibility:public"], -) - -rust_test( - name = "semver_test", - srcs = ["semver_test.rs"], - edition = "2021", - deps = [ - ":semver_rs_proto", - ], -) diff --git a/proto/prost/private/tests/complex_imports/remote-apis/build/bazel/semver/semver.proto b/proto/prost/private/tests/complex_imports/remote-apis/build/bazel/semver/semver.proto deleted file mode 100644 index 3b626b7e47..0000000000 --- a/proto/prost/private/tests/complex_imports/remote-apis/build/bazel/semver/semver.proto +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2018 The Bazel Authors. -// -// 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 build.bazel.semver; - -option csharp_namespace = "Build.Bazel.Semver"; -option go_package = "semver"; -option java_multiple_files = true; -option java_outer_classname = "SemverProto"; -option java_package = "build.bazel.semver"; -option objc_class_prefix = "SMV"; - -// The full version of a given tool. -message SemVer { - // The major version, e.g 10 for 10.2.3. - int32 major = 1; - - // The minor version, e.g. 2 for 10.2.3. - int32 minor = 2; - - // The patch version, e.g 3 for 10.2.3. - int32 patch = 3; - - // The pre-release version. Either this field or major/minor/patch fields - // must be filled. They are mutually exclusive. Pre-release versions are - // assumed to be earlier than any released versions. - string prerelease = 4; -} diff --git a/test/deps.bzl b/test/deps.bzl index 35821618fc..dfbfd413af 100644 --- a/test/deps.bzl +++ b/test/deps.bzl @@ -45,3 +45,29 @@ def rules_rust_test_deps(): name = "rules_rust_toolchain_test_target_json", target_json = Label("//test/unit/toolchain:toolchain-test-triple.json"), ) + + maybe( + http_archive, + name = "bazel_remote_apis", + urls = ["https://github.com/bazelbuild/remote-apis/archive/068363a3625e166056c155f6441cfb35ca8dfbf2.zip"], + sha256 = "34263013f19e6161195747dc0d3293f8bf65c8fed1f60ba40d4246c4f8008de1", + strip_prefix = "remote-apis-068363a3625e166056c155f6441cfb35ca8dfbf2", + workspace_file_content = "exports_files(['external/BUILD.googleapis'])", + ) + + maybe( + http_archive, + name = "googleapis", + build_file = "@bazel_remote_apis//:external/BUILD.googleapis", + sha256 = "7b6ea252f0b8fb5cd722f45feb83e115b689909bbb6a393a873b6cbad4ceae1d", + strip_prefix = "googleapis-143084a2624b6591ee1f9d23e7f5241856642f4d", + urls = ["https://github.com/googleapis/googleapis/archive/143084a2624b6591ee1f9d23e7f5241856642f4d.zip"], + ) + + maybe( + http_archive, + name = "com_github_grpc_grpc", + sha256 = "b391a327429279f6f29b9ae7e5317cd80d5e9d49cc100e6d682221af73d984a6", + strip_prefix = "grpc-93e8830070e9afcbaa992c75817009ee3f4b63a0", # v1.24.3 with fixes + urls = ["https://github.com/grpc/grpc/archive/93e8830070e9afcbaa992c75817009ee3f4b63a0.zip"], + )