diff --git a/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/Control.java b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/Control.java index c07cc66096..f5522a01b7 100644 --- a/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/Control.java +++ b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/Control.java @@ -44,6 +44,7 @@ private Control(com.google.protobuf.GeneratedMessageV3.Builder builder) { private Control() { environment_ = ""; + methodPolicies_ = java.util.Collections.emptyList(); } @java.lang.Override @@ -119,6 +120,77 @@ public com.google.protobuf.ByteString getEnvironmentBytes() { } } + public static final int METHOD_POLICIES_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private java.util.List methodPolicies_; + /** + * + * + *
+   * Defines policies applying to the API methods of the service.
+   * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + @java.lang.Override + public java.util.List getMethodPoliciesList() { + return methodPolicies_; + } + /** + * + * + *
+   * Defines policies applying to the API methods of the service.
+   * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + @java.lang.Override + public java.util.List + getMethodPoliciesOrBuilderList() { + return methodPolicies_; + } + /** + * + * + *
+   * Defines policies applying to the API methods of the service.
+   * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + @java.lang.Override + public int getMethodPoliciesCount() { + return methodPolicies_.size(); + } + /** + * + * + *
+   * Defines policies applying to the API methods of the service.
+   * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + @java.lang.Override + public com.google.api.MethodPolicy getMethodPolicies(int index) { + return methodPolicies_.get(index); + } + /** + * + * + *
+   * Defines policies applying to the API methods of the service.
+   * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + @java.lang.Override + public com.google.api.MethodPolicyOrBuilder getMethodPoliciesOrBuilder(int index) { + return methodPolicies_.get(index); + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -136,6 +208,9 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(environment_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, environment_); } + for (int i = 0; i < methodPolicies_.size(); i++) { + output.writeMessage(4, methodPolicies_.get(i)); + } getUnknownFields().writeTo(output); } @@ -148,6 +223,9 @@ public int getSerializedSize() { if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(environment_)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, environment_); } + for (int i = 0; i < methodPolicies_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, methodPolicies_.get(i)); + } size += getUnknownFields().getSerializedSize(); memoizedSize = size; return size; @@ -164,6 +242,7 @@ public boolean equals(final java.lang.Object obj) { com.google.api.Control other = (com.google.api.Control) obj; if (!getEnvironment().equals(other.getEnvironment())) return false; + if (!getMethodPoliciesList().equals(other.getMethodPoliciesList())) return false; if (!getUnknownFields().equals(other.getUnknownFields())) return false; return true; } @@ -177,6 +256,10 @@ public int hashCode() { hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + ENVIRONMENT_FIELD_NUMBER; hash = (53 * hash) + getEnvironment().hashCode(); + if (getMethodPoliciesCount() > 0) { + hash = (37 * hash) + METHOD_POLICIES_FIELD_NUMBER; + hash = (53 * hash) + getMethodPoliciesList().hashCode(); + } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; @@ -318,6 +401,13 @@ public Builder clear() { super.clear(); bitField0_ = 0; environment_ = ""; + if (methodPoliciesBuilder_ == null) { + methodPolicies_ = java.util.Collections.emptyList(); + } else { + methodPolicies_ = null; + methodPoliciesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); return this; } @@ -343,6 +433,7 @@ public com.google.api.Control build() { @java.lang.Override public com.google.api.Control buildPartial() { com.google.api.Control result = new com.google.api.Control(this); + buildPartialRepeatedFields(result); if (bitField0_ != 0) { buildPartial0(result); } @@ -350,6 +441,18 @@ public com.google.api.Control buildPartial() { return result; } + private void buildPartialRepeatedFields(com.google.api.Control result) { + if (methodPoliciesBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + methodPolicies_ = java.util.Collections.unmodifiableList(methodPolicies_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.methodPolicies_ = methodPolicies_; + } else { + result.methodPolicies_ = methodPoliciesBuilder_.build(); + } + } + private void buildPartial0(com.google.api.Control result) { int from_bitField0_ = bitField0_; if (((from_bitField0_ & 0x00000001) != 0)) { @@ -407,6 +510,33 @@ public Builder mergeFrom(com.google.api.Control other) { bitField0_ |= 0x00000001; onChanged(); } + if (methodPoliciesBuilder_ == null) { + if (!other.methodPolicies_.isEmpty()) { + if (methodPolicies_.isEmpty()) { + methodPolicies_ = other.methodPolicies_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureMethodPoliciesIsMutable(); + methodPolicies_.addAll(other.methodPolicies_); + } + onChanged(); + } + } else { + if (!other.methodPolicies_.isEmpty()) { + if (methodPoliciesBuilder_.isEmpty()) { + methodPoliciesBuilder_.dispose(); + methodPoliciesBuilder_ = null; + methodPolicies_ = other.methodPolicies_; + bitField0_ = (bitField0_ & ~0x00000002); + methodPoliciesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getMethodPoliciesFieldBuilder() + : null; + } else { + methodPoliciesBuilder_.addAllMessages(other.methodPolicies_); + } + } + } this.mergeUnknownFields(other.getUnknownFields()); onChanged(); return this; @@ -439,6 +569,18 @@ public Builder mergeFrom( bitField0_ |= 0x00000001; break; } // case 10 + case 34: + { + com.google.api.MethodPolicy m = + input.readMessage(com.google.api.MethodPolicy.parser(), extensionRegistry); + if (methodPoliciesBuilder_ == null) { + ensureMethodPoliciesIsMutable(); + methodPolicies_.add(m); + } else { + methodPoliciesBuilder_.addMessage(m); + } + break; + } // case 34 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { @@ -574,6 +716,357 @@ public Builder setEnvironmentBytes(com.google.protobuf.ByteString value) { return this; } + private java.util.List methodPolicies_ = + java.util.Collections.emptyList(); + + private void ensureMethodPoliciesIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + methodPolicies_ = new java.util.ArrayList(methodPolicies_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.api.MethodPolicy, + com.google.api.MethodPolicy.Builder, + com.google.api.MethodPolicyOrBuilder> + methodPoliciesBuilder_; + + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public java.util.List getMethodPoliciesList() { + if (methodPoliciesBuilder_ == null) { + return java.util.Collections.unmodifiableList(methodPolicies_); + } else { + return methodPoliciesBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public int getMethodPoliciesCount() { + if (methodPoliciesBuilder_ == null) { + return methodPolicies_.size(); + } else { + return methodPoliciesBuilder_.getCount(); + } + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public com.google.api.MethodPolicy getMethodPolicies(int index) { + if (methodPoliciesBuilder_ == null) { + return methodPolicies_.get(index); + } else { + return methodPoliciesBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public Builder setMethodPolicies(int index, com.google.api.MethodPolicy value) { + if (methodPoliciesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMethodPoliciesIsMutable(); + methodPolicies_.set(index, value); + onChanged(); + } else { + methodPoliciesBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public Builder setMethodPolicies( + int index, com.google.api.MethodPolicy.Builder builderForValue) { + if (methodPoliciesBuilder_ == null) { + ensureMethodPoliciesIsMutable(); + methodPolicies_.set(index, builderForValue.build()); + onChanged(); + } else { + methodPoliciesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public Builder addMethodPolicies(com.google.api.MethodPolicy value) { + if (methodPoliciesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMethodPoliciesIsMutable(); + methodPolicies_.add(value); + onChanged(); + } else { + methodPoliciesBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public Builder addMethodPolicies(int index, com.google.api.MethodPolicy value) { + if (methodPoliciesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMethodPoliciesIsMutable(); + methodPolicies_.add(index, value); + onChanged(); + } else { + methodPoliciesBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public Builder addMethodPolicies(com.google.api.MethodPolicy.Builder builderForValue) { + if (methodPoliciesBuilder_ == null) { + ensureMethodPoliciesIsMutable(); + methodPolicies_.add(builderForValue.build()); + onChanged(); + } else { + methodPoliciesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public Builder addMethodPolicies( + int index, com.google.api.MethodPolicy.Builder builderForValue) { + if (methodPoliciesBuilder_ == null) { + ensureMethodPoliciesIsMutable(); + methodPolicies_.add(index, builderForValue.build()); + onChanged(); + } else { + methodPoliciesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public Builder addAllMethodPolicies( + java.lang.Iterable values) { + if (methodPoliciesBuilder_ == null) { + ensureMethodPoliciesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, methodPolicies_); + onChanged(); + } else { + methodPoliciesBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public Builder clearMethodPolicies() { + if (methodPoliciesBuilder_ == null) { + methodPolicies_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + methodPoliciesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public Builder removeMethodPolicies(int index) { + if (methodPoliciesBuilder_ == null) { + ensureMethodPoliciesIsMutable(); + methodPolicies_.remove(index); + onChanged(); + } else { + methodPoliciesBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public com.google.api.MethodPolicy.Builder getMethodPoliciesBuilder(int index) { + return getMethodPoliciesFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public com.google.api.MethodPolicyOrBuilder getMethodPoliciesOrBuilder(int index) { + if (methodPoliciesBuilder_ == null) { + return methodPolicies_.get(index); + } else { + return methodPoliciesBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public java.util.List + getMethodPoliciesOrBuilderList() { + if (methodPoliciesBuilder_ != null) { + return methodPoliciesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(methodPolicies_); + } + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public com.google.api.MethodPolicy.Builder addMethodPoliciesBuilder() { + return getMethodPoliciesFieldBuilder() + .addBuilder(com.google.api.MethodPolicy.getDefaultInstance()); + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public com.google.api.MethodPolicy.Builder addMethodPoliciesBuilder(int index) { + return getMethodPoliciesFieldBuilder() + .addBuilder(index, com.google.api.MethodPolicy.getDefaultInstance()); + } + /** + * + * + *
+     * Defines policies applying to the API methods of the service.
+     * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + public java.util.List getMethodPoliciesBuilderList() { + return getMethodPoliciesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.api.MethodPolicy, + com.google.api.MethodPolicy.Builder, + com.google.api.MethodPolicyOrBuilder> + getMethodPoliciesFieldBuilder() { + if (methodPoliciesBuilder_ == null) { + methodPoliciesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.api.MethodPolicy, + com.google.api.MethodPolicy.Builder, + com.google.api.MethodPolicyOrBuilder>( + methodPolicies_, + ((bitField0_ & 0x00000002) != 0), + getParentForChildren(), + isClean()); + methodPolicies_ = null; + } + return methodPoliciesBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/ControlOrBuilder.java b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/ControlOrBuilder.java index c50ef6031a..0cf9413df8 100644 --- a/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/ControlOrBuilder.java +++ b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/ControlOrBuilder.java @@ -51,4 +51,55 @@ public interface ControlOrBuilder * @return The bytes for environment. */ com.google.protobuf.ByteString getEnvironmentBytes(); + + /** + * + * + *
+   * Defines policies applying to the API methods of the service.
+   * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + java.util.List getMethodPoliciesList(); + /** + * + * + *
+   * Defines policies applying to the API methods of the service.
+   * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + com.google.api.MethodPolicy getMethodPolicies(int index); + /** + * + * + *
+   * Defines policies applying to the API methods of the service.
+   * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + int getMethodPoliciesCount(); + /** + * + * + *
+   * Defines policies applying to the API methods of the service.
+   * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + java.util.List getMethodPoliciesOrBuilderList(); + /** + * + * + *
+   * Defines policies applying to the API methods of the service.
+   * 
+ * + * repeated .google.api.MethodPolicy method_policies = 4; + */ + com.google.api.MethodPolicyOrBuilder getMethodPoliciesOrBuilder(int index); } diff --git a/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/ControlProto.java b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/ControlProto.java index f315b5ddd4..47802a784d 100644 --- a/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/ControlProto.java +++ b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/ControlProto.java @@ -40,22 +40,28 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { static { java.lang.String[] descriptorData = { - "\n\030google/api/control.proto\022\ngoogle.api\"\036" - + "\n\007Control\022\023\n\013environment\030\001 \001(\tBn\n\016com.go" - + "ogle.apiB\014ControlProtoP\001ZEgoogle.golang." - + "org/genproto/googleapis/api/serviceconfi" - + "g;serviceconfig\242\002\004GAPIb\006proto3" + "\n\030google/api/control.proto\022\ngoogle.api\032\027" + + "google/api/policy.proto\"Q\n\007Control\022\023\n\013en" + + "vironment\030\001 \001(\t\0221\n\017method_policies\030\004 \003(\013" + + "2\030.google.api.MethodPolicyBn\n\016com.google" + + ".apiB\014ControlProtoP\001ZEgoogle.golang.org/" + + "genproto/googleapis/api/serviceconfig;se" + + "rviceconfig\242\002\004GAPIb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( - descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {}); + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.PolicyProto.getDescriptor(), + }); internal_static_google_api_Control_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_api_Control_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_api_Control_descriptor, new java.lang.String[] { - "Environment", + "Environment", "MethodPolicies", }); + com.google.api.PolicyProto.getDescriptor(); } // @@protoc_insertion_point(outer_class_scope) diff --git a/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/FieldPolicy.java b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/FieldPolicy.java new file mode 100644 index 0000000000..bed8a148ea --- /dev/null +++ b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/FieldPolicy.java @@ -0,0 +1,1075 @@ +/* + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/policy.proto + +package com.google.api; + +/** + * + * + *
+ * Google API Policy Annotation
+ *
+ * This message defines a simple API policy annotation that can be used to
+ * annotate API request and response message fields with applicable policies.
+ * One field may have multiple applicable policies that must all be satisfied
+ * before a request can be processed. This policy annotation is used to
+ * generate the overall policy that will be used for automatic runtime
+ * policy enforcement and documentation generation.
+ * 
+ * + * Protobuf type {@code google.api.FieldPolicy} + */ +public final class FieldPolicy extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.api.FieldPolicy) + FieldPolicyOrBuilder { + private static final long serialVersionUID = 0L; + // Use FieldPolicy.newBuilder() to construct. + private FieldPolicy(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private FieldPolicy() { + selector_ = ""; + resourcePermission_ = ""; + resourceType_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new FieldPolicy(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.api.PolicyProto.internal_static_google_api_FieldPolicy_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.PolicyProto.internal_static_google_api_FieldPolicy_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.FieldPolicy.class, com.google.api.FieldPolicy.Builder.class); + } + + public static final int SELECTOR_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object selector_ = ""; + /** + * + * + *
+   * Selects one or more request or response message fields to apply this
+   * `FieldPolicy`.
+   *
+   * When a `FieldPolicy` is used in proto annotation, the selector must
+   * be left as empty. The service config generator will automatically fill
+   * the correct value.
+   *
+   * When a `FieldPolicy` is used in service config, the selector must be a
+   * comma-separated string with valid request or response field paths,
+   * such as "foo.bar" or "foo.bar,foo.baz".
+   * 
+ * + * string selector = 1; + * + * @return The selector. + */ + @java.lang.Override + public java.lang.String getSelector() { + java.lang.Object ref = selector_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + selector_ = s; + return s; + } + } + /** + * + * + *
+   * Selects one or more request or response message fields to apply this
+   * `FieldPolicy`.
+   *
+   * When a `FieldPolicy` is used in proto annotation, the selector must
+   * be left as empty. The service config generator will automatically fill
+   * the correct value.
+   *
+   * When a `FieldPolicy` is used in service config, the selector must be a
+   * comma-separated string with valid request or response field paths,
+   * such as "foo.bar" or "foo.bar,foo.baz".
+   * 
+ * + * string selector = 1; + * + * @return The bytes for selector. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSelectorBytes() { + java.lang.Object ref = selector_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + selector_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int RESOURCE_PERMISSION_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object resourcePermission_ = ""; + /** + * + * + *
+   * Specifies the required permission(s) for the resource referred to by the
+   * field. It requires the field contains a valid resource reference, and
+   * the request must pass the permission checks to proceed. For example,
+   * "resourcemanager.projects.get".
+   * 
+ * + * string resource_permission = 2; + * + * @return The resourcePermission. + */ + @java.lang.Override + public java.lang.String getResourcePermission() { + java.lang.Object ref = resourcePermission_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + resourcePermission_ = s; + return s; + } + } + /** + * + * + *
+   * Specifies the required permission(s) for the resource referred to by the
+   * field. It requires the field contains a valid resource reference, and
+   * the request must pass the permission checks to proceed. For example,
+   * "resourcemanager.projects.get".
+   * 
+ * + * string resource_permission = 2; + * + * @return The bytes for resourcePermission. + */ + @java.lang.Override + public com.google.protobuf.ByteString getResourcePermissionBytes() { + java.lang.Object ref = resourcePermission_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + resourcePermission_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int RESOURCE_TYPE_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object resourceType_ = ""; + /** + * + * + *
+   * Specifies the resource type for the resource referred to by the field.
+   * 
+ * + * string resource_type = 3; + * + * @return The resourceType. + */ + @java.lang.Override + public java.lang.String getResourceType() { + java.lang.Object ref = resourceType_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + resourceType_ = s; + return s; + } + } + /** + * + * + *
+   * Specifies the resource type for the resource referred to by the field.
+   * 
+ * + * string resource_type = 3; + * + * @return The bytes for resourceType. + */ + @java.lang.Override + public com.google.protobuf.ByteString getResourceTypeBytes() { + java.lang.Object ref = resourceType_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + resourceType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(selector_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, selector_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(resourcePermission_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, resourcePermission_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(resourceType_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, resourceType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(selector_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, selector_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(resourcePermission_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, resourcePermission_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(resourceType_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, resourceType_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.api.FieldPolicy)) { + return super.equals(obj); + } + com.google.api.FieldPolicy other = (com.google.api.FieldPolicy) obj; + + if (!getSelector().equals(other.getSelector())) return false; + if (!getResourcePermission().equals(other.getResourcePermission())) return false; + if (!getResourceType().equals(other.getResourceType())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SELECTOR_FIELD_NUMBER; + hash = (53 * hash) + getSelector().hashCode(); + hash = (37 * hash) + RESOURCE_PERMISSION_FIELD_NUMBER; + hash = (53 * hash) + getResourcePermission().hashCode(); + hash = (37 * hash) + RESOURCE_TYPE_FIELD_NUMBER; + hash = (53 * hash) + getResourceType().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.api.FieldPolicy parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.api.FieldPolicy parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.api.FieldPolicy parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.api.FieldPolicy parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.api.FieldPolicy parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.api.FieldPolicy parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.api.FieldPolicy parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.api.FieldPolicy parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.api.FieldPolicy parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.api.FieldPolicy parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.api.FieldPolicy parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.api.FieldPolicy parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.api.FieldPolicy prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Google API Policy Annotation
+   *
+   * This message defines a simple API policy annotation that can be used to
+   * annotate API request and response message fields with applicable policies.
+   * One field may have multiple applicable policies that must all be satisfied
+   * before a request can be processed. This policy annotation is used to
+   * generate the overall policy that will be used for automatic runtime
+   * policy enforcement and documentation generation.
+   * 
+ * + * Protobuf type {@code google.api.FieldPolicy} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.api.FieldPolicy) + com.google.api.FieldPolicyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.api.PolicyProto.internal_static_google_api_FieldPolicy_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.PolicyProto.internal_static_google_api_FieldPolicy_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.FieldPolicy.class, com.google.api.FieldPolicy.Builder.class); + } + + // Construct using com.google.api.FieldPolicy.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + selector_ = ""; + resourcePermission_ = ""; + resourceType_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.api.PolicyProto.internal_static_google_api_FieldPolicy_descriptor; + } + + @java.lang.Override + public com.google.api.FieldPolicy getDefaultInstanceForType() { + return com.google.api.FieldPolicy.getDefaultInstance(); + } + + @java.lang.Override + public com.google.api.FieldPolicy build() { + com.google.api.FieldPolicy result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.api.FieldPolicy buildPartial() { + com.google.api.FieldPolicy result = new com.google.api.FieldPolicy(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.api.FieldPolicy result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.selector_ = selector_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.resourcePermission_ = resourcePermission_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.resourceType_ = resourceType_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.FieldPolicy) { + return mergeFrom((com.google.api.FieldPolicy) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.FieldPolicy other) { + if (other == com.google.api.FieldPolicy.getDefaultInstance()) return this; + if (!other.getSelector().isEmpty()) { + selector_ = other.selector_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getResourcePermission().isEmpty()) { + resourcePermission_ = other.resourcePermission_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (!other.getResourceType().isEmpty()) { + resourceType_ = other.resourceType_; + bitField0_ |= 0x00000004; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + selector_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + resourcePermission_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + resourceType_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object selector_ = ""; + /** + * + * + *
+     * Selects one or more request or response message fields to apply this
+     * `FieldPolicy`.
+     *
+     * When a `FieldPolicy` is used in proto annotation, the selector must
+     * be left as empty. The service config generator will automatically fill
+     * the correct value.
+     *
+     * When a `FieldPolicy` is used in service config, the selector must be a
+     * comma-separated string with valid request or response field paths,
+     * such as "foo.bar" or "foo.bar,foo.baz".
+     * 
+ * + * string selector = 1; + * + * @return The selector. + */ + public java.lang.String getSelector() { + java.lang.Object ref = selector_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + selector_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Selects one or more request or response message fields to apply this
+     * `FieldPolicy`.
+     *
+     * When a `FieldPolicy` is used in proto annotation, the selector must
+     * be left as empty. The service config generator will automatically fill
+     * the correct value.
+     *
+     * When a `FieldPolicy` is used in service config, the selector must be a
+     * comma-separated string with valid request or response field paths,
+     * such as "foo.bar" or "foo.bar,foo.baz".
+     * 
+ * + * string selector = 1; + * + * @return The bytes for selector. + */ + public com.google.protobuf.ByteString getSelectorBytes() { + java.lang.Object ref = selector_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + selector_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Selects one or more request or response message fields to apply this
+     * `FieldPolicy`.
+     *
+     * When a `FieldPolicy` is used in proto annotation, the selector must
+     * be left as empty. The service config generator will automatically fill
+     * the correct value.
+     *
+     * When a `FieldPolicy` is used in service config, the selector must be a
+     * comma-separated string with valid request or response field paths,
+     * such as "foo.bar" or "foo.bar,foo.baz".
+     * 
+ * + * string selector = 1; + * + * @param value The selector to set. + * @return This builder for chaining. + */ + public Builder setSelector(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + selector_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Selects one or more request or response message fields to apply this
+     * `FieldPolicy`.
+     *
+     * When a `FieldPolicy` is used in proto annotation, the selector must
+     * be left as empty. The service config generator will automatically fill
+     * the correct value.
+     *
+     * When a `FieldPolicy` is used in service config, the selector must be a
+     * comma-separated string with valid request or response field paths,
+     * such as "foo.bar" or "foo.bar,foo.baz".
+     * 
+ * + * string selector = 1; + * + * @return This builder for chaining. + */ + public Builder clearSelector() { + selector_ = getDefaultInstance().getSelector(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Selects one or more request or response message fields to apply this
+     * `FieldPolicy`.
+     *
+     * When a `FieldPolicy` is used in proto annotation, the selector must
+     * be left as empty. The service config generator will automatically fill
+     * the correct value.
+     *
+     * When a `FieldPolicy` is used in service config, the selector must be a
+     * comma-separated string with valid request or response field paths,
+     * such as "foo.bar" or "foo.bar,foo.baz".
+     * 
+ * + * string selector = 1; + * + * @param value The bytes for selector to set. + * @return This builder for chaining. + */ + public Builder setSelectorBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + selector_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object resourcePermission_ = ""; + /** + * + * + *
+     * Specifies the required permission(s) for the resource referred to by the
+     * field. It requires the field contains a valid resource reference, and
+     * the request must pass the permission checks to proceed. For example,
+     * "resourcemanager.projects.get".
+     * 
+ * + * string resource_permission = 2; + * + * @return The resourcePermission. + */ + public java.lang.String getResourcePermission() { + java.lang.Object ref = resourcePermission_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + resourcePermission_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Specifies the required permission(s) for the resource referred to by the
+     * field. It requires the field contains a valid resource reference, and
+     * the request must pass the permission checks to proceed. For example,
+     * "resourcemanager.projects.get".
+     * 
+ * + * string resource_permission = 2; + * + * @return The bytes for resourcePermission. + */ + public com.google.protobuf.ByteString getResourcePermissionBytes() { + java.lang.Object ref = resourcePermission_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + resourcePermission_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Specifies the required permission(s) for the resource referred to by the
+     * field. It requires the field contains a valid resource reference, and
+     * the request must pass the permission checks to proceed. For example,
+     * "resourcemanager.projects.get".
+     * 
+ * + * string resource_permission = 2; + * + * @param value The resourcePermission to set. + * @return This builder for chaining. + */ + public Builder setResourcePermission(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + resourcePermission_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Specifies the required permission(s) for the resource referred to by the
+     * field. It requires the field contains a valid resource reference, and
+     * the request must pass the permission checks to proceed. For example,
+     * "resourcemanager.projects.get".
+     * 
+ * + * string resource_permission = 2; + * + * @return This builder for chaining. + */ + public Builder clearResourcePermission() { + resourcePermission_ = getDefaultInstance().getResourcePermission(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * + * + *
+     * Specifies the required permission(s) for the resource referred to by the
+     * field. It requires the field contains a valid resource reference, and
+     * the request must pass the permission checks to proceed. For example,
+     * "resourcemanager.projects.get".
+     * 
+ * + * string resource_permission = 2; + * + * @param value The bytes for resourcePermission to set. + * @return This builder for chaining. + */ + public Builder setResourcePermissionBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + resourcePermission_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private java.lang.Object resourceType_ = ""; + /** + * + * + *
+     * Specifies the resource type for the resource referred to by the field.
+     * 
+ * + * string resource_type = 3; + * + * @return The resourceType. + */ + public java.lang.String getResourceType() { + java.lang.Object ref = resourceType_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + resourceType_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Specifies the resource type for the resource referred to by the field.
+     * 
+ * + * string resource_type = 3; + * + * @return The bytes for resourceType. + */ + public com.google.protobuf.ByteString getResourceTypeBytes() { + java.lang.Object ref = resourceType_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + resourceType_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Specifies the resource type for the resource referred to by the field.
+     * 
+ * + * string resource_type = 3; + * + * @param value The resourceType to set. + * @return This builder for chaining. + */ + public Builder setResourceType(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + resourceType_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Specifies the resource type for the resource referred to by the field.
+     * 
+ * + * string resource_type = 3; + * + * @return This builder for chaining. + */ + public Builder clearResourceType() { + resourceType_ = getDefaultInstance().getResourceType(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + /** + * + * + *
+     * Specifies the resource type for the resource referred to by the field.
+     * 
+ * + * string resource_type = 3; + * + * @param value The bytes for resourceType to set. + * @return This builder for chaining. + */ + public Builder setResourceTypeBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + resourceType_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.api.FieldPolicy) + } + + // @@protoc_insertion_point(class_scope:google.api.FieldPolicy) + private static final com.google.api.FieldPolicy DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.api.FieldPolicy(); + } + + public static com.google.api.FieldPolicy getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public FieldPolicy parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.api.FieldPolicy getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/FieldPolicyOrBuilder.java b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/FieldPolicyOrBuilder.java new file mode 100644 index 0000000000..beadd43b06 --- /dev/null +++ b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/FieldPolicyOrBuilder.java @@ -0,0 +1,124 @@ +/* + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/policy.proto + +package com.google.api; + +public interface FieldPolicyOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.api.FieldPolicy) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Selects one or more request or response message fields to apply this
+   * `FieldPolicy`.
+   *
+   * When a `FieldPolicy` is used in proto annotation, the selector must
+   * be left as empty. The service config generator will automatically fill
+   * the correct value.
+   *
+   * When a `FieldPolicy` is used in service config, the selector must be a
+   * comma-separated string with valid request or response field paths,
+   * such as "foo.bar" or "foo.bar,foo.baz".
+   * 
+ * + * string selector = 1; + * + * @return The selector. + */ + java.lang.String getSelector(); + /** + * + * + *
+   * Selects one or more request or response message fields to apply this
+   * `FieldPolicy`.
+   *
+   * When a `FieldPolicy` is used in proto annotation, the selector must
+   * be left as empty. The service config generator will automatically fill
+   * the correct value.
+   *
+   * When a `FieldPolicy` is used in service config, the selector must be a
+   * comma-separated string with valid request or response field paths,
+   * such as "foo.bar" or "foo.bar,foo.baz".
+   * 
+ * + * string selector = 1; + * + * @return The bytes for selector. + */ + com.google.protobuf.ByteString getSelectorBytes(); + + /** + * + * + *
+   * Specifies the required permission(s) for the resource referred to by the
+   * field. It requires the field contains a valid resource reference, and
+   * the request must pass the permission checks to proceed. For example,
+   * "resourcemanager.projects.get".
+   * 
+ * + * string resource_permission = 2; + * + * @return The resourcePermission. + */ + java.lang.String getResourcePermission(); + /** + * + * + *
+   * Specifies the required permission(s) for the resource referred to by the
+   * field. It requires the field contains a valid resource reference, and
+   * the request must pass the permission checks to proceed. For example,
+   * "resourcemanager.projects.get".
+   * 
+ * + * string resource_permission = 2; + * + * @return The bytes for resourcePermission. + */ + com.google.protobuf.ByteString getResourcePermissionBytes(); + + /** + * + * + *
+   * Specifies the resource type for the resource referred to by the field.
+   * 
+ * + * string resource_type = 3; + * + * @return The resourceType. + */ + java.lang.String getResourceType(); + /** + * + * + *
+   * Specifies the resource type for the resource referred to by the field.
+   * 
+ * + * string resource_type = 3; + * + * @return The bytes for resourceType. + */ + com.google.protobuf.ByteString getResourceTypeBytes(); +} diff --git a/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/MethodPolicy.java b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/MethodPolicy.java new file mode 100644 index 0000000000..c9aacf3b7a --- /dev/null +++ b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/MethodPolicy.java @@ -0,0 +1,1155 @@ +/* + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/policy.proto + +package com.google.api; + +/** + * + * + *
+ * Defines policies applying to an RPC method.
+ * 
+ * + * Protobuf type {@code google.api.MethodPolicy} + */ +public final class MethodPolicy extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.api.MethodPolicy) + MethodPolicyOrBuilder { + private static final long serialVersionUID = 0L; + // Use MethodPolicy.newBuilder() to construct. + private MethodPolicy(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private MethodPolicy() { + selector_ = ""; + requestPolicies_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new MethodPolicy(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.api.PolicyProto.internal_static_google_api_MethodPolicy_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.PolicyProto.internal_static_google_api_MethodPolicy_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.MethodPolicy.class, com.google.api.MethodPolicy.Builder.class); + } + + public static final int SELECTOR_FIELD_NUMBER = 9; + + @SuppressWarnings("serial") + private volatile java.lang.Object selector_ = ""; + /** + * + * + *
+   * Selects a method to which these policies should be enforced, for example,
+   * "google.pubsub.v1.Subscriber.CreateSubscription".
+   *
+   * Refer to [selector][google.api.DocumentationRule.selector] for syntax
+   * details.
+   *
+   * NOTE: This field must not be set in the proto annotation. It will be
+   * automatically filled by the service config compiler .
+   * 
+ * + * string selector = 9; + * + * @return The selector. + */ + @java.lang.Override + public java.lang.String getSelector() { + java.lang.Object ref = selector_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + selector_ = s; + return s; + } + } + /** + * + * + *
+   * Selects a method to which these policies should be enforced, for example,
+   * "google.pubsub.v1.Subscriber.CreateSubscription".
+   *
+   * Refer to [selector][google.api.DocumentationRule.selector] for syntax
+   * details.
+   *
+   * NOTE: This field must not be set in the proto annotation. It will be
+   * automatically filled by the service config compiler .
+   * 
+ * + * string selector = 9; + * + * @return The bytes for selector. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSelectorBytes() { + java.lang.Object ref = selector_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + selector_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int REQUEST_POLICIES_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List requestPolicies_; + /** + * + * + *
+   * Policies that are applicable to the request message.
+   * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + @java.lang.Override + public java.util.List getRequestPoliciesList() { + return requestPolicies_; + } + /** + * + * + *
+   * Policies that are applicable to the request message.
+   * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + @java.lang.Override + public java.util.List + getRequestPoliciesOrBuilderList() { + return requestPolicies_; + } + /** + * + * + *
+   * Policies that are applicable to the request message.
+   * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + @java.lang.Override + public int getRequestPoliciesCount() { + return requestPolicies_.size(); + } + /** + * + * + *
+   * Policies that are applicable to the request message.
+   * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + @java.lang.Override + public com.google.api.FieldPolicy getRequestPolicies(int index) { + return requestPolicies_.get(index); + } + /** + * + * + *
+   * Policies that are applicable to the request message.
+   * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + @java.lang.Override + public com.google.api.FieldPolicyOrBuilder getRequestPoliciesOrBuilder(int index) { + return requestPolicies_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < requestPolicies_.size(); i++) { + output.writeMessage(2, requestPolicies_.get(i)); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(selector_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, selector_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < requestPolicies_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, requestPolicies_.get(i)); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(selector_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, selector_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.api.MethodPolicy)) { + return super.equals(obj); + } + com.google.api.MethodPolicy other = (com.google.api.MethodPolicy) obj; + + if (!getSelector().equals(other.getSelector())) return false; + if (!getRequestPoliciesList().equals(other.getRequestPoliciesList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SELECTOR_FIELD_NUMBER; + hash = (53 * hash) + getSelector().hashCode(); + if (getRequestPoliciesCount() > 0) { + hash = (37 * hash) + REQUEST_POLICIES_FIELD_NUMBER; + hash = (53 * hash) + getRequestPoliciesList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.api.MethodPolicy parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.api.MethodPolicy parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.api.MethodPolicy parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.api.MethodPolicy parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.api.MethodPolicy parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.api.MethodPolicy parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.api.MethodPolicy parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.api.MethodPolicy parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.api.MethodPolicy parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.api.MethodPolicy parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.api.MethodPolicy parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.api.MethodPolicy parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.api.MethodPolicy prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * Defines policies applying to an RPC method.
+   * 
+ * + * Protobuf type {@code google.api.MethodPolicy} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.api.MethodPolicy) + com.google.api.MethodPolicyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.api.PolicyProto.internal_static_google_api_MethodPolicy_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.api.PolicyProto.internal_static_google_api_MethodPolicy_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.api.MethodPolicy.class, com.google.api.MethodPolicy.Builder.class); + } + + // Construct using com.google.api.MethodPolicy.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + selector_ = ""; + if (requestPoliciesBuilder_ == null) { + requestPolicies_ = java.util.Collections.emptyList(); + } else { + requestPolicies_ = null; + requestPoliciesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.api.PolicyProto.internal_static_google_api_MethodPolicy_descriptor; + } + + @java.lang.Override + public com.google.api.MethodPolicy getDefaultInstanceForType() { + return com.google.api.MethodPolicy.getDefaultInstance(); + } + + @java.lang.Override + public com.google.api.MethodPolicy build() { + com.google.api.MethodPolicy result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.api.MethodPolicy buildPartial() { + com.google.api.MethodPolicy result = new com.google.api.MethodPolicy(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.api.MethodPolicy result) { + if (requestPoliciesBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + requestPolicies_ = java.util.Collections.unmodifiableList(requestPolicies_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.requestPolicies_ = requestPolicies_; + } else { + result.requestPolicies_ = requestPoliciesBuilder_.build(); + } + } + + private void buildPartial0(com.google.api.MethodPolicy result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.selector_ = selector_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.api.MethodPolicy) { + return mergeFrom((com.google.api.MethodPolicy) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.api.MethodPolicy other) { + if (other == com.google.api.MethodPolicy.getDefaultInstance()) return this; + if (!other.getSelector().isEmpty()) { + selector_ = other.selector_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (requestPoliciesBuilder_ == null) { + if (!other.requestPolicies_.isEmpty()) { + if (requestPolicies_.isEmpty()) { + requestPolicies_ = other.requestPolicies_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureRequestPoliciesIsMutable(); + requestPolicies_.addAll(other.requestPolicies_); + } + onChanged(); + } + } else { + if (!other.requestPolicies_.isEmpty()) { + if (requestPoliciesBuilder_.isEmpty()) { + requestPoliciesBuilder_.dispose(); + requestPoliciesBuilder_ = null; + requestPolicies_ = other.requestPolicies_; + bitField0_ = (bitField0_ & ~0x00000002); + requestPoliciesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getRequestPoliciesFieldBuilder() + : null; + } else { + requestPoliciesBuilder_.addAllMessages(other.requestPolicies_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 18: + { + com.google.api.FieldPolicy m = + input.readMessage(com.google.api.FieldPolicy.parser(), extensionRegistry); + if (requestPoliciesBuilder_ == null) { + ensureRequestPoliciesIsMutable(); + requestPolicies_.add(m); + } else { + requestPoliciesBuilder_.addMessage(m); + } + break; + } // case 18 + case 74: + { + selector_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 74 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object selector_ = ""; + /** + * + * + *
+     * Selects a method to which these policies should be enforced, for example,
+     * "google.pubsub.v1.Subscriber.CreateSubscription".
+     *
+     * Refer to [selector][google.api.DocumentationRule.selector] for syntax
+     * details.
+     *
+     * NOTE: This field must not be set in the proto annotation. It will be
+     * automatically filled by the service config compiler .
+     * 
+ * + * string selector = 9; + * + * @return The selector. + */ + public java.lang.String getSelector() { + java.lang.Object ref = selector_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + selector_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Selects a method to which these policies should be enforced, for example,
+     * "google.pubsub.v1.Subscriber.CreateSubscription".
+     *
+     * Refer to [selector][google.api.DocumentationRule.selector] for syntax
+     * details.
+     *
+     * NOTE: This field must not be set in the proto annotation. It will be
+     * automatically filled by the service config compiler .
+     * 
+ * + * string selector = 9; + * + * @return The bytes for selector. + */ + public com.google.protobuf.ByteString getSelectorBytes() { + java.lang.Object ref = selector_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + selector_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Selects a method to which these policies should be enforced, for example,
+     * "google.pubsub.v1.Subscriber.CreateSubscription".
+     *
+     * Refer to [selector][google.api.DocumentationRule.selector] for syntax
+     * details.
+     *
+     * NOTE: This field must not be set in the proto annotation. It will be
+     * automatically filled by the service config compiler .
+     * 
+ * + * string selector = 9; + * + * @param value The selector to set. + * @return This builder for chaining. + */ + public Builder setSelector(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + selector_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Selects a method to which these policies should be enforced, for example,
+     * "google.pubsub.v1.Subscriber.CreateSubscription".
+     *
+     * Refer to [selector][google.api.DocumentationRule.selector] for syntax
+     * details.
+     *
+     * NOTE: This field must not be set in the proto annotation. It will be
+     * automatically filled by the service config compiler .
+     * 
+ * + * string selector = 9; + * + * @return This builder for chaining. + */ + public Builder clearSelector() { + selector_ = getDefaultInstance().getSelector(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Selects a method to which these policies should be enforced, for example,
+     * "google.pubsub.v1.Subscriber.CreateSubscription".
+     *
+     * Refer to [selector][google.api.DocumentationRule.selector] for syntax
+     * details.
+     *
+     * NOTE: This field must not be set in the proto annotation. It will be
+     * automatically filled by the service config compiler .
+     * 
+ * + * string selector = 9; + * + * @param value The bytes for selector to set. + * @return This builder for chaining. + */ + public Builder setSelectorBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + selector_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.util.List requestPolicies_ = + java.util.Collections.emptyList(); + + private void ensureRequestPoliciesIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + requestPolicies_ = new java.util.ArrayList(requestPolicies_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.api.FieldPolicy, + com.google.api.FieldPolicy.Builder, + com.google.api.FieldPolicyOrBuilder> + requestPoliciesBuilder_; + + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public java.util.List getRequestPoliciesList() { + if (requestPoliciesBuilder_ == null) { + return java.util.Collections.unmodifiableList(requestPolicies_); + } else { + return requestPoliciesBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public int getRequestPoliciesCount() { + if (requestPoliciesBuilder_ == null) { + return requestPolicies_.size(); + } else { + return requestPoliciesBuilder_.getCount(); + } + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public com.google.api.FieldPolicy getRequestPolicies(int index) { + if (requestPoliciesBuilder_ == null) { + return requestPolicies_.get(index); + } else { + return requestPoliciesBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public Builder setRequestPolicies(int index, com.google.api.FieldPolicy value) { + if (requestPoliciesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRequestPoliciesIsMutable(); + requestPolicies_.set(index, value); + onChanged(); + } else { + requestPoliciesBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public Builder setRequestPolicies( + int index, com.google.api.FieldPolicy.Builder builderForValue) { + if (requestPoliciesBuilder_ == null) { + ensureRequestPoliciesIsMutable(); + requestPolicies_.set(index, builderForValue.build()); + onChanged(); + } else { + requestPoliciesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public Builder addRequestPolicies(com.google.api.FieldPolicy value) { + if (requestPoliciesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRequestPoliciesIsMutable(); + requestPolicies_.add(value); + onChanged(); + } else { + requestPoliciesBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public Builder addRequestPolicies(int index, com.google.api.FieldPolicy value) { + if (requestPoliciesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRequestPoliciesIsMutable(); + requestPolicies_.add(index, value); + onChanged(); + } else { + requestPoliciesBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public Builder addRequestPolicies(com.google.api.FieldPolicy.Builder builderForValue) { + if (requestPoliciesBuilder_ == null) { + ensureRequestPoliciesIsMutable(); + requestPolicies_.add(builderForValue.build()); + onChanged(); + } else { + requestPoliciesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public Builder addRequestPolicies( + int index, com.google.api.FieldPolicy.Builder builderForValue) { + if (requestPoliciesBuilder_ == null) { + ensureRequestPoliciesIsMutable(); + requestPolicies_.add(index, builderForValue.build()); + onChanged(); + } else { + requestPoliciesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public Builder addAllRequestPolicies( + java.lang.Iterable values) { + if (requestPoliciesBuilder_ == null) { + ensureRequestPoliciesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, requestPolicies_); + onChanged(); + } else { + requestPoliciesBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public Builder clearRequestPolicies() { + if (requestPoliciesBuilder_ == null) { + requestPolicies_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + requestPoliciesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public Builder removeRequestPolicies(int index) { + if (requestPoliciesBuilder_ == null) { + ensureRequestPoliciesIsMutable(); + requestPolicies_.remove(index); + onChanged(); + } else { + requestPoliciesBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public com.google.api.FieldPolicy.Builder getRequestPoliciesBuilder(int index) { + return getRequestPoliciesFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public com.google.api.FieldPolicyOrBuilder getRequestPoliciesOrBuilder(int index) { + if (requestPoliciesBuilder_ == null) { + return requestPolicies_.get(index); + } else { + return requestPoliciesBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public java.util.List + getRequestPoliciesOrBuilderList() { + if (requestPoliciesBuilder_ != null) { + return requestPoliciesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(requestPolicies_); + } + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public com.google.api.FieldPolicy.Builder addRequestPoliciesBuilder() { + return getRequestPoliciesFieldBuilder() + .addBuilder(com.google.api.FieldPolicy.getDefaultInstance()); + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public com.google.api.FieldPolicy.Builder addRequestPoliciesBuilder(int index) { + return getRequestPoliciesFieldBuilder() + .addBuilder(index, com.google.api.FieldPolicy.getDefaultInstance()); + } + /** + * + * + *
+     * Policies that are applicable to the request message.
+     * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + public java.util.List getRequestPoliciesBuilderList() { + return getRequestPoliciesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.api.FieldPolicy, + com.google.api.FieldPolicy.Builder, + com.google.api.FieldPolicyOrBuilder> + getRequestPoliciesFieldBuilder() { + if (requestPoliciesBuilder_ == null) { + requestPoliciesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.api.FieldPolicy, + com.google.api.FieldPolicy.Builder, + com.google.api.FieldPolicyOrBuilder>( + requestPolicies_, + ((bitField0_ & 0x00000002) != 0), + getParentForChildren(), + isClean()); + requestPolicies_ = null; + } + return requestPoliciesBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.api.MethodPolicy) + } + + // @@protoc_insertion_point(class_scope:google.api.MethodPolicy) + private static final com.google.api.MethodPolicy DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.api.MethodPolicy(); + } + + public static com.google.api.MethodPolicy getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public MethodPolicy parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.api.MethodPolicy getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/MethodPolicyOrBuilder.java b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/MethodPolicyOrBuilder.java new file mode 100644 index 0000000000..f417591bea --- /dev/null +++ b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/MethodPolicyOrBuilder.java @@ -0,0 +1,115 @@ +/* + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/policy.proto + +package com.google.api; + +public interface MethodPolicyOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.api.MethodPolicy) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Selects a method to which these policies should be enforced, for example,
+   * "google.pubsub.v1.Subscriber.CreateSubscription".
+   *
+   * Refer to [selector][google.api.DocumentationRule.selector] for syntax
+   * details.
+   *
+   * NOTE: This field must not be set in the proto annotation. It will be
+   * automatically filled by the service config compiler .
+   * 
+ * + * string selector = 9; + * + * @return The selector. + */ + java.lang.String getSelector(); + /** + * + * + *
+   * Selects a method to which these policies should be enforced, for example,
+   * "google.pubsub.v1.Subscriber.CreateSubscription".
+   *
+   * Refer to [selector][google.api.DocumentationRule.selector] for syntax
+   * details.
+   *
+   * NOTE: This field must not be set in the proto annotation. It will be
+   * automatically filled by the service config compiler .
+   * 
+ * + * string selector = 9; + * + * @return The bytes for selector. + */ + com.google.protobuf.ByteString getSelectorBytes(); + + /** + * + * + *
+   * Policies that are applicable to the request message.
+   * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + java.util.List getRequestPoliciesList(); + /** + * + * + *
+   * Policies that are applicable to the request message.
+   * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + com.google.api.FieldPolicy getRequestPolicies(int index); + /** + * + * + *
+   * Policies that are applicable to the request message.
+   * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + int getRequestPoliciesCount(); + /** + * + * + *
+   * Policies that are applicable to the request message.
+   * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + java.util.List getRequestPoliciesOrBuilderList(); + /** + * + * + *
+   * Policies that are applicable to the request message.
+   * 
+ * + * repeated .google.api.FieldPolicy request_policies = 2; + */ + com.google.api.FieldPolicyOrBuilder getRequestPoliciesOrBuilder(int index); +} diff --git a/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/PolicyProto.java b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/PolicyProto.java new file mode 100644 index 0000000000..96f4f9abe8 --- /dev/null +++ b/java-common-protos/proto-google-common-protos/src/main/java/com/google/api/PolicyProto.java @@ -0,0 +1,123 @@ +/* + * 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 + * + * https://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. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/api/policy.proto + +package com.google.api; + +public final class PolicyProto { + private PolicyProto() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) { + registry.add(com.google.api.PolicyProto.fieldPolicy); + registry.add(com.google.api.PolicyProto.methodPolicy); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + public static final int FIELD_POLICY_FIELD_NUMBER = 158361448; + /** + * + * + *
+   * See [FieldPolicy][].
+   * 
+ * + * extend .google.protobuf.FieldOptions { ... } + */ + public static final com.google.protobuf.GeneratedMessage.GeneratedExtension< + com.google.protobuf.DescriptorProtos.FieldOptions, com.google.api.FieldPolicy> + fieldPolicy = + com.google.protobuf.GeneratedMessage.newFileScopedGeneratedExtension( + com.google.api.FieldPolicy.class, com.google.api.FieldPolicy.getDefaultInstance()); + + public static final int METHOD_POLICY_FIELD_NUMBER = 161893301; + /** + * + * + *
+   * See [MethodPolicy][].
+   * 
+ * + * extend .google.protobuf.MethodOptions { ... } + */ + public static final com.google.protobuf.GeneratedMessage.GeneratedExtension< + com.google.protobuf.DescriptorProtos.MethodOptions, com.google.api.MethodPolicy> + methodPolicy = + com.google.protobuf.GeneratedMessage.newFileScopedGeneratedExtension( + com.google.api.MethodPolicy.class, com.google.api.MethodPolicy.getDefaultInstance()); + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_FieldPolicy_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_api_FieldPolicy_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_api_MethodPolicy_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_api_MethodPolicy_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\027google/api/policy.proto\022\ngoogle.api\032 g" + + "oogle/protobuf/descriptor.proto\"S\n\013Field" + + "Policy\022\020\n\010selector\030\001 \001(\t\022\033\n\023resource_per" + + "mission\030\002 \001(\t\022\025\n\rresource_type\030\003 \001(\t\"S\n\014" + + "MethodPolicy\022\020\n\010selector\030\t \001(\t\0221\n\020reques" + + "t_policies\030\002 \003(\0132\027.google.api.FieldPolic" + + "y:O\n\014field_policy\022\035.google.protobuf.Fiel" + + "dOptions\030\350\316\301K \001(\0132\027.google.api.FieldPoli" + + "cy:R\n\rmethod_policy\022\036.google.protobuf.Me" + + "thodOptions\030\265\227\231M \001(\0132\030.google.api.Method" + + "PolicyBp\n\016com.google.apiB\013PolicyProtoP\001Z" + + "Egoogle.golang.org/genproto/googleapis/a" + + "pi/serviceconfig;serviceconfig\370\001\001\242\002\004GAPI" + + "b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.DescriptorProtos.getDescriptor(), + }); + internal_static_google_api_FieldPolicy_descriptor = getDescriptor().getMessageTypes().get(0); + internal_static_google_api_FieldPolicy_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_api_FieldPolicy_descriptor, + new java.lang.String[] { + "Selector", "ResourcePermission", "ResourceType", + }); + internal_static_google_api_MethodPolicy_descriptor = getDescriptor().getMessageTypes().get(1); + internal_static_google_api_MethodPolicy_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_api_MethodPolicy_descriptor, + new java.lang.String[] { + "Selector", "RequestPolicies", + }); + fieldPolicy.internalInit(descriptor.getExtensions().get(0)); + methodPolicy.internalInit(descriptor.getExtensions().get(1)); + com.google.protobuf.DescriptorProtos.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-common-protos/proto-google-common-protos/src/main/proto/google/api/control.proto b/java-common-protos/proto-google-common-protos/src/main/proto/google/api/control.proto index 275e4388a3..cbbce6f61f 100644 --- a/java-common-protos/proto-google-common-protos/src/main/proto/google/api/control.proto +++ b/java-common-protos/proto-google-common-protos/src/main/proto/google/api/control.proto @@ -16,6 +16,8 @@ syntax = "proto3"; package google.api; +import "google/api/policy.proto"; + option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; option java_multiple_files = true; option java_outer_classname = "ControlProto"; @@ -33,4 +35,7 @@ message Control { // feature (like quota and billing) will be enabled. The recommended value for // most services is servicecontrol.googleapis.com string environment = 1; + + // Defines policies applying to the API methods of the service. + repeated MethodPolicy method_policies = 4; } diff --git a/java-common-protos/proto-google-common-protos/src/main/proto/google/api/policy.proto b/java-common-protos/proto-google-common-protos/src/main/proto/google/api/policy.proto new file mode 100644 index 0000000000..dd202bc872 --- /dev/null +++ b/java-common-protos/proto-google-common-protos/src/main/proto/google/api/policy.proto @@ -0,0 +1,85 @@ +// Copyright 2023 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 cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/serviceconfig;serviceconfig"; +option java_multiple_files = true; +option java_outer_classname = "PolicyProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +// Provides `google.api.field_policy` annotation at proto fields. +extend google.protobuf.FieldOptions { + // See [FieldPolicy][]. + FieldPolicy field_policy = 158361448; +} + +// Provides `google.api.method_policy` annotation at proto methods. +extend google.protobuf.MethodOptions { + // See [MethodPolicy][]. + MethodPolicy method_policy = 161893301; +} + +// Google API Policy Annotation +// +// This message defines a simple API policy annotation that can be used to +// annotate API request and response message fields with applicable policies. +// One field may have multiple applicable policies that must all be satisfied +// before a request can be processed. This policy annotation is used to +// generate the overall policy that will be used for automatic runtime +// policy enforcement and documentation generation. +message FieldPolicy { + // Selects one or more request or response message fields to apply this + // `FieldPolicy`. + // + // When a `FieldPolicy` is used in proto annotation, the selector must + // be left as empty. The service config generator will automatically fill + // the correct value. + // + // When a `FieldPolicy` is used in service config, the selector must be a + // comma-separated string with valid request or response field paths, + // such as "foo.bar" or "foo.bar,foo.baz". + string selector = 1; + + // Specifies the required permission(s) for the resource referred to by the + // field. It requires the field contains a valid resource reference, and + // the request must pass the permission checks to proceed. For example, + // "resourcemanager.projects.get". + string resource_permission = 2; + + // Specifies the resource type for the resource referred to by the field. + string resource_type = 3; +} + +// Defines policies applying to an RPC method. +message MethodPolicy { + // Selects a method to which these policies should be enforced, for example, + // "google.pubsub.v1.Subscriber.CreateSubscription". + // + // Refer to [selector][google.api.DocumentationRule.selector] for syntax + // details. + // + // NOTE: This field must not be set in the proto annotation. It will be + // automatically filled by the service config compiler . + string selector = 9; + + // Policies that are applicable to the request message. + repeated FieldPolicy request_policies = 2; +}