diff --git a/google-cloud-orgpolicy-bom/pom.xml b/google-cloud-orgpolicy-bom/pom.xml new file mode 100644 index 0000000..e33088f --- /dev/null +++ b/google-cloud-orgpolicy-bom/pom.xml @@ -0,0 +1,101 @@ + + 4.0.0 + com.google.cloud + google-cloud-orgpolicy-bom + 1.0.12-SNAPSHOT + pom + + com.google.cloud + google-cloud-shared-config + 0.10.0 + + + Google Cloud Org Policy BOM + BOM for Google Cloud Org Policy + + + + Google LLC + + + + chingor13 + Jeff Ching + chingor@google.com + Google LLC + + Developer + + + + + + scm:git:https://github.com/googleapis/java-orgpolicy.git + scm:git:git@github.com:googleapis/java-orgpolicy.git + https://github.com/googleapis/java-orgpolicy + + + + true + + + + + sonatype-nexus-snapshots + https://oss.sonatype.org/content/repositories/snapshots + + + sonatype-nexus-staging + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + + + com.google.cloud + google-cloud-orgpolicy + 1.0.12-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-orgpolicy-v1 + 1.0.12-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-orgpolicy-v2 + 1.0.12-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-orgpolicy-v2 + 1.0.12-SNAPSHOT + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + true + + + + + + \ No newline at end of file diff --git a/google-cloud-orgpolicy/pom.xml b/google-cloud-orgpolicy/pom.xml new file mode 100644 index 0000000..460bb8d --- /dev/null +++ b/google-cloud-orgpolicy/pom.xml @@ -0,0 +1,111 @@ + + 4.0.0 + com.google.cloud + google-cloud-orgpolicy + 1.0.12-SNAPSHOT + Google Cloud Org Policy + The Org Policy API allows users to configure governance rules on + their GCP resources across the Cloud Resource Hierarchy. + + + com.google.cloud + google-cloud-orgpolicy-parent + 1.0.12-SNAPSHOT + + + google-cloud-orgpolicy + + + + io.grpc + grpc-api + + + io.grpc + grpc-stub + + + io.grpc + grpc-protobuf + + + com.google.api + api-common + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-common-protos + + + com.google.api.grpc + proto-google-cloud-orgpolicy-v2 + + + com.google.guava + guava + + + com.google.api + gax + + + com.google.api + gax-grpc + + + org.threeten + threetenbp + + + + + junit + junit + test + 4.13.1 + + + + com.google.api.grpc + grpc-google-cloud-orgpolicy-v2 + test + + + + com.google.api + gax-grpc + testlib + test + + + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + + \ No newline at end of file diff --git a/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicyClient.java b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicyClient.java new file mode 100644 index 0000000..0e18605 --- /dev/null +++ b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicyClient.java @@ -0,0 +1,1380 @@ +/* + * 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. + */ + +package com.google.cloud.orgpolicy.v2; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.orgpolicy.v2.stub.OrgPolicyStub; +import com.google.cloud.orgpolicy.v2.stub.OrgPolicyStubSettings; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Service Description: An interface for managing organization policies. + * + *

The Cloud Org Policy service provides a simple mechanism for organizations to restrict the + * allowed configurations across their entire Cloud Resource hierarchy. + * + *

You can use a `policy` to configure restrictions in Cloud resources. For example, you can + * enforce a `policy` that restricts which Google Cloud Platform APIs can be activated in a certain + * part of your resource hierarchy, or prevents serial port access to VM instances in a particular + * folder. + * + *

`Policies` are inherited down through the resource hierarchy. A `policy` applied to a parent + * resource automatically applies to all its child resources unless overridden with a `policy` lower + * in the hierarchy. + * + *

A `constraint` defines an aspect of a resource's configuration that can be controlled by an + * organization's policy administrator. `Policies` are a collection of `constraints` that defines + * their allowable configuration on a particular resource and its child resources. + * + *

This class provides the ability to make remote calls to the backing service through method + * calls that map to API methods. Sample code to get started: + * + *

{@code
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ *   PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]");
+ *   Policy response = orgPolicyClient.getPolicy(name);
+ * }
+ * }
+ * + *

Note: close() needs to be called on the OrgPolicyClient object to clean up resources such as + * threads. In the example above, try-with-resources is used, which automatically calls close(). + * + *

The surface of this class includes several types of Java methods for each of the API's + * methods: + * + *

    + *
  1. A "flattened" method. With this type of method, the fields of the request type have been + * converted into function parameters. It may be the case that not all fields are available as + * parameters, and not every API method will have a flattened method entry point. + *
  2. A "request object" method. This type of method only takes one parameter, a request object, + * which must be constructed before the call. Not every API method will have a request object + * method. + *
  3. A "callable" method. This type of method takes no parameters and returns an immutable API + * callable object, which can be used to initiate calls to the service. + *
+ * + *

See the individual methods for example code. + * + *

Many parameters require resource names to be formatted in a particular way. To assist with + * these names, this class includes a format method for each type of name, and additionally a parse + * method to extract the individual identifiers contained within names that are returned. + * + *

This class can be customized by passing in a custom instance of OrgPolicySettings to create(). + * For example: + * + *

To customize credentials: + * + *

{@code
+ * OrgPolicySettings orgPolicySettings =
+ *     OrgPolicySettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * OrgPolicyClient orgPolicyClient = OrgPolicyClient.create(orgPolicySettings);
+ * }
+ * + *

To customize the endpoint: + * + *

{@code
+ * OrgPolicySettings orgPolicySettings =
+ *     OrgPolicySettings.newBuilder().setEndpoint(myEndpoint).build();
+ * OrgPolicyClient orgPolicyClient = OrgPolicyClient.create(orgPolicySettings);
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@Generated("by gapic-generator-java") +public class OrgPolicyClient implements BackgroundResource { + private final OrgPolicySettings settings; + private final OrgPolicyStub stub; + + /** Constructs an instance of OrgPolicyClient with default settings. */ + public static final OrgPolicyClient create() throws IOException { + return create(OrgPolicySettings.newBuilder().build()); + } + + /** + * Constructs an instance of OrgPolicyClient, using the given settings. The channels are created + * based on the settings passed in, or defaults for any settings that are not set. + */ + public static final OrgPolicyClient create(OrgPolicySettings settings) throws IOException { + return new OrgPolicyClient(settings); + } + + /** + * Constructs an instance of OrgPolicyClient, using the given stub for making calls. This is for + * advanced usage - prefer using create(OrgPolicySettings). + */ + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public static final OrgPolicyClient create(OrgPolicyStub stub) { + return new OrgPolicyClient(stub); + } + + /** + * Constructs an instance of OrgPolicyClient, using the given settings. This is protected so that + * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected OrgPolicyClient(OrgPolicySettings settings) throws IOException { + this.settings = settings; + this.stub = ((OrgPolicyStubSettings) settings.getStubSettings()).createStub(); + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + protected OrgPolicyClient(OrgPolicyStub stub) { + this.settings = null; + this.stub = stub; + } + + public final OrgPolicySettings getSettings() { + return settings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public OrgPolicyStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists `Constraints` that could be applied on the specified resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   FolderName parent = FolderName.of("[FOLDER]");
+   *   for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param parent Required. The Cloud resource that parents the constraint. Must be in one of the + * following forms: + * + * + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListConstraintsPagedResponse listConstraints(FolderName parent) { + ListConstraintsRequest request = + ListConstraintsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listConstraints(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists `Constraints` that could be applied on the specified resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+   *   for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param parent Required. The Cloud resource that parents the constraint. Must be in one of the + * following forms: + * + * + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListConstraintsPagedResponse listConstraints(OrganizationName parent) { + ListConstraintsRequest request = + ListConstraintsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listConstraints(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists `Constraints` that could be applied on the specified resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param parent Required. The Cloud resource that parents the constraint. Must be in one of the + * following forms: + * + * + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListConstraintsPagedResponse listConstraints(ProjectName parent) { + ListConstraintsRequest request = + ListConstraintsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listConstraints(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists `Constraints` that could be applied on the specified resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   String parent =
+   *       ConstraintName.ofProjectConstraintName("[PROJECT]", "[CONSTRAINT]").toString();
+   *   for (Constraint element : orgPolicyClient.listConstraints(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param parent Required. The Cloud resource that parents the constraint. Must be in one of the + * following forms: + * + * + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListConstraintsPagedResponse listConstraints(String parent) { + ListConstraintsRequest request = ListConstraintsRequest.newBuilder().setParent(parent).build(); + return listConstraints(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists `Constraints` that could be applied on the specified resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   ListConstraintsRequest request =
+   *       ListConstraintsRequest.newBuilder()
+   *           .setParent(
+   *               ConstraintName.ofProjectConstraintName("[PROJECT]", "[CONSTRAINT]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Constraint element : orgPolicyClient.listConstraints(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListConstraintsPagedResponse listConstraints(ListConstraintsRequest request) { + return listConstraintsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists `Constraints` that could be applied on the specified resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   ListConstraintsRequest request =
+   *       ListConstraintsRequest.newBuilder()
+   *           .setParent(
+   *               ConstraintName.ofProjectConstraintName("[PROJECT]", "[CONSTRAINT]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       orgPolicyClient.listConstraintsPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Constraint element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + listConstraintsPagedCallable() { + return stub.listConstraintsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists `Constraints` that could be applied on the specified resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   while (true) {
+   *     ListConstraintsResponse response = orgPolicyClient.listConstraintsCallable().call(request);
+   *     for (Constraint element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + listConstraintsCallable() { + return stub.listConstraintsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves all of the `Policies` that exist on a particular resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   FolderName parent = FolderName.of("[FOLDER]");
+   *   for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param parent Required. The target Cloud resource that parents the set of constraints and + * policies that will be returned from this call. Must be in one of the following forms: + * + * + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListPoliciesPagedResponse listPolicies(FolderName parent) { + ListPoliciesRequest request = + ListPoliciesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listPolicies(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves all of the `Policies` that exist on a particular resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+   *   for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param parent Required. The target Cloud resource that parents the set of constraints and + * policies that will be returned from this call. Must be in one of the following forms: + * + * + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListPoliciesPagedResponse listPolicies(OrganizationName parent) { + ListPoliciesRequest request = + ListPoliciesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listPolicies(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves all of the `Policies` that exist on a particular resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param parent Required. The target Cloud resource that parents the set of constraints and + * policies that will be returned from this call. Must be in one of the following forms: + * + * + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListPoliciesPagedResponse listPolicies(ProjectName parent) { + ListPoliciesRequest request = + ListPoliciesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listPolicies(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves all of the `Policies` that exist on a particular resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   String parent = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString();
+   *   for (Policy element : orgPolicyClient.listPolicies(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param parent Required. The target Cloud resource that parents the set of constraints and + * policies that will be returned from this call. Must be in one of the following forms: + * + * + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListPoliciesPagedResponse listPolicies(String parent) { + ListPoliciesRequest request = ListPoliciesRequest.newBuilder().setParent(parent).build(); + return listPolicies(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves all of the `Policies` that exist on a particular resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   ListPoliciesRequest request =
+   *       ListPoliciesRequest.newBuilder()
+   *           .setParent(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Policy element : orgPolicyClient.listPolicies(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListPoliciesPagedResponse listPolicies(ListPoliciesRequest request) { + return listPoliciesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves all of the `Policies` that exist on a particular resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   ListPoliciesRequest request =
+   *       ListPoliciesRequest.newBuilder()
+   *           .setParent(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future = orgPolicyClient.listPoliciesPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Policy element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + listPoliciesPagedCallable() { + return stub.listPoliciesPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Retrieves all of the `Policies` that exist on a particular resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   while (true) {
+   *     ListPoliciesResponse response = orgPolicyClient.listPoliciesCallable().call(request);
+   *     for (Policy element : response.getResponsesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable listPoliciesCallable() { + return stub.listPoliciesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a `Policy` on a resource. + * + *

If no `Policy` is set on the resource, NOT_FOUND is returned. The `etag` value can be used + * with `UpdatePolicy()` to update a `Policy` during read-modify-write. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]");
+   *   Policy response = orgPolicyClient.getPolicy(name);
+   * }
+   * }
+ * + * @param name Required. Resource name of the policy. See `Policy` for naming requirements. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getPolicy(PolicyName name) { + GetPolicyRequest request = + GetPolicyRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a `Policy` on a resource. + * + *

If no `Policy` is set on the resource, NOT_FOUND is returned. The `etag` value can be used + * with `UpdatePolicy()` to update a `Policy` during read-modify-write. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   String name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString();
+   *   Policy response = orgPolicyClient.getPolicy(name);
+   * }
+   * }
+ * + * @param name Required. Resource name of the policy. See `Policy` for naming requirements. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getPolicy(String name) { + GetPolicyRequest request = GetPolicyRequest.newBuilder().setName(name).build(); + return getPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a `Policy` on a resource. + * + *

If no `Policy` is set on the resource, NOT_FOUND is returned. The `etag` value can be used + * with `UpdatePolicy()` to update a `Policy` during read-modify-write. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   GetPolicyRequest request =
+   *       GetPolicyRequest.newBuilder()
+   *           .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
+   *           .build();
+   *   Policy response = orgPolicyClient.getPolicy(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getPolicy(GetPolicyRequest request) { + return getPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a `Policy` on a resource. + * + *

If no `Policy` is set on the resource, NOT_FOUND is returned. The `etag` value can be used + * with `UpdatePolicy()` to update a `Policy` during read-modify-write. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   GetPolicyRequest request =
+   *       GetPolicyRequest.newBuilder()
+   *           .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
+   *           .build();
+   *   ApiFuture future = orgPolicyClient.getPolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getPolicyCallable() { + return stub.getPolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the + * resource hierarchy and evaluating conditions. The returned `Policy` will not have an `etag` or + * `condition` set because it is a computed `Policy` across multiple resources. Subtrees of + * Resource Manager resource hierarchy with 'under:' prefix will not be expanded. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]");
+   *   Policy response = orgPolicyClient.getEffectivePolicy(name);
+   * }
+   * }
+ * + * @param name Required. The effective policy to compute. See `Policy` for naming rules. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getEffectivePolicy(PolicyName name) { + GetEffectivePolicyRequest request = + GetEffectivePolicyRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getEffectivePolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the + * resource hierarchy and evaluating conditions. The returned `Policy` will not have an `etag` or + * `condition` set because it is a computed `Policy` across multiple resources. Subtrees of + * Resource Manager resource hierarchy with 'under:' prefix will not be expanded. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   String name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString();
+   *   Policy response = orgPolicyClient.getEffectivePolicy(name);
+   * }
+   * }
+ * + * @param name Required. The effective policy to compute. See `Policy` for naming rules. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getEffectivePolicy(String name) { + GetEffectivePolicyRequest request = + GetEffectivePolicyRequest.newBuilder().setName(name).build(); + return getEffectivePolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the + * resource hierarchy and evaluating conditions. The returned `Policy` will not have an `etag` or + * `condition` set because it is a computed `Policy` across multiple resources. Subtrees of + * Resource Manager resource hierarchy with 'under:' prefix will not be expanded. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   GetEffectivePolicyRequest request =
+   *       GetEffectivePolicyRequest.newBuilder()
+   *           .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
+   *           .build();
+   *   Policy response = orgPolicyClient.getEffectivePolicy(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy getEffectivePolicy(GetEffectivePolicyRequest request) { + return getEffectivePolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the effective `Policy` on a resource. This is the result of merging `Policies` in the + * resource hierarchy and evaluating conditions. The returned `Policy` will not have an `etag` or + * `condition` set because it is a computed `Policy` across multiple resources. Subtrees of + * Resource Manager resource hierarchy with 'under:' prefix will not be expanded. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   GetEffectivePolicyRequest request =
+   *       GetEffectivePolicyRequest.newBuilder()
+   *           .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
+   *           .build();
+   *   ApiFuture future = orgPolicyClient.getEffectivePolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getEffectivePolicyCallable() { + return stub.getEffectivePolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a Policy. + * + *

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not + * exist. Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the policy + * already exists on the given Cloud resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   FolderName parent = FolderName.of("[FOLDER]");
+   *   Policy policy = Policy.newBuilder().build();
+   *   Policy response = orgPolicyClient.createPolicy(parent, policy);
+   * }
+   * }
+ * + * @param parent Required. The Cloud resource that will parent the new Policy. Must be in one of + * the following forms: + *
    + *
  • `projects/{project_number}` + *
  • `projects/{project_id}` + *
  • `folders/{folder_id}` + *
  • `organizations/{organization_id}` + *
+ * + * @param policy Required. `Policy` to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy createPolicy(FolderName parent, Policy policy) { + CreatePolicyRequest request = + CreatePolicyRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setPolicy(policy) + .build(); + return createPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a Policy. + * + *

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not + * exist. Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the policy + * already exists on the given Cloud resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
+   *   Policy policy = Policy.newBuilder().build();
+   *   Policy response = orgPolicyClient.createPolicy(parent, policy);
+   * }
+   * }
+ * + * @param parent Required. The Cloud resource that will parent the new Policy. Must be in one of + * the following forms: + *
    + *
  • `projects/{project_number}` + *
  • `projects/{project_id}` + *
  • `folders/{folder_id}` + *
  • `organizations/{organization_id}` + *
+ * + * @param policy Required. `Policy` to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy createPolicy(OrganizationName parent, Policy policy) { + CreatePolicyRequest request = + CreatePolicyRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setPolicy(policy) + .build(); + return createPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a Policy. + * + *

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not + * exist. Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the policy + * already exists on the given Cloud resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   Policy policy = Policy.newBuilder().build();
+   *   Policy response = orgPolicyClient.createPolicy(parent, policy);
+   * }
+   * }
+ * + * @param parent Required. The Cloud resource that will parent the new Policy. Must be in one of + * the following forms: + *
    + *
  • `projects/{project_number}` + *
  • `projects/{project_id}` + *
  • `folders/{folder_id}` + *
  • `organizations/{organization_id}` + *
+ * + * @param policy Required. `Policy` to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy createPolicy(ProjectName parent, Policy policy) { + CreatePolicyRequest request = + CreatePolicyRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setPolicy(policy) + .build(); + return createPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a Policy. + * + *

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not + * exist. Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the policy + * already exists on the given Cloud resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   String parent = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString();
+   *   Policy policy = Policy.newBuilder().build();
+   *   Policy response = orgPolicyClient.createPolicy(parent, policy);
+   * }
+   * }
+ * + * @param parent Required. The Cloud resource that will parent the new Policy. Must be in one of + * the following forms: + *
    + *
  • `projects/{project_number}` + *
  • `projects/{project_id}` + *
  • `folders/{folder_id}` + *
  • `organizations/{organization_id}` + *
+ * + * @param policy Required. `Policy` to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy createPolicy(String parent, Policy policy) { + CreatePolicyRequest request = + CreatePolicyRequest.newBuilder().setParent(parent).setPolicy(policy).build(); + return createPolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a Policy. + * + *

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not + * exist. Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the policy + * already exists on the given Cloud resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   CreatePolicyRequest request =
+   *       CreatePolicyRequest.newBuilder()
+   *           .setParent(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
+   *           .setPolicy(Policy.newBuilder().build())
+   *           .build();
+   *   Policy response = orgPolicyClient.createPolicy(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy createPolicy(CreatePolicyRequest request) { + return createPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a Policy. + * + *

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint does not + * exist. Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the policy + * already exists on the given Cloud resource. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   CreatePolicyRequest request =
+   *       CreatePolicyRequest.newBuilder()
+   *           .setParent(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
+   *           .setPolicy(Policy.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = orgPolicyClient.createPolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable createPolicyCallable() { + return stub.createPolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a Policy. + * + *

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or the + * policy do not exist. Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag + * supplied in the request does not match the persisted etag of the policy + * + *

Note: the supplied policy will perform a full overwrite of all fields. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   Policy policy = Policy.newBuilder().build();
+   *   Policy response = orgPolicyClient.updatePolicy(policy);
+   * }
+   * }
+ * + * @param policy Required. `Policy` to update. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy updatePolicy(Policy policy) { + UpdatePolicyRequest request = UpdatePolicyRequest.newBuilder().setPolicy(policy).build(); + return updatePolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a Policy. + * + *

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or the + * policy do not exist. Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag + * supplied in the request does not match the persisted etag of the policy + * + *

Note: the supplied policy will perform a full overwrite of all fields. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   UpdatePolicyRequest request =
+   *       UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
+   *   Policy response = orgPolicyClient.updatePolicy(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Policy updatePolicy(UpdatePolicyRequest request) { + return updatePolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a Policy. + * + *

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or the + * policy do not exist. Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag + * supplied in the request does not match the persisted etag of the policy + * + *

Note: the supplied policy will perform a full overwrite of all fields. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   UpdatePolicyRequest request =
+   *       UpdatePolicyRequest.newBuilder().setPolicy(Policy.newBuilder().build()).build();
+   *   ApiFuture future = orgPolicyClient.updatePolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable updatePolicyCallable() { + return stub.updatePolicyCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a Policy. + * + *

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or Org + * Policy does not exist. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]");
+   *   orgPolicyClient.deletePolicy(name);
+   * }
+   * }
+ * + * @param name Required. Name of the policy to delete. See `Policy` for naming rules. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deletePolicy(PolicyName name) { + DeletePolicyRequest request = + DeletePolicyRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deletePolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a Policy. + * + *

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or Org + * Policy does not exist. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   String name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString();
+   *   orgPolicyClient.deletePolicy(name);
+   * }
+   * }
+ * + * @param name Required. Name of the policy to delete. See `Policy` for naming rules. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deletePolicy(String name) { + DeletePolicyRequest request = DeletePolicyRequest.newBuilder().setName(name).build(); + deletePolicy(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a Policy. + * + *

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or Org + * Policy does not exist. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   DeletePolicyRequest request =
+   *       DeletePolicyRequest.newBuilder()
+   *           .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
+   *           .build();
+   *   orgPolicyClient.deletePolicy(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deletePolicy(DeletePolicyRequest request) { + deletePolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a Policy. + * + *

Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the constraint or Org + * Policy does not exist. + * + *

Sample code: + * + *

{@code
+   * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+   *   DeletePolicyRequest request =
+   *       DeletePolicyRequest.newBuilder()
+   *           .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString())
+   *           .build();
+   *   ApiFuture future = orgPolicyClient.deletePolicyCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
+ */ + public final UnaryCallable deletePolicyCallable() { + return stub.deletePolicyCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + public static class ListConstraintsPagedResponse + extends AbstractPagedListResponse< + ListConstraintsRequest, + ListConstraintsResponse, + Constraint, + ListConstraintsPage, + ListConstraintsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListConstraintsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListConstraintsPagedResponse apply(ListConstraintsPage input) { + return new ListConstraintsPagedResponse(input); + } + }, + MoreExecutors.directExecutor()); + } + + private ListConstraintsPagedResponse(ListConstraintsPage page) { + super(page, ListConstraintsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListConstraintsPage + extends AbstractPage< + ListConstraintsRequest, ListConstraintsResponse, Constraint, ListConstraintsPage> { + + private ListConstraintsPage( + PageContext context, + ListConstraintsResponse response) { + super(context, response); + } + + private static ListConstraintsPage createEmptyPage() { + return new ListConstraintsPage(null, null); + } + + @Override + protected ListConstraintsPage createPage( + PageContext context, + ListConstraintsResponse response) { + return new ListConstraintsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListConstraintsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListConstraintsRequest, + ListConstraintsResponse, + Constraint, + ListConstraintsPage, + ListConstraintsFixedSizeCollection> { + + private ListConstraintsFixedSizeCollection( + List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListConstraintsFixedSizeCollection createEmptyCollection() { + return new ListConstraintsFixedSizeCollection(null, 0); + } + + @Override + protected ListConstraintsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListConstraintsFixedSizeCollection(pages, collectionSize); + } + } + + public static class ListPoliciesPagedResponse + extends AbstractPagedListResponse< + ListPoliciesRequest, + ListPoliciesResponse, + Policy, + ListPoliciesPage, + ListPoliciesFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListPoliciesPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + new ApiFunction() { + @Override + public ListPoliciesPagedResponse apply(ListPoliciesPage input) { + return new ListPoliciesPagedResponse(input); + } + }, + MoreExecutors.directExecutor()); + } + + private ListPoliciesPagedResponse(ListPoliciesPage page) { + super(page, ListPoliciesFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListPoliciesPage + extends AbstractPage { + + private ListPoliciesPage( + PageContext context, + ListPoliciesResponse response) { + super(context, response); + } + + private static ListPoliciesPage createEmptyPage() { + return new ListPoliciesPage(null, null); + } + + @Override + protected ListPoliciesPage createPage( + PageContext context, + ListPoliciesResponse response) { + return new ListPoliciesPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListPoliciesFixedSizeCollection + extends AbstractFixedSizeCollection< + ListPoliciesRequest, + ListPoliciesResponse, + Policy, + ListPoliciesPage, + ListPoliciesFixedSizeCollection> { + + private ListPoliciesFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListPoliciesFixedSizeCollection createEmptyCollection() { + return new ListPoliciesFixedSizeCollection(null, 0); + } + + @Override + protected ListPoliciesFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListPoliciesFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicySettings.java b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicySettings.java new file mode 100644 index 0000000..9c4a955 --- /dev/null +++ b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicySettings.java @@ -0,0 +1,253 @@ +/* + * 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. + */ + +package com.google.cloud.orgpolicy.v2; + +import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse; +import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.orgpolicy.v2.stub.OrgPolicyStubSettings; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link OrgPolicyClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (orgpolicy.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *

For example, to set the total timeout of getPolicy to 30 seconds: + * + *

{@code
+ * OrgPolicySettings.Builder orgPolicySettingsBuilder = OrgPolicySettings.newBuilder();
+ * orgPolicySettingsBuilder
+ *     .getPolicySettings()
+ *     .setRetrySettings(
+ *         orgPolicySettingsBuilder
+ *             .getPolicySettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * OrgPolicySettings orgPolicySettings = orgPolicySettingsBuilder.build();
+ * }
+ */ +@Generated("by gapic-generator-java") +public class OrgPolicySettings extends ClientSettings { + + /** Returns the object with the settings used for calls to listConstraints. */ + public PagedCallSettings< + ListConstraintsRequest, ListConstraintsResponse, ListConstraintsPagedResponse> + listConstraintsSettings() { + return ((OrgPolicyStubSettings) getStubSettings()).listConstraintsSettings(); + } + + /** Returns the object with the settings used for calls to listPolicies. */ + public PagedCallSettings + listPoliciesSettings() { + return ((OrgPolicyStubSettings) getStubSettings()).listPoliciesSettings(); + } + + /** Returns the object with the settings used for calls to getPolicy. */ + public UnaryCallSettings getPolicySettings() { + return ((OrgPolicyStubSettings) getStubSettings()).getPolicySettings(); + } + + /** Returns the object with the settings used for calls to getEffectivePolicy. */ + public UnaryCallSettings getEffectivePolicySettings() { + return ((OrgPolicyStubSettings) getStubSettings()).getEffectivePolicySettings(); + } + + /** Returns the object with the settings used for calls to createPolicy. */ + public UnaryCallSettings createPolicySettings() { + return ((OrgPolicyStubSettings) getStubSettings()).createPolicySettings(); + } + + /** Returns the object with the settings used for calls to updatePolicy. */ + public UnaryCallSettings updatePolicySettings() { + return ((OrgPolicyStubSettings) getStubSettings()).updatePolicySettings(); + } + + /** Returns the object with the settings used for calls to deletePolicy. */ + public UnaryCallSettings deletePolicySettings() { + return ((OrgPolicyStubSettings) getStubSettings()).deletePolicySettings(); + } + + public static final OrgPolicySettings create(OrgPolicyStubSettings stub) throws IOException { + return new OrgPolicySettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return OrgPolicyStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return OrgPolicyStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return OrgPolicyStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return OrgPolicyStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return OrgPolicyStubSettings.defaultGrpcTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return OrgPolicyStubSettings.defaultTransportChannelProvider(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return OrgPolicyStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected OrgPolicySettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for OrgPolicySettings. */ + public static class Builder extends ClientSettings.Builder { + + protected Builder() throws IOException { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(OrgPolicyStubSettings.newBuilder(clientContext)); + } + + protected Builder(OrgPolicySettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(OrgPolicyStubSettings.Builder stubSettings) { + super(stubSettings); + } + + private static Builder createDefault() { + return new Builder(OrgPolicyStubSettings.newBuilder()); + } + + public OrgPolicyStubSettings.Builder getStubSettingsBuilder() { + return ((OrgPolicyStubSettings.Builder) getStubSettings()); + } + + // NEXT_MAJOR_VER: remove 'throws Exception'. + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** Returns the builder for the settings used for calls to listConstraints. */ + public PagedCallSettings.Builder< + ListConstraintsRequest, ListConstraintsResponse, ListConstraintsPagedResponse> + listConstraintsSettings() { + return getStubSettingsBuilder().listConstraintsSettings(); + } + + /** Returns the builder for the settings used for calls to listPolicies. */ + public PagedCallSettings.Builder< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse> + listPoliciesSettings() { + return getStubSettingsBuilder().listPoliciesSettings(); + } + + /** Returns the builder for the settings used for calls to getPolicy. */ + public UnaryCallSettings.Builder getPolicySettings() { + return getStubSettingsBuilder().getPolicySettings(); + } + + /** Returns the builder for the settings used for calls to getEffectivePolicy. */ + public UnaryCallSettings.Builder + getEffectivePolicySettings() { + return getStubSettingsBuilder().getEffectivePolicySettings(); + } + + /** Returns the builder for the settings used for calls to createPolicy. */ + public UnaryCallSettings.Builder createPolicySettings() { + return getStubSettingsBuilder().createPolicySettings(); + } + + /** Returns the builder for the settings used for calls to updatePolicy. */ + public UnaryCallSettings.Builder updatePolicySettings() { + return getStubSettingsBuilder().updatePolicySettings(); + } + + /** Returns the builder for the settings used for calls to deletePolicy. */ + public UnaryCallSettings.Builder deletePolicySettings() { + return getStubSettingsBuilder().deletePolicySettings(); + } + + @Override + public OrgPolicySettings build() throws IOException { + return new OrgPolicySettings(this); + } + } +} diff --git a/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/gapic_metadata.json b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/gapic_metadata.json new file mode 100644 index 0000000..6be4d57 --- /dev/null +++ b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/gapic_metadata.json @@ -0,0 +1,39 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "java", + "protoPackage": "google.cloud.orgpolicy.v2", + "libraryPackage": "com.google.cloud.orgpolicy.v2", + "services": { + "OrgPolicy": { + "clients": { + "grpc": { + "libraryClient": "OrgPolicyClient", + "rpcs": { + "CreatePolicy": { + "methods": ["createPolicy", "createPolicy", "createPolicy", "createPolicy", "createPolicy", "createPolicyCallable"] + }, + "DeletePolicy": { + "methods": ["deletePolicy", "deletePolicy", "deletePolicy", "deletePolicyCallable"] + }, + "GetEffectivePolicy": { + "methods": ["getEffectivePolicy", "getEffectivePolicy", "getEffectivePolicy", "getEffectivePolicyCallable"] + }, + "GetPolicy": { + "methods": ["getPolicy", "getPolicy", "getPolicy", "getPolicyCallable"] + }, + "ListConstraints": { + "methods": ["listConstraints", "listConstraints", "listConstraints", "listConstraints", "listConstraints", "listConstraintsPagedCallable", "listConstraintsCallable"] + }, + "ListPolicies": { + "methods": ["listPolicies", "listPolicies", "listPolicies", "listPolicies", "listPolicies", "listPoliciesPagedCallable", "listPoliciesCallable"] + }, + "UpdatePolicy": { + "methods": ["updatePolicy", "updatePolicy", "updatePolicyCallable"] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/package-info.java b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/package-info.java new file mode 100644 index 0000000..6a1cd3d --- /dev/null +++ b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/package-info.java @@ -0,0 +1,52 @@ +/* + * 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. + */ + +/** + * The interfaces provided are listed below, along with usage samples. + * + *

======================= OrgPolicyClient ======================= + * + *

Service Description: An interface for managing organization policies. + * + *

The Cloud Org Policy service provides a simple mechanism for organizations to restrict the + * allowed configurations across their entire Cloud Resource hierarchy. + * + *

You can use a `policy` to configure restrictions in Cloud resources. For example, you can + * enforce a `policy` that restricts which Google Cloud Platform APIs can be activated in a certain + * part of your resource hierarchy, or prevents serial port access to VM instances in a particular + * folder. + * + *

`Policies` are inherited down through the resource hierarchy. A `policy` applied to a parent + * resource automatically applies to all its child resources unless overridden with a `policy` lower + * in the hierarchy. + * + *

A `constraint` defines an aspect of a resource's configuration that can be controlled by an + * organization's policy administrator. `Policies` are a collection of `constraints` that defines + * their allowable configuration on a particular resource and its child resources. + * + *

Sample for OrgPolicyClient: + * + *

{@code
+ * try (OrgPolicyClient orgPolicyClient = OrgPolicyClient.create()) {
+ *   PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]");
+ *   Policy response = orgPolicyClient.getPolicy(name);
+ * }
+ * }
+ */ +@Generated("by gapic-generator-java") +package com.google.cloud.orgpolicy.v2; + +import javax.annotation.Generated; diff --git a/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/GrpcOrgPolicyCallableFactory.java b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/GrpcOrgPolicyCallableFactory.java new file mode 100644 index 0000000..e26ea7e --- /dev/null +++ b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/GrpcOrgPolicyCallableFactory.java @@ -0,0 +1,113 @@ +/* + * 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. + */ + +package com.google.cloud.orgpolicy.v2.stub; + +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC callable factory implementation for the OrgPolicy service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +public class GrpcOrgPolicyCallableFactory implements GrpcStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, callSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/GrpcOrgPolicyStub.java b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/GrpcOrgPolicyStub.java new file mode 100644 index 0000000..bc90ca4 --- /dev/null +++ b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/GrpcOrgPolicyStub.java @@ -0,0 +1,380 @@ +/* + * 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. + */ + +package com.google.cloud.orgpolicy.v2.stub; + +import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse; +import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.RequestParamsExtractor; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.orgpolicy.v2.CreatePolicyRequest; +import com.google.cloud.orgpolicy.v2.DeletePolicyRequest; +import com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest; +import com.google.cloud.orgpolicy.v2.GetPolicyRequest; +import com.google.cloud.orgpolicy.v2.ListConstraintsRequest; +import com.google.cloud.orgpolicy.v2.ListConstraintsResponse; +import com.google.cloud.orgpolicy.v2.ListPoliciesRequest; +import com.google.cloud.orgpolicy.v2.ListPoliciesResponse; +import com.google.cloud.orgpolicy.v2.Policy; +import com.google.cloud.orgpolicy.v2.UpdatePolicyRequest; +import com.google.common.collect.ImmutableMap; +import com.google.longrunning.stub.GrpcOperationsStub; +import com.google.protobuf.Empty; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC stub implementation for the OrgPolicy service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public class GrpcOrgPolicyStub extends OrgPolicyStub { + private static final MethodDescriptor + listConstraintsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/ListConstraints") + .setRequestMarshaller( + ProtoUtils.marshaller(ListConstraintsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListConstraintsResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + listPoliciesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/ListPolicies") + .setRequestMarshaller(ProtoUtils.marshaller(ListPoliciesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListPoliciesResponse.getDefaultInstance())) + .build(); + + private static final MethodDescriptor getPolicyMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/GetPolicy") + .setRequestMarshaller(ProtoUtils.marshaller(GetPolicyRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + getEffectivePolicyMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/GetEffectivePolicy") + .setRequestMarshaller( + ProtoUtils.marshaller(GetEffectivePolicyRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) + .build(); + + private static final MethodDescriptor createPolicyMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/CreatePolicy") + .setRequestMarshaller(ProtoUtils.marshaller(CreatePolicyRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) + .build(); + + private static final MethodDescriptor updatePolicyMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/UpdatePolicy") + .setRequestMarshaller(ProtoUtils.marshaller(UpdatePolicyRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) + .build(); + + private static final MethodDescriptor deletePolicyMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.orgpolicy.v2.OrgPolicy/DeletePolicy") + .setRequestMarshaller(ProtoUtils.marshaller(DeletePolicyRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .build(); + + private final UnaryCallable + listConstraintsCallable; + private final UnaryCallable + listConstraintsPagedCallable; + private final UnaryCallable listPoliciesCallable; + private final UnaryCallable + listPoliciesPagedCallable; + private final UnaryCallable getPolicyCallable; + private final UnaryCallable getEffectivePolicyCallable; + private final UnaryCallable createPolicyCallable; + private final UnaryCallable updatePolicyCallable; + private final UnaryCallable deletePolicyCallable; + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcOrgPolicyStub create(OrgPolicyStubSettings settings) throws IOException { + return new GrpcOrgPolicyStub(settings, ClientContext.create(settings)); + } + + public static final GrpcOrgPolicyStub create(ClientContext clientContext) throws IOException { + return new GrpcOrgPolicyStub(OrgPolicyStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcOrgPolicyStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcOrgPolicyStub( + OrgPolicyStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcOrgPolicyStub, using the given settings. This is protected so + * that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected GrpcOrgPolicyStub(OrgPolicyStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new GrpcOrgPolicyCallableFactory()); + } + + /** + * Constructs an instance of GrpcOrgPolicyStub, using the given settings. This is protected so + * that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected GrpcOrgPolicyStub( + OrgPolicyStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings + listConstraintsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listConstraintsMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(ListConstraintsRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); + GrpcCallSettings listPoliciesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listPoliciesMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(ListPoliciesRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); + GrpcCallSettings getPolicyTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getPolicyMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(GetPolicyRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings getEffectivePolicyTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getEffectivePolicyMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(GetEffectivePolicyRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings createPolicyTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createPolicyMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(CreatePolicyRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("parent", String.valueOf(request.getParent())); + return params.build(); + } + }) + .build(); + GrpcCallSettings updatePolicyTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updatePolicyMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(UpdatePolicyRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("policy.name", String.valueOf(request.getPolicy().getName())); + return params.build(); + } + }) + .build(); + GrpcCallSettings deletePolicyTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deletePolicyMethodDescriptor) + .setParamsExtractor( + new RequestParamsExtractor() { + @Override + public Map extract(DeletePolicyRequest request) { + ImmutableMap.Builder params = ImmutableMap.builder(); + params.put("name", String.valueOf(request.getName())); + return params.build(); + } + }) + .build(); + + this.listConstraintsCallable = + callableFactory.createUnaryCallable( + listConstraintsTransportSettings, settings.listConstraintsSettings(), clientContext); + this.listConstraintsPagedCallable = + callableFactory.createPagedCallable( + listConstraintsTransportSettings, settings.listConstraintsSettings(), clientContext); + this.listPoliciesCallable = + callableFactory.createUnaryCallable( + listPoliciesTransportSettings, settings.listPoliciesSettings(), clientContext); + this.listPoliciesPagedCallable = + callableFactory.createPagedCallable( + listPoliciesTransportSettings, settings.listPoliciesSettings(), clientContext); + this.getPolicyCallable = + callableFactory.createUnaryCallable( + getPolicyTransportSettings, settings.getPolicySettings(), clientContext); + this.getEffectivePolicyCallable = + callableFactory.createUnaryCallable( + getEffectivePolicyTransportSettings, + settings.getEffectivePolicySettings(), + clientContext); + this.createPolicyCallable = + callableFactory.createUnaryCallable( + createPolicyTransportSettings, settings.createPolicySettings(), clientContext); + this.updatePolicyCallable = + callableFactory.createUnaryCallable( + updatePolicyTransportSettings, settings.updatePolicySettings(), clientContext); + this.deletePolicyCallable = + callableFactory.createUnaryCallable( + deletePolicyTransportSettings, settings.deletePolicySettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + @Override + public UnaryCallable listConstraintsCallable() { + return listConstraintsCallable; + } + + @Override + public UnaryCallable + listConstraintsPagedCallable() { + return listConstraintsPagedCallable; + } + + @Override + public UnaryCallable listPoliciesCallable() { + return listPoliciesCallable; + } + + @Override + public UnaryCallable listPoliciesPagedCallable() { + return listPoliciesPagedCallable; + } + + @Override + public UnaryCallable getPolicyCallable() { + return getPolicyCallable; + } + + @Override + public UnaryCallable getEffectivePolicyCallable() { + return getEffectivePolicyCallable; + } + + @Override + public UnaryCallable createPolicyCallable() { + return createPolicyCallable; + } + + @Override + public UnaryCallable updatePolicyCallable() { + return updatePolicyCallable; + } + + @Override + public UnaryCallable deletePolicyCallable() { + return deletePolicyCallable; + } + + @Override + public final void close() { + shutdown(); + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/OrgPolicyStub.java b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/OrgPolicyStub.java new file mode 100644 index 0000000..6612d49 --- /dev/null +++ b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/OrgPolicyStub.java @@ -0,0 +1,85 @@ +/* + * 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. + */ + +package com.google.cloud.orgpolicy.v2.stub; + +import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse; +import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.orgpolicy.v2.CreatePolicyRequest; +import com.google.cloud.orgpolicy.v2.DeletePolicyRequest; +import com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest; +import com.google.cloud.orgpolicy.v2.GetPolicyRequest; +import com.google.cloud.orgpolicy.v2.ListConstraintsRequest; +import com.google.cloud.orgpolicy.v2.ListConstraintsResponse; +import com.google.cloud.orgpolicy.v2.ListPoliciesRequest; +import com.google.cloud.orgpolicy.v2.ListPoliciesResponse; +import com.google.cloud.orgpolicy.v2.Policy; +import com.google.cloud.orgpolicy.v2.UpdatePolicyRequest; +import com.google.protobuf.Empty; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Base stub class for the OrgPolicy service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public abstract class OrgPolicyStub implements BackgroundResource { + + public UnaryCallable + listConstraintsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listConstraintsPagedCallable()"); + } + + public UnaryCallable listConstraintsCallable() { + throw new UnsupportedOperationException("Not implemented: listConstraintsCallable()"); + } + + public UnaryCallable listPoliciesPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listPoliciesPagedCallable()"); + } + + public UnaryCallable listPoliciesCallable() { + throw new UnsupportedOperationException("Not implemented: listPoliciesCallable()"); + } + + public UnaryCallable getPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: getPolicyCallable()"); + } + + public UnaryCallable getEffectivePolicyCallable() { + throw new UnsupportedOperationException("Not implemented: getEffectivePolicyCallable()"); + } + + public UnaryCallable createPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: createPolicyCallable()"); + } + + public UnaryCallable updatePolicyCallable() { + throw new UnsupportedOperationException("Not implemented: updatePolicyCallable()"); + } + + public UnaryCallable deletePolicyCallable() { + throw new UnsupportedOperationException("Not implemented: deletePolicyCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/OrgPolicyStubSettings.java b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/OrgPolicyStubSettings.java new file mode 100644 index 0000000..1e1a17d --- /dev/null +++ b/google-cloud-orgpolicy/src/main/java/com/google/cloud/orgpolicy/v2/stub/OrgPolicyStubSettings.java @@ -0,0 +1,546 @@ +/* + * 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. + */ + +package com.google.cloud.orgpolicy.v2.stub; + +import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse; +import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiCallContext; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.PagedListDescriptor; +import com.google.api.gax.rpc.PagedListResponseFactory; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.orgpolicy.v2.Constraint; +import com.google.cloud.orgpolicy.v2.CreatePolicyRequest; +import com.google.cloud.orgpolicy.v2.DeletePolicyRequest; +import com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest; +import com.google.cloud.orgpolicy.v2.GetPolicyRequest; +import com.google.cloud.orgpolicy.v2.ListConstraintsRequest; +import com.google.cloud.orgpolicy.v2.ListConstraintsResponse; +import com.google.cloud.orgpolicy.v2.ListPoliciesRequest; +import com.google.cloud.orgpolicy.v2.ListPoliciesResponse; +import com.google.cloud.orgpolicy.v2.Policy; +import com.google.cloud.orgpolicy.v2.UpdatePolicyRequest; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; +import org.threeten.bp.Duration; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link OrgPolicyStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (orgpolicy.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

The builder of this class is recursive, so contained classes are themselves builders. When + * build() is called, the tree of builders is called to create the complete settings object. + * + *

For example, to set the total timeout of getPolicy to 30 seconds: + * + *

{@code
+ * OrgPolicyStubSettings.Builder orgPolicySettingsBuilder = OrgPolicyStubSettings.newBuilder();
+ * orgPolicySettingsBuilder
+ *     .getPolicySettings()
+ *     .setRetrySettings(
+ *         orgPolicySettingsBuilder
+ *             .getPolicySettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
+ *             .setTotalTimeout(Duration.ofSeconds(30))
+ *             .build());
+ * OrgPolicyStubSettings orgPolicySettings = orgPolicySettingsBuilder.build();
+ * }
+ */ +@Generated("by gapic-generator-java") +public class OrgPolicyStubSettings extends StubSettings { + /** The default scopes of the service. */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build(); + + private final PagedCallSettings< + ListConstraintsRequest, ListConstraintsResponse, ListConstraintsPagedResponse> + listConstraintsSettings; + private final PagedCallSettings< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse> + listPoliciesSettings; + private final UnaryCallSettings getPolicySettings; + private final UnaryCallSettings getEffectivePolicySettings; + private final UnaryCallSettings createPolicySettings; + private final UnaryCallSettings updatePolicySettings; + private final UnaryCallSettings deletePolicySettings; + + private static final PagedListDescriptor< + ListConstraintsRequest, ListConstraintsResponse, Constraint> + LIST_CONSTRAINTS_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListConstraintsRequest injectToken( + ListConstraintsRequest payload, String token) { + return ListConstraintsRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListConstraintsRequest injectPageSize( + ListConstraintsRequest payload, int pageSize) { + return ListConstraintsRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListConstraintsRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListConstraintsResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListConstraintsResponse payload) { + return payload.getConstraintsList() == null + ? ImmutableList.of() + : payload.getConstraintsList(); + } + }; + + private static final PagedListDescriptor + LIST_POLICIES_PAGE_STR_DESC = + new PagedListDescriptor() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListPoliciesRequest injectToken(ListPoliciesRequest payload, String token) { + return ListPoliciesRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListPoliciesRequest injectPageSize(ListPoliciesRequest payload, int pageSize) { + return ListPoliciesRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListPoliciesRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListPoliciesResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListPoliciesResponse payload) { + return payload.getPoliciesList() == null + ? ImmutableList.of() + : payload.getPoliciesList(); + } + }; + + private static final PagedListResponseFactory< + ListConstraintsRequest, ListConstraintsResponse, ListConstraintsPagedResponse> + LIST_CONSTRAINTS_PAGE_STR_FACT = + new PagedListResponseFactory< + ListConstraintsRequest, ListConstraintsResponse, ListConstraintsPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListConstraintsRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_CONSTRAINTS_PAGE_STR_DESC, request, context); + return ListConstraintsPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + private static final PagedListResponseFactory< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse> + LIST_POLICIES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListPoliciesRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext pageContext = + PageContext.create(callable, LIST_POLICIES_PAGE_STR_DESC, request, context); + return ListPoliciesPagedResponse.createAsync(pageContext, futureResponse); + } + }; + + /** Returns the object with the settings used for calls to listConstraints. */ + public PagedCallSettings< + ListConstraintsRequest, ListConstraintsResponse, ListConstraintsPagedResponse> + listConstraintsSettings() { + return listConstraintsSettings; + } + + /** Returns the object with the settings used for calls to listPolicies. */ + public PagedCallSettings + listPoliciesSettings() { + return listPoliciesSettings; + } + + /** Returns the object with the settings used for calls to getPolicy. */ + public UnaryCallSettings getPolicySettings() { + return getPolicySettings; + } + + /** Returns the object with the settings used for calls to getEffectivePolicy. */ + public UnaryCallSettings getEffectivePolicySettings() { + return getEffectivePolicySettings; + } + + /** Returns the object with the settings used for calls to createPolicy. */ + public UnaryCallSettings createPolicySettings() { + return createPolicySettings; + } + + /** Returns the object with the settings used for calls to updatePolicy. */ + public UnaryCallSettings updatePolicySettings() { + return updatePolicySettings; + } + + /** Returns the object with the settings used for calls to deletePolicy. */ + public UnaryCallSettings deletePolicySettings() { + return deletePolicySettings; + } + + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") + public OrgPolicyStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcOrgPolicyStub.create(this); + } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return "orgpolicy.googleapis.com:443"; + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES); + } + + /** Returns a builder for the default ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder() + .setMaxInboundMessageSize(Integer.MAX_VALUE); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().build(); + } + + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(OrgPolicyStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected OrgPolicyStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + listConstraintsSettings = settingsBuilder.listConstraintsSettings().build(); + listPoliciesSettings = settingsBuilder.listPoliciesSettings().build(); + getPolicySettings = settingsBuilder.getPolicySettings().build(); + getEffectivePolicySettings = settingsBuilder.getEffectivePolicySettings().build(); + createPolicySettings = settingsBuilder.createPolicySettings().build(); + updatePolicySettings = settingsBuilder.updatePolicySettings().build(); + deletePolicySettings = settingsBuilder.deletePolicySettings().build(); + } + + /** Builder for OrgPolicyStubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + private final PagedCallSettings.Builder< + ListConstraintsRequest, ListConstraintsResponse, ListConstraintsPagedResponse> + listConstraintsSettings; + private final PagedCallSettings.Builder< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse> + listPoliciesSettings; + private final UnaryCallSettings.Builder getPolicySettings; + private final UnaryCallSettings.Builder + getEffectivePolicySettings; + private final UnaryCallSettings.Builder createPolicySettings; + private final UnaryCallSettings.Builder updatePolicySettings; + private final UnaryCallSettings.Builder deletePolicySettings; + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "retry_policy_0_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED))); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRetryDelay(Duration.ofMillis(1000L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelay(Duration.ofMillis(10000L)) + .setInitialRpcTimeout(Duration.ofMillis(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeout(Duration.ofMillis(60000L)) + .setTotalTimeout(Duration.ofMillis(60000L)) + .build(); + definitions.put("retry_policy_0_params", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + listConstraintsSettings = PagedCallSettings.newBuilder(LIST_CONSTRAINTS_PAGE_STR_FACT); + listPoliciesSettings = PagedCallSettings.newBuilder(LIST_POLICIES_PAGE_STR_FACT); + getPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + getEffectivePolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + createPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updatePolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deletePolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listConstraintsSettings, + listPoliciesSettings, + getPolicySettings, + getEffectivePolicySettings, + createPolicySettings, + updatePolicySettings, + deletePolicySettings); + initDefaults(this); + } + + protected Builder(OrgPolicyStubSettings settings) { + super(settings); + + listConstraintsSettings = settings.listConstraintsSettings.toBuilder(); + listPoliciesSettings = settings.listPoliciesSettings.toBuilder(); + getPolicySettings = settings.getPolicySettings.toBuilder(); + getEffectivePolicySettings = settings.getEffectivePolicySettings.toBuilder(); + createPolicySettings = settings.createPolicySettings.toBuilder(); + updatePolicySettings = settings.updatePolicySettings.toBuilder(); + deletePolicySettings = settings.deletePolicySettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + listConstraintsSettings, + listPoliciesSettings, + getPolicySettings, + getEffectivePolicySettings, + createPolicySettings, + updatePolicySettings, + deletePolicySettings); + } + + private static Builder createDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + builder + .listConstraintsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .listPoliciesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .getPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .getEffectivePolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .createPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .updatePolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .deletePolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + return builder; + } + + // NEXT_MAJOR_VER: remove 'throws Exception'. + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) throws Exception { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** Returns the builder for the settings used for calls to listConstraints. */ + public PagedCallSettings.Builder< + ListConstraintsRequest, ListConstraintsResponse, ListConstraintsPagedResponse> + listConstraintsSettings() { + return listConstraintsSettings; + } + + /** Returns the builder for the settings used for calls to listPolicies. */ + public PagedCallSettings.Builder< + ListPoliciesRequest, ListPoliciesResponse, ListPoliciesPagedResponse> + listPoliciesSettings() { + return listPoliciesSettings; + } + + /** Returns the builder for the settings used for calls to getPolicy. */ + public UnaryCallSettings.Builder getPolicySettings() { + return getPolicySettings; + } + + /** Returns the builder for the settings used for calls to getEffectivePolicy. */ + public UnaryCallSettings.Builder + getEffectivePolicySettings() { + return getEffectivePolicySettings; + } + + /** Returns the builder for the settings used for calls to createPolicy. */ + public UnaryCallSettings.Builder createPolicySettings() { + return createPolicySettings; + } + + /** Returns the builder for the settings used for calls to updatePolicy. */ + public UnaryCallSettings.Builder updatePolicySettings() { + return updatePolicySettings; + } + + /** Returns the builder for the settings used for calls to deletePolicy. */ + public UnaryCallSettings.Builder deletePolicySettings() { + return deletePolicySettings; + } + + @Override + public OrgPolicyStubSettings build() throws IOException { + return new OrgPolicyStubSettings(this); + } + } +} diff --git a/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/MockOrgPolicy.java b/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/MockOrgPolicy.java new file mode 100644 index 0000000..21eef80 --- /dev/null +++ b/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/MockOrgPolicy.java @@ -0,0 +1,59 @@ +/* + * 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. + */ + +package com.google.cloud.orgpolicy.v2; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockOrgPolicy implements MockGrpcService { + private final MockOrgPolicyImpl serviceImpl; + + public MockOrgPolicy() { + serviceImpl = new MockOrgPolicyImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(AbstractMessage response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/MockOrgPolicyImpl.java b/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/MockOrgPolicyImpl.java new file mode 100644 index 0000000..91656cd --- /dev/null +++ b/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/MockOrgPolicyImpl.java @@ -0,0 +1,204 @@ +/* + * 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. + */ + +package com.google.cloud.orgpolicy.v2; + +import com.google.api.core.BetaApi; +import com.google.cloud.orgpolicy.v2.OrgPolicyGrpc.OrgPolicyImplBase; +import com.google.protobuf.AbstractMessage; +import com.google.protobuf.Empty; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockOrgPolicyImpl extends OrgPolicyImplBase { + private List requests; + private Queue responses; + + public MockOrgPolicyImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(AbstractMessage response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void listConstraints( + ListConstraintsRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof ListConstraintsResponse) { + requests.add(request); + responseObserver.onNext(((ListConstraintsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListConstraints, expected %s or %s", + response.getClass().getName(), + ListConstraintsResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void listPolicies( + ListPoliciesRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof ListPoliciesResponse) { + requests.add(request); + responseObserver.onNext(((ListPoliciesResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListPolicies, expected %s or %s", + response.getClass().getName(), + ListPoliciesResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getPolicy(GetPolicyRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Policy) { + requests.add(request); + responseObserver.onNext(((Policy) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetPolicy, expected %s or %s", + response.getClass().getName(), + Policy.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getEffectivePolicy( + GetEffectivePolicyRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Policy) { + requests.add(request); + responseObserver.onNext(((Policy) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetEffectivePolicy, expected %s or %s", + response.getClass().getName(), + Policy.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void createPolicy(CreatePolicyRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Policy) { + requests.add(request); + responseObserver.onNext(((Policy) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method CreatePolicy, expected %s or %s", + response.getClass().getName(), + Policy.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void updatePolicy(UpdatePolicyRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Policy) { + requests.add(request); + responseObserver.onNext(((Policy) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method UpdatePolicy, expected %s or %s", + response.getClass().getName(), + Policy.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void deletePolicy(DeletePolicyRequest request, StreamObserver responseObserver) { + Object response = responses.remove(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext(((Empty) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method DeletePolicy, expected %s or %s", + response.getClass().getName(), + Empty.class.getName(), + Exception.class.getName()))); + } + } +} diff --git a/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/OrgPolicyClientTest.java b/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/OrgPolicyClientTest.java new file mode 100644 index 0000000..9de6c7f --- /dev/null +++ b/google-cloud-orgpolicy/src/test/java/com/google/cloud/orgpolicy/v2/OrgPolicyClientTest.java @@ -0,0 +1,874 @@ +/* + * 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. + */ + +package com.google.cloud.orgpolicy.v2; + +import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListConstraintsPagedResponse; +import static com.google.cloud.orgpolicy.v2.OrgPolicyClient.ListPoliciesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.testing.LocalChannelProvider; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.api.gax.grpc.testing.MockServiceHelper; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.common.collect.Lists; +import com.google.protobuf.AbstractMessage; +import com.google.protobuf.Empty; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class OrgPolicyClientTest { + private static MockOrgPolicy mockOrgPolicy; + private static MockServiceHelper mockServiceHelper; + private OrgPolicyClient client; + private LocalChannelProvider channelProvider; + + @BeforeClass + public static void startStaticServer() { + mockOrgPolicy = new MockOrgPolicy(); + mockServiceHelper = + new MockServiceHelper( + UUID.randomUUID().toString(), Arrays.asList(mockOrgPolicy)); + mockServiceHelper.start(); + } + + @AfterClass + public static void stopServer() { + mockServiceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); + OrgPolicySettings settings = + OrgPolicySettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = OrgPolicyClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + public void listConstraintsTest() throws Exception { + Constraint responsesElement = Constraint.newBuilder().build(); + ListConstraintsResponse expectedResponse = + ListConstraintsResponse.newBuilder() + .setNextPageToken("") + .addAllConstraints(Arrays.asList(responsesElement)) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + FolderName parent = FolderName.of("[FOLDER]"); + + ListConstraintsPagedResponse pagedListResponse = client.listConstraints(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConstraintsList().get(0), resources.get(0)); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListConstraintsRequest actualRequest = ((ListConstraintsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listConstraintsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + FolderName parent = FolderName.of("[FOLDER]"); + client.listConstraints(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConstraintsTest2() throws Exception { + Constraint responsesElement = Constraint.newBuilder().build(); + ListConstraintsResponse expectedResponse = + ListConstraintsResponse.newBuilder() + .setNextPageToken("") + .addAllConstraints(Arrays.asList(responsesElement)) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + ListConstraintsPagedResponse pagedListResponse = client.listConstraints(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConstraintsList().get(0), resources.get(0)); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListConstraintsRequest actualRequest = ((ListConstraintsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listConstraintsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.listConstraints(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConstraintsTest3() throws Exception { + Constraint responsesElement = Constraint.newBuilder().build(); + ListConstraintsResponse expectedResponse = + ListConstraintsResponse.newBuilder() + .setNextPageToken("") + .addAllConstraints(Arrays.asList(responsesElement)) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListConstraintsPagedResponse pagedListResponse = client.listConstraints(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConstraintsList().get(0), resources.get(0)); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListConstraintsRequest actualRequest = ((ListConstraintsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listConstraintsExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listConstraints(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listConstraintsTest4() throws Exception { + Constraint responsesElement = Constraint.newBuilder().build(); + ListConstraintsResponse expectedResponse = + ListConstraintsResponse.newBuilder() + .setNextPageToken("") + .addAllConstraints(Arrays.asList(responsesElement)) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListConstraintsPagedResponse pagedListResponse = client.listConstraints(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getConstraintsList().get(0), resources.get(0)); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListConstraintsRequest actualRequest = ((ListConstraintsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listConstraintsExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + String parent = "parent-995424086"; + client.listConstraints(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPoliciesTest() throws Exception { + Policy responsesElement = Policy.newBuilder().build(); + ListPoliciesResponse expectedResponse = + ListPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllPolicies(Arrays.asList(responsesElement)) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + FolderName parent = FolderName.of("[FOLDER]"); + + ListPoliciesPagedResponse pagedListResponse = client.listPolicies(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPoliciesList().get(0), resources.get(0)); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListPoliciesRequest actualRequest = ((ListPoliciesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listPoliciesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + FolderName parent = FolderName.of("[FOLDER]"); + client.listPolicies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPoliciesTest2() throws Exception { + Policy responsesElement = Policy.newBuilder().build(); + ListPoliciesResponse expectedResponse = + ListPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllPolicies(Arrays.asList(responsesElement)) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + + ListPoliciesPagedResponse pagedListResponse = client.listPolicies(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPoliciesList().get(0), resources.get(0)); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListPoliciesRequest actualRequest = ((ListPoliciesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listPoliciesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + client.listPolicies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPoliciesTest3() throws Exception { + Policy responsesElement = Policy.newBuilder().build(); + ListPoliciesResponse expectedResponse = + ListPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllPolicies(Arrays.asList(responsesElement)) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListPoliciesPagedResponse pagedListResponse = client.listPolicies(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPoliciesList().get(0), resources.get(0)); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListPoliciesRequest actualRequest = ((ListPoliciesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listPoliciesExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listPolicies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPoliciesTest4() throws Exception { + Policy responsesElement = Policy.newBuilder().build(); + ListPoliciesResponse expectedResponse = + ListPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllPolicies(Arrays.asList(responsesElement)) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListPoliciesPagedResponse pagedListResponse = client.listPolicies(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPoliciesList().get(0), resources.get(0)); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListPoliciesRequest actualRequest = ((ListPoliciesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listPoliciesExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + String parent = "parent-995424086"; + client.listPolicies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + .setSpec(PolicySpec.newBuilder().build()) + .setAlternate(AlternatePolicySpec.newBuilder().build()) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]"); + + Policy actualResponse = client.getPolicy(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetPolicyRequest actualRequest = ((GetPolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getPolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]"); + client.getPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + .setSpec(PolicySpec.newBuilder().build()) + .setAlternate(AlternatePolicySpec.newBuilder().build()) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + String name = "name3373707"; + + Policy actualResponse = client.getPolicy(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetPolicyRequest actualRequest = ((GetPolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getPolicyExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + String name = "name3373707"; + client.getPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEffectivePolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + .setSpec(PolicySpec.newBuilder().build()) + .setAlternate(AlternatePolicySpec.newBuilder().build()) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]"); + + Policy actualResponse = client.getEffectivePolicy(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetEffectivePolicyRequest actualRequest = ((GetEffectivePolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getEffectivePolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]"); + client.getEffectivePolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getEffectivePolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + .setSpec(PolicySpec.newBuilder().build()) + .setAlternate(AlternatePolicySpec.newBuilder().build()) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + String name = "name3373707"; + + Policy actualResponse = client.getEffectivePolicy(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetEffectivePolicyRequest actualRequest = ((GetEffectivePolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getEffectivePolicyExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + String name = "name3373707"; + client.getEffectivePolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + .setSpec(PolicySpec.newBuilder().build()) + .setAlternate(AlternatePolicySpec.newBuilder().build()) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + FolderName parent = FolderName.of("[FOLDER]"); + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.createPolicy(parent, policy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreatePolicyRequest actualRequest = ((CreatePolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(policy, actualRequest.getPolicy()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createPolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + FolderName parent = FolderName.of("[FOLDER]"); + Policy policy = Policy.newBuilder().build(); + client.createPolicy(parent, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + .setSpec(PolicySpec.newBuilder().build()) + .setAlternate(AlternatePolicySpec.newBuilder().build()) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.createPolicy(parent, policy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreatePolicyRequest actualRequest = ((CreatePolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(policy, actualRequest.getPolicy()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createPolicyExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + OrganizationName parent = OrganizationName.of("[ORGANIZATION]"); + Policy policy = Policy.newBuilder().build(); + client.createPolicy(parent, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPolicyTest3() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + .setSpec(PolicySpec.newBuilder().build()) + .setAlternate(AlternatePolicySpec.newBuilder().build()) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.createPolicy(parent, policy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreatePolicyRequest actualRequest = ((CreatePolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(policy, actualRequest.getPolicy()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createPolicyExceptionTest3() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + Policy policy = Policy.newBuilder().build(); + client.createPolicy(parent, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPolicyTest4() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + .setSpec(PolicySpec.newBuilder().build()) + .setAlternate(AlternatePolicySpec.newBuilder().build()) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + String parent = "parent-995424086"; + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.createPolicy(parent, policy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreatePolicyRequest actualRequest = ((CreatePolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(policy, actualRequest.getPolicy()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createPolicyExceptionTest4() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + String parent = "parent-995424086"; + Policy policy = Policy.newBuilder().build(); + client.createPolicy(parent, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updatePolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName(PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]").toString()) + .setSpec(PolicySpec.newBuilder().build()) + .setAlternate(AlternatePolicySpec.newBuilder().build()) + .build(); + mockOrgPolicy.addResponse(expectedResponse); + + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.updatePolicy(policy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdatePolicyRequest actualRequest = ((UpdatePolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(policy, actualRequest.getPolicy()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void updatePolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + Policy policy = Policy.newBuilder().build(); + client.updatePolicy(policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deletePolicyTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockOrgPolicy.addResponse(expectedResponse); + + PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]"); + + client.deletePolicy(name); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeletePolicyRequest actualRequest = ((DeletePolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deletePolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + PolicyName name = PolicyName.ofProjectPolicyName("[PROJECT]", "[POLICY]"); + client.deletePolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deletePolicyTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockOrgPolicy.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deletePolicy(name); + + List actualRequests = mockOrgPolicy.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeletePolicyRequest actualRequest = ((DeletePolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deletePolicyExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockOrgPolicy.addException(exception); + + try { + String name = "name3373707"; + client.deletePolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/grpc-google-cloud-orgpolicy-v2/pom.xml b/grpc-google-cloud-orgpolicy-v2/pom.xml new file mode 100644 index 0000000..5dabc35 --- /dev/null +++ b/grpc-google-cloud-orgpolicy-v2/pom.xml @@ -0,0 +1,65 @@ + + 4.0.0 + com.google.api.grpc + grpc-google-cloud-orgpolicy-v2 + 1.0.12-SNAPSHOT + grpc-google-cloud-orgpolicy-v2 + GRPC library for grpc-google-cloud-orgpolicy-v2 + + com.google.cloud + google-cloud-orgpolicy-parent + 1.0.12-SNAPSHOT + + + + io.grpc + grpc-api + + + io.grpc + grpc-stub + + + io.grpc + grpc-protobuf + + + com.google.api.grpc + proto-google-cloud-orgpolicy-v2 + + + com.google.guava + guava + + + com.google.protobuf + protobuf-java + + + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + + \ No newline at end of file diff --git a/grpc-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicyGrpc.java b/grpc-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicyGrpc.java new file mode 100644 index 0000000..0d3faf4 --- /dev/null +++ b/grpc-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicyGrpc.java @@ -0,0 +1,1180 @@ +/* + * 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. + */ +package com.google.cloud.orgpolicy.v2; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + * + * + *
+ * An interface for managing organization policies.
+ * The Cloud Org Policy service provides a simple mechanism for organizations to
+ * restrict the allowed configurations across their entire Cloud Resource
+ * hierarchy.
+ * You can use a `policy` to configure restrictions in Cloud resources. For
+ * example, you can enforce a `policy` that restricts which Google
+ * Cloud Platform APIs can be activated in a certain part of your resource
+ * hierarchy, or prevents serial port access to VM instances in a particular
+ * folder.
+ * `Policies` are inherited down through the resource hierarchy. A `policy`
+ * applied to a parent resource automatically applies to all its child resources
+ * unless overridden with a `policy` lower in the hierarchy.
+ * A `constraint` defines an aspect of a resource's configuration that can be
+ * controlled by an organization's policy administrator. `Policies` are a
+ * collection of `constraints` that defines their allowable configuration on a
+ * particular resource and its child resources.
+ * 
+ */ +@javax.annotation.Generated( + value = "by gRPC proto compiler", + comments = "Source: google/cloud/orgpolicy/v2/orgpolicy.proto") +public final class OrgPolicyGrpc { + + private OrgPolicyGrpc() {} + + public static final String SERVICE_NAME = "google.cloud.orgpolicy.v2.OrgPolicy"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.ListConstraintsRequest, + com.google.cloud.orgpolicy.v2.ListConstraintsResponse> + getListConstraintsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListConstraints", + requestType = com.google.cloud.orgpolicy.v2.ListConstraintsRequest.class, + responseType = com.google.cloud.orgpolicy.v2.ListConstraintsResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.ListConstraintsRequest, + com.google.cloud.orgpolicy.v2.ListConstraintsResponse> + getListConstraintsMethod() { + io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.ListConstraintsRequest, + com.google.cloud.orgpolicy.v2.ListConstraintsResponse> + getListConstraintsMethod; + if ((getListConstraintsMethod = OrgPolicyGrpc.getListConstraintsMethod) == null) { + synchronized (OrgPolicyGrpc.class) { + if ((getListConstraintsMethod = OrgPolicyGrpc.getListConstraintsMethod) == null) { + OrgPolicyGrpc.getListConstraintsMethod = + getListConstraintsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListConstraints")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.orgpolicy.v2.ListConstraintsRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.orgpolicy.v2.ListConstraintsResponse + .getDefaultInstance())) + .setSchemaDescriptor(new OrgPolicyMethodDescriptorSupplier("ListConstraints")) + .build(); + } + } + } + return getListConstraintsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.ListPoliciesRequest, + com.google.cloud.orgpolicy.v2.ListPoliciesResponse> + getListPoliciesMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListPolicies", + requestType = com.google.cloud.orgpolicy.v2.ListPoliciesRequest.class, + responseType = com.google.cloud.orgpolicy.v2.ListPoliciesResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.ListPoliciesRequest, + com.google.cloud.orgpolicy.v2.ListPoliciesResponse> + getListPoliciesMethod() { + io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.ListPoliciesRequest, + com.google.cloud.orgpolicy.v2.ListPoliciesResponse> + getListPoliciesMethod; + if ((getListPoliciesMethod = OrgPolicyGrpc.getListPoliciesMethod) == null) { + synchronized (OrgPolicyGrpc.class) { + if ((getListPoliciesMethod = OrgPolicyGrpc.getListPoliciesMethod) == null) { + OrgPolicyGrpc.getListPoliciesMethod = + getListPoliciesMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListPolicies")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.orgpolicy.v2.ListPoliciesRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.orgpolicy.v2.ListPoliciesResponse + .getDefaultInstance())) + .setSchemaDescriptor(new OrgPolicyMethodDescriptorSupplier("ListPolicies")) + .build(); + } + } + } + return getListPoliciesMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.GetPolicyRequest, com.google.cloud.orgpolicy.v2.Policy> + getGetPolicyMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetPolicy", + requestType = com.google.cloud.orgpolicy.v2.GetPolicyRequest.class, + responseType = com.google.cloud.orgpolicy.v2.Policy.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.GetPolicyRequest, com.google.cloud.orgpolicy.v2.Policy> + getGetPolicyMethod() { + io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.GetPolicyRequest, com.google.cloud.orgpolicy.v2.Policy> + getGetPolicyMethod; + if ((getGetPolicyMethod = OrgPolicyGrpc.getGetPolicyMethod) == null) { + synchronized (OrgPolicyGrpc.class) { + if ((getGetPolicyMethod = OrgPolicyGrpc.getGetPolicyMethod) == null) { + OrgPolicyGrpc.getGetPolicyMethod = + getGetPolicyMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetPolicy")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.orgpolicy.v2.GetPolicyRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.orgpolicy.v2.Policy.getDefaultInstance())) + .setSchemaDescriptor(new OrgPolicyMethodDescriptorSupplier("GetPolicy")) + .build(); + } + } + } + return getGetPolicyMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest, + com.google.cloud.orgpolicy.v2.Policy> + getGetEffectivePolicyMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetEffectivePolicy", + requestType = com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest.class, + responseType = com.google.cloud.orgpolicy.v2.Policy.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest, + com.google.cloud.orgpolicy.v2.Policy> + getGetEffectivePolicyMethod() { + io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest, + com.google.cloud.orgpolicy.v2.Policy> + getGetEffectivePolicyMethod; + if ((getGetEffectivePolicyMethod = OrgPolicyGrpc.getGetEffectivePolicyMethod) == null) { + synchronized (OrgPolicyGrpc.class) { + if ((getGetEffectivePolicyMethod = OrgPolicyGrpc.getGetEffectivePolicyMethod) == null) { + OrgPolicyGrpc.getGetEffectivePolicyMethod = + getGetEffectivePolicyMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetEffectivePolicy")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.orgpolicy.v2.Policy.getDefaultInstance())) + .setSchemaDescriptor( + new OrgPolicyMethodDescriptorSupplier("GetEffectivePolicy")) + .build(); + } + } + } + return getGetEffectivePolicyMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.CreatePolicyRequest, com.google.cloud.orgpolicy.v2.Policy> + getCreatePolicyMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "CreatePolicy", + requestType = com.google.cloud.orgpolicy.v2.CreatePolicyRequest.class, + responseType = com.google.cloud.orgpolicy.v2.Policy.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.CreatePolicyRequest, com.google.cloud.orgpolicy.v2.Policy> + getCreatePolicyMethod() { + io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.CreatePolicyRequest, com.google.cloud.orgpolicy.v2.Policy> + getCreatePolicyMethod; + if ((getCreatePolicyMethod = OrgPolicyGrpc.getCreatePolicyMethod) == null) { + synchronized (OrgPolicyGrpc.class) { + if ((getCreatePolicyMethod = OrgPolicyGrpc.getCreatePolicyMethod) == null) { + OrgPolicyGrpc.getCreatePolicyMethod = + getCreatePolicyMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "CreatePolicy")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.orgpolicy.v2.CreatePolicyRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.orgpolicy.v2.Policy.getDefaultInstance())) + .setSchemaDescriptor(new OrgPolicyMethodDescriptorSupplier("CreatePolicy")) + .build(); + } + } + } + return getCreatePolicyMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest, com.google.cloud.orgpolicy.v2.Policy> + getUpdatePolicyMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "UpdatePolicy", + requestType = com.google.cloud.orgpolicy.v2.UpdatePolicyRequest.class, + responseType = com.google.cloud.orgpolicy.v2.Policy.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest, com.google.cloud.orgpolicy.v2.Policy> + getUpdatePolicyMethod() { + io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest, com.google.cloud.orgpolicy.v2.Policy> + getUpdatePolicyMethod; + if ((getUpdatePolicyMethod = OrgPolicyGrpc.getUpdatePolicyMethod) == null) { + synchronized (OrgPolicyGrpc.class) { + if ((getUpdatePolicyMethod = OrgPolicyGrpc.getUpdatePolicyMethod) == null) { + OrgPolicyGrpc.getUpdatePolicyMethod = + getUpdatePolicyMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "UpdatePolicy")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.orgpolicy.v2.Policy.getDefaultInstance())) + .setSchemaDescriptor(new OrgPolicyMethodDescriptorSupplier("UpdatePolicy")) + .build(); + } + } + } + return getUpdatePolicyMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.DeletePolicyRequest, com.google.protobuf.Empty> + getDeletePolicyMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "DeletePolicy", + requestType = com.google.cloud.orgpolicy.v2.DeletePolicyRequest.class, + responseType = com.google.protobuf.Empty.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.DeletePolicyRequest, com.google.protobuf.Empty> + getDeletePolicyMethod() { + io.grpc.MethodDescriptor< + com.google.cloud.orgpolicy.v2.DeletePolicyRequest, com.google.protobuf.Empty> + getDeletePolicyMethod; + if ((getDeletePolicyMethod = OrgPolicyGrpc.getDeletePolicyMethod) == null) { + synchronized (OrgPolicyGrpc.class) { + if ((getDeletePolicyMethod = OrgPolicyGrpc.getDeletePolicyMethod) == null) { + OrgPolicyGrpc.getDeletePolicyMethod = + getDeletePolicyMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "DeletePolicy")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.cloud.orgpolicy.v2.DeletePolicyRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.protobuf.Empty.getDefaultInstance())) + .setSchemaDescriptor(new OrgPolicyMethodDescriptorSupplier("DeletePolicy")) + .build(); + } + } + } + return getDeletePolicyMethod; + } + + /** Creates a new async stub that supports all call types for the service */ + public static OrgPolicyStub newStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public OrgPolicyStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new OrgPolicyStub(channel, callOptions); + } + }; + return OrgPolicyStub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static OrgPolicyBlockingStub newBlockingStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public OrgPolicyBlockingStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new OrgPolicyBlockingStub(channel, callOptions); + } + }; + return OrgPolicyBlockingStub.newStub(factory, channel); + } + + /** Creates a new ListenableFuture-style stub that supports unary calls on the service */ + public static OrgPolicyFutureStub newFutureStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public OrgPolicyFutureStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new OrgPolicyFutureStub(channel, callOptions); + } + }; + return OrgPolicyFutureStub.newStub(factory, channel); + } + + /** + * + * + *
+   * An interface for managing organization policies.
+   * The Cloud Org Policy service provides a simple mechanism for organizations to
+   * restrict the allowed configurations across their entire Cloud Resource
+   * hierarchy.
+   * You can use a `policy` to configure restrictions in Cloud resources. For
+   * example, you can enforce a `policy` that restricts which Google
+   * Cloud Platform APIs can be activated in a certain part of your resource
+   * hierarchy, or prevents serial port access to VM instances in a particular
+   * folder.
+   * `Policies` are inherited down through the resource hierarchy. A `policy`
+   * applied to a parent resource automatically applies to all its child resources
+   * unless overridden with a `policy` lower in the hierarchy.
+   * A `constraint` defines an aspect of a resource's configuration that can be
+   * controlled by an organization's policy administrator. `Policies` are a
+   * collection of `constraints` that defines their allowable configuration on a
+   * particular resource and its child resources.
+   * 
+ */ + public abstract static class OrgPolicyImplBase implements io.grpc.BindableService { + + /** + * + * + *
+     * Lists `Constraints` that could be applied on the specified resource.
+     * 
+ */ + public void listConstraints( + com.google.cloud.orgpolicy.v2.ListConstraintsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + asyncUnimplementedUnaryCall(getListConstraintsMethod(), responseObserver); + } + + /** + * + * + *
+     * Retrieves all of the `Policies` that exist on a particular resource.
+     * 
+ */ + public void listPolicies( + com.google.cloud.orgpolicy.v2.ListPoliciesRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + asyncUnimplementedUnaryCall(getListPoliciesMethod(), responseObserver); + } + + /** + * + * + *
+     * Gets a `Policy` on a resource.
+     * If no `Policy` is set on the resource, NOT_FOUND is returned. The
+     * `etag` value can be used with `UpdatePolicy()` to update a
+     * `Policy` during read-modify-write.
+     * 
+ */ + public void getPolicy( + com.google.cloud.orgpolicy.v2.GetPolicyRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetPolicyMethod(), responseObserver); + } + + /** + * + * + *
+     * Gets the effective `Policy` on a resource. This is the result of merging
+     * `Policies` in the resource hierarchy and evaluating conditions. The
+     * returned `Policy` will not have an `etag` or `condition` set because it is
+     * a computed `Policy` across multiple resources.
+     * Subtrees of Resource Manager resource hierarchy with 'under:' prefix will
+     * not be expanded.
+     * 
+ */ + public void getEffectivePolicy( + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetEffectivePolicyMethod(), responseObserver); + } + + /** + * + * + *
+     * Creates a Policy.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
+     * constraint does not exist.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
+     * policy already exists on the given Cloud resource.
+     * 
+ */ + public void createPolicy( + com.google.cloud.orgpolicy.v2.CreatePolicyRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getCreatePolicyMethod(), responseObserver); + } + + /** + * + * + *
+     * Updates a Policy.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
+     * constraint or the policy do not exist.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
+     * supplied in the request does not match the persisted etag of the policy
+     * Note: the supplied policy will perform a full overwrite of all
+     * fields.
+     * 
+ */ + public void updatePolicy( + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getUpdatePolicyMethod(), responseObserver); + } + + /** + * + * + *
+     * Deletes a Policy.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
+     * constraint or Org Policy does not exist.
+     * 
+ */ + public void deletePolicy( + com.google.cloud.orgpolicy.v2.DeletePolicyRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getDeletePolicyMethod(), responseObserver); + } + + @java.lang.Override + public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getListConstraintsMethod(), + asyncUnaryCall( + new MethodHandlers< + com.google.cloud.orgpolicy.v2.ListConstraintsRequest, + com.google.cloud.orgpolicy.v2.ListConstraintsResponse>( + this, METHODID_LIST_CONSTRAINTS))) + .addMethod( + getListPoliciesMethod(), + asyncUnaryCall( + new MethodHandlers< + com.google.cloud.orgpolicy.v2.ListPoliciesRequest, + com.google.cloud.orgpolicy.v2.ListPoliciesResponse>( + this, METHODID_LIST_POLICIES))) + .addMethod( + getGetPolicyMethod(), + asyncUnaryCall( + new MethodHandlers< + com.google.cloud.orgpolicy.v2.GetPolicyRequest, + com.google.cloud.orgpolicy.v2.Policy>(this, METHODID_GET_POLICY))) + .addMethod( + getGetEffectivePolicyMethod(), + asyncUnaryCall( + new MethodHandlers< + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest, + com.google.cloud.orgpolicy.v2.Policy>(this, METHODID_GET_EFFECTIVE_POLICY))) + .addMethod( + getCreatePolicyMethod(), + asyncUnaryCall( + new MethodHandlers< + com.google.cloud.orgpolicy.v2.CreatePolicyRequest, + com.google.cloud.orgpolicy.v2.Policy>(this, METHODID_CREATE_POLICY))) + .addMethod( + getUpdatePolicyMethod(), + asyncUnaryCall( + new MethodHandlers< + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest, + com.google.cloud.orgpolicy.v2.Policy>(this, METHODID_UPDATE_POLICY))) + .addMethod( + getDeletePolicyMethod(), + asyncUnaryCall( + new MethodHandlers< + com.google.cloud.orgpolicy.v2.DeletePolicyRequest, com.google.protobuf.Empty>( + this, METHODID_DELETE_POLICY))) + .build(); + } + } + + /** + * + * + *
+   * An interface for managing organization policies.
+   * The Cloud Org Policy service provides a simple mechanism for organizations to
+   * restrict the allowed configurations across their entire Cloud Resource
+   * hierarchy.
+   * You can use a `policy` to configure restrictions in Cloud resources. For
+   * example, you can enforce a `policy` that restricts which Google
+   * Cloud Platform APIs can be activated in a certain part of your resource
+   * hierarchy, or prevents serial port access to VM instances in a particular
+   * folder.
+   * `Policies` are inherited down through the resource hierarchy. A `policy`
+   * applied to a parent resource automatically applies to all its child resources
+   * unless overridden with a `policy` lower in the hierarchy.
+   * A `constraint` defines an aspect of a resource's configuration that can be
+   * controlled by an organization's policy administrator. `Policies` are a
+   * collection of `constraints` that defines their allowable configuration on a
+   * particular resource and its child resources.
+   * 
+ */ + public static final class OrgPolicyStub extends io.grpc.stub.AbstractAsyncStub { + private OrgPolicyStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected OrgPolicyStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new OrgPolicyStub(channel, callOptions); + } + + /** + * + * + *
+     * Lists `Constraints` that could be applied on the specified resource.
+     * 
+ */ + public void listConstraints( + com.google.cloud.orgpolicy.v2.ListConstraintsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + asyncUnaryCall( + getChannel().newCall(getListConstraintsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Retrieves all of the `Policies` that exist on a particular resource.
+     * 
+ */ + public void listPolicies( + com.google.cloud.orgpolicy.v2.ListPoliciesRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + asyncUnaryCall( + getChannel().newCall(getListPoliciesMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Gets a `Policy` on a resource.
+     * If no `Policy` is set on the resource, NOT_FOUND is returned. The
+     * `etag` value can be used with `UpdatePolicy()` to update a
+     * `Policy` during read-modify-write.
+     * 
+ */ + public void getPolicy( + com.google.cloud.orgpolicy.v2.GetPolicyRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetPolicyMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + * + *
+     * Gets the effective `Policy` on a resource. This is the result of merging
+     * `Policies` in the resource hierarchy and evaluating conditions. The
+     * returned `Policy` will not have an `etag` or `condition` set because it is
+     * a computed `Policy` across multiple resources.
+     * Subtrees of Resource Manager resource hierarchy with 'under:' prefix will
+     * not be expanded.
+     * 
+ */ + public void getEffectivePolicy( + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetEffectivePolicyMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Creates a Policy.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
+     * constraint does not exist.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
+     * policy already exists on the given Cloud resource.
+     * 
+ */ + public void createPolicy( + com.google.cloud.orgpolicy.v2.CreatePolicyRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getCreatePolicyMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Updates a Policy.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
+     * constraint or the policy do not exist.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
+     * supplied in the request does not match the persisted etag of the policy
+     * Note: the supplied policy will perform a full overwrite of all
+     * fields.
+     * 
+ */ + public void updatePolicy( + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getUpdatePolicyMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Deletes a Policy.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
+     * constraint or Org Policy does not exist.
+     * 
+ */ + public void deletePolicy( + com.google.cloud.orgpolicy.v2.DeletePolicyRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getDeletePolicyMethod(), getCallOptions()), + request, + responseObserver); + } + } + + /** + * + * + *
+   * An interface for managing organization policies.
+   * The Cloud Org Policy service provides a simple mechanism for organizations to
+   * restrict the allowed configurations across their entire Cloud Resource
+   * hierarchy.
+   * You can use a `policy` to configure restrictions in Cloud resources. For
+   * example, you can enforce a `policy` that restricts which Google
+   * Cloud Platform APIs can be activated in a certain part of your resource
+   * hierarchy, or prevents serial port access to VM instances in a particular
+   * folder.
+   * `Policies` are inherited down through the resource hierarchy. A `policy`
+   * applied to a parent resource automatically applies to all its child resources
+   * unless overridden with a `policy` lower in the hierarchy.
+   * A `constraint` defines an aspect of a resource's configuration that can be
+   * controlled by an organization's policy administrator. `Policies` are a
+   * collection of `constraints` that defines their allowable configuration on a
+   * particular resource and its child resources.
+   * 
+ */ + public static final class OrgPolicyBlockingStub + extends io.grpc.stub.AbstractBlockingStub { + private OrgPolicyBlockingStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected OrgPolicyBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new OrgPolicyBlockingStub(channel, callOptions); + } + + /** + * + * + *
+     * Lists `Constraints` that could be applied on the specified resource.
+     * 
+ */ + public com.google.cloud.orgpolicy.v2.ListConstraintsResponse listConstraints( + com.google.cloud.orgpolicy.v2.ListConstraintsRequest request) { + return blockingUnaryCall(getChannel(), getListConstraintsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Retrieves all of the `Policies` that exist on a particular resource.
+     * 
+ */ + public com.google.cloud.orgpolicy.v2.ListPoliciesResponse listPolicies( + com.google.cloud.orgpolicy.v2.ListPoliciesRequest request) { + return blockingUnaryCall(getChannel(), getListPoliciesMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets a `Policy` on a resource.
+     * If no `Policy` is set on the resource, NOT_FOUND is returned. The
+     * `etag` value can be used with `UpdatePolicy()` to update a
+     * `Policy` during read-modify-write.
+     * 
+ */ + public com.google.cloud.orgpolicy.v2.Policy getPolicy( + com.google.cloud.orgpolicy.v2.GetPolicyRequest request) { + return blockingUnaryCall(getChannel(), getGetPolicyMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets the effective `Policy` on a resource. This is the result of merging
+     * `Policies` in the resource hierarchy and evaluating conditions. The
+     * returned `Policy` will not have an `etag` or `condition` set because it is
+     * a computed `Policy` across multiple resources.
+     * Subtrees of Resource Manager resource hierarchy with 'under:' prefix will
+     * not be expanded.
+     * 
+ */ + public com.google.cloud.orgpolicy.v2.Policy getEffectivePolicy( + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest request) { + return blockingUnaryCall( + getChannel(), getGetEffectivePolicyMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Creates a Policy.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
+     * constraint does not exist.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
+     * policy already exists on the given Cloud resource.
+     * 
+ */ + public com.google.cloud.orgpolicy.v2.Policy createPolicy( + com.google.cloud.orgpolicy.v2.CreatePolicyRequest request) { + return blockingUnaryCall(getChannel(), getCreatePolicyMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Updates a Policy.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
+     * constraint or the policy do not exist.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
+     * supplied in the request does not match the persisted etag of the policy
+     * Note: the supplied policy will perform a full overwrite of all
+     * fields.
+     * 
+ */ + public com.google.cloud.orgpolicy.v2.Policy updatePolicy( + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest request) { + return blockingUnaryCall(getChannel(), getUpdatePolicyMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a Policy.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
+     * constraint or Org Policy does not exist.
+     * 
+ */ + public com.google.protobuf.Empty deletePolicy( + com.google.cloud.orgpolicy.v2.DeletePolicyRequest request) { + return blockingUnaryCall(getChannel(), getDeletePolicyMethod(), getCallOptions(), request); + } + } + + /** + * + * + *
+   * An interface for managing organization policies.
+   * The Cloud Org Policy service provides a simple mechanism for organizations to
+   * restrict the allowed configurations across their entire Cloud Resource
+   * hierarchy.
+   * You can use a `policy` to configure restrictions in Cloud resources. For
+   * example, you can enforce a `policy` that restricts which Google
+   * Cloud Platform APIs can be activated in a certain part of your resource
+   * hierarchy, or prevents serial port access to VM instances in a particular
+   * folder.
+   * `Policies` are inherited down through the resource hierarchy. A `policy`
+   * applied to a parent resource automatically applies to all its child resources
+   * unless overridden with a `policy` lower in the hierarchy.
+   * A `constraint` defines an aspect of a resource's configuration that can be
+   * controlled by an organization's policy administrator. `Policies` are a
+   * collection of `constraints` that defines their allowable configuration on a
+   * particular resource and its child resources.
+   * 
+ */ + public static final class OrgPolicyFutureStub + extends io.grpc.stub.AbstractFutureStub { + private OrgPolicyFutureStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected OrgPolicyFutureStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new OrgPolicyFutureStub(channel, callOptions); + } + + /** + * + * + *
+     * Lists `Constraints` that could be applied on the specified resource.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.cloud.orgpolicy.v2.ListConstraintsResponse> + listConstraints(com.google.cloud.orgpolicy.v2.ListConstraintsRequest request) { + return futureUnaryCall( + getChannel().newCall(getListConstraintsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Retrieves all of the `Policies` that exist on a particular resource.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.cloud.orgpolicy.v2.ListPoliciesResponse> + listPolicies(com.google.cloud.orgpolicy.v2.ListPoliciesRequest request) { + return futureUnaryCall( + getChannel().newCall(getListPoliciesMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Gets a `Policy` on a resource.
+     * If no `Policy` is set on the resource, NOT_FOUND is returned. The
+     * `etag` value can be used with `UpdatePolicy()` to update a
+     * `Policy` during read-modify-write.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + getPolicy(com.google.cloud.orgpolicy.v2.GetPolicyRequest request) { + return futureUnaryCall(getChannel().newCall(getGetPolicyMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Gets the effective `Policy` on a resource. This is the result of merging
+     * `Policies` in the resource hierarchy and evaluating conditions. The
+     * returned `Policy` will not have an `etag` or `condition` set because it is
+     * a computed `Policy` across multiple resources.
+     * Subtrees of Resource Manager resource hierarchy with 'under:' prefix will
+     * not be expanded.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + getEffectivePolicy(com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest request) { + return futureUnaryCall( + getChannel().newCall(getGetEffectivePolicyMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Creates a Policy.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
+     * constraint does not exist.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
+     * policy already exists on the given Cloud resource.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + createPolicy(com.google.cloud.orgpolicy.v2.CreatePolicyRequest request) { + return futureUnaryCall( + getChannel().newCall(getCreatePolicyMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Updates a Policy.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
+     * constraint or the policy do not exist.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
+     * supplied in the request does not match the persisted etag of the policy
+     * Note: the supplied policy will perform a full overwrite of all
+     * fields.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + updatePolicy(com.google.cloud.orgpolicy.v2.UpdatePolicyRequest request) { + return futureUnaryCall( + getChannel().newCall(getUpdatePolicyMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Deletes a Policy.
+     * Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
+     * constraint or Org Policy does not exist.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + deletePolicy(com.google.cloud.orgpolicy.v2.DeletePolicyRequest request) { + return futureUnaryCall( + getChannel().newCall(getDeletePolicyMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_LIST_CONSTRAINTS = 0; + private static final int METHODID_LIST_POLICIES = 1; + private static final int METHODID_GET_POLICY = 2; + private static final int METHODID_GET_EFFECTIVE_POLICY = 3; + private static final int METHODID_CREATE_POLICY = 4; + private static final int METHODID_UPDATE_POLICY = 5; + private static final int METHODID_DELETE_POLICY = 6; + + private static final class MethodHandlers + implements io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final OrgPolicyImplBase serviceImpl; + private final int methodId; + + MethodHandlers(OrgPolicyImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_LIST_CONSTRAINTS: + serviceImpl.listConstraints( + (com.google.cloud.orgpolicy.v2.ListConstraintsRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_LIST_POLICIES: + serviceImpl.listPolicies( + (com.google.cloud.orgpolicy.v2.ListPoliciesRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_GET_POLICY: + serviceImpl.getPolicy( + (com.google.cloud.orgpolicy.v2.GetPolicyRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_EFFECTIVE_POLICY: + serviceImpl.getEffectivePolicy( + (com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CREATE_POLICY: + serviceImpl.createPolicy( + (com.google.cloud.orgpolicy.v2.CreatePolicyRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UPDATE_POLICY: + serviceImpl.updatePolicy( + (com.google.cloud.orgpolicy.v2.UpdatePolicyRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_DELETE_POLICY: + serviceImpl.deletePolicy( + (com.google.cloud.orgpolicy.v2.DeletePolicyRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private abstract static class OrgPolicyBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, + io.grpc.protobuf.ProtoServiceDescriptorSupplier { + OrgPolicyBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("OrgPolicy"); + } + } + + private static final class OrgPolicyFileDescriptorSupplier + extends OrgPolicyBaseDescriptorSupplier { + OrgPolicyFileDescriptorSupplier() {} + } + + private static final class OrgPolicyMethodDescriptorSupplier + extends OrgPolicyBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + OrgPolicyMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (OrgPolicyGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = + result = + io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new OrgPolicyFileDescriptorSupplier()) + .addMethod(getListConstraintsMethod()) + .addMethod(getListPoliciesMethod()) + .addMethod(getGetPolicyMethod()) + .addMethod(getGetEffectivePolicyMethod()) + .addMethod(getCreatePolicyMethod()) + .addMethod(getUpdatePolicyMethod()) + .addMethod(getDeletePolicyMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/pom.xml b/pom.xml index 741de3c..750ae43 100644 --- a/pom.xml +++ b/pom.xml @@ -67,6 +67,26 @@ + + com.google.api.grpc + google-cloud-orgpolicy + 1.0.12-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-orgpolicy-v1 + 1.0.12-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-orgpolicy-v2 + 1.0.12-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-orgpolicy-v2 + 1.0.12-SNAPSHOT + com.google.cloud google-cloud-shared-dependencies @@ -85,7 +105,11 @@ + google-cloud-orgpolicy proto-google-cloud-orgpolicy-v1 + proto-google-cloud-orgpolicy-v2 + grpc-google-cloud-orgpolicy-v2 + google-cloud-orgpolicy-bom diff --git a/proto-google-cloud-orgpolicy-v1/pom.xml b/proto-google-cloud-orgpolicy-v1/pom.xml index 29b19f5..15ee32a 100644 --- a/proto-google-cloud-orgpolicy-v1/pom.xml +++ b/proto-google-cloud-orgpolicy-v1/pom.xml @@ -10,7 +10,7 @@ com.google.cloud google-cloud-orgpolicy-parent - 1.0.12-SNAPSHOT + 1.0.12-SNAPSHOT diff --git a/proto-google-cloud-orgpolicy-v2/pom.xml b/proto-google-cloud-orgpolicy-v2/pom.xml new file mode 100644 index 0000000..539f606 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/pom.xml @@ -0,0 +1,42 @@ + + 4.0.0 + com.google.api.grpc + proto-google-cloud-orgpolicy-v2 + 1.0.12-SNAPSHOT + proto-google-cloud-orgpolicy-v2 + PROTO library for proto-google-cloud-orgpolicy-v2 + + com.google.cloud + google-cloud-orgpolicy-parent + 1.0.12-SNAPSHOT + + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-common-protos + + + com.google.api + api-common + + + com.google.guava + guava + + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + + \ No newline at end of file diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/AlternatePolicySpec.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/AlternatePolicySpec.java new file mode 100644 index 0000000..c0b45a6 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/AlternatePolicySpec.java @@ -0,0 +1,927 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +/** + * + * + *
+ * Similar to PolicySpec but with an extra 'launch' field for launch reference.
+ * The PolicySpec here is specific for dry-run/darklaunch.
+ * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.AlternatePolicySpec} + */ +public final class AlternatePolicySpec extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.AlternatePolicySpec) + AlternatePolicySpecOrBuilder { + private static final long serialVersionUID = 0L; + // Use AlternatePolicySpec.newBuilder() to construct. + private AlternatePolicySpec(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private AlternatePolicySpec() { + launch_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new AlternatePolicySpec(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private AlternatePolicySpec( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + launch_ = s; + break; + } + case 18: + { + com.google.cloud.orgpolicy.v2.PolicySpec.Builder subBuilder = null; + if (spec_ != null) { + subBuilder = spec_.toBuilder(); + } + spec_ = + input.readMessage( + com.google.cloud.orgpolicy.v2.PolicySpec.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(spec_); + spec_ = subBuilder.buildPartial(); + } + + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_AlternatePolicySpec_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_AlternatePolicySpec_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.AlternatePolicySpec.class, + com.google.cloud.orgpolicy.v2.AlternatePolicySpec.Builder.class); + } + + public static final int LAUNCH_FIELD_NUMBER = 1; + private volatile java.lang.Object launch_; + /** + * + * + *
+   * Reference to the launch that will be used while audit logging and to
+   * control the launch.
+   * Should be set only in the alternate policy.
+   * 
+ * + * string launch = 1; + * + * @return The launch. + */ + @java.lang.Override + public java.lang.String getLaunch() { + java.lang.Object ref = launch_; + 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(); + launch_ = s; + return s; + } + } + /** + * + * + *
+   * Reference to the launch that will be used while audit logging and to
+   * control the launch.
+   * Should be set only in the alternate policy.
+   * 
+ * + * string launch = 1; + * + * @return The bytes for launch. + */ + @java.lang.Override + public com.google.protobuf.ByteString getLaunchBytes() { + java.lang.Object ref = launch_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + launch_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SPEC_FIELD_NUMBER = 2; + private com.google.cloud.orgpolicy.v2.PolicySpec spec_; + /** + * + * + *
+   * Specify `Constraint` for configurations of Cloud Platform resources.
+   * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + * + * @return Whether the spec field is set. + */ + @java.lang.Override + public boolean hasSpec() { + return spec_ != null; + } + /** + * + * + *
+   * Specify `Constraint` for configurations of Cloud Platform resources.
+   * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + * + * @return The spec. + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec getSpec() { + return spec_ == null ? com.google.cloud.orgpolicy.v2.PolicySpec.getDefaultInstance() : spec_; + } + /** + * + * + *
+   * Specify `Constraint` for configurations of Cloud Platform resources.
+   * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpecOrBuilder getSpecOrBuilder() { + return getSpec(); + } + + 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 (!getLaunchBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, launch_); + } + if (spec_ != null) { + output.writeMessage(2, getSpec()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getLaunchBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, launch_); + } + if (spec_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getSpec()); + } + size += unknownFields.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.cloud.orgpolicy.v2.AlternatePolicySpec)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.AlternatePolicySpec other = + (com.google.cloud.orgpolicy.v2.AlternatePolicySpec) obj; + + if (!getLaunch().equals(other.getLaunch())) return false; + if (hasSpec() != other.hasSpec()) return false; + if (hasSpec()) { + if (!getSpec().equals(other.getSpec())) return false; + } + if (!unknownFields.equals(other.unknownFields)) 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) + LAUNCH_FIELD_NUMBER; + hash = (53 * hash) + getLaunch().hashCode(); + if (hasSpec()) { + hash = (37 * hash) + SPEC_FIELD_NUMBER; + hash = (53 * hash) + getSpec().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.AlternatePolicySpec parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.AlternatePolicySpec parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.AlternatePolicySpec parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.AlternatePolicySpec 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.cloud.orgpolicy.v2.AlternatePolicySpec parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.AlternatePolicySpec parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.AlternatePolicySpec parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.AlternatePolicySpec 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.cloud.orgpolicy.v2.AlternatePolicySpec parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.AlternatePolicySpec 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.cloud.orgpolicy.v2.AlternatePolicySpec parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.AlternatePolicySpec 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.cloud.orgpolicy.v2.AlternatePolicySpec 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; + } + /** + * + * + *
+   * Similar to PolicySpec but with an extra 'launch' field for launch reference.
+   * The PolicySpec here is specific for dry-run/darklaunch.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.AlternatePolicySpec} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.AlternatePolicySpec) + com.google.cloud.orgpolicy.v2.AlternatePolicySpecOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_AlternatePolicySpec_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_AlternatePolicySpec_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.AlternatePolicySpec.class, + com.google.cloud.orgpolicy.v2.AlternatePolicySpec.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.AlternatePolicySpec.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + launch_ = ""; + + if (specBuilder_ == null) { + spec_ = null; + } else { + spec_ = null; + specBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_AlternatePolicySpec_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.AlternatePolicySpec getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.AlternatePolicySpec.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.AlternatePolicySpec build() { + com.google.cloud.orgpolicy.v2.AlternatePolicySpec result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.AlternatePolicySpec buildPartial() { + com.google.cloud.orgpolicy.v2.AlternatePolicySpec result = + new com.google.cloud.orgpolicy.v2.AlternatePolicySpec(this); + result.launch_ = launch_; + if (specBuilder_ == null) { + result.spec_ = spec_; + } else { + result.spec_ = specBuilder_.build(); + } + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.AlternatePolicySpec) { + return mergeFrom((com.google.cloud.orgpolicy.v2.AlternatePolicySpec) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.AlternatePolicySpec other) { + if (other == com.google.cloud.orgpolicy.v2.AlternatePolicySpec.getDefaultInstance()) + return this; + if (!other.getLaunch().isEmpty()) { + launch_ = other.launch_; + onChanged(); + } + if (other.hasSpec()) { + mergeSpec(other.getSpec()); + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.AlternatePolicySpec parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.orgpolicy.v2.AlternatePolicySpec) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object launch_ = ""; + /** + * + * + *
+     * Reference to the launch that will be used while audit logging and to
+     * control the launch.
+     * Should be set only in the alternate policy.
+     * 
+ * + * string launch = 1; + * + * @return The launch. + */ + public java.lang.String getLaunch() { + java.lang.Object ref = launch_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + launch_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Reference to the launch that will be used while audit logging and to
+     * control the launch.
+     * Should be set only in the alternate policy.
+     * 
+ * + * string launch = 1; + * + * @return The bytes for launch. + */ + public com.google.protobuf.ByteString getLaunchBytes() { + java.lang.Object ref = launch_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + launch_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Reference to the launch that will be used while audit logging and to
+     * control the launch.
+     * Should be set only in the alternate policy.
+     * 
+ * + * string launch = 1; + * + * @param value The launch to set. + * @return This builder for chaining. + */ + public Builder setLaunch(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + launch_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Reference to the launch that will be used while audit logging and to
+     * control the launch.
+     * Should be set only in the alternate policy.
+     * 
+ * + * string launch = 1; + * + * @return This builder for chaining. + */ + public Builder clearLaunch() { + + launch_ = getDefaultInstance().getLaunch(); + onChanged(); + return this; + } + /** + * + * + *
+     * Reference to the launch that will be used while audit logging and to
+     * control the launch.
+     * Should be set only in the alternate policy.
+     * 
+ * + * string launch = 1; + * + * @param value The bytes for launch to set. + * @return This builder for chaining. + */ + public Builder setLaunchBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + launch_ = value; + onChanged(); + return this; + } + + private com.google.cloud.orgpolicy.v2.PolicySpec spec_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.PolicySpec, + com.google.cloud.orgpolicy.v2.PolicySpec.Builder, + com.google.cloud.orgpolicy.v2.PolicySpecOrBuilder> + specBuilder_; + /** + * + * + *
+     * Specify `Constraint` for configurations of Cloud Platform resources.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + * + * @return Whether the spec field is set. + */ + public boolean hasSpec() { + return specBuilder_ != null || spec_ != null; + } + /** + * + * + *
+     * Specify `Constraint` for configurations of Cloud Platform resources.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + * + * @return The spec. + */ + public com.google.cloud.orgpolicy.v2.PolicySpec getSpec() { + if (specBuilder_ == null) { + return spec_ == null + ? com.google.cloud.orgpolicy.v2.PolicySpec.getDefaultInstance() + : spec_; + } else { + return specBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Specify `Constraint` for configurations of Cloud Platform resources.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + public Builder setSpec(com.google.cloud.orgpolicy.v2.PolicySpec value) { + if (specBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + spec_ = value; + onChanged(); + } else { + specBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Specify `Constraint` for configurations of Cloud Platform resources.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + public Builder setSpec(com.google.cloud.orgpolicy.v2.PolicySpec.Builder builderForValue) { + if (specBuilder_ == null) { + spec_ = builderForValue.build(); + onChanged(); + } else { + specBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Specify `Constraint` for configurations of Cloud Platform resources.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + public Builder mergeSpec(com.google.cloud.orgpolicy.v2.PolicySpec value) { + if (specBuilder_ == null) { + if (spec_ != null) { + spec_ = + com.google.cloud.orgpolicy.v2.PolicySpec.newBuilder(spec_) + .mergeFrom(value) + .buildPartial(); + } else { + spec_ = value; + } + onChanged(); + } else { + specBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Specify `Constraint` for configurations of Cloud Platform resources.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + public Builder clearSpec() { + if (specBuilder_ == null) { + spec_ = null; + onChanged(); + } else { + spec_ = null; + specBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Specify `Constraint` for configurations of Cloud Platform resources.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + public com.google.cloud.orgpolicy.v2.PolicySpec.Builder getSpecBuilder() { + + onChanged(); + return getSpecFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Specify `Constraint` for configurations of Cloud Platform resources.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + public com.google.cloud.orgpolicy.v2.PolicySpecOrBuilder getSpecOrBuilder() { + if (specBuilder_ != null) { + return specBuilder_.getMessageOrBuilder(); + } else { + return spec_ == null + ? com.google.cloud.orgpolicy.v2.PolicySpec.getDefaultInstance() + : spec_; + } + } + /** + * + * + *
+     * Specify `Constraint` for configurations of Cloud Platform resources.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.PolicySpec, + com.google.cloud.orgpolicy.v2.PolicySpec.Builder, + com.google.cloud.orgpolicy.v2.PolicySpecOrBuilder> + getSpecFieldBuilder() { + if (specBuilder_ == null) { + specBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.PolicySpec, + com.google.cloud.orgpolicy.v2.PolicySpec.Builder, + com.google.cloud.orgpolicy.v2.PolicySpecOrBuilder>( + getSpec(), getParentForChildren(), isClean()); + spec_ = null; + } + return specBuilder_; + } + + @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.cloud.orgpolicy.v2.AlternatePolicySpec) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.AlternatePolicySpec) + private static final com.google.cloud.orgpolicy.v2.AlternatePolicySpec DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.AlternatePolicySpec(); + } + + public static com.google.cloud.orgpolicy.v2.AlternatePolicySpec getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public AlternatePolicySpec parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new AlternatePolicySpec(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.AlternatePolicySpec getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/AlternatePolicySpecOrBuilder.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/AlternatePolicySpecOrBuilder.java new file mode 100644 index 0000000..2416752 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/AlternatePolicySpecOrBuilder.java @@ -0,0 +1,89 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +public interface AlternatePolicySpecOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.AlternatePolicySpec) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Reference to the launch that will be used while audit logging and to
+   * control the launch.
+   * Should be set only in the alternate policy.
+   * 
+ * + * string launch = 1; + * + * @return The launch. + */ + java.lang.String getLaunch(); + /** + * + * + *
+   * Reference to the launch that will be used while audit logging and to
+   * control the launch.
+   * Should be set only in the alternate policy.
+   * 
+ * + * string launch = 1; + * + * @return The bytes for launch. + */ + com.google.protobuf.ByteString getLaunchBytes(); + + /** + * + * + *
+   * Specify `Constraint` for configurations of Cloud Platform resources.
+   * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + * + * @return Whether the spec field is set. + */ + boolean hasSpec(); + /** + * + * + *
+   * Specify `Constraint` for configurations of Cloud Platform resources.
+   * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + * + * @return The spec. + */ + com.google.cloud.orgpolicy.v2.PolicySpec getSpec(); + /** + * + * + *
+   * Specify `Constraint` for configurations of Cloud Platform resources.
+   * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + com.google.cloud.orgpolicy.v2.PolicySpecOrBuilder getSpecOrBuilder(); +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/Constraint.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/Constraint.java new file mode 100644 index 0000000..813853e --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/Constraint.java @@ -0,0 +1,3245 @@ +/* + * 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/cloud/orgpolicy/v2/constraint.proto + +package com.google.cloud.orgpolicy.v2; + +/** + * + * + *
+ * A `constraint` describes a way to restrict resource's configuration. For
+ * example, you could enforce a constraint that controls which cloud services
+ * can be activated across an organization, or whether a Compute Engine instance
+ * can have serial port connections established. `Constraints` can be configured
+ * by the organization's policy adminstrator to fit the needs of the organzation
+ * by setting a `policy` that includes `constraints` at different locations in
+ * the organization's resource hierarchy. Policies are inherited down the
+ * resource hierarchy from higher levels, but can also be overridden. For
+ * details about the inheritance rules please read about
+ * [`policies`][google.cloud.OrgPolicy.v2.Policy].
+ * `Constraints` have a default behavior determined by the `constraint_default`
+ * field, which is the enforcement behavior that is used in the absence of a
+ * `policy` being defined or inherited for the resource in question.
+ * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.Constraint} + */ +public final class Constraint extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.Constraint) + ConstraintOrBuilder { + private static final long serialVersionUID = 0L; + // Use Constraint.newBuilder() to construct. + private Constraint(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Constraint() { + name_ = ""; + displayName_ = ""; + description_ = ""; + constraintDefault_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Constraint(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private Constraint( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + + displayName_ = s; + break; + } + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + + description_ = s; + break; + } + case 32: + { + int rawValue = input.readEnum(); + + constraintDefault_ = rawValue; + break; + } + case 42: + { + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.Builder subBuilder = null; + if (constraintTypeCase_ == 5) { + subBuilder = + ((com.google.cloud.orgpolicy.v2.Constraint.ListConstraint) constraintType_) + .toBuilder(); + } + constraintType_ = + input.readMessage( + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.parser(), + extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom( + (com.google.cloud.orgpolicy.v2.Constraint.ListConstraint) constraintType_); + constraintType_ = subBuilder.buildPartial(); + } + constraintTypeCase_ = 5; + break; + } + case 50: + { + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.Builder subBuilder = null; + if (constraintTypeCase_ == 6) { + subBuilder = + ((com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) constraintType_) + .toBuilder(); + } + constraintType_ = + input.readMessage( + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.parser(), + extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom( + (com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) constraintType_); + constraintType_ = subBuilder.buildPartial(); + } + constraintTypeCase_ = 6; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.ConstraintProto + .internal_static_google_cloud_orgpolicy_v2_Constraint_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.ConstraintProto + .internal_static_google_cloud_orgpolicy_v2_Constraint_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.Constraint.class, + com.google.cloud.orgpolicy.v2.Constraint.Builder.class); + } + + /** + * + * + *
+   * Specifies the default behavior in the absence of any `Policy` for the
+   * `Constraint`. This must not be `CONSTRAINT_DEFAULT_UNSPECIFIED`.
+   * Immutable after creation.
+   * 
+ * + * Protobuf enum {@code google.cloud.orgpolicy.v2.Constraint.ConstraintDefault} + */ + public enum ConstraintDefault implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * This is only used for distinguishing unset values and should never be
+     * used.
+     * 
+ * + * CONSTRAINT_DEFAULT_UNSPECIFIED = 0; + */ + CONSTRAINT_DEFAULT_UNSPECIFIED(0), + /** + * + * + *
+     * Indicate that all values are allowed for list constraints.
+     * Indicate that enforcement is off for boolean constraints.
+     * 
+ * + * ALLOW = 1; + */ + ALLOW(1), + /** + * + * + *
+     * Indicate that all values are denied for list constraints.
+     * Indicate that enforcement is on for boolean constraints.
+     * 
+ * + * DENY = 2; + */ + DENY(2), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * This is only used for distinguishing unset values and should never be
+     * used.
+     * 
+ * + * CONSTRAINT_DEFAULT_UNSPECIFIED = 0; + */ + public static final int CONSTRAINT_DEFAULT_UNSPECIFIED_VALUE = 0; + /** + * + * + *
+     * Indicate that all values are allowed for list constraints.
+     * Indicate that enforcement is off for boolean constraints.
+     * 
+ * + * ALLOW = 1; + */ + public static final int ALLOW_VALUE = 1; + /** + * + * + *
+     * Indicate that all values are denied for list constraints.
+     * Indicate that enforcement is on for boolean constraints.
+     * 
+ * + * DENY = 2; + */ + public static final int DENY_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConstraintDefault valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static ConstraintDefault forNumber(int value) { + switch (value) { + case 0: + return CONSTRAINT_DEFAULT_UNSPECIFIED; + case 1: + return ALLOW; + case 2: + return DENY; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ConstraintDefault findValueByNumber(int number) { + return ConstraintDefault.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.Constraint.getDescriptor().getEnumTypes().get(0); + } + + private static final ConstraintDefault[] VALUES = values(); + + public static ConstraintDefault valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ConstraintDefault(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.cloud.orgpolicy.v2.Constraint.ConstraintDefault) + } + + public interface ListConstraintOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.Constraint.ListConstraint) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Indicates whether values grouped into categories can be used in
+     * `Policy.allowed_values` and `Policy.denied_values`. For example,
+     * `"in:Python"` would match any value in the 'Python' group.
+     * 
+ * + * bool supports_in = 1; + * + * @return The supportsIn. + */ + boolean getSupportsIn(); + + /** + * + * + *
+     * Indicates whether subtrees of Cloud Resource Manager resource hierarchy
+     * can be used in `Policy.allowed_values` and `Policy.denied_values`. For
+     * example, `"under:folders/123"` would match any resource under the
+     * 'folders/123' folder.
+     * 
+ * + * bool supports_under = 2; + * + * @return The supportsUnder. + */ + boolean getSupportsUnder(); + } + /** + * + * + *
+   * A `Constraint` that allows or disallows a list of string values, which are
+   * configured by an Organization's policy administrator with a `Policy`.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.Constraint.ListConstraint} + */ + public static final class ListConstraint extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.Constraint.ListConstraint) + ListConstraintOrBuilder { + private static final long serialVersionUID = 0L; + // Use ListConstraint.newBuilder() to construct. + private ListConstraint(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ListConstraint() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListConstraint(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private ListConstraint( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + supportsIn_ = input.readBool(); + break; + } + case 16: + { + supportsUnder_ = input.readBool(); + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.ConstraintProto + .internal_static_google_cloud_orgpolicy_v2_Constraint_ListConstraint_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.ConstraintProto + .internal_static_google_cloud_orgpolicy_v2_Constraint_ListConstraint_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.class, + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.Builder.class); + } + + public static final int SUPPORTS_IN_FIELD_NUMBER = 1; + private boolean supportsIn_; + /** + * + * + *
+     * Indicates whether values grouped into categories can be used in
+     * `Policy.allowed_values` and `Policy.denied_values`. For example,
+     * `"in:Python"` would match any value in the 'Python' group.
+     * 
+ * + * bool supports_in = 1; + * + * @return The supportsIn. + */ + @java.lang.Override + public boolean getSupportsIn() { + return supportsIn_; + } + + public static final int SUPPORTS_UNDER_FIELD_NUMBER = 2; + private boolean supportsUnder_; + /** + * + * + *
+     * Indicates whether subtrees of Cloud Resource Manager resource hierarchy
+     * can be used in `Policy.allowed_values` and `Policy.denied_values`. For
+     * example, `"under:folders/123"` would match any resource under the
+     * 'folders/123' folder.
+     * 
+ * + * bool supports_under = 2; + * + * @return The supportsUnder. + */ + @java.lang.Override + public boolean getSupportsUnder() { + return supportsUnder_; + } + + 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 (supportsIn_ != false) { + output.writeBool(1, supportsIn_); + } + if (supportsUnder_ != false) { + output.writeBool(2, supportsUnder_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (supportsIn_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(1, supportsIn_); + } + if (supportsUnder_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(2, supportsUnder_); + } + size += unknownFields.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.cloud.orgpolicy.v2.Constraint.ListConstraint)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint other = + (com.google.cloud.orgpolicy.v2.Constraint.ListConstraint) obj; + + if (getSupportsIn() != other.getSupportsIn()) return false; + if (getSupportsUnder() != other.getSupportsUnder()) return false; + if (!unknownFields.equals(other.unknownFields)) 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) + SUPPORTS_IN_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getSupportsIn()); + hash = (37 * hash) + SUPPORTS_UNDER_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getSupportsUnder()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.Constraint.ListConstraint parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.ListConstraint parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.ListConstraint parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.ListConstraint 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.cloud.orgpolicy.v2.Constraint.ListConstraint parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.ListConstraint parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.ListConstraint parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.ListConstraint 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.cloud.orgpolicy.v2.Constraint.ListConstraint parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.ListConstraint 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.cloud.orgpolicy.v2.Constraint.ListConstraint parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.ListConstraint 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.cloud.orgpolicy.v2.Constraint.ListConstraint 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; + } + /** + * + * + *
+     * A `Constraint` that allows or disallows a list of string values, which are
+     * configured by an Organization's policy administrator with a `Policy`.
+     * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.Constraint.ListConstraint} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.Constraint.ListConstraint) + com.google.cloud.orgpolicy.v2.Constraint.ListConstraintOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.ConstraintProto + .internal_static_google_cloud_orgpolicy_v2_Constraint_ListConstraint_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.ConstraintProto + .internal_static_google_cloud_orgpolicy_v2_Constraint_ListConstraint_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.class, + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + supportsIn_ = false; + + supportsUnder_ = false; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.ConstraintProto + .internal_static_google_cloud_orgpolicy_v2_Constraint_ListConstraint_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.ListConstraint getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.ListConstraint build() { + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.ListConstraint buildPartial() { + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint result = + new com.google.cloud.orgpolicy.v2.Constraint.ListConstraint(this); + result.supportsIn_ = supportsIn_; + result.supportsUnder_ = supportsUnder_; + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.Constraint.ListConstraint) { + return mergeFrom((com.google.cloud.orgpolicy.v2.Constraint.ListConstraint) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.Constraint.ListConstraint other) { + if (other == com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.getDefaultInstance()) + return this; + if (other.getSupportsIn() != false) { + setSupportsIn(other.getSupportsIn()); + } + if (other.getSupportsUnder() != false) { + setSupportsUnder(other.getSupportsUnder()); + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.orgpolicy.v2.Constraint.ListConstraint) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private boolean supportsIn_; + /** + * + * + *
+       * Indicates whether values grouped into categories can be used in
+       * `Policy.allowed_values` and `Policy.denied_values`. For example,
+       * `"in:Python"` would match any value in the 'Python' group.
+       * 
+ * + * bool supports_in = 1; + * + * @return The supportsIn. + */ + @java.lang.Override + public boolean getSupportsIn() { + return supportsIn_; + } + /** + * + * + *
+       * Indicates whether values grouped into categories can be used in
+       * `Policy.allowed_values` and `Policy.denied_values`. For example,
+       * `"in:Python"` would match any value in the 'Python' group.
+       * 
+ * + * bool supports_in = 1; + * + * @param value The supportsIn to set. + * @return This builder for chaining. + */ + public Builder setSupportsIn(boolean value) { + + supportsIn_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * Indicates whether values grouped into categories can be used in
+       * `Policy.allowed_values` and `Policy.denied_values`. For example,
+       * `"in:Python"` would match any value in the 'Python' group.
+       * 
+ * + * bool supports_in = 1; + * + * @return This builder for chaining. + */ + public Builder clearSupportsIn() { + + supportsIn_ = false; + onChanged(); + return this; + } + + private boolean supportsUnder_; + /** + * + * + *
+       * Indicates whether subtrees of Cloud Resource Manager resource hierarchy
+       * can be used in `Policy.allowed_values` and `Policy.denied_values`. For
+       * example, `"under:folders/123"` would match any resource under the
+       * 'folders/123' folder.
+       * 
+ * + * bool supports_under = 2; + * + * @return The supportsUnder. + */ + @java.lang.Override + public boolean getSupportsUnder() { + return supportsUnder_; + } + /** + * + * + *
+       * Indicates whether subtrees of Cloud Resource Manager resource hierarchy
+       * can be used in `Policy.allowed_values` and `Policy.denied_values`. For
+       * example, `"under:folders/123"` would match any resource under the
+       * 'folders/123' folder.
+       * 
+ * + * bool supports_under = 2; + * + * @param value The supportsUnder to set. + * @return This builder for chaining. + */ + public Builder setSupportsUnder(boolean value) { + + supportsUnder_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * Indicates whether subtrees of Cloud Resource Manager resource hierarchy
+       * can be used in `Policy.allowed_values` and `Policy.denied_values`. For
+       * example, `"under:folders/123"` would match any resource under the
+       * 'folders/123' folder.
+       * 
+ * + * bool supports_under = 2; + * + * @return This builder for chaining. + */ + public Builder clearSupportsUnder() { + + supportsUnder_ = false; + 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.cloud.orgpolicy.v2.Constraint.ListConstraint) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.Constraint.ListConstraint) + private static final com.google.cloud.orgpolicy.v2.Constraint.ListConstraint DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.Constraint.ListConstraint(); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.ListConstraint getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListConstraint parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ListConstraint(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.Constraint.ListConstraint getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface BooleanConstraintOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) + com.google.protobuf.MessageOrBuilder {} + /** + * + * + *
+   * A `Constraint` that is either enforced or not.
+   * For example a constraint `constraints/compute.disableSerialPortAccess`.
+   * If it is enforced on a VM instance, serial port connections will not be
+   * opened to that instance.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.Constraint.BooleanConstraint} + */ + public static final class BooleanConstraint extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) + BooleanConstraintOrBuilder { + private static final long serialVersionUID = 0L; + // Use BooleanConstraint.newBuilder() to construct. + private BooleanConstraint(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private BooleanConstraint() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new BooleanConstraint(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private BooleanConstraint( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.ConstraintProto + .internal_static_google_cloud_orgpolicy_v2_Constraint_BooleanConstraint_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.ConstraintProto + .internal_static_google_cloud_orgpolicy_v2_Constraint_BooleanConstraint_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.class, + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.Builder.class); + } + + 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 { + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += unknownFields.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.cloud.orgpolicy.v2.Constraint.BooleanConstraint)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint other = + (com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) obj; + + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint 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.cloud.orgpolicy.v2.Constraint.BooleanConstraint parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint 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.cloud.orgpolicy.v2.Constraint.BooleanConstraint parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint 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.cloud.orgpolicy.v2.Constraint.BooleanConstraint parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint 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.cloud.orgpolicy.v2.Constraint.BooleanConstraint 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; + } + /** + * + * + *
+     * A `Constraint` that is either enforced or not.
+     * For example a constraint `constraints/compute.disableSerialPortAccess`.
+     * If it is enforced on a VM instance, serial port connections will not be
+     * opened to that instance.
+     * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.Constraint.BooleanConstraint} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraintOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.ConstraintProto + .internal_static_google_cloud_orgpolicy_v2_Constraint_BooleanConstraint_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.ConstraintProto + .internal_static_google_cloud_orgpolicy_v2_Constraint_BooleanConstraint_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.class, + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.ConstraintProto + .internal_static_google_cloud_orgpolicy_v2_Constraint_BooleanConstraint_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint + getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint build() { + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint buildPartial() { + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint result = + new com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint(this); + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.Constraint.BooleanConstraint) { + return mergeFrom((com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint other) { + if (other + == com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.getDefaultInstance()) + return this; + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + 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.cloud.orgpolicy.v2.Constraint.BooleanConstraint) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) + private static final com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint(); + } + + public static com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BooleanConstraint parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BooleanConstraint(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.Constraint.BooleanConstraint getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int constraintTypeCase_ = 0; + private java.lang.Object constraintType_; + + public enum ConstraintTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + LIST_CONSTRAINT(5), + BOOLEAN_CONSTRAINT(6), + CONSTRAINTTYPE_NOT_SET(0); + private final int value; + + private ConstraintTypeCase(int value) { + this.value = value; + } + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConstraintTypeCase valueOf(int value) { + return forNumber(value); + } + + public static ConstraintTypeCase forNumber(int value) { + switch (value) { + case 5: + return LIST_CONSTRAINT; + case 6: + return BOOLEAN_CONSTRAINT; + case 0: + return CONSTRAINTTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ConstraintTypeCase getConstraintTypeCase() { + return ConstraintTypeCase.forNumber(constraintTypeCase_); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * + * + *
+   * Immutable. The resource name of the Constraint. Must be in one of
+   * the following forms:
+   * * `projects/{project_number}/constraints/{constraint_name}`
+   * * `folders/{folder_id}/constraints/{constraint_name}`
+   * * `organizations/{organization_id}/constraints/{constraint_name}`
+   * For example, "/projects/123/constraints/compute.disableSerialPortAccess".
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + 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(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Immutable. The resource name of the Constraint. Must be in one of
+   * the following forms:
+   * * `projects/{project_number}/constraints/{constraint_name}`
+   * * `folders/{folder_id}/constraints/{constraint_name}`
+   * * `organizations/{organization_id}/constraints/{constraint_name}`
+   * For example, "/projects/123/constraints/compute.disableSerialPortAccess".
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DISPLAY_NAME_FIELD_NUMBER = 2; + private volatile java.lang.Object displayName_; + /** + * + * + *
+   * The human readable name.
+   * Mutable.
+   * 
+ * + * string display_name = 2; + * + * @return The displayName. + */ + @java.lang.Override + public java.lang.String getDisplayName() { + java.lang.Object ref = displayName_; + 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(); + displayName_ = s; + return s; + } + } + /** + * + * + *
+   * The human readable name.
+   * Mutable.
+   * 
+ * + * string display_name = 2; + * + * @return The bytes for displayName. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDisplayNameBytes() { + java.lang.Object ref = displayName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + displayName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DESCRIPTION_FIELD_NUMBER = 3; + private volatile java.lang.Object description_; + /** + * + * + *
+   * Detailed description of what this `Constraint` controls as well as how and
+   * where it is enforced.
+   * Mutable.
+   * 
+ * + * string description = 3; + * + * @return The description. + */ + @java.lang.Override + public java.lang.String getDescription() { + java.lang.Object ref = description_; + 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(); + description_ = s; + return s; + } + } + /** + * + * + *
+   * Detailed description of what this `Constraint` controls as well as how and
+   * where it is enforced.
+   * Mutable.
+   * 
+ * + * string description = 3; + * + * @return The bytes for description. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CONSTRAINT_DEFAULT_FIELD_NUMBER = 4; + private int constraintDefault_; + /** + * + * + *
+   * The evaluation behavior of this constraint in the absence of 'Policy'.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ConstraintDefault constraint_default = 4; + * + * @return The enum numeric value on the wire for constraintDefault. + */ + @java.lang.Override + public int getConstraintDefaultValue() { + return constraintDefault_; + } + /** + * + * + *
+   * The evaluation behavior of this constraint in the absence of 'Policy'.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ConstraintDefault constraint_default = 4; + * + * @return The constraintDefault. + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault getConstraintDefault() { + @SuppressWarnings("deprecation") + com.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault result = + com.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault.valueOf(constraintDefault_); + return result == null + ? com.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault.UNRECOGNIZED + : result; + } + + public static final int LIST_CONSTRAINT_FIELD_NUMBER = 5; + /** + * + * + *
+   * Defines this constraint as being a ListConstraint.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5; + * + * @return Whether the listConstraint field is set. + */ + @java.lang.Override + public boolean hasListConstraint() { + return constraintTypeCase_ == 5; + } + /** + * + * + *
+   * Defines this constraint as being a ListConstraint.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5; + * + * @return The listConstraint. + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.ListConstraint getListConstraint() { + if (constraintTypeCase_ == 5) { + return (com.google.cloud.orgpolicy.v2.Constraint.ListConstraint) constraintType_; + } + return com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.getDefaultInstance(); + } + /** + * + * + *
+   * Defines this constraint as being a ListConstraint.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5; + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.ListConstraintOrBuilder + getListConstraintOrBuilder() { + if (constraintTypeCase_ == 5) { + return (com.google.cloud.orgpolicy.v2.Constraint.ListConstraint) constraintType_; + } + return com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.getDefaultInstance(); + } + + public static final int BOOLEAN_CONSTRAINT_FIELD_NUMBER = 6; + /** + * + * + *
+   * Defines this constraint as being a BooleanConstraint.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6; + * + * @return Whether the booleanConstraint field is set. + */ + @java.lang.Override + public boolean hasBooleanConstraint() { + return constraintTypeCase_ == 6; + } + /** + * + * + *
+   * Defines this constraint as being a BooleanConstraint.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6; + * + * @return The booleanConstraint. + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint getBooleanConstraint() { + if (constraintTypeCase_ == 6) { + return (com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) constraintType_; + } + return com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.getDefaultInstance(); + } + /** + * + * + *
+   * Defines this constraint as being a BooleanConstraint.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6; + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraintOrBuilder + getBooleanConstraintOrBuilder() { + if (constraintTypeCase_ == 6) { + return (com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) constraintType_; + } + return com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.getDefaultInstance(); + } + + 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 (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (!getDisplayNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, displayName_); + } + if (!getDescriptionBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, description_); + } + if (constraintDefault_ + != com.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault.CONSTRAINT_DEFAULT_UNSPECIFIED + .getNumber()) { + output.writeEnum(4, constraintDefault_); + } + if (constraintTypeCase_ == 5) { + output.writeMessage( + 5, (com.google.cloud.orgpolicy.v2.Constraint.ListConstraint) constraintType_); + } + if (constraintTypeCase_ == 6) { + output.writeMessage( + 6, (com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) constraintType_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (!getDisplayNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, displayName_); + } + if (!getDescriptionBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, description_); + } + if (constraintDefault_ + != com.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault.CONSTRAINT_DEFAULT_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(4, constraintDefault_); + } + if (constraintTypeCase_ == 5) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 5, (com.google.cloud.orgpolicy.v2.Constraint.ListConstraint) constraintType_); + } + if (constraintTypeCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) constraintType_); + } + size += unknownFields.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.cloud.orgpolicy.v2.Constraint)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.Constraint other = (com.google.cloud.orgpolicy.v2.Constraint) obj; + + if (!getName().equals(other.getName())) return false; + if (!getDisplayName().equals(other.getDisplayName())) return false; + if (!getDescription().equals(other.getDescription())) return false; + if (constraintDefault_ != other.constraintDefault_) return false; + if (!getConstraintTypeCase().equals(other.getConstraintTypeCase())) return false; + switch (constraintTypeCase_) { + case 5: + if (!getListConstraint().equals(other.getListConstraint())) return false; + break; + case 6: + if (!getBooleanConstraint().equals(other.getBooleanConstraint())) return false; + break; + case 0: + default: + } + if (!unknownFields.equals(other.unknownFields)) 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) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + DISPLAY_NAME_FIELD_NUMBER; + hash = (53 * hash) + getDisplayName().hashCode(); + hash = (37 * hash) + DESCRIPTION_FIELD_NUMBER; + hash = (53 * hash) + getDescription().hashCode(); + hash = (37 * hash) + CONSTRAINT_DEFAULT_FIELD_NUMBER; + hash = (53 * hash) + constraintDefault_; + switch (constraintTypeCase_) { + case 5: + hash = (37 * hash) + LIST_CONSTRAINT_FIELD_NUMBER; + hash = (53 * hash) + getListConstraint().hashCode(); + break; + case 6: + hash = (37 * hash) + BOOLEAN_CONSTRAINT_FIELD_NUMBER; + hash = (53 * hash) + getBooleanConstraint().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.Constraint parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.Constraint parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.Constraint parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.Constraint 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.cloud.orgpolicy.v2.Constraint parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.Constraint parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.Constraint parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.Constraint 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.cloud.orgpolicy.v2.Constraint parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.Constraint 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.cloud.orgpolicy.v2.Constraint parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.Constraint 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.cloud.orgpolicy.v2.Constraint 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; + } + /** + * + * + *
+   * A `constraint` describes a way to restrict resource's configuration. For
+   * example, you could enforce a constraint that controls which cloud services
+   * can be activated across an organization, or whether a Compute Engine instance
+   * can have serial port connections established. `Constraints` can be configured
+   * by the organization's policy adminstrator to fit the needs of the organzation
+   * by setting a `policy` that includes `constraints` at different locations in
+   * the organization's resource hierarchy. Policies are inherited down the
+   * resource hierarchy from higher levels, but can also be overridden. For
+   * details about the inheritance rules please read about
+   * [`policies`][google.cloud.OrgPolicy.v2.Policy].
+   * `Constraints` have a default behavior determined by the `constraint_default`
+   * field, which is the enforcement behavior that is used in the absence of a
+   * `policy` being defined or inherited for the resource in question.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.Constraint} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.Constraint) + com.google.cloud.orgpolicy.v2.ConstraintOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.ConstraintProto + .internal_static_google_cloud_orgpolicy_v2_Constraint_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.ConstraintProto + .internal_static_google_cloud_orgpolicy_v2_Constraint_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.Constraint.class, + com.google.cloud.orgpolicy.v2.Constraint.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.Constraint.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + name_ = ""; + + displayName_ = ""; + + description_ = ""; + + constraintDefault_ = 0; + + constraintTypeCase_ = 0; + constraintType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.ConstraintProto + .internal_static_google_cloud_orgpolicy_v2_Constraint_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.Constraint.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint build() { + com.google.cloud.orgpolicy.v2.Constraint result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint buildPartial() { + com.google.cloud.orgpolicy.v2.Constraint result = + new com.google.cloud.orgpolicy.v2.Constraint(this); + result.name_ = name_; + result.displayName_ = displayName_; + result.description_ = description_; + result.constraintDefault_ = constraintDefault_; + if (constraintTypeCase_ == 5) { + if (listConstraintBuilder_ == null) { + result.constraintType_ = constraintType_; + } else { + result.constraintType_ = listConstraintBuilder_.build(); + } + } + if (constraintTypeCase_ == 6) { + if (booleanConstraintBuilder_ == null) { + result.constraintType_ = constraintType_; + } else { + result.constraintType_ = booleanConstraintBuilder_.build(); + } + } + result.constraintTypeCase_ = constraintTypeCase_; + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.Constraint) { + return mergeFrom((com.google.cloud.orgpolicy.v2.Constraint) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.Constraint other) { + if (other == com.google.cloud.orgpolicy.v2.Constraint.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (!other.getDisplayName().isEmpty()) { + displayName_ = other.displayName_; + onChanged(); + } + if (!other.getDescription().isEmpty()) { + description_ = other.description_; + onChanged(); + } + if (other.constraintDefault_ != 0) { + setConstraintDefaultValue(other.getConstraintDefaultValue()); + } + switch (other.getConstraintTypeCase()) { + case LIST_CONSTRAINT: + { + mergeListConstraint(other.getListConstraint()); + break; + } + case BOOLEAN_CONSTRAINT: + { + mergeBooleanConstraint(other.getBooleanConstraint()); + break; + } + case CONSTRAINTTYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.Constraint parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.cloud.orgpolicy.v2.Constraint) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int constraintTypeCase_ = 0; + private java.lang.Object constraintType_; + + public ConstraintTypeCase getConstraintTypeCase() { + return ConstraintTypeCase.forNumber(constraintTypeCase_); + } + + public Builder clearConstraintType() { + constraintTypeCase_ = 0; + constraintType_ = null; + onChanged(); + return this; + } + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Immutable. The resource name of the Constraint. Must be in one of
+     * the following forms:
+     * * `projects/{project_number}/constraints/{constraint_name}`
+     * * `folders/{folder_id}/constraints/{constraint_name}`
+     * * `organizations/{organization_id}/constraints/{constraint_name}`
+     * For example, "/projects/123/constraints/compute.disableSerialPortAccess".
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Immutable. The resource name of the Constraint. Must be in one of
+     * the following forms:
+     * * `projects/{project_number}/constraints/{constraint_name}`
+     * * `folders/{folder_id}/constraints/{constraint_name}`
+     * * `organizations/{organization_id}/constraints/{constraint_name}`
+     * For example, "/projects/123/constraints/compute.disableSerialPortAccess".
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Immutable. The resource name of the Constraint. Must be in one of
+     * the following forms:
+     * * `projects/{project_number}/constraints/{constraint_name}`
+     * * `folders/{folder_id}/constraints/{constraint_name}`
+     * * `organizations/{organization_id}/constraints/{constraint_name}`
+     * For example, "/projects/123/constraints/compute.disableSerialPortAccess".
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Immutable. The resource name of the Constraint. Must be in one of
+     * the following forms:
+     * * `projects/{project_number}/constraints/{constraint_name}`
+     * * `folders/{folder_id}/constraints/{constraint_name}`
+     * * `organizations/{organization_id}/constraints/{constraint_name}`
+     * For example, "/projects/123/constraints/compute.disableSerialPortAccess".
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @return This builder for chaining. + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * + * + *
+     * Immutable. The resource name of the Constraint. Must be in one of
+     * the following forms:
+     * * `projects/{project_number}/constraints/{constraint_name}`
+     * * `folders/{folder_id}/constraints/{constraint_name}`
+     * * `organizations/{organization_id}/constraints/{constraint_name}`
+     * For example, "/projects/123/constraints/compute.disableSerialPortAccess".
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private java.lang.Object displayName_ = ""; + /** + * + * + *
+     * The human readable name.
+     * Mutable.
+     * 
+ * + * string display_name = 2; + * + * @return The displayName. + */ + public java.lang.String getDisplayName() { + java.lang.Object ref = displayName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + displayName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * The human readable name.
+     * Mutable.
+     * 
+ * + * string display_name = 2; + * + * @return The bytes for displayName. + */ + public com.google.protobuf.ByteString getDisplayNameBytes() { + java.lang.Object ref = displayName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + displayName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * The human readable name.
+     * Mutable.
+     * 
+ * + * string display_name = 2; + * + * @param value The displayName to set. + * @return This builder for chaining. + */ + public Builder setDisplayName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + displayName_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * The human readable name.
+     * Mutable.
+     * 
+ * + * string display_name = 2; + * + * @return This builder for chaining. + */ + public Builder clearDisplayName() { + + displayName_ = getDefaultInstance().getDisplayName(); + onChanged(); + return this; + } + /** + * + * + *
+     * The human readable name.
+     * Mutable.
+     * 
+ * + * string display_name = 2; + * + * @param value The bytes for displayName to set. + * @return This builder for chaining. + */ + public Builder setDisplayNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + displayName_ = value; + onChanged(); + return this; + } + + private java.lang.Object description_ = ""; + /** + * + * + *
+     * Detailed description of what this `Constraint` controls as well as how and
+     * where it is enforced.
+     * Mutable.
+     * 
+ * + * string description = 3; + * + * @return The description. + */ + public java.lang.String getDescription() { + java.lang.Object ref = description_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + description_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Detailed description of what this `Constraint` controls as well as how and
+     * where it is enforced.
+     * Mutable.
+     * 
+ * + * string description = 3; + * + * @return The bytes for description. + */ + public com.google.protobuf.ByteString getDescriptionBytes() { + java.lang.Object ref = description_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + description_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Detailed description of what this `Constraint` controls as well as how and
+     * where it is enforced.
+     * Mutable.
+     * 
+ * + * string description = 3; + * + * @param value The description to set. + * @return This builder for chaining. + */ + public Builder setDescription(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + description_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Detailed description of what this `Constraint` controls as well as how and
+     * where it is enforced.
+     * Mutable.
+     * 
+ * + * string description = 3; + * + * @return This builder for chaining. + */ + public Builder clearDescription() { + + description_ = getDefaultInstance().getDescription(); + onChanged(); + return this; + } + /** + * + * + *
+     * Detailed description of what this `Constraint` controls as well as how and
+     * where it is enforced.
+     * Mutable.
+     * 
+ * + * string description = 3; + * + * @param value The bytes for description to set. + * @return This builder for chaining. + */ + public Builder setDescriptionBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + description_ = value; + onChanged(); + return this; + } + + private int constraintDefault_ = 0; + /** + * + * + *
+     * The evaluation behavior of this constraint in the absence of 'Policy'.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ConstraintDefault constraint_default = 4; + * + * @return The enum numeric value on the wire for constraintDefault. + */ + @java.lang.Override + public int getConstraintDefaultValue() { + return constraintDefault_; + } + /** + * + * + *
+     * The evaluation behavior of this constraint in the absence of 'Policy'.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ConstraintDefault constraint_default = 4; + * + * @param value The enum numeric value on the wire for constraintDefault to set. + * @return This builder for chaining. + */ + public Builder setConstraintDefaultValue(int value) { + + constraintDefault_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * The evaluation behavior of this constraint in the absence of 'Policy'.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ConstraintDefault constraint_default = 4; + * + * @return The constraintDefault. + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault getConstraintDefault() { + @SuppressWarnings("deprecation") + com.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault result = + com.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault.valueOf(constraintDefault_); + return result == null + ? com.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault.UNRECOGNIZED + : result; + } + /** + * + * + *
+     * The evaluation behavior of this constraint in the absence of 'Policy'.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ConstraintDefault constraint_default = 4; + * + * @param value The constraintDefault to set. + * @return This builder for chaining. + */ + public Builder setConstraintDefault( + com.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault value) { + if (value == null) { + throw new NullPointerException(); + } + + constraintDefault_ = value.getNumber(); + onChanged(); + return this; + } + /** + * + * + *
+     * The evaluation behavior of this constraint in the absence of 'Policy'.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ConstraintDefault constraint_default = 4; + * + * @return This builder for chaining. + */ + public Builder clearConstraintDefault() { + + constraintDefault_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint, + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.Builder, + com.google.cloud.orgpolicy.v2.Constraint.ListConstraintOrBuilder> + listConstraintBuilder_; + /** + * + * + *
+     * Defines this constraint as being a ListConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5; + * + * @return Whether the listConstraint field is set. + */ + @java.lang.Override + public boolean hasListConstraint() { + return constraintTypeCase_ == 5; + } + /** + * + * + *
+     * Defines this constraint as being a ListConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5; + * + * @return The listConstraint. + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.ListConstraint getListConstraint() { + if (listConstraintBuilder_ == null) { + if (constraintTypeCase_ == 5) { + return (com.google.cloud.orgpolicy.v2.Constraint.ListConstraint) constraintType_; + } + return com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.getDefaultInstance(); + } else { + if (constraintTypeCase_ == 5) { + return listConstraintBuilder_.getMessage(); + } + return com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.getDefaultInstance(); + } + } + /** + * + * + *
+     * Defines this constraint as being a ListConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5; + */ + public Builder setListConstraint( + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint value) { + if (listConstraintBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + constraintType_ = value; + onChanged(); + } else { + listConstraintBuilder_.setMessage(value); + } + constraintTypeCase_ = 5; + return this; + } + /** + * + * + *
+     * Defines this constraint as being a ListConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5; + */ + public Builder setListConstraint( + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.Builder builderForValue) { + if (listConstraintBuilder_ == null) { + constraintType_ = builderForValue.build(); + onChanged(); + } else { + listConstraintBuilder_.setMessage(builderForValue.build()); + } + constraintTypeCase_ = 5; + return this; + } + /** + * + * + *
+     * Defines this constraint as being a ListConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5; + */ + public Builder mergeListConstraint( + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint value) { + if (listConstraintBuilder_ == null) { + if (constraintTypeCase_ == 5 + && constraintType_ + != com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.getDefaultInstance()) { + constraintType_ = + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.newBuilder( + (com.google.cloud.orgpolicy.v2.Constraint.ListConstraint) constraintType_) + .mergeFrom(value) + .buildPartial(); + } else { + constraintType_ = value; + } + onChanged(); + } else { + if (constraintTypeCase_ == 5) { + listConstraintBuilder_.mergeFrom(value); + } + listConstraintBuilder_.setMessage(value); + } + constraintTypeCase_ = 5; + return this; + } + /** + * + * + *
+     * Defines this constraint as being a ListConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5; + */ + public Builder clearListConstraint() { + if (listConstraintBuilder_ == null) { + if (constraintTypeCase_ == 5) { + constraintTypeCase_ = 0; + constraintType_ = null; + onChanged(); + } + } else { + if (constraintTypeCase_ == 5) { + constraintTypeCase_ = 0; + constraintType_ = null; + } + listConstraintBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Defines this constraint as being a ListConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5; + */ + public com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.Builder + getListConstraintBuilder() { + return getListConstraintFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Defines this constraint as being a ListConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5; + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.ListConstraintOrBuilder + getListConstraintOrBuilder() { + if ((constraintTypeCase_ == 5) && (listConstraintBuilder_ != null)) { + return listConstraintBuilder_.getMessageOrBuilder(); + } else { + if (constraintTypeCase_ == 5) { + return (com.google.cloud.orgpolicy.v2.Constraint.ListConstraint) constraintType_; + } + return com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.getDefaultInstance(); + } + } + /** + * + * + *
+     * Defines this constraint as being a ListConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint, + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.Builder, + com.google.cloud.orgpolicy.v2.Constraint.ListConstraintOrBuilder> + getListConstraintFieldBuilder() { + if (listConstraintBuilder_ == null) { + if (!(constraintTypeCase_ == 5)) { + constraintType_ = + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.getDefaultInstance(); + } + listConstraintBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint, + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint.Builder, + com.google.cloud.orgpolicy.v2.Constraint.ListConstraintOrBuilder>( + (com.google.cloud.orgpolicy.v2.Constraint.ListConstraint) constraintType_, + getParentForChildren(), + isClean()); + constraintType_ = null; + } + constraintTypeCase_ = 5; + onChanged(); + ; + return listConstraintBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint, + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.Builder, + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraintOrBuilder> + booleanConstraintBuilder_; + /** + * + * + *
+     * Defines this constraint as being a BooleanConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6; + * + * @return Whether the booleanConstraint field is set. + */ + @java.lang.Override + public boolean hasBooleanConstraint() { + return constraintTypeCase_ == 6; + } + /** + * + * + *
+     * Defines this constraint as being a BooleanConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6; + * + * @return The booleanConstraint. + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint getBooleanConstraint() { + if (booleanConstraintBuilder_ == null) { + if (constraintTypeCase_ == 6) { + return (com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) constraintType_; + } + return com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.getDefaultInstance(); + } else { + if (constraintTypeCase_ == 6) { + return booleanConstraintBuilder_.getMessage(); + } + return com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.getDefaultInstance(); + } + } + /** + * + * + *
+     * Defines this constraint as being a BooleanConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6; + */ + public Builder setBooleanConstraint( + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint value) { + if (booleanConstraintBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + constraintType_ = value; + onChanged(); + } else { + booleanConstraintBuilder_.setMessage(value); + } + constraintTypeCase_ = 6; + return this; + } + /** + * + * + *
+     * Defines this constraint as being a BooleanConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6; + */ + public Builder setBooleanConstraint( + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.Builder builderForValue) { + if (booleanConstraintBuilder_ == null) { + constraintType_ = builderForValue.build(); + onChanged(); + } else { + booleanConstraintBuilder_.setMessage(builderForValue.build()); + } + constraintTypeCase_ = 6; + return this; + } + /** + * + * + *
+     * Defines this constraint as being a BooleanConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6; + */ + public Builder mergeBooleanConstraint( + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint value) { + if (booleanConstraintBuilder_ == null) { + if (constraintTypeCase_ == 6 + && constraintType_ + != com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint + .getDefaultInstance()) { + constraintType_ = + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.newBuilder( + (com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) constraintType_) + .mergeFrom(value) + .buildPartial(); + } else { + constraintType_ = value; + } + onChanged(); + } else { + if (constraintTypeCase_ == 6) { + booleanConstraintBuilder_.mergeFrom(value); + } + booleanConstraintBuilder_.setMessage(value); + } + constraintTypeCase_ = 6; + return this; + } + /** + * + * + *
+     * Defines this constraint as being a BooleanConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6; + */ + public Builder clearBooleanConstraint() { + if (booleanConstraintBuilder_ == null) { + if (constraintTypeCase_ == 6) { + constraintTypeCase_ = 0; + constraintType_ = null; + onChanged(); + } + } else { + if (constraintTypeCase_ == 6) { + constraintTypeCase_ = 0; + constraintType_ = null; + } + booleanConstraintBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Defines this constraint as being a BooleanConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6; + */ + public com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.Builder + getBooleanConstraintBuilder() { + return getBooleanConstraintFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Defines this constraint as being a BooleanConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6; + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraintOrBuilder + getBooleanConstraintOrBuilder() { + if ((constraintTypeCase_ == 6) && (booleanConstraintBuilder_ != null)) { + return booleanConstraintBuilder_.getMessageOrBuilder(); + } else { + if (constraintTypeCase_ == 6) { + return (com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) constraintType_; + } + return com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.getDefaultInstance(); + } + } + /** + * + * + *
+     * Defines this constraint as being a BooleanConstraint.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint, + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.Builder, + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraintOrBuilder> + getBooleanConstraintFieldBuilder() { + if (booleanConstraintBuilder_ == null) { + if (!(constraintTypeCase_ == 6)) { + constraintType_ = + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.getDefaultInstance(); + } + booleanConstraintBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint, + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint.Builder, + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraintOrBuilder>( + (com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint) constraintType_, + getParentForChildren(), + isClean()); + constraintType_ = null; + } + constraintTypeCase_ = 6; + onChanged(); + ; + return booleanConstraintBuilder_; + } + + @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.cloud.orgpolicy.v2.Constraint) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.Constraint) + private static final com.google.cloud.orgpolicy.v2.Constraint DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.Constraint(); + } + + public static com.google.cloud.orgpolicy.v2.Constraint getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Constraint parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Constraint(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.Constraint getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ConstraintName.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ConstraintName.java new file mode 100644 index 0000000..c2af655 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ConstraintName.java @@ -0,0 +1,377 @@ +/* + * 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. + */ + +package com.google.cloud.orgpolicy.v2; + +import com.google.api.core.BetaApi; +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.pathtemplate.ValidationException; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class ConstraintName implements ResourceName { + private static final PathTemplate PROJECT_CONSTRAINT = + PathTemplate.createWithoutUrlEncoding("projects/{project}/constraints/{constraint}"); + private static final PathTemplate FOLDER_CONSTRAINT = + PathTemplate.createWithoutUrlEncoding("folders/{folder}/constraints/{constraint}"); + private static final PathTemplate ORGANIZATION_CONSTRAINT = + PathTemplate.createWithoutUrlEncoding( + "organizations/{organization}/constraints/{constraint}"); + private volatile Map fieldValuesMap; + private PathTemplate pathTemplate; + private String fixedValue; + private final String project; + private final String constraint; + private final String folder; + private final String organization; + + @Deprecated + protected ConstraintName() { + project = null; + constraint = null; + folder = null; + organization = null; + } + + private ConstraintName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + constraint = Preconditions.checkNotNull(builder.getConstraint()); + folder = null; + organization = null; + pathTemplate = PROJECT_CONSTRAINT; + } + + private ConstraintName(FolderConstraintBuilder builder) { + folder = Preconditions.checkNotNull(builder.getFolder()); + constraint = Preconditions.checkNotNull(builder.getConstraint()); + project = null; + organization = null; + pathTemplate = FOLDER_CONSTRAINT; + } + + private ConstraintName(OrganizationConstraintBuilder builder) { + organization = Preconditions.checkNotNull(builder.getOrganization()); + constraint = Preconditions.checkNotNull(builder.getConstraint()); + project = null; + folder = null; + pathTemplate = ORGANIZATION_CONSTRAINT; + } + + public String getProject() { + return project; + } + + public String getConstraint() { + return constraint; + } + + public String getFolder() { + return folder; + } + + public String getOrganization() { + return organization; + } + + public static Builder newBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static Builder newProjectConstraintBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static FolderConstraintBuilder newFolderConstraintBuilder() { + return new FolderConstraintBuilder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static OrganizationConstraintBuilder newOrganizationConstraintBuilder() { + return new OrganizationConstraintBuilder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static ConstraintName of(String project, String constraint) { + return newBuilder().setProject(project).setConstraint(constraint).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static ConstraintName ofProjectConstraintName(String project, String constraint) { + return newBuilder().setProject(project).setConstraint(constraint).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static ConstraintName ofFolderConstraintName(String folder, String constraint) { + return newFolderConstraintBuilder().setFolder(folder).setConstraint(constraint).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static ConstraintName ofOrganizationConstraintName( + String organization, String constraint) { + return newOrganizationConstraintBuilder() + .setOrganization(organization) + .setConstraint(constraint) + .build(); + } + + public static String format(String project, String constraint) { + return newBuilder().setProject(project).setConstraint(constraint).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatProjectConstraintName(String project, String constraint) { + return newBuilder().setProject(project).setConstraint(constraint).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatFolderConstraintName(String folder, String constraint) { + return newFolderConstraintBuilder() + .setFolder(folder) + .setConstraint(constraint) + .build() + .toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatOrganizationConstraintName(String organization, String constraint) { + return newOrganizationConstraintBuilder() + .setOrganization(organization) + .setConstraint(constraint) + .build() + .toString(); + } + + public static ConstraintName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + if (PROJECT_CONSTRAINT.matches(formattedString)) { + Map matchMap = PROJECT_CONSTRAINT.match(formattedString); + return ofProjectConstraintName(matchMap.get("project"), matchMap.get("constraint")); + } else if (FOLDER_CONSTRAINT.matches(formattedString)) { + Map matchMap = FOLDER_CONSTRAINT.match(formattedString); + return ofFolderConstraintName(matchMap.get("folder"), matchMap.get("constraint")); + } else if (ORGANIZATION_CONSTRAINT.matches(formattedString)) { + Map matchMap = ORGANIZATION_CONSTRAINT.match(formattedString); + return ofOrganizationConstraintName(matchMap.get("organization"), matchMap.get("constraint")); + } + throw new ValidationException("ConstraintName.parse: formattedString not in valid format"); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (ConstraintName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_CONSTRAINT.matches(formattedString) + || FOLDER_CONSTRAINT.matches(formattedString) + || ORGANIZATION_CONSTRAINT.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (constraint != null) { + fieldMapBuilder.put("constraint", constraint); + } + if (folder != null) { + fieldMapBuilder.put("folder", folder); + } + if (organization != null) { + fieldMapBuilder.put("organization", organization); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + ConstraintName that = ((ConstraintName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.constraint, that.constraint) + && Objects.equals(this.folder, that.folder) + && Objects.equals(this.organization, that.organization); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(constraint); + h *= 1000003; + h ^= Objects.hashCode(folder); + h *= 1000003; + h ^= Objects.hashCode(organization); + return h; + } + + /** Builder for projects/{project}/constraints/{constraint}. */ + public static class Builder { + private String project; + private String constraint; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getConstraint() { + return constraint; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setConstraint(String constraint) { + this.constraint = constraint; + return this; + } + + private Builder(ConstraintName constraintName) { + Preconditions.checkArgument( + Objects.equals(constraintName.pathTemplate, PROJECT_CONSTRAINT), + "toBuilder is only supported when ConstraintName has the pattern of projects/{project}/constraints/{constraint}"); + project = constraintName.project; + constraint = constraintName.constraint; + } + + public ConstraintName build() { + return new ConstraintName(this); + } + } + + /** Builder for folders/{folder}/constraints/{constraint}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class FolderConstraintBuilder { + private String folder; + private String constraint; + + protected FolderConstraintBuilder() {} + + public String getFolder() { + return folder; + } + + public String getConstraint() { + return constraint; + } + + public FolderConstraintBuilder setFolder(String folder) { + this.folder = folder; + return this; + } + + public FolderConstraintBuilder setConstraint(String constraint) { + this.constraint = constraint; + return this; + } + + public ConstraintName build() { + return new ConstraintName(this); + } + } + + /** Builder for organizations/{organization}/constraints/{constraint}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class OrganizationConstraintBuilder { + private String organization; + private String constraint; + + protected OrganizationConstraintBuilder() {} + + public String getOrganization() { + return organization; + } + + public String getConstraint() { + return constraint; + } + + public OrganizationConstraintBuilder setOrganization(String organization) { + this.organization = organization; + return this; + } + + public OrganizationConstraintBuilder setConstraint(String constraint) { + this.constraint = constraint; + return this; + } + + public ConstraintName build() { + return new ConstraintName(this); + } + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ConstraintOrBuilder.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ConstraintOrBuilder.java new file mode 100644 index 0000000..e046906 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ConstraintOrBuilder.java @@ -0,0 +1,214 @@ +/* + * 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/cloud/orgpolicy/v2/constraint.proto + +package com.google.cloud.orgpolicy.v2; + +public interface ConstraintOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.Constraint) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Immutable. The resource name of the Constraint. Must be in one of
+   * the following forms:
+   * * `projects/{project_number}/constraints/{constraint_name}`
+   * * `folders/{folder_id}/constraints/{constraint_name}`
+   * * `organizations/{organization_id}/constraints/{constraint_name}`
+   * For example, "/projects/123/constraints/compute.disableSerialPortAccess".
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Immutable. The resource name of the Constraint. Must be in one of
+   * the following forms:
+   * * `projects/{project_number}/constraints/{constraint_name}`
+   * * `folders/{folder_id}/constraints/{constraint_name}`
+   * * `organizations/{organization_id}/constraints/{constraint_name}`
+   * For example, "/projects/123/constraints/compute.disableSerialPortAccess".
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * The human readable name.
+   * Mutable.
+   * 
+ * + * string display_name = 2; + * + * @return The displayName. + */ + java.lang.String getDisplayName(); + /** + * + * + *
+   * The human readable name.
+   * Mutable.
+   * 
+ * + * string display_name = 2; + * + * @return The bytes for displayName. + */ + com.google.protobuf.ByteString getDisplayNameBytes(); + + /** + * + * + *
+   * Detailed description of what this `Constraint` controls as well as how and
+   * where it is enforced.
+   * Mutable.
+   * 
+ * + * string description = 3; + * + * @return The description. + */ + java.lang.String getDescription(); + /** + * + * + *
+   * Detailed description of what this `Constraint` controls as well as how and
+   * where it is enforced.
+   * Mutable.
+   * 
+ * + * string description = 3; + * + * @return The bytes for description. + */ + com.google.protobuf.ByteString getDescriptionBytes(); + + /** + * + * + *
+   * The evaluation behavior of this constraint in the absence of 'Policy'.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ConstraintDefault constraint_default = 4; + * + * @return The enum numeric value on the wire for constraintDefault. + */ + int getConstraintDefaultValue(); + /** + * + * + *
+   * The evaluation behavior of this constraint in the absence of 'Policy'.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ConstraintDefault constraint_default = 4; + * + * @return The constraintDefault. + */ + com.google.cloud.orgpolicy.v2.Constraint.ConstraintDefault getConstraintDefault(); + + /** + * + * + *
+   * Defines this constraint as being a ListConstraint.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5; + * + * @return Whether the listConstraint field is set. + */ + boolean hasListConstraint(); + /** + * + * + *
+   * Defines this constraint as being a ListConstraint.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5; + * + * @return The listConstraint. + */ + com.google.cloud.orgpolicy.v2.Constraint.ListConstraint getListConstraint(); + /** + * + * + *
+   * Defines this constraint as being a ListConstraint.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.ListConstraint list_constraint = 5; + */ + com.google.cloud.orgpolicy.v2.Constraint.ListConstraintOrBuilder getListConstraintOrBuilder(); + + /** + * + * + *
+   * Defines this constraint as being a BooleanConstraint.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6; + * + * @return Whether the booleanConstraint field is set. + */ + boolean hasBooleanConstraint(); + /** + * + * + *
+   * Defines this constraint as being a BooleanConstraint.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6; + * + * @return The booleanConstraint. + */ + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraint getBooleanConstraint(); + /** + * + * + *
+   * Defines this constraint as being a BooleanConstraint.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Constraint.BooleanConstraint boolean_constraint = 6; + */ + com.google.cloud.orgpolicy.v2.Constraint.BooleanConstraintOrBuilder + getBooleanConstraintOrBuilder(); + + public com.google.cloud.orgpolicy.v2.Constraint.ConstraintTypeCase getConstraintTypeCase(); +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ConstraintProto.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ConstraintProto.java new file mode 100644 index 0000000..d3b21d0 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ConstraintProto.java @@ -0,0 +1,125 @@ +/* + * 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/cloud/orgpolicy/v2/constraint.proto + +package com.google.cloud.orgpolicy.v2; + +public final class ConstraintProto { + private ConstraintProto() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_Constraint_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_Constraint_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_Constraint_ListConstraint_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_Constraint_ListConstraint_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_Constraint_BooleanConstraint_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_Constraint_BooleanConstraint_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*google/cloud/orgpolicy/v2/constraint.p" + + "roto\022\031google.cloud.orgpolicy.v2\032\037google/" + + "api/field_behavior.proto\032\031google/api/res" + + "ource.proto\"\267\005\n\nConstraint\022\021\n\004name\030\001 \001(\t" + + "B\003\340A\005\022\024\n\014display_name\030\002 \001(\t\022\023\n\013descripti" + + "on\030\003 \001(\t\022S\n\022constraint_default\030\004 \001(\01627.g" + + "oogle.cloud.orgpolicy.v2.Constraint.Cons" + + "traintDefault\022O\n\017list_constraint\030\005 \001(\01324" + + ".google.cloud.orgpolicy.v2.Constraint.Li" + + "stConstraintH\000\022U\n\022boolean_constraint\030\006 \001" + + "(\01327.google.cloud.orgpolicy.v2.Constrain" + + "t.BooleanConstraintH\000\032=\n\016ListConstraint\022" + + "\023\n\013supports_in\030\001 \001(\010\022\026\n\016supports_under\030\002" + + " \001(\010\032\023\n\021BooleanConstraint\"L\n\021ConstraintD" + + "efault\022\"\n\036CONSTRAINT_DEFAULT_UNSPECIFIED" + + "\020\000\022\t\n\005ALLOW\020\001\022\010\n\004DENY\020\002:\270\001\352A\264\001\n#orgpolic" + + "y.googleapis.com/Constraint\022+projects/{p" + + "roject}/constraints/{constraint}\022)folder" + + "s/{folder}/constraints/{constraint}\0225org" + + "anizations/{organization}/constraints/{c" + + "onstraint}B\021\n\017constraint_typeB\315\001\n\035com.go" + + "ogle.cloud.orgpolicy.v2B\017ConstraintProto" + + "P\001ZBgoogle.golang.org/genproto/googleapi" + + "s/cloud/orgpolicy/v2;orgpolicy\252\002\031Google." + + "Cloud.OrgPolicy.V2\312\002\031Google\\Cloud\\OrgPol" + + "icy\\V2\352\002\034Google::Cloud::OrgPolicy::V2b\006p" + + "roto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + }); + internal_static_google_cloud_orgpolicy_v2_Constraint_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_cloud_orgpolicy_v2_Constraint_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_Constraint_descriptor, + new java.lang.String[] { + "Name", + "DisplayName", + "Description", + "ConstraintDefault", + "ListConstraint", + "BooleanConstraint", + "ConstraintType", + }); + internal_static_google_cloud_orgpolicy_v2_Constraint_ListConstraint_descriptor = + internal_static_google_cloud_orgpolicy_v2_Constraint_descriptor.getNestedTypes().get(0); + internal_static_google_cloud_orgpolicy_v2_Constraint_ListConstraint_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_Constraint_ListConstraint_descriptor, + new java.lang.String[] { + "SupportsIn", "SupportsUnder", + }); + internal_static_google_cloud_orgpolicy_v2_Constraint_BooleanConstraint_descriptor = + internal_static_google_cloud_orgpolicy_v2_Constraint_descriptor.getNestedTypes().get(1); + internal_static_google_cloud_orgpolicy_v2_Constraint_BooleanConstraint_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_Constraint_BooleanConstraint_descriptor, + new java.lang.String[] {}); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.ResourceProto.resource); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.ResourceProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/CreatePolicyRequest.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/CreatePolicyRequest.java new file mode 100644 index 0000000..b0b711f --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/CreatePolicyRequest.java @@ -0,0 +1,974 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +/** + * + * + *
+ * The request sent to the [CreatePolicyRequest]
+ * [google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy] method.
+ * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.CreatePolicyRequest} + */ +public final class CreatePolicyRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.CreatePolicyRequest) + CreatePolicyRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use CreatePolicyRequest.newBuilder() to construct. + private CreatePolicyRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private CreatePolicyRequest() { + parent_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CreatePolicyRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private CreatePolicyRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + parent_ = s; + break; + } + case 26: + { + com.google.cloud.orgpolicy.v2.Policy.Builder subBuilder = null; + if (policy_ != null) { + subBuilder = policy_.toBuilder(); + } + policy_ = + input.readMessage( + com.google.cloud.orgpolicy.v2.Policy.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(policy_); + policy_ = subBuilder.buildPartial(); + } + + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_CreatePolicyRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_CreatePolicyRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.CreatePolicyRequest.class, + com.google.cloud.orgpolicy.v2.CreatePolicyRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + private volatile java.lang.Object parent_; + /** + * + * + *
+   * Required. The Cloud resource that will parent the new Policy. Must be in one of the
+   * following forms:
+   * * `projects/{project_number}`
+   * * `projects/{project_id}`
+   * * `folders/{folder_id}`
+   * * `organizations/{organization_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + 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(); + parent_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The Cloud resource that will parent the new Policy. Must be in one of the
+   * following forms:
+   * * `projects/{project_number}`
+   * * `projects/{project_id}`
+   * * `folders/{folder_id}`
+   * * `organizations/{organization_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int POLICY_FIELD_NUMBER = 3; + private com.google.cloud.orgpolicy.v2.Policy policy_; + /** + * + * + *
+   * Required. `Policy` to create.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the policy field is set. + */ + @java.lang.Override + public boolean hasPolicy() { + return policy_ != null; + } + /** + * + * + *
+   * Required. `Policy` to create.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The policy. + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Policy getPolicy() { + return policy_ == null ? com.google.cloud.orgpolicy.v2.Policy.getDefaultInstance() : policy_; + } + /** + * + * + *
+   * Required. `Policy` to create.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicyOrBuilder getPolicyOrBuilder() { + return getPolicy(); + } + + 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 (!getParentBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); + } + if (policy_ != null) { + output.writeMessage(3, getPolicy()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getParentBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); + } + if (policy_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getPolicy()); + } + size += unknownFields.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.cloud.orgpolicy.v2.CreatePolicyRequest)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.CreatePolicyRequest other = + (com.google.cloud.orgpolicy.v2.CreatePolicyRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (hasPolicy() != other.hasPolicy()) return false; + if (hasPolicy()) { + if (!getPolicy().equals(other.getPolicy())) return false; + } + if (!unknownFields.equals(other.unknownFields)) 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) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + if (hasPolicy()) { + hash = (37 * hash) + POLICY_FIELD_NUMBER; + hash = (53 * hash) + getPolicy().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.CreatePolicyRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.CreatePolicyRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.CreatePolicyRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.CreatePolicyRequest 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.cloud.orgpolicy.v2.CreatePolicyRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.CreatePolicyRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.CreatePolicyRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.CreatePolicyRequest 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.cloud.orgpolicy.v2.CreatePolicyRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.CreatePolicyRequest 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.cloud.orgpolicy.v2.CreatePolicyRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.CreatePolicyRequest 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.cloud.orgpolicy.v2.CreatePolicyRequest 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; + } + /** + * + * + *
+   * The request sent to the [CreatePolicyRequest]
+   * [google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy] method.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.CreatePolicyRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.CreatePolicyRequest) + com.google.cloud.orgpolicy.v2.CreatePolicyRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_CreatePolicyRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_CreatePolicyRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.CreatePolicyRequest.class, + com.google.cloud.orgpolicy.v2.CreatePolicyRequest.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.CreatePolicyRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + parent_ = ""; + + if (policyBuilder_ == null) { + policy_ = null; + } else { + policy_ = null; + policyBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_CreatePolicyRequest_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.CreatePolicyRequest getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.CreatePolicyRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.CreatePolicyRequest build() { + com.google.cloud.orgpolicy.v2.CreatePolicyRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.CreatePolicyRequest buildPartial() { + com.google.cloud.orgpolicy.v2.CreatePolicyRequest result = + new com.google.cloud.orgpolicy.v2.CreatePolicyRequest(this); + result.parent_ = parent_; + if (policyBuilder_ == null) { + result.policy_ = policy_; + } else { + result.policy_ = policyBuilder_.build(); + } + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.CreatePolicyRequest) { + return mergeFrom((com.google.cloud.orgpolicy.v2.CreatePolicyRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.CreatePolicyRequest other) { + if (other == com.google.cloud.orgpolicy.v2.CreatePolicyRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + onChanged(); + } + if (other.hasPolicy()) { + mergePolicy(other.getPolicy()); + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.CreatePolicyRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.orgpolicy.v2.CreatePolicyRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object parent_ = ""; + /** + * + * + *
+     * Required. The Cloud resource that will parent the new Policy. Must be in one of the
+     * following forms:
+     * * `projects/{project_number}`
+     * * `projects/{project_id}`
+     * * `folders/{folder_id}`
+     * * `organizations/{organization_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The Cloud resource that will parent the new Policy. Must be in one of the
+     * following forms:
+     * * `projects/{project_number}`
+     * * `projects/{project_id}`
+     * * `folders/{folder_id}`
+     * * `organizations/{organization_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The Cloud resource that will parent the new Policy. Must be in one of the
+     * following forms:
+     * * `projects/{project_number}`
+     * * `projects/{project_id}`
+     * * `folders/{folder_id}`
+     * * `organizations/{organization_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + parent_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Cloud resource that will parent the new Policy. Must be in one of the
+     * following forms:
+     * * `projects/{project_number}`
+     * * `projects/{project_id}`
+     * * `folders/{folder_id}`
+     * * `organizations/{organization_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + + parent_ = getDefaultInstance().getParent(); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Cloud resource that will parent the new Policy. Must be in one of the
+     * following forms:
+     * * `projects/{project_number}`
+     * * `projects/{project_id}`
+     * * `folders/{folder_id}`
+     * * `organizations/{organization_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + parent_ = value; + onChanged(); + return this; + } + + private com.google.cloud.orgpolicy.v2.Policy policy_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Policy, + com.google.cloud.orgpolicy.v2.Policy.Builder, + com.google.cloud.orgpolicy.v2.PolicyOrBuilder> + policyBuilder_; + /** + * + * + *
+     * Required. `Policy` to create.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the policy field is set. + */ + public boolean hasPolicy() { + return policyBuilder_ != null || policy_ != null; + } + /** + * + * + *
+     * Required. `Policy` to create.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The policy. + */ + public com.google.cloud.orgpolicy.v2.Policy getPolicy() { + if (policyBuilder_ == null) { + return policy_ == null + ? com.google.cloud.orgpolicy.v2.Policy.getDefaultInstance() + : policy_; + } else { + return policyBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. `Policy` to create.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setPolicy(com.google.cloud.orgpolicy.v2.Policy value) { + if (policyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + policy_ = value; + onChanged(); + } else { + policyBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Required. `Policy` to create.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setPolicy(com.google.cloud.orgpolicy.v2.Policy.Builder builderForValue) { + if (policyBuilder_ == null) { + policy_ = builderForValue.build(); + onChanged(); + } else { + policyBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Required. `Policy` to create.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergePolicy(com.google.cloud.orgpolicy.v2.Policy value) { + if (policyBuilder_ == null) { + if (policy_ != null) { + policy_ = + com.google.cloud.orgpolicy.v2.Policy.newBuilder(policy_) + .mergeFrom(value) + .buildPartial(); + } else { + policy_ = value; + } + onChanged(); + } else { + policyBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Required. `Policy` to create.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearPolicy() { + if (policyBuilder_ == null) { + policy_ = null; + onChanged(); + } else { + policy_ = null; + policyBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Required. `Policy` to create.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.cloud.orgpolicy.v2.Policy.Builder getPolicyBuilder() { + + onChanged(); + return getPolicyFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. `Policy` to create.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.cloud.orgpolicy.v2.PolicyOrBuilder getPolicyOrBuilder() { + if (policyBuilder_ != null) { + return policyBuilder_.getMessageOrBuilder(); + } else { + return policy_ == null + ? com.google.cloud.orgpolicy.v2.Policy.getDefaultInstance() + : policy_; + } + } + /** + * + * + *
+     * Required. `Policy` to create.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Policy, + com.google.cloud.orgpolicy.v2.Policy.Builder, + com.google.cloud.orgpolicy.v2.PolicyOrBuilder> + getPolicyFieldBuilder() { + if (policyBuilder_ == null) { + policyBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Policy, + com.google.cloud.orgpolicy.v2.Policy.Builder, + com.google.cloud.orgpolicy.v2.PolicyOrBuilder>( + getPolicy(), getParentForChildren(), isClean()); + policy_ = null; + } + return policyBuilder_; + } + + @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.cloud.orgpolicy.v2.CreatePolicyRequest) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.CreatePolicyRequest) + private static final com.google.cloud.orgpolicy.v2.CreatePolicyRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.CreatePolicyRequest(); + } + + public static com.google.cloud.orgpolicy.v2.CreatePolicyRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CreatePolicyRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new CreatePolicyRequest(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.CreatePolicyRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/CreatePolicyRequestOrBuilder.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/CreatePolicyRequestOrBuilder.java new file mode 100644 index 0000000..f14fb59 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/CreatePolicyRequestOrBuilder.java @@ -0,0 +1,102 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +public interface CreatePolicyRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.CreatePolicyRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The Cloud resource that will parent the new Policy. Must be in one of the
+   * following forms:
+   * * `projects/{project_number}`
+   * * `projects/{project_id}`
+   * * `folders/{folder_id}`
+   * * `organizations/{organization_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + /** + * + * + *
+   * Required. The Cloud resource that will parent the new Policy. Must be in one of the
+   * following forms:
+   * * `projects/{project_number}`
+   * * `projects/{project_id}`
+   * * `folders/{folder_id}`
+   * * `organizations/{organization_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Required. `Policy` to create.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the policy field is set. + */ + boolean hasPolicy(); + /** + * + * + *
+   * Required. `Policy` to create.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The policy. + */ + com.google.cloud.orgpolicy.v2.Policy getPolicy(); + /** + * + * + *
+   * Required. `Policy` to create.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.cloud.orgpolicy.v2.PolicyOrBuilder getPolicyOrBuilder(); +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/DeletePolicyRequest.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/DeletePolicyRequest.java new file mode 100644 index 0000000..b9fe201 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/DeletePolicyRequest.java @@ -0,0 +1,659 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +/** + * + * + *
+ * The request sent to the [DeletePolicy]
+ * [google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy] method.
+ * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.DeletePolicyRequest} + */ +public final class DeletePolicyRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.DeletePolicyRequest) + DeletePolicyRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use DeletePolicyRequest.newBuilder() to construct. + private DeletePolicyRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private DeletePolicyRequest() { + name_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new DeletePolicyRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private DeletePolicyRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_DeletePolicyRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_DeletePolicyRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.DeletePolicyRequest.class, + com.google.cloud.orgpolicy.v2.DeletePolicyRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * + * + *
+   * Required. Name of the policy to delete.
+   * See `Policy` for naming rules.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + 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(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Required. Name of the policy to delete.
+   * See `Policy` for naming rules.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = 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 (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + size += unknownFields.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.cloud.orgpolicy.v2.DeletePolicyRequest)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.DeletePolicyRequest other = + (com.google.cloud.orgpolicy.v2.DeletePolicyRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!unknownFields.equals(other.unknownFields)) 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) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.DeletePolicyRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.DeletePolicyRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.DeletePolicyRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.DeletePolicyRequest 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.cloud.orgpolicy.v2.DeletePolicyRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.DeletePolicyRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.DeletePolicyRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.DeletePolicyRequest 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.cloud.orgpolicy.v2.DeletePolicyRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.DeletePolicyRequest 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.cloud.orgpolicy.v2.DeletePolicyRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.DeletePolicyRequest 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.cloud.orgpolicy.v2.DeletePolicyRequest 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; + } + /** + * + * + *
+   * The request sent to the [DeletePolicy]
+   * [google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy] method.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.DeletePolicyRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.DeletePolicyRequest) + com.google.cloud.orgpolicy.v2.DeletePolicyRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_DeletePolicyRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_DeletePolicyRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.DeletePolicyRequest.class, + com.google.cloud.orgpolicy.v2.DeletePolicyRequest.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.DeletePolicyRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + name_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_DeletePolicyRequest_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.DeletePolicyRequest getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.DeletePolicyRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.DeletePolicyRequest build() { + com.google.cloud.orgpolicy.v2.DeletePolicyRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.DeletePolicyRequest buildPartial() { + com.google.cloud.orgpolicy.v2.DeletePolicyRequest result = + new com.google.cloud.orgpolicy.v2.DeletePolicyRequest(this); + result.name_ = name_; + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.DeletePolicyRequest) { + return mergeFrom((com.google.cloud.orgpolicy.v2.DeletePolicyRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.DeletePolicyRequest other) { + if (other == com.google.cloud.orgpolicy.v2.DeletePolicyRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.DeletePolicyRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.orgpolicy.v2.DeletePolicyRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Required. Name of the policy to delete.
+     * See `Policy` for naming rules.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. Name of the policy to delete.
+     * See `Policy` for naming rules.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. Name of the policy to delete.
+     * See `Policy` for naming rules.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Name of the policy to delete.
+     * See `Policy` for naming rules.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Name of the policy to delete.
+     * See `Policy` for naming rules.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + 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.cloud.orgpolicy.v2.DeletePolicyRequest) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.DeletePolicyRequest) + private static final com.google.cloud.orgpolicy.v2.DeletePolicyRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.DeletePolicyRequest(); + } + + public static com.google.cloud.orgpolicy.v2.DeletePolicyRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DeletePolicyRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new DeletePolicyRequest(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.DeletePolicyRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/DeletePolicyRequestOrBuilder.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/DeletePolicyRequestOrBuilder.java new file mode 100644 index 0000000..f727ca1 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/DeletePolicyRequestOrBuilder.java @@ -0,0 +1,56 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +public interface DeletePolicyRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.DeletePolicyRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Name of the policy to delete.
+   * See `Policy` for naming rules.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Required. Name of the policy to delete.
+   * See `Policy` for naming rules.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/FolderName.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/FolderName.java new file mode 100644 index 0000000..203bd3f --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/FolderName.java @@ -0,0 +1,168 @@ +/* + * 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. + */ + +package com.google.cloud.orgpolicy.v2; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class FolderName implements ResourceName { + private static final PathTemplate FOLDER = + PathTemplate.createWithoutUrlEncoding("folders/{folder}"); + private volatile Map fieldValuesMap; + private final String folder; + + @Deprecated + protected FolderName() { + folder = null; + } + + private FolderName(Builder builder) { + folder = Preconditions.checkNotNull(builder.getFolder()); + } + + public String getFolder() { + return folder; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static FolderName of(String folder) { + return newBuilder().setFolder(folder).build(); + } + + public static String format(String folder) { + return newBuilder().setFolder(folder).build().toString(); + } + + public static FolderName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + FOLDER.validatedMatch( + formattedString, "FolderName.parse: formattedString not in valid format"); + return of(matchMap.get("folder")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (FolderName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return FOLDER.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (folder != null) { + fieldMapBuilder.put("folder", folder); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return FOLDER.instantiate("folder", folder); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + FolderName that = ((FolderName) o); + return Objects.equals(this.folder, that.folder); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(folder); + return h; + } + + /** Builder for folders/{folder}. */ + public static class Builder { + private String folder; + + protected Builder() {} + + public String getFolder() { + return folder; + } + + public Builder setFolder(String folder) { + this.folder = folder; + return this; + } + + private Builder(FolderName folderName) { + folder = folderName.folder; + } + + public FolderName build() { + return new FolderName(this); + } + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/GetEffectivePolicyRequest.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/GetEffectivePolicyRequest.java new file mode 100644 index 0000000..4b77b07 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/GetEffectivePolicyRequest.java @@ -0,0 +1,653 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +/** + * + * + *
+ * The request sent to the [GetEffectivePolicy]
+ * [google.cloud.orgpolicy.v2.OrgPolicy.GetEffectivePolicy] method.
+ * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.GetEffectivePolicyRequest} + */ +public final class GetEffectivePolicyRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.GetEffectivePolicyRequest) + GetEffectivePolicyRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use GetEffectivePolicyRequest.newBuilder() to construct. + private GetEffectivePolicyRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private GetEffectivePolicyRequest() { + name_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GetEffectivePolicyRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private GetEffectivePolicyRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_GetEffectivePolicyRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_GetEffectivePolicyRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest.class, + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * + * + *
+   * Required. The effective policy to compute. See `Policy` for naming rules.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + 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(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The effective policy to compute. See `Policy` for naming rules.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = 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 (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + size += unknownFields.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.cloud.orgpolicy.v2.GetEffectivePolicyRequest)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest other = + (com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!unknownFields.equals(other.unknownFields)) 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) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest 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.cloud.orgpolicy.v2.GetEffectivePolicyRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest 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.cloud.orgpolicy.v2.GetEffectivePolicyRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest 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.cloud.orgpolicy.v2.GetEffectivePolicyRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest 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.cloud.orgpolicy.v2.GetEffectivePolicyRequest 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; + } + /** + * + * + *
+   * The request sent to the [GetEffectivePolicy]
+   * [google.cloud.orgpolicy.v2.OrgPolicy.GetEffectivePolicy] method.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.GetEffectivePolicyRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.GetEffectivePolicyRequest) + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_GetEffectivePolicyRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_GetEffectivePolicyRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest.class, + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + name_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_GetEffectivePolicyRequest_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest build() { + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest buildPartial() { + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest result = + new com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest(this); + result.name_ = name_; + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.GetEffectivePolicyRequest) { + return mergeFrom((com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest other) { + if (other == com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Required. The effective policy to compute. See `Policy` for naming rules.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The effective policy to compute. See `Policy` for naming rules.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The effective policy to compute. See `Policy` for naming rules.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The effective policy to compute. See `Policy` for naming rules.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The effective policy to compute. See `Policy` for naming rules.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + 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.cloud.orgpolicy.v2.GetEffectivePolicyRequest) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.GetEffectivePolicyRequest) + private static final com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest(); + } + + public static com.google.cloud.orgpolicy.v2.GetEffectivePolicyRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GetEffectivePolicyRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new GetEffectivePolicyRequest(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.GetEffectivePolicyRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/GetEffectivePolicyRequestOrBuilder.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/GetEffectivePolicyRequestOrBuilder.java new file mode 100644 index 0000000..a4aa317 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/GetEffectivePolicyRequestOrBuilder.java @@ -0,0 +1,54 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +public interface GetEffectivePolicyRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.GetEffectivePolicyRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The effective policy to compute. See `Policy` for naming rules.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Required. The effective policy to compute. See `Policy` for naming rules.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/GetPolicyRequest.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/GetPolicyRequest.java new file mode 100644 index 0000000..33b4ec5 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/GetPolicyRequest.java @@ -0,0 +1,650 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +/** + * + * + *
+ * The request sent to the [GetPolicy]
+ * [google.cloud.orgpolicy.v2.OrgPolicy.GetPolicy] method.
+ * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.GetPolicyRequest} + */ +public final class GetPolicyRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.GetPolicyRequest) + GetPolicyRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use GetPolicyRequest.newBuilder() to construct. + private GetPolicyRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private GetPolicyRequest() { + name_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GetPolicyRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private GetPolicyRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_GetPolicyRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_GetPolicyRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.GetPolicyRequest.class, + com.google.cloud.orgpolicy.v2.GetPolicyRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * + * + *
+   * Required. Resource name of the policy. See `Policy` for naming requirements.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + 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(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Required. Resource name of the policy. See `Policy` for naming requirements.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = 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 (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + size += unknownFields.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.cloud.orgpolicy.v2.GetPolicyRequest)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.GetPolicyRequest other = + (com.google.cloud.orgpolicy.v2.GetPolicyRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!unknownFields.equals(other.unknownFields)) 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) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.GetPolicyRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.GetPolicyRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.GetPolicyRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.GetPolicyRequest 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.cloud.orgpolicy.v2.GetPolicyRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.GetPolicyRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.GetPolicyRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.GetPolicyRequest 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.cloud.orgpolicy.v2.GetPolicyRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.GetPolicyRequest 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.cloud.orgpolicy.v2.GetPolicyRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.GetPolicyRequest 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.cloud.orgpolicy.v2.GetPolicyRequest 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; + } + /** + * + * + *
+   * The request sent to the [GetPolicy]
+   * [google.cloud.orgpolicy.v2.OrgPolicy.GetPolicy] method.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.GetPolicyRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.GetPolicyRequest) + com.google.cloud.orgpolicy.v2.GetPolicyRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_GetPolicyRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_GetPolicyRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.GetPolicyRequest.class, + com.google.cloud.orgpolicy.v2.GetPolicyRequest.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.GetPolicyRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + name_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_GetPolicyRequest_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.GetPolicyRequest getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.GetPolicyRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.GetPolicyRequest build() { + com.google.cloud.orgpolicy.v2.GetPolicyRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.GetPolicyRequest buildPartial() { + com.google.cloud.orgpolicy.v2.GetPolicyRequest result = + new com.google.cloud.orgpolicy.v2.GetPolicyRequest(this); + result.name_ = name_; + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.GetPolicyRequest) { + return mergeFrom((com.google.cloud.orgpolicy.v2.GetPolicyRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.GetPolicyRequest other) { + if (other == com.google.cloud.orgpolicy.v2.GetPolicyRequest.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.GetPolicyRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.cloud.orgpolicy.v2.GetPolicyRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Required. Resource name of the policy. See `Policy` for naming requirements.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. Resource name of the policy. See `Policy` for naming requirements.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. Resource name of the policy. See `Policy` for naming requirements.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Resource name of the policy. See `Policy` for naming requirements.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Resource name of the policy. See `Policy` for naming requirements.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + 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.cloud.orgpolicy.v2.GetPolicyRequest) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.GetPolicyRequest) + private static final com.google.cloud.orgpolicy.v2.GetPolicyRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.GetPolicyRequest(); + } + + public static com.google.cloud.orgpolicy.v2.GetPolicyRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GetPolicyRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new GetPolicyRequest(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.GetPolicyRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/GetPolicyRequestOrBuilder.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/GetPolicyRequestOrBuilder.java new file mode 100644 index 0000000..697a96b --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/GetPolicyRequestOrBuilder.java @@ -0,0 +1,54 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +public interface GetPolicyRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.GetPolicyRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Resource name of the policy. See `Policy` for naming requirements.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Required. Resource name of the policy. See `Policy` for naming requirements.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListConstraintsRequest.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListConstraintsRequest.java new file mode 100644 index 0000000..df340d8 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListConstraintsRequest.java @@ -0,0 +1,971 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +/** + * + * + *
+ * The request sent to the [ListConstraints]
+ * [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method.
+ * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.ListConstraintsRequest} + */ +public final class ListConstraintsRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.ListConstraintsRequest) + ListConstraintsRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use ListConstraintsRequest.newBuilder() to construct. + private ListConstraintsRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ListConstraintsRequest() { + parent_ = ""; + pageToken_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListConstraintsRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private ListConstraintsRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + parent_ = s; + break; + } + case 16: + { + pageSize_ = input.readInt32(); + break; + } + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + + pageToken_ = s; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListConstraintsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListConstraintsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.ListConstraintsRequest.class, + com.google.cloud.orgpolicy.v2.ListConstraintsRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + private volatile java.lang.Object parent_; + /** + * + * + *
+   * Required. The Cloud resource that parents the constraint. Must be in one of the
+   * following forms:
+   * * `projects/{project_number}`
+   * * `projects/{project_id}`
+   * * `folders/{folder_id}`
+   * * `organizations/{organization_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + 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(); + parent_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The Cloud resource that parents the constraint. Must be in one of the
+   * following forms:
+   * * `projects/{project_number}`
+   * * `projects/{project_id}`
+   * * `folders/{folder_id}`
+   * * `organizations/{organization_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PAGE_SIZE_FIELD_NUMBER = 2; + private int pageSize_; + /** + * + * + *
+   * Size of the pages to be returned. This is currently unsupported and will
+   * be ignored. The server may at any point start using this field to limit
+   * page size.
+   * 
+ * + * int32 page_size = 2; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + public static final int PAGE_TOKEN_FIELD_NUMBER = 3; + private volatile java.lang.Object pageToken_; + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently unsupported
+   * and will be ignored. The server may at any point start using this field.
+   * 
+ * + * string page_token = 3; + * + * @return The pageToken. + */ + @java.lang.Override + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + 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(); + pageToken_ = s; + return s; + } + } + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently unsupported
+   * and will be ignored. The server may at any point start using this field.
+   * 
+ * + * string page_token = 3; + * + * @return The bytes for pageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = 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 (!getParentBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); + } + if (pageSize_ != 0) { + output.writeInt32(2, pageSize_); + } + if (!getPageTokenBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, pageToken_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getParentBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); + } + if (pageSize_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, pageSize_); + } + if (!getPageTokenBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, pageToken_); + } + size += unknownFields.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.cloud.orgpolicy.v2.ListConstraintsRequest)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.ListConstraintsRequest other = + (com.google.cloud.orgpolicy.v2.ListConstraintsRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (getPageSize() != other.getPageSize()) return false; + if (!getPageToken().equals(other.getPageToken())) return false; + if (!unknownFields.equals(other.unknownFields)) 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) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER; + hash = (53 * hash) + getPageSize(); + hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getPageToken().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsRequest 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.cloud.orgpolicy.v2.ListConstraintsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsRequest 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.cloud.orgpolicy.v2.ListConstraintsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsRequest 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.cloud.orgpolicy.v2.ListConstraintsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsRequest 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.cloud.orgpolicy.v2.ListConstraintsRequest 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; + } + /** + * + * + *
+   * The request sent to the [ListConstraints]
+   * [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.ListConstraintsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.ListConstraintsRequest) + com.google.cloud.orgpolicy.v2.ListConstraintsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListConstraintsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListConstraintsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.ListConstraintsRequest.class, + com.google.cloud.orgpolicy.v2.ListConstraintsRequest.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.ListConstraintsRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + parent_ = ""; + + pageSize_ = 0; + + pageToken_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListConstraintsRequest_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.ListConstraintsRequest getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.ListConstraintsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.ListConstraintsRequest build() { + com.google.cloud.orgpolicy.v2.ListConstraintsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.ListConstraintsRequest buildPartial() { + com.google.cloud.orgpolicy.v2.ListConstraintsRequest result = + new com.google.cloud.orgpolicy.v2.ListConstraintsRequest(this); + result.parent_ = parent_; + result.pageSize_ = pageSize_; + result.pageToken_ = pageToken_; + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.ListConstraintsRequest) { + return mergeFrom((com.google.cloud.orgpolicy.v2.ListConstraintsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.ListConstraintsRequest other) { + if (other == com.google.cloud.orgpolicy.v2.ListConstraintsRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + onChanged(); + } + if (other.getPageSize() != 0) { + setPageSize(other.getPageSize()); + } + if (!other.getPageToken().isEmpty()) { + pageToken_ = other.pageToken_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.ListConstraintsRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.orgpolicy.v2.ListConstraintsRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object parent_ = ""; + /** + * + * + *
+     * Required. The Cloud resource that parents the constraint. Must be in one of the
+     * following forms:
+     * * `projects/{project_number}`
+     * * `projects/{project_id}`
+     * * `folders/{folder_id}`
+     * * `organizations/{organization_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The Cloud resource that parents the constraint. Must be in one of the
+     * following forms:
+     * * `projects/{project_number}`
+     * * `projects/{project_id}`
+     * * `folders/{folder_id}`
+     * * `organizations/{organization_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The Cloud resource that parents the constraint. Must be in one of the
+     * following forms:
+     * * `projects/{project_number}`
+     * * `projects/{project_id}`
+     * * `folders/{folder_id}`
+     * * `organizations/{organization_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + parent_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Cloud resource that parents the constraint. Must be in one of the
+     * following forms:
+     * * `projects/{project_number}`
+     * * `projects/{project_id}`
+     * * `folders/{folder_id}`
+     * * `organizations/{organization_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + + parent_ = getDefaultInstance().getParent(); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Cloud resource that parents the constraint. Must be in one of the
+     * following forms:
+     * * `projects/{project_number}`
+     * * `projects/{project_id}`
+     * * `folders/{folder_id}`
+     * * `organizations/{organization_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + parent_ = value; + onChanged(); + return this; + } + + private int pageSize_; + /** + * + * + *
+     * Size of the pages to be returned. This is currently unsupported and will
+     * be ignored. The server may at any point start using this field to limit
+     * page size.
+     * 
+ * + * int32 page_size = 2; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + /** + * + * + *
+     * Size of the pages to be returned. This is currently unsupported and will
+     * be ignored. The server may at any point start using this field to limit
+     * page size.
+     * 
+ * + * int32 page_size = 2; + * + * @param value The pageSize to set. + * @return This builder for chaining. + */ + public Builder setPageSize(int value) { + + pageSize_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Size of the pages to be returned. This is currently unsupported and will
+     * be ignored. The server may at any point start using this field to limit
+     * page size.
+     * 
+ * + * int32 page_size = 2; + * + * @return This builder for chaining. + */ + public Builder clearPageSize() { + + pageSize_ = 0; + onChanged(); + return this; + } + + private java.lang.Object pageToken_ = ""; + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently unsupported
+     * and will be ignored. The server may at any point start using this field.
+     * 
+ * + * string page_token = 3; + * + * @return The pageToken. + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently unsupported
+     * and will be ignored. The server may at any point start using this field.
+     * 
+ * + * string page_token = 3; + * + * @return The bytes for pageToken. + */ + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently unsupported
+     * and will be ignored. The server may at any point start using this field.
+     * 
+ * + * string page_token = 3; + * + * @param value The pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + pageToken_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently unsupported
+     * and will be ignored. The server may at any point start using this field.
+     * 
+ * + * string page_token = 3; + * + * @return This builder for chaining. + */ + public Builder clearPageToken() { + + pageToken_ = getDefaultInstance().getPageToken(); + onChanged(); + return this; + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently unsupported
+     * and will be ignored. The server may at any point start using this field.
+     * 
+ * + * string page_token = 3; + * + * @param value The bytes for pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + pageToken_ = value; + 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.cloud.orgpolicy.v2.ListConstraintsRequest) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.ListConstraintsRequest) + private static final com.google.cloud.orgpolicy.v2.ListConstraintsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.ListConstraintsRequest(); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListConstraintsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ListConstraintsRequest(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.ListConstraintsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListConstraintsRequestOrBuilder.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListConstraintsRequestOrBuilder.java new file mode 100644 index 0000000..3ef37e7 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListConstraintsRequestOrBuilder.java @@ -0,0 +1,106 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +public interface ListConstraintsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.ListConstraintsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The Cloud resource that parents the constraint. Must be in one of the
+   * following forms:
+   * * `projects/{project_number}`
+   * * `projects/{project_id}`
+   * * `folders/{folder_id}`
+   * * `organizations/{organization_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + /** + * + * + *
+   * Required. The Cloud resource that parents the constraint. Must be in one of the
+   * following forms:
+   * * `projects/{project_number}`
+   * * `projects/{project_id}`
+   * * `folders/{folder_id}`
+   * * `organizations/{organization_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Size of the pages to be returned. This is currently unsupported and will
+   * be ignored. The server may at any point start using this field to limit
+   * page size.
+   * 
+ * + * int32 page_size = 2; + * + * @return The pageSize. + */ + int getPageSize(); + + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently unsupported
+   * and will be ignored. The server may at any point start using this field.
+   * 
+ * + * string page_token = 3; + * + * @return The pageToken. + */ + java.lang.String getPageToken(); + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently unsupported
+   * and will be ignored. The server may at any point start using this field.
+   * 
+ * + * string page_token = 3; + * + * @return The bytes for pageToken. + */ + com.google.protobuf.ByteString getPageTokenBytes(); +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListConstraintsResponse.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListConstraintsResponse.java new file mode 100644 index 0000000..ef4dd4f --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListConstraintsResponse.java @@ -0,0 +1,1133 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +/** + * + * + *
+ * The response returned from the [ListConstraints]
+ * [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method.
+ * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.ListConstraintsResponse} + */ +public final class ListConstraintsResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.ListConstraintsResponse) + ListConstraintsResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use ListConstraintsResponse.newBuilder() to construct. + private ListConstraintsResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ListConstraintsResponse() { + constraints_ = java.util.Collections.emptyList(); + nextPageToken_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListConstraintsResponse(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private ListConstraintsResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + constraints_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + constraints_.add( + input.readMessage( + com.google.cloud.orgpolicy.v2.Constraint.parser(), extensionRegistry)); + break; + } + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + + nextPageToken_ = s; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + constraints_ = java.util.Collections.unmodifiableList(constraints_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListConstraintsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListConstraintsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.ListConstraintsResponse.class, + com.google.cloud.orgpolicy.v2.ListConstraintsResponse.Builder.class); + } + + public static final int CONSTRAINTS_FIELD_NUMBER = 1; + private java.util.List constraints_; + /** + * + * + *
+   * The collection of constraints that are available on the targeted resource.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + @java.lang.Override + public java.util.List getConstraintsList() { + return constraints_; + } + /** + * + * + *
+   * The collection of constraints that are available on the targeted resource.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + @java.lang.Override + public java.util.List + getConstraintsOrBuilderList() { + return constraints_; + } + /** + * + * + *
+   * The collection of constraints that are available on the targeted resource.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + @java.lang.Override + public int getConstraintsCount() { + return constraints_.size(); + } + /** + * + * + *
+   * The collection of constraints that are available on the targeted resource.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Constraint getConstraints(int index) { + return constraints_.get(index); + } + /** + * + * + *
+   * The collection of constraints that are available on the targeted resource.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.ConstraintOrBuilder getConstraintsOrBuilder(int index) { + return constraints_.get(index); + } + + public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; + private volatile java.lang.Object nextPageToken_; + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently not used.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + @java.lang.Override + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + 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(); + nextPageToken_ = s; + return s; + } + } + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently not used.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = 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 { + for (int i = 0; i < constraints_.size(); i++) { + output.writeMessage(1, constraints_.get(i)); + } + if (!getNextPageTokenBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, nextPageToken_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < constraints_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, constraints_.get(i)); + } + if (!getNextPageTokenBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, nextPageToken_); + } + size += unknownFields.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.cloud.orgpolicy.v2.ListConstraintsResponse)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.ListConstraintsResponse other = + (com.google.cloud.orgpolicy.v2.ListConstraintsResponse) obj; + + if (!getConstraintsList().equals(other.getConstraintsList())) return false; + if (!getNextPageToken().equals(other.getNextPageToken())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getConstraintsCount() > 0) { + hash = (37 * hash) + CONSTRAINTS_FIELD_NUMBER; + hash = (53 * hash) + getConstraintsList().hashCode(); + } + hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getNextPageToken().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsResponse 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.cloud.orgpolicy.v2.ListConstraintsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsResponse 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.cloud.orgpolicy.v2.ListConstraintsResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsResponse 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.cloud.orgpolicy.v2.ListConstraintsResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsResponse 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.cloud.orgpolicy.v2.ListConstraintsResponse 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; + } + /** + * + * + *
+   * The response returned from the [ListConstraints]
+   * [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.ListConstraintsResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.ListConstraintsResponse) + com.google.cloud.orgpolicy.v2.ListConstraintsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListConstraintsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListConstraintsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.ListConstraintsResponse.class, + com.google.cloud.orgpolicy.v2.ListConstraintsResponse.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.ListConstraintsResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getConstraintsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + if (constraintsBuilder_ == null) { + constraints_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + constraintsBuilder_.clear(); + } + nextPageToken_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListConstraintsResponse_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.ListConstraintsResponse getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.ListConstraintsResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.ListConstraintsResponse build() { + com.google.cloud.orgpolicy.v2.ListConstraintsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.ListConstraintsResponse buildPartial() { + com.google.cloud.orgpolicy.v2.ListConstraintsResponse result = + new com.google.cloud.orgpolicy.v2.ListConstraintsResponse(this); + int from_bitField0_ = bitField0_; + if (constraintsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + constraints_ = java.util.Collections.unmodifiableList(constraints_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.constraints_ = constraints_; + } else { + result.constraints_ = constraintsBuilder_.build(); + } + result.nextPageToken_ = nextPageToken_; + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.ListConstraintsResponse) { + return mergeFrom((com.google.cloud.orgpolicy.v2.ListConstraintsResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.ListConstraintsResponse other) { + if (other == com.google.cloud.orgpolicy.v2.ListConstraintsResponse.getDefaultInstance()) + return this; + if (constraintsBuilder_ == null) { + if (!other.constraints_.isEmpty()) { + if (constraints_.isEmpty()) { + constraints_ = other.constraints_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureConstraintsIsMutable(); + constraints_.addAll(other.constraints_); + } + onChanged(); + } + } else { + if (!other.constraints_.isEmpty()) { + if (constraintsBuilder_.isEmpty()) { + constraintsBuilder_.dispose(); + constraintsBuilder_ = null; + constraints_ = other.constraints_; + bitField0_ = (bitField0_ & ~0x00000001); + constraintsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getConstraintsFieldBuilder() + : null; + } else { + constraintsBuilder_.addAllMessages(other.constraints_); + } + } + } + if (!other.getNextPageToken().isEmpty()) { + nextPageToken_ = other.nextPageToken_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.ListConstraintsResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.orgpolicy.v2.ListConstraintsResponse) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private java.util.List constraints_ = + java.util.Collections.emptyList(); + + private void ensureConstraintsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + constraints_ = + new java.util.ArrayList(constraints_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Constraint, + com.google.cloud.orgpolicy.v2.Constraint.Builder, + com.google.cloud.orgpolicy.v2.ConstraintOrBuilder> + constraintsBuilder_; + + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public java.util.List getConstraintsList() { + if (constraintsBuilder_ == null) { + return java.util.Collections.unmodifiableList(constraints_); + } else { + return constraintsBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public int getConstraintsCount() { + if (constraintsBuilder_ == null) { + return constraints_.size(); + } else { + return constraintsBuilder_.getCount(); + } + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public com.google.cloud.orgpolicy.v2.Constraint getConstraints(int index) { + if (constraintsBuilder_ == null) { + return constraints_.get(index); + } else { + return constraintsBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public Builder setConstraints(int index, com.google.cloud.orgpolicy.v2.Constraint value) { + if (constraintsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureConstraintsIsMutable(); + constraints_.set(index, value); + onChanged(); + } else { + constraintsBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public Builder setConstraints( + int index, com.google.cloud.orgpolicy.v2.Constraint.Builder builderForValue) { + if (constraintsBuilder_ == null) { + ensureConstraintsIsMutable(); + constraints_.set(index, builderForValue.build()); + onChanged(); + } else { + constraintsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public Builder addConstraints(com.google.cloud.orgpolicy.v2.Constraint value) { + if (constraintsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureConstraintsIsMutable(); + constraints_.add(value); + onChanged(); + } else { + constraintsBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public Builder addConstraints(int index, com.google.cloud.orgpolicy.v2.Constraint value) { + if (constraintsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureConstraintsIsMutable(); + constraints_.add(index, value); + onChanged(); + } else { + constraintsBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public Builder addConstraints( + com.google.cloud.orgpolicy.v2.Constraint.Builder builderForValue) { + if (constraintsBuilder_ == null) { + ensureConstraintsIsMutable(); + constraints_.add(builderForValue.build()); + onChanged(); + } else { + constraintsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public Builder addConstraints( + int index, com.google.cloud.orgpolicy.v2.Constraint.Builder builderForValue) { + if (constraintsBuilder_ == null) { + ensureConstraintsIsMutable(); + constraints_.add(index, builderForValue.build()); + onChanged(); + } else { + constraintsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public Builder addAllConstraints( + java.lang.Iterable values) { + if (constraintsBuilder_ == null) { + ensureConstraintsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, constraints_); + onChanged(); + } else { + constraintsBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public Builder clearConstraints() { + if (constraintsBuilder_ == null) { + constraints_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + constraintsBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public Builder removeConstraints(int index) { + if (constraintsBuilder_ == null) { + ensureConstraintsIsMutable(); + constraints_.remove(index); + onChanged(); + } else { + constraintsBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public com.google.cloud.orgpolicy.v2.Constraint.Builder getConstraintsBuilder(int index) { + return getConstraintsFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public com.google.cloud.orgpolicy.v2.ConstraintOrBuilder getConstraintsOrBuilder(int index) { + if (constraintsBuilder_ == null) { + return constraints_.get(index); + } else { + return constraintsBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public java.util.List + getConstraintsOrBuilderList() { + if (constraintsBuilder_ != null) { + return constraintsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(constraints_); + } + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public com.google.cloud.orgpolicy.v2.Constraint.Builder addConstraintsBuilder() { + return getConstraintsFieldBuilder() + .addBuilder(com.google.cloud.orgpolicy.v2.Constraint.getDefaultInstance()); + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public com.google.cloud.orgpolicy.v2.Constraint.Builder addConstraintsBuilder(int index) { + return getConstraintsFieldBuilder() + .addBuilder(index, com.google.cloud.orgpolicy.v2.Constraint.getDefaultInstance()); + } + /** + * + * + *
+     * The collection of constraints that are available on the targeted resource.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + public java.util.List + getConstraintsBuilderList() { + return getConstraintsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Constraint, + com.google.cloud.orgpolicy.v2.Constraint.Builder, + com.google.cloud.orgpolicy.v2.ConstraintOrBuilder> + getConstraintsFieldBuilder() { + if (constraintsBuilder_ == null) { + constraintsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Constraint, + com.google.cloud.orgpolicy.v2.Constraint.Builder, + com.google.cloud.orgpolicy.v2.ConstraintOrBuilder>( + constraints_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + constraints_ = null; + } + return constraintsBuilder_; + } + + private java.lang.Object nextPageToken_ = ""; + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently not used.
+     * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently not used.
+     * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently not used.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + nextPageToken_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently not used.
+     * 
+ * + * string next_page_token = 2; + * + * @return This builder for chaining. + */ + public Builder clearNextPageToken() { + + nextPageToken_ = getDefaultInstance().getNextPageToken(); + onChanged(); + return this; + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently not used.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The bytes for nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + nextPageToken_ = value; + 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.cloud.orgpolicy.v2.ListConstraintsResponse) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.ListConstraintsResponse) + private static final com.google.cloud.orgpolicy.v2.ListConstraintsResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.ListConstraintsResponse(); + } + + public static com.google.cloud.orgpolicy.v2.ListConstraintsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListConstraintsResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ListConstraintsResponse(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.ListConstraintsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListConstraintsResponseOrBuilder.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListConstraintsResponseOrBuilder.java new file mode 100644 index 0000000..3dff2e8 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListConstraintsResponseOrBuilder.java @@ -0,0 +1,102 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +public interface ListConstraintsResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.ListConstraintsResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The collection of constraints that are available on the targeted resource.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + java.util.List getConstraintsList(); + /** + * + * + *
+   * The collection of constraints that are available on the targeted resource.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + com.google.cloud.orgpolicy.v2.Constraint getConstraints(int index); + /** + * + * + *
+   * The collection of constraints that are available on the targeted resource.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + int getConstraintsCount(); + /** + * + * + *
+   * The collection of constraints that are available on the targeted resource.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + java.util.List + getConstraintsOrBuilderList(); + /** + * + * + *
+   * The collection of constraints that are available on the targeted resource.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Constraint constraints = 1; + */ + com.google.cloud.orgpolicy.v2.ConstraintOrBuilder getConstraintsOrBuilder(int index); + + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently not used.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + java.lang.String getNextPageToken(); + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently not used.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + com.google.protobuf.ByteString getNextPageTokenBytes(); +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListPoliciesRequest.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListPoliciesRequest.java new file mode 100644 index 0000000..6f0a090 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListPoliciesRequest.java @@ -0,0 +1,978 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +/** + * + * + *
+ * The request sent to the [ListPolicies]
+ * [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method.
+ * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.ListPoliciesRequest} + */ +public final class ListPoliciesRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.ListPoliciesRequest) + ListPoliciesRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use ListPoliciesRequest.newBuilder() to construct. + private ListPoliciesRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ListPoliciesRequest() { + parent_ = ""; + pageToken_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListPoliciesRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private ListPoliciesRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + parent_ = s; + break; + } + case 16: + { + pageSize_ = input.readInt32(); + break; + } + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + + pageToken_ = s; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListPoliciesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListPoliciesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.ListPoliciesRequest.class, + com.google.cloud.orgpolicy.v2.ListPoliciesRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + private volatile java.lang.Object parent_; + /** + * + * + *
+   * Required. The target Cloud resource that parents the set of constraints and policies
+   * that will be returned from this call. Must be in one of the following
+   * forms:
+   * * `projects/{project_number}`
+   * * `projects/{project_id}`
+   * * `folders/{folder_id}`
+   * * `organizations/{organization_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + 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(); + parent_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The target Cloud resource that parents the set of constraints and policies
+   * that will be returned from this call. Must be in one of the following
+   * forms:
+   * * `projects/{project_number}`
+   * * `projects/{project_id}`
+   * * `folders/{folder_id}`
+   * * `organizations/{organization_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PAGE_SIZE_FIELD_NUMBER = 2; + private int pageSize_; + /** + * + * + *
+   * Size of the pages to be returned. This is currently unsupported and will
+   * be ignored. The server may at any point start using this field to limit
+   * page size.
+   * 
+ * + * int32 page_size = 2; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + public static final int PAGE_TOKEN_FIELD_NUMBER = 3; + private volatile java.lang.Object pageToken_; + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently unsupported
+   * and will be ignored. The server may at any point start using this field.
+   * 
+ * + * string page_token = 3; + * + * @return The pageToken. + */ + @java.lang.Override + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + 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(); + pageToken_ = s; + return s; + } + } + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently unsupported
+   * and will be ignored. The server may at any point start using this field.
+   * 
+ * + * string page_token = 3; + * + * @return The bytes for pageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = 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 (!getParentBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); + } + if (pageSize_ != 0) { + output.writeInt32(2, pageSize_); + } + if (!getPageTokenBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, pageToken_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getParentBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); + } + if (pageSize_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, pageSize_); + } + if (!getPageTokenBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, pageToken_); + } + size += unknownFields.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.cloud.orgpolicy.v2.ListPoliciesRequest)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.ListPoliciesRequest other = + (com.google.cloud.orgpolicy.v2.ListPoliciesRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (getPageSize() != other.getPageSize()) return false; + if (!getPageToken().equals(other.getPageToken())) return false; + if (!unknownFields.equals(other.unknownFields)) 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) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER; + hash = (53 * hash) + getPageSize(); + hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getPageToken().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesRequest 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.cloud.orgpolicy.v2.ListPoliciesRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesRequest 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.cloud.orgpolicy.v2.ListPoliciesRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesRequest 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.cloud.orgpolicy.v2.ListPoliciesRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesRequest 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.cloud.orgpolicy.v2.ListPoliciesRequest 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; + } + /** + * + * + *
+   * The request sent to the [ListPolicies]
+   * [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.ListPoliciesRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.ListPoliciesRequest) + com.google.cloud.orgpolicy.v2.ListPoliciesRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListPoliciesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListPoliciesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.ListPoliciesRequest.class, + com.google.cloud.orgpolicy.v2.ListPoliciesRequest.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.ListPoliciesRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + parent_ = ""; + + pageSize_ = 0; + + pageToken_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListPoliciesRequest_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.ListPoliciesRequest getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.ListPoliciesRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.ListPoliciesRequest build() { + com.google.cloud.orgpolicy.v2.ListPoliciesRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.ListPoliciesRequest buildPartial() { + com.google.cloud.orgpolicy.v2.ListPoliciesRequest result = + new com.google.cloud.orgpolicy.v2.ListPoliciesRequest(this); + result.parent_ = parent_; + result.pageSize_ = pageSize_; + result.pageToken_ = pageToken_; + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.ListPoliciesRequest) { + return mergeFrom((com.google.cloud.orgpolicy.v2.ListPoliciesRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.ListPoliciesRequest other) { + if (other == com.google.cloud.orgpolicy.v2.ListPoliciesRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + onChanged(); + } + if (other.getPageSize() != 0) { + setPageSize(other.getPageSize()); + } + if (!other.getPageToken().isEmpty()) { + pageToken_ = other.pageToken_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.ListPoliciesRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.orgpolicy.v2.ListPoliciesRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object parent_ = ""; + /** + * + * + *
+     * Required. The target Cloud resource that parents the set of constraints and policies
+     * that will be returned from this call. Must be in one of the following
+     * forms:
+     * * `projects/{project_number}`
+     * * `projects/{project_id}`
+     * * `folders/{folder_id}`
+     * * `organizations/{organization_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The target Cloud resource that parents the set of constraints and policies
+     * that will be returned from this call. Must be in one of the following
+     * forms:
+     * * `projects/{project_number}`
+     * * `projects/{project_id}`
+     * * `folders/{folder_id}`
+     * * `organizations/{organization_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The target Cloud resource that parents the set of constraints and policies
+     * that will be returned from this call. Must be in one of the following
+     * forms:
+     * * `projects/{project_number}`
+     * * `projects/{project_id}`
+     * * `folders/{folder_id}`
+     * * `organizations/{organization_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + parent_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The target Cloud resource that parents the set of constraints and policies
+     * that will be returned from this call. Must be in one of the following
+     * forms:
+     * * `projects/{project_number}`
+     * * `projects/{project_id}`
+     * * `folders/{folder_id}`
+     * * `organizations/{organization_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + + parent_ = getDefaultInstance().getParent(); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The target Cloud resource that parents the set of constraints and policies
+     * that will be returned from this call. Must be in one of the following
+     * forms:
+     * * `projects/{project_number}`
+     * * `projects/{project_id}`
+     * * `folders/{folder_id}`
+     * * `organizations/{organization_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + parent_ = value; + onChanged(); + return this; + } + + private int pageSize_; + /** + * + * + *
+     * Size of the pages to be returned. This is currently unsupported and will
+     * be ignored. The server may at any point start using this field to limit
+     * page size.
+     * 
+ * + * int32 page_size = 2; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + /** + * + * + *
+     * Size of the pages to be returned. This is currently unsupported and will
+     * be ignored. The server may at any point start using this field to limit
+     * page size.
+     * 
+ * + * int32 page_size = 2; + * + * @param value The pageSize to set. + * @return This builder for chaining. + */ + public Builder setPageSize(int value) { + + pageSize_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Size of the pages to be returned. This is currently unsupported and will
+     * be ignored. The server may at any point start using this field to limit
+     * page size.
+     * 
+ * + * int32 page_size = 2; + * + * @return This builder for chaining. + */ + public Builder clearPageSize() { + + pageSize_ = 0; + onChanged(); + return this; + } + + private java.lang.Object pageToken_ = ""; + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently unsupported
+     * and will be ignored. The server may at any point start using this field.
+     * 
+ * + * string page_token = 3; + * + * @return The pageToken. + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently unsupported
+     * and will be ignored. The server may at any point start using this field.
+     * 
+ * + * string page_token = 3; + * + * @return The bytes for pageToken. + */ + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently unsupported
+     * and will be ignored. The server may at any point start using this field.
+     * 
+ * + * string page_token = 3; + * + * @param value The pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + pageToken_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently unsupported
+     * and will be ignored. The server may at any point start using this field.
+     * 
+ * + * string page_token = 3; + * + * @return This builder for chaining. + */ + public Builder clearPageToken() { + + pageToken_ = getDefaultInstance().getPageToken(); + onChanged(); + return this; + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently unsupported
+     * and will be ignored. The server may at any point start using this field.
+     * 
+ * + * string page_token = 3; + * + * @param value The bytes for pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + pageToken_ = value; + 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.cloud.orgpolicy.v2.ListPoliciesRequest) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.ListPoliciesRequest) + private static final com.google.cloud.orgpolicy.v2.ListPoliciesRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.ListPoliciesRequest(); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListPoliciesRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ListPoliciesRequest(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.ListPoliciesRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListPoliciesRequestOrBuilder.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListPoliciesRequestOrBuilder.java new file mode 100644 index 0000000..0663a96 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListPoliciesRequestOrBuilder.java @@ -0,0 +1,108 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +public interface ListPoliciesRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.ListPoliciesRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The target Cloud resource that parents the set of constraints and policies
+   * that will be returned from this call. Must be in one of the following
+   * forms:
+   * * `projects/{project_number}`
+   * * `projects/{project_id}`
+   * * `folders/{folder_id}`
+   * * `organizations/{organization_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + /** + * + * + *
+   * Required. The target Cloud resource that parents the set of constraints and policies
+   * that will be returned from this call. Must be in one of the following
+   * forms:
+   * * `projects/{project_number}`
+   * * `projects/{project_id}`
+   * * `folders/{folder_id}`
+   * * `organizations/{organization_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Size of the pages to be returned. This is currently unsupported and will
+   * be ignored. The server may at any point start using this field to limit
+   * page size.
+   * 
+ * + * int32 page_size = 2; + * + * @return The pageSize. + */ + int getPageSize(); + + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently unsupported
+   * and will be ignored. The server may at any point start using this field.
+   * 
+ * + * string page_token = 3; + * + * @return The pageToken. + */ + java.lang.String getPageToken(); + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently unsupported
+   * and will be ignored. The server may at any point start using this field.
+   * 
+ * + * string page_token = 3; + * + * @return The bytes for pageToken. + */ + com.google.protobuf.ByteString getPageTokenBytes(); +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListPoliciesResponse.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListPoliciesResponse.java new file mode 100644 index 0000000..b21452c --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListPoliciesResponse.java @@ -0,0 +1,1161 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +/** + * + * + *
+ * The response returned from the [ListPolicies]
+ * [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method. It will be empty
+ * if no `Policies` are set on the resource.
+ * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.ListPoliciesResponse} + */ +public final class ListPoliciesResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.ListPoliciesResponse) + ListPoliciesResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use ListPoliciesResponse.newBuilder() to construct. + private ListPoliciesResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ListPoliciesResponse() { + policies_ = java.util.Collections.emptyList(); + nextPageToken_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListPoliciesResponse(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private ListPoliciesResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + policies_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + policies_.add( + input.readMessage( + com.google.cloud.orgpolicy.v2.Policy.parser(), extensionRegistry)); + break; + } + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + + nextPageToken_ = s; + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + policies_ = java.util.Collections.unmodifiableList(policies_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListPoliciesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListPoliciesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.ListPoliciesResponse.class, + com.google.cloud.orgpolicy.v2.ListPoliciesResponse.Builder.class); + } + + public static final int POLICIES_FIELD_NUMBER = 1; + private java.util.List policies_; + /** + * + * + *
+   * All `Policies` that exist on the resource. It will be empty if no
+   * `Policies` are set.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + @java.lang.Override + public java.util.List getPoliciesList() { + return policies_; + } + /** + * + * + *
+   * All `Policies` that exist on the resource. It will be empty if no
+   * `Policies` are set.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + @java.lang.Override + public java.util.List + getPoliciesOrBuilderList() { + return policies_; + } + /** + * + * + *
+   * All `Policies` that exist on the resource. It will be empty if no
+   * `Policies` are set.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + @java.lang.Override + public int getPoliciesCount() { + return policies_.size(); + } + /** + * + * + *
+   * All `Policies` that exist on the resource. It will be empty if no
+   * `Policies` are set.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Policy getPolicies(int index) { + return policies_.get(index); + } + /** + * + * + *
+   * All `Policies` that exist on the resource. It will be empty if no
+   * `Policies` are set.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicyOrBuilder getPoliciesOrBuilder(int index) { + return policies_.get(index); + } + + public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; + private volatile java.lang.Object nextPageToken_; + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently not used, but
+   * the server may at any point start supplying a valid token.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + @java.lang.Override + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + 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(); + nextPageToken_ = s; + return s; + } + } + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently not used, but
+   * the server may at any point start supplying a valid token.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = 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 { + for (int i = 0; i < policies_.size(); i++) { + output.writeMessage(1, policies_.get(i)); + } + if (!getNextPageTokenBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, nextPageToken_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < policies_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, policies_.get(i)); + } + if (!getNextPageTokenBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, nextPageToken_); + } + size += unknownFields.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.cloud.orgpolicy.v2.ListPoliciesResponse)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.ListPoliciesResponse other = + (com.google.cloud.orgpolicy.v2.ListPoliciesResponse) obj; + + if (!getPoliciesList().equals(other.getPoliciesList())) return false; + if (!getNextPageToken().equals(other.getNextPageToken())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getPoliciesCount() > 0) { + hash = (37 * hash) + POLICIES_FIELD_NUMBER; + hash = (53 * hash) + getPoliciesList().hashCode(); + } + hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getNextPageToken().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesResponse 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.cloud.orgpolicy.v2.ListPoliciesResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesResponse 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.cloud.orgpolicy.v2.ListPoliciesResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesResponse 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.cloud.orgpolicy.v2.ListPoliciesResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesResponse 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.cloud.orgpolicy.v2.ListPoliciesResponse 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; + } + /** + * + * + *
+   * The response returned from the [ListPolicies]
+   * [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method. It will be empty
+   * if no `Policies` are set on the resource.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.ListPoliciesResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.ListPoliciesResponse) + com.google.cloud.orgpolicy.v2.ListPoliciesResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListPoliciesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListPoliciesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.ListPoliciesResponse.class, + com.google.cloud.orgpolicy.v2.ListPoliciesResponse.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.ListPoliciesResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPoliciesFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + if (policiesBuilder_ == null) { + policies_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + policiesBuilder_.clear(); + } + nextPageToken_ = ""; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_ListPoliciesResponse_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.ListPoliciesResponse getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.ListPoliciesResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.ListPoliciesResponse build() { + com.google.cloud.orgpolicy.v2.ListPoliciesResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.ListPoliciesResponse buildPartial() { + com.google.cloud.orgpolicy.v2.ListPoliciesResponse result = + new com.google.cloud.orgpolicy.v2.ListPoliciesResponse(this); + int from_bitField0_ = bitField0_; + if (policiesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + policies_ = java.util.Collections.unmodifiableList(policies_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.policies_ = policies_; + } else { + result.policies_ = policiesBuilder_.build(); + } + result.nextPageToken_ = nextPageToken_; + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.ListPoliciesResponse) { + return mergeFrom((com.google.cloud.orgpolicy.v2.ListPoliciesResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.ListPoliciesResponse other) { + if (other == com.google.cloud.orgpolicy.v2.ListPoliciesResponse.getDefaultInstance()) + return this; + if (policiesBuilder_ == null) { + if (!other.policies_.isEmpty()) { + if (policies_.isEmpty()) { + policies_ = other.policies_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensurePoliciesIsMutable(); + policies_.addAll(other.policies_); + } + onChanged(); + } + } else { + if (!other.policies_.isEmpty()) { + if (policiesBuilder_.isEmpty()) { + policiesBuilder_.dispose(); + policiesBuilder_ = null; + policies_ = other.policies_; + bitField0_ = (bitField0_ & ~0x00000001); + policiesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getPoliciesFieldBuilder() + : null; + } else { + policiesBuilder_.addAllMessages(other.policies_); + } + } + } + if (!other.getNextPageToken().isEmpty()) { + nextPageToken_ = other.nextPageToken_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.ListPoliciesResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.orgpolicy.v2.ListPoliciesResponse) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private java.util.List policies_ = + java.util.Collections.emptyList(); + + private void ensurePoliciesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + policies_ = new java.util.ArrayList(policies_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Policy, + com.google.cloud.orgpolicy.v2.Policy.Builder, + com.google.cloud.orgpolicy.v2.PolicyOrBuilder> + policiesBuilder_; + + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public java.util.List getPoliciesList() { + if (policiesBuilder_ == null) { + return java.util.Collections.unmodifiableList(policies_); + } else { + return policiesBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public int getPoliciesCount() { + if (policiesBuilder_ == null) { + return policies_.size(); + } else { + return policiesBuilder_.getCount(); + } + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public com.google.cloud.orgpolicy.v2.Policy getPolicies(int index) { + if (policiesBuilder_ == null) { + return policies_.get(index); + } else { + return policiesBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public Builder setPolicies(int index, com.google.cloud.orgpolicy.v2.Policy value) { + if (policiesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePoliciesIsMutable(); + policies_.set(index, value); + onChanged(); + } else { + policiesBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public Builder setPolicies( + int index, com.google.cloud.orgpolicy.v2.Policy.Builder builderForValue) { + if (policiesBuilder_ == null) { + ensurePoliciesIsMutable(); + policies_.set(index, builderForValue.build()); + onChanged(); + } else { + policiesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public Builder addPolicies(com.google.cloud.orgpolicy.v2.Policy value) { + if (policiesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePoliciesIsMutable(); + policies_.add(value); + onChanged(); + } else { + policiesBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public Builder addPolicies(int index, com.google.cloud.orgpolicy.v2.Policy value) { + if (policiesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePoliciesIsMutable(); + policies_.add(index, value); + onChanged(); + } else { + policiesBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public Builder addPolicies(com.google.cloud.orgpolicy.v2.Policy.Builder builderForValue) { + if (policiesBuilder_ == null) { + ensurePoliciesIsMutable(); + policies_.add(builderForValue.build()); + onChanged(); + } else { + policiesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public Builder addPolicies( + int index, com.google.cloud.orgpolicy.v2.Policy.Builder builderForValue) { + if (policiesBuilder_ == null) { + ensurePoliciesIsMutable(); + policies_.add(index, builderForValue.build()); + onChanged(); + } else { + policiesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public Builder addAllPolicies( + java.lang.Iterable values) { + if (policiesBuilder_ == null) { + ensurePoliciesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, policies_); + onChanged(); + } else { + policiesBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public Builder clearPolicies() { + if (policiesBuilder_ == null) { + policies_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + policiesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public Builder removePolicies(int index) { + if (policiesBuilder_ == null) { + ensurePoliciesIsMutable(); + policies_.remove(index); + onChanged(); + } else { + policiesBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public com.google.cloud.orgpolicy.v2.Policy.Builder getPoliciesBuilder(int index) { + return getPoliciesFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public com.google.cloud.orgpolicy.v2.PolicyOrBuilder getPoliciesOrBuilder(int index) { + if (policiesBuilder_ == null) { + return policies_.get(index); + } else { + return policiesBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public java.util.List + getPoliciesOrBuilderList() { + if (policiesBuilder_ != null) { + return policiesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(policies_); + } + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public com.google.cloud.orgpolicy.v2.Policy.Builder addPoliciesBuilder() { + return getPoliciesFieldBuilder() + .addBuilder(com.google.cloud.orgpolicy.v2.Policy.getDefaultInstance()); + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public com.google.cloud.orgpolicy.v2.Policy.Builder addPoliciesBuilder(int index) { + return getPoliciesFieldBuilder() + .addBuilder(index, com.google.cloud.orgpolicy.v2.Policy.getDefaultInstance()); + } + /** + * + * + *
+     * All `Policies` that exist on the resource. It will be empty if no
+     * `Policies` are set.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + public java.util.List getPoliciesBuilderList() { + return getPoliciesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Policy, + com.google.cloud.orgpolicy.v2.Policy.Builder, + com.google.cloud.orgpolicy.v2.PolicyOrBuilder> + getPoliciesFieldBuilder() { + if (policiesBuilder_ == null) { + policiesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Policy, + com.google.cloud.orgpolicy.v2.Policy.Builder, + com.google.cloud.orgpolicy.v2.PolicyOrBuilder>( + policies_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + policies_ = null; + } + return policiesBuilder_; + } + + private java.lang.Object nextPageToken_ = ""; + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently not used, but
+     * the server may at any point start supplying a valid token.
+     * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently not used, but
+     * the server may at any point start supplying a valid token.
+     * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently not used, but
+     * the server may at any point start supplying a valid token.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + nextPageToken_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently not used, but
+     * the server may at any point start supplying a valid token.
+     * 
+ * + * string next_page_token = 2; + * + * @return This builder for chaining. + */ + public Builder clearNextPageToken() { + + nextPageToken_ = getDefaultInstance().getNextPageToken(); + onChanged(); + return this; + } + /** + * + * + *
+     * Page token used to retrieve the next page. This is currently not used, but
+     * the server may at any point start supplying a valid token.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The bytes for nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + nextPageToken_ = value; + 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.cloud.orgpolicy.v2.ListPoliciesResponse) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.ListPoliciesResponse) + private static final com.google.cloud.orgpolicy.v2.ListPoliciesResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.ListPoliciesResponse(); + } + + public static com.google.cloud.orgpolicy.v2.ListPoliciesResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListPoliciesResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ListPoliciesResponse(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.ListPoliciesResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListPoliciesResponseOrBuilder.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListPoliciesResponseOrBuilder.java new file mode 100644 index 0000000..4ead283 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ListPoliciesResponseOrBuilder.java @@ -0,0 +1,109 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +public interface ListPoliciesResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.ListPoliciesResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * All `Policies` that exist on the resource. It will be empty if no
+   * `Policies` are set.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + java.util.List getPoliciesList(); + /** + * + * + *
+   * All `Policies` that exist on the resource. It will be empty if no
+   * `Policies` are set.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + com.google.cloud.orgpolicy.v2.Policy getPolicies(int index); + /** + * + * + *
+   * All `Policies` that exist on the resource. It will be empty if no
+   * `Policies` are set.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + int getPoliciesCount(); + /** + * + * + *
+   * All `Policies` that exist on the resource. It will be empty if no
+   * `Policies` are set.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + java.util.List + getPoliciesOrBuilderList(); + /** + * + * + *
+   * All `Policies` that exist on the resource. It will be empty if no
+   * `Policies` are set.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.Policy policies = 1; + */ + com.google.cloud.orgpolicy.v2.PolicyOrBuilder getPoliciesOrBuilder(int index); + + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently not used, but
+   * the server may at any point start supplying a valid token.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + java.lang.String getNextPageToken(); + /** + * + * + *
+   * Page token used to retrieve the next page. This is currently not used, but
+   * the server may at any point start supplying a valid token.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + com.google.protobuf.ByteString getNextPageTokenBytes(); +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicyProto.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicyProto.java new file mode 100644 index 0000000..06b4db5 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/OrgPolicyProto.java @@ -0,0 +1,349 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +public final class OrgPolicyProto { + private OrgPolicyProto() {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_Policy_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_Policy_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_AlternatePolicySpec_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_AlternatePolicySpec_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_PolicySpec_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_PolicySpec_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_StringValues_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_StringValues_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_ListConstraintsRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_ListConstraintsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_ListConstraintsResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_ListConstraintsResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_ListPoliciesRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_ListPoliciesRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_ListPoliciesResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_ListPoliciesResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_GetPolicyRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_GetPolicyRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_GetEffectivePolicyRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_GetEffectivePolicyRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_CreatePolicyRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_CreatePolicyRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_UpdatePolicyRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_UpdatePolicyRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_cloud_orgpolicy_v2_DeletePolicyRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_cloud_orgpolicy_v2_DeletePolicyRequest_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)google/cloud/orgpolicy/v2/orgpolicy.pr" + + "oto\022\031google.cloud.orgpolicy.v2\032\034google/a" + + "pi/annotations.proto\032\027google/api/client." + + "proto\032\037google/api/field_behavior.proto\032\031" + + "google/api/resource.proto\032*google/cloud/" + + "orgpolicy/v2/constraint.proto\032\033google/pr" + + "otobuf/empty.proto\032\037google/protobuf/time" + + "stamp.proto\032\026google/type/expr.proto\"\265\002\n\006" + + "Policy\022\021\n\004name\030\001 \001(\tB\003\340A\005\0223\n\004spec\030\002 \001(\0132" + + "%.google.cloud.orgpolicy.v2.PolicySpec\022A" + + "\n\talternate\030\003 \001(\0132..google.cloud.orgpoli" + + "cy.v2.AlternatePolicySpec:\237\001\352A\233\001\n\037orgpol" + + "icy.googleapis.com/Policy\022$projects/{pro" + + "ject}/policies/{policy}\022\"folders/{folder" + + "}/policies/{policy}\022.organizations/{orga" + + "nization}/policies/{policy}\"Z\n\023Alternate" + + "PolicySpec\022\016\n\006launch\030\001 \001(\t\0223\n\004spec\030\002 \001(\013" + + "2%.google.cloud.orgpolicy.v2.PolicySpec\"" + + "\306\003\n\nPolicySpec\022\014\n\004etag\030\001 \001(\t\0224\n\013update_t" + + "ime\030\002 \001(\0132\032.google.protobuf.TimestampB\003\340" + + "A\003\022?\n\005rules\030\003 \003(\01320.google.cloud.orgpoli" + + "cy.v2.PolicySpec.PolicyRule\022\033\n\023inherit_f" + + "rom_parent\030\004 \001(\010\022\r\n\005reset\030\005 \001(\010\032\206\002\n\nPoli" + + "cyRule\022O\n\006values\030\001 \001(\0132=.google.cloud.or" + + "gpolicy.v2.PolicySpec.PolicyRule.StringV" + + "aluesH\000\022\023\n\tallow_all\030\002 \001(\010H\000\022\022\n\010deny_all" + + "\030\003 \001(\010H\000\022\021\n\007enforce\030\004 \001(\010H\000\022$\n\tcondition" + + "\030\005 \001(\0132\021.google.type.Expr\032=\n\014StringValue" + + "s\022\026\n\016allowed_values\030\001 \003(\t\022\025\n\rdenied_valu" + + "es\030\002 \003(\tB\006\n\004kind\"|\n\026ListConstraintsReque" + + "st\022;\n\006parent\030\001 \001(\tB+\340A\002\372A%\022#orgpolicy.go" + + "ogleapis.com/Constraint\022\021\n\tpage_size\030\002 \001" + + "(\005\022\022\n\npage_token\030\003 \001(\t\"n\n\027ListConstraint" + + "sResponse\022:\n\013constraints\030\001 \003(\0132%.google." + + "cloud.orgpolicy.v2.Constraint\022\027\n\017next_pa" + + "ge_token\030\002 \001(\t\"u\n\023ListPoliciesRequest\0227\n" + + "\006parent\030\001 \001(\tB\'\340A\002\372A!\022\037orgpolicy.googlea" + + "pis.com/Policy\022\021\n\tpage_size\030\002 \001(\005\022\022\n\npag" + + "e_token\030\003 \001(\t\"d\n\024ListPoliciesResponse\0223\n" + + "\010policies\030\001 \003(\0132!.google.cloud.orgpolicy" + + ".v2.Policy\022\027\n\017next_page_token\030\002 \001(\t\"I\n\020G" + + "etPolicyRequest\0225\n\004name\030\001 \001(\tB\'\340A\002\372A!\n\037o" + + "rgpolicy.googleapis.com/Policy\"R\n\031GetEff" + + "ectivePolicyRequest\0225\n\004name\030\001 \001(\tB\'\340A\002\372A" + + "!\n\037orgpolicy.googleapis.com/Policy\"\206\001\n\023C" + + "reatePolicyRequest\0227\n\006parent\030\001 \001(\tB\'\340A\002\372" + + "A!\022\037orgpolicy.googleapis.com/Policy\0226\n\006p" + + "olicy\030\003 \001(\0132!.google.cloud.orgpolicy.v2." + + "PolicyB\003\340A\002\"M\n\023UpdatePolicyRequest\0226\n\006po" + + "licy\030\001 \001(\0132!.google.cloud.orgpolicy.v2.P" + + "olicyB\003\340A\002\"L\n\023DeletePolicyRequest\0225\n\004nam" + + "e\030\001 \001(\tB\'\340A\002\372A!\n\037orgpolicy.googleapis.co" + + "m/Policy2\275\016\n\tOrgPolicy\022\201\002\n\017ListConstrain" + + "ts\0221.google.cloud.orgpolicy.v2.ListConst" + + "raintsRequest\0322.google.cloud.orgpolicy.v" + + "2.ListConstraintsResponse\"\206\001\202\323\344\223\002w\022#/v2/" + + "{parent=projects/*}/constraintsZ$\022\"/v2/{" + + "parent=folders/*}/constraintsZ*\022(/v2/{pa" + + "rent=organizations/*}/constraints\332A\006pare" + + "nt\022\356\001\n\014ListPolicies\022..google.cloud.orgpo" + + "licy.v2.ListPoliciesRequest\032/.google.clo" + + "ud.orgpolicy.v2.ListPoliciesResponse\"}\202\323" + + "\344\223\002n\022 /v2/{parent=projects/*}/policiesZ!" + + "\022\037/v2/{parent=folders/*}/policiesZ\'\022%/v2" + + "/{parent=organizations/*}/policies\332A\006par" + + "ent\022\330\001\n\tGetPolicy\022+.google.cloud.orgpoli" + + "cy.v2.GetPolicyRequest\032!.google.cloud.or" + + "gpolicy.v2.Policy\"{\202\323\344\223\002n\022 /v2/{name=pro" + + "jects/*/policies/*}Z!\022\037/v2/{name=folders" + + "/*/policies/*}Z\'\022%/v2/{name=organization" + + "s/*/policies/*}\332A\004name\022\245\002\n\022GetEffectiveP" + + "olicy\0224.google.cloud.orgpolicy.v2.GetEff" + + "ectivePolicyRequest\032!.google.cloud.orgpo" + + "licy.v2.Policy\"\265\001\202\323\344\223\002\247\001\0223/v2/{name=proj" + + "ects/*/policies/*}:getEffectivePolicyZ4\022" + + "2/v2/{name=folders/*/policies/*}:getEffe" + + "ctivePolicyZ:\0228/v2/{name=organizations/*" + + "/policies/*}:getEffectivePolicy\332A\004name\022\201" + + "\002\n\014CreatePolicy\022..google.cloud.orgpolicy" + + ".v2.CreatePolicyRequest\032!.google.cloud.o" + + "rgpolicy.v2.Policy\"\235\001\202\323\344\223\002\206\001\" /v2/{paren" + + "t=projects/*}/policies:\006policyZ)\"\037/v2/{p" + + "arent=folders/*}/policies:\006policyZ/\"%/v2" + + "/{parent=organizations/*}/policies:\006poli" + + "cy\332A\rparent,policy\022\217\002\n\014UpdatePolicy\022..go" + + "ogle.cloud.orgpolicy.v2.UpdatePolicyRequ" + + "est\032!.google.cloud.orgpolicy.v2.Policy\"\253" + + "\001\202\323\344\223\002\233\0012\'/v2/{policy.name=projects/*/po" + + "licies/*}:\006policyZ02&/v2/{policy.name=fo" + + "lders/*/policies/*}:\006policyZ62,/v2/{poli" + + "cy.name=organizations/*/policies/*}:\006pol" + + "icy\332A\006policy\022\323\001\n\014DeletePolicy\022..google.c" + + "loud.orgpolicy.v2.DeletePolicyRequest\032\026." + + "google.protobuf.Empty\"{\202\323\344\223\002n* /v2/{name" + + "=projects/*/policies/*}Z!*\037/v2/{name=fol" + + "ders/*/policies/*}Z\'*%/v2/{name=organiza" + + "tions/*/policies/*}\332A\004name\032L\312A\030orgpolicy" + + ".googleapis.com\322A.https://www.googleapis" + + ".com/auth/cloud-platformB\314\001\n\035com.google." + + "cloud.orgpolicy.v2B\016OrgPolicyProtoP\001ZBgo" + + "ogle.golang.org/genproto/googleapis/clou" + + "d/orgpolicy/v2;orgpolicy\252\002\031Google.Cloud." + + "OrgPolicy.V2\312\002\031Google\\Cloud\\OrgPolicy\\V2" + + "\352\002\034Google::Cloud::OrgPolicy::V2b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.AnnotationsProto.getDescriptor(), + com.google.api.ClientProto.getDescriptor(), + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.cloud.orgpolicy.v2.ConstraintProto.getDescriptor(), + com.google.protobuf.EmptyProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + com.google.type.ExprProto.getDescriptor(), + }); + internal_static_google_cloud_orgpolicy_v2_Policy_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_cloud_orgpolicy_v2_Policy_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_Policy_descriptor, + new java.lang.String[] { + "Name", "Spec", "Alternate", + }); + internal_static_google_cloud_orgpolicy_v2_AlternatePolicySpec_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_cloud_orgpolicy_v2_AlternatePolicySpec_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_AlternatePolicySpec_descriptor, + new java.lang.String[] { + "Launch", "Spec", + }); + internal_static_google_cloud_orgpolicy_v2_PolicySpec_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_cloud_orgpolicy_v2_PolicySpec_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_PolicySpec_descriptor, + new java.lang.String[] { + "Etag", "UpdateTime", "Rules", "InheritFromParent", "Reset", + }); + internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_descriptor = + internal_static_google_cloud_orgpolicy_v2_PolicySpec_descriptor.getNestedTypes().get(0); + internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_descriptor, + new java.lang.String[] { + "Values", "AllowAll", "DenyAll", "Enforce", "Condition", "Kind", + }); + internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_StringValues_descriptor = + internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_descriptor + .getNestedTypes() + .get(0); + internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_StringValues_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_StringValues_descriptor, + new java.lang.String[] { + "AllowedValues", "DeniedValues", + }); + internal_static_google_cloud_orgpolicy_v2_ListConstraintsRequest_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_google_cloud_orgpolicy_v2_ListConstraintsRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_ListConstraintsRequest_descriptor, + new java.lang.String[] { + "Parent", "PageSize", "PageToken", + }); + internal_static_google_cloud_orgpolicy_v2_ListConstraintsResponse_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_google_cloud_orgpolicy_v2_ListConstraintsResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_ListConstraintsResponse_descriptor, + new java.lang.String[] { + "Constraints", "NextPageToken", + }); + internal_static_google_cloud_orgpolicy_v2_ListPoliciesRequest_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_google_cloud_orgpolicy_v2_ListPoliciesRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_ListPoliciesRequest_descriptor, + new java.lang.String[] { + "Parent", "PageSize", "PageToken", + }); + internal_static_google_cloud_orgpolicy_v2_ListPoliciesResponse_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_google_cloud_orgpolicy_v2_ListPoliciesResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_ListPoliciesResponse_descriptor, + new java.lang.String[] { + "Policies", "NextPageToken", + }); + internal_static_google_cloud_orgpolicy_v2_GetPolicyRequest_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_google_cloud_orgpolicy_v2_GetPolicyRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_GetPolicyRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_cloud_orgpolicy_v2_GetEffectivePolicyRequest_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_google_cloud_orgpolicy_v2_GetEffectivePolicyRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_GetEffectivePolicyRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_cloud_orgpolicy_v2_CreatePolicyRequest_descriptor = + getDescriptor().getMessageTypes().get(9); + internal_static_google_cloud_orgpolicy_v2_CreatePolicyRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_CreatePolicyRequest_descriptor, + new java.lang.String[] { + "Parent", "Policy", + }); + internal_static_google_cloud_orgpolicy_v2_UpdatePolicyRequest_descriptor = + getDescriptor().getMessageTypes().get(10); + internal_static_google_cloud_orgpolicy_v2_UpdatePolicyRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_UpdatePolicyRequest_descriptor, + new java.lang.String[] { + "Policy", + }); + internal_static_google_cloud_orgpolicy_v2_DeletePolicyRequest_descriptor = + getDescriptor().getMessageTypes().get(11); + internal_static_google_cloud_orgpolicy_v2_DeletePolicyRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_cloud_orgpolicy_v2_DeletePolicyRequest_descriptor, + new java.lang.String[] { + "Name", + }); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.ClientProto.defaultHost); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.AnnotationsProto.http); + registry.add(com.google.api.ClientProto.methodSignature); + registry.add(com.google.api.ClientProto.oauthScopes); + registry.add(com.google.api.ResourceProto.resource); + registry.add(com.google.api.ResourceProto.resourceReference); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + com.google.api.AnnotationsProto.getDescriptor(); + com.google.api.ClientProto.getDescriptor(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.ResourceProto.getDescriptor(); + com.google.cloud.orgpolicy.v2.ConstraintProto.getDescriptor(); + com.google.protobuf.EmptyProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + com.google.type.ExprProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/OrganizationName.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/OrganizationName.java new file mode 100644 index 0000000..303c8c2 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/OrganizationName.java @@ -0,0 +1,168 @@ +/* + * 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. + */ + +package com.google.cloud.orgpolicy.v2; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class OrganizationName implements ResourceName { + private static final PathTemplate ORGANIZATION = + PathTemplate.createWithoutUrlEncoding("organizations/{organization}"); + private volatile Map fieldValuesMap; + private final String organization; + + @Deprecated + protected OrganizationName() { + organization = null; + } + + private OrganizationName(Builder builder) { + organization = Preconditions.checkNotNull(builder.getOrganization()); + } + + public String getOrganization() { + return organization; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static OrganizationName of(String organization) { + return newBuilder().setOrganization(organization).build(); + } + + public static String format(String organization) { + return newBuilder().setOrganization(organization).build().toString(); + } + + public static OrganizationName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + ORGANIZATION.validatedMatch( + formattedString, "OrganizationName.parse: formattedString not in valid format"); + return of(matchMap.get("organization")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (OrganizationName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return ORGANIZATION.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (organization != null) { + fieldMapBuilder.put("organization", organization); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return ORGANIZATION.instantiate("organization", organization); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + OrganizationName that = ((OrganizationName) o); + return Objects.equals(this.organization, that.organization); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(organization); + return h; + } + + /** Builder for organizations/{organization}. */ + public static class Builder { + private String organization; + + protected Builder() {} + + public String getOrganization() { + return organization; + } + + public Builder setOrganization(String organization) { + this.organization = organization; + return this; + } + + private Builder(OrganizationName organizationName) { + organization = organizationName.organization; + } + + public OrganizationName build() { + return new OrganizationName(this); + } + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/Policy.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/Policy.java new file mode 100644 index 0000000..80a409b --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/Policy.java @@ -0,0 +1,1286 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +/** + * + * + *
+ * Defines a Cloud Organization `Policy` which is used to specify `Constraints`
+ * for configurations of Cloud Platform resources.
+ * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.Policy} + */ +public final class Policy extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.Policy) + PolicyOrBuilder { + private static final long serialVersionUID = 0L; + // Use Policy.newBuilder() to construct. + private Policy(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Policy() { + name_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Policy(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private Policy( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 18: + { + com.google.cloud.orgpolicy.v2.PolicySpec.Builder subBuilder = null; + if (spec_ != null) { + subBuilder = spec_.toBuilder(); + } + spec_ = + input.readMessage( + com.google.cloud.orgpolicy.v2.PolicySpec.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(spec_); + spec_ = subBuilder.buildPartial(); + } + + break; + } + case 26: + { + com.google.cloud.orgpolicy.v2.AlternatePolicySpec.Builder subBuilder = null; + if (alternate_ != null) { + subBuilder = alternate_.toBuilder(); + } + alternate_ = + input.readMessage( + com.google.cloud.orgpolicy.v2.AlternatePolicySpec.parser(), + extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(alternate_); + alternate_ = subBuilder.buildPartial(); + } + + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_Policy_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_Policy_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.Policy.class, + com.google.cloud.orgpolicy.v2.Policy.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * + * + *
+   * Immutable. The resource name of the Policy. Must be one of the following
+   * forms, where constraint_name is the name of the constraint which this
+   * Policy configures:
+   * * `projects/{project_number}/policies/{constraint_name}`
+   * * `folders/{folder_id}/policies/{constraint_name}`
+   * * `organizations/{organization_id}/policies/{constraint_name}`
+   * For example, "projects/123/policies/compute.disableSerialPortAccess".
+   * Note: `projects/{project_id}/policies/{constraint_name}` is also an
+   * acceptable name for API requests, but responses will return the name using
+   * the equivalent project number.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + 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(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Immutable. The resource name of the Policy. Must be one of the following
+   * forms, where constraint_name is the name of the constraint which this
+   * Policy configures:
+   * * `projects/{project_number}/policies/{constraint_name}`
+   * * `folders/{folder_id}/policies/{constraint_name}`
+   * * `organizations/{organization_id}/policies/{constraint_name}`
+   * For example, "projects/123/policies/compute.disableSerialPortAccess".
+   * Note: `projects/{project_id}/policies/{constraint_name}` is also an
+   * acceptable name for API requests, but responses will return the name using
+   * the equivalent project number.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SPEC_FIELD_NUMBER = 2; + private com.google.cloud.orgpolicy.v2.PolicySpec spec_; + /** + * + * + *
+   * Basic information about the Organization Policy.
+   * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + * + * @return Whether the spec field is set. + */ + @java.lang.Override + public boolean hasSpec() { + return spec_ != null; + } + /** + * + * + *
+   * Basic information about the Organization Policy.
+   * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + * + * @return The spec. + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec getSpec() { + return spec_ == null ? com.google.cloud.orgpolicy.v2.PolicySpec.getDefaultInstance() : spec_; + } + /** + * + * + *
+   * Basic information about the Organization Policy.
+   * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpecOrBuilder getSpecOrBuilder() { + return getSpec(); + } + + public static final int ALTERNATE_FIELD_NUMBER = 3; + private com.google.cloud.orgpolicy.v2.AlternatePolicySpec alternate_; + /** + * + * + *
+   * An alternate policy configuration that will be used instead of the baseline
+   * policy configurations as determined by the launch.
+   * Currently the only way the launch can trigger the alternate configuration
+   * is via dry-run/darklaunch.
+   * 
+ * + * .google.cloud.orgpolicy.v2.AlternatePolicySpec alternate = 3; + * + * @return Whether the alternate field is set. + */ + @java.lang.Override + public boolean hasAlternate() { + return alternate_ != null; + } + /** + * + * + *
+   * An alternate policy configuration that will be used instead of the baseline
+   * policy configurations as determined by the launch.
+   * Currently the only way the launch can trigger the alternate configuration
+   * is via dry-run/darklaunch.
+   * 
+ * + * .google.cloud.orgpolicy.v2.AlternatePolicySpec alternate = 3; + * + * @return The alternate. + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.AlternatePolicySpec getAlternate() { + return alternate_ == null + ? com.google.cloud.orgpolicy.v2.AlternatePolicySpec.getDefaultInstance() + : alternate_; + } + /** + * + * + *
+   * An alternate policy configuration that will be used instead of the baseline
+   * policy configurations as determined by the launch.
+   * Currently the only way the launch can trigger the alternate configuration
+   * is via dry-run/darklaunch.
+   * 
+ * + * .google.cloud.orgpolicy.v2.AlternatePolicySpec alternate = 3; + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.AlternatePolicySpecOrBuilder getAlternateOrBuilder() { + return getAlternate(); + } + + 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 (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (spec_ != null) { + output.writeMessage(2, getSpec()); + } + if (alternate_ != null) { + output.writeMessage(3, getAlternate()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (spec_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getSpec()); + } + if (alternate_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getAlternate()); + } + size += unknownFields.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.cloud.orgpolicy.v2.Policy)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.Policy other = (com.google.cloud.orgpolicy.v2.Policy) obj; + + if (!getName().equals(other.getName())) return false; + if (hasSpec() != other.hasSpec()) return false; + if (hasSpec()) { + if (!getSpec().equals(other.getSpec())) return false; + } + if (hasAlternate() != other.hasAlternate()) return false; + if (hasAlternate()) { + if (!getAlternate().equals(other.getAlternate())) return false; + } + if (!unknownFields.equals(other.unknownFields)) 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) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (hasSpec()) { + hash = (37 * hash) + SPEC_FIELD_NUMBER; + hash = (53 * hash) + getSpec().hashCode(); + } + if (hasAlternate()) { + hash = (37 * hash) + ALTERNATE_FIELD_NUMBER; + hash = (53 * hash) + getAlternate().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.Policy parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.Policy parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.Policy parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.Policy 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.cloud.orgpolicy.v2.Policy parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.Policy parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.Policy parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.Policy 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.cloud.orgpolicy.v2.Policy parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.Policy 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.cloud.orgpolicy.v2.Policy parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.Policy 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.cloud.orgpolicy.v2.Policy 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 a Cloud Organization `Policy` which is used to specify `Constraints`
+   * for configurations of Cloud Platform resources.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.Policy} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.Policy) + com.google.cloud.orgpolicy.v2.PolicyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_Policy_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_Policy_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.Policy.class, + com.google.cloud.orgpolicy.v2.Policy.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.Policy.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + name_ = ""; + + if (specBuilder_ == null) { + spec_ = null; + } else { + spec_ = null; + specBuilder_ = null; + } + if (alternateBuilder_ == null) { + alternate_ = null; + } else { + alternate_ = null; + alternateBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_Policy_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Policy getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.Policy.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Policy build() { + com.google.cloud.orgpolicy.v2.Policy result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Policy buildPartial() { + com.google.cloud.orgpolicy.v2.Policy result = new com.google.cloud.orgpolicy.v2.Policy(this); + result.name_ = name_; + if (specBuilder_ == null) { + result.spec_ = spec_; + } else { + result.spec_ = specBuilder_.build(); + } + if (alternateBuilder_ == null) { + result.alternate_ = alternate_; + } else { + result.alternate_ = alternateBuilder_.build(); + } + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.Policy) { + return mergeFrom((com.google.cloud.orgpolicy.v2.Policy) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.Policy other) { + if (other == com.google.cloud.orgpolicy.v2.Policy.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (other.hasSpec()) { + mergeSpec(other.getSpec()); + } + if (other.hasAlternate()) { + mergeAlternate(other.getAlternate()); + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.Policy parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.cloud.orgpolicy.v2.Policy) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Immutable. The resource name of the Policy. Must be one of the following
+     * forms, where constraint_name is the name of the constraint which this
+     * Policy configures:
+     * * `projects/{project_number}/policies/{constraint_name}`
+     * * `folders/{folder_id}/policies/{constraint_name}`
+     * * `organizations/{organization_id}/policies/{constraint_name}`
+     * For example, "projects/123/policies/compute.disableSerialPortAccess".
+     * Note: `projects/{project_id}/policies/{constraint_name}` is also an
+     * acceptable name for API requests, but responses will return the name using
+     * the equivalent project number.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Immutable. The resource name of the Policy. Must be one of the following
+     * forms, where constraint_name is the name of the constraint which this
+     * Policy configures:
+     * * `projects/{project_number}/policies/{constraint_name}`
+     * * `folders/{folder_id}/policies/{constraint_name}`
+     * * `organizations/{organization_id}/policies/{constraint_name}`
+     * For example, "projects/123/policies/compute.disableSerialPortAccess".
+     * Note: `projects/{project_id}/policies/{constraint_name}` is also an
+     * acceptable name for API requests, but responses will return the name using
+     * the equivalent project number.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Immutable. The resource name of the Policy. Must be one of the following
+     * forms, where constraint_name is the name of the constraint which this
+     * Policy configures:
+     * * `projects/{project_number}/policies/{constraint_name}`
+     * * `folders/{folder_id}/policies/{constraint_name}`
+     * * `organizations/{organization_id}/policies/{constraint_name}`
+     * For example, "projects/123/policies/compute.disableSerialPortAccess".
+     * Note: `projects/{project_id}/policies/{constraint_name}` is also an
+     * acceptable name for API requests, but responses will return the name using
+     * the equivalent project number.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Immutable. The resource name of the Policy. Must be one of the following
+     * forms, where constraint_name is the name of the constraint which this
+     * Policy configures:
+     * * `projects/{project_number}/policies/{constraint_name}`
+     * * `folders/{folder_id}/policies/{constraint_name}`
+     * * `organizations/{organization_id}/policies/{constraint_name}`
+     * For example, "projects/123/policies/compute.disableSerialPortAccess".
+     * Note: `projects/{project_id}/policies/{constraint_name}` is also an
+     * acceptable name for API requests, but responses will return the name using
+     * the equivalent project number.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @return This builder for chaining. + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * + * + *
+     * Immutable. The resource name of the Policy. Must be one of the following
+     * forms, where constraint_name is the name of the constraint which this
+     * Policy configures:
+     * * `projects/{project_number}/policies/{constraint_name}`
+     * * `folders/{folder_id}/policies/{constraint_name}`
+     * * `organizations/{organization_id}/policies/{constraint_name}`
+     * For example, "projects/123/policies/compute.disableSerialPortAccess".
+     * Note: `projects/{project_id}/policies/{constraint_name}` is also an
+     * acceptable name for API requests, but responses will return the name using
+     * the equivalent project number.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private com.google.cloud.orgpolicy.v2.PolicySpec spec_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.PolicySpec, + com.google.cloud.orgpolicy.v2.PolicySpec.Builder, + com.google.cloud.orgpolicy.v2.PolicySpecOrBuilder> + specBuilder_; + /** + * + * + *
+     * Basic information about the Organization Policy.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + * + * @return Whether the spec field is set. + */ + public boolean hasSpec() { + return specBuilder_ != null || spec_ != null; + } + /** + * + * + *
+     * Basic information about the Organization Policy.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + * + * @return The spec. + */ + public com.google.cloud.orgpolicy.v2.PolicySpec getSpec() { + if (specBuilder_ == null) { + return spec_ == null + ? com.google.cloud.orgpolicy.v2.PolicySpec.getDefaultInstance() + : spec_; + } else { + return specBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Basic information about the Organization Policy.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + public Builder setSpec(com.google.cloud.orgpolicy.v2.PolicySpec value) { + if (specBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + spec_ = value; + onChanged(); + } else { + specBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Basic information about the Organization Policy.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + public Builder setSpec(com.google.cloud.orgpolicy.v2.PolicySpec.Builder builderForValue) { + if (specBuilder_ == null) { + spec_ = builderForValue.build(); + onChanged(); + } else { + specBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Basic information about the Organization Policy.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + public Builder mergeSpec(com.google.cloud.orgpolicy.v2.PolicySpec value) { + if (specBuilder_ == null) { + if (spec_ != null) { + spec_ = + com.google.cloud.orgpolicy.v2.PolicySpec.newBuilder(spec_) + .mergeFrom(value) + .buildPartial(); + } else { + spec_ = value; + } + onChanged(); + } else { + specBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Basic information about the Organization Policy.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + public Builder clearSpec() { + if (specBuilder_ == null) { + spec_ = null; + onChanged(); + } else { + spec_ = null; + specBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Basic information about the Organization Policy.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + public com.google.cloud.orgpolicy.v2.PolicySpec.Builder getSpecBuilder() { + + onChanged(); + return getSpecFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Basic information about the Organization Policy.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + public com.google.cloud.orgpolicy.v2.PolicySpecOrBuilder getSpecOrBuilder() { + if (specBuilder_ != null) { + return specBuilder_.getMessageOrBuilder(); + } else { + return spec_ == null + ? com.google.cloud.orgpolicy.v2.PolicySpec.getDefaultInstance() + : spec_; + } + } + /** + * + * + *
+     * Basic information about the Organization Policy.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.PolicySpec, + com.google.cloud.orgpolicy.v2.PolicySpec.Builder, + com.google.cloud.orgpolicy.v2.PolicySpecOrBuilder> + getSpecFieldBuilder() { + if (specBuilder_ == null) { + specBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.PolicySpec, + com.google.cloud.orgpolicy.v2.PolicySpec.Builder, + com.google.cloud.orgpolicy.v2.PolicySpecOrBuilder>( + getSpec(), getParentForChildren(), isClean()); + spec_ = null; + } + return specBuilder_; + } + + private com.google.cloud.orgpolicy.v2.AlternatePolicySpec alternate_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.AlternatePolicySpec, + com.google.cloud.orgpolicy.v2.AlternatePolicySpec.Builder, + com.google.cloud.orgpolicy.v2.AlternatePolicySpecOrBuilder> + alternateBuilder_; + /** + * + * + *
+     * An alternate policy configuration that will be used instead of the baseline
+     * policy configurations as determined by the launch.
+     * Currently the only way the launch can trigger the alternate configuration
+     * is via dry-run/darklaunch.
+     * 
+ * + * .google.cloud.orgpolicy.v2.AlternatePolicySpec alternate = 3; + * + * @return Whether the alternate field is set. + */ + public boolean hasAlternate() { + return alternateBuilder_ != null || alternate_ != null; + } + /** + * + * + *
+     * An alternate policy configuration that will be used instead of the baseline
+     * policy configurations as determined by the launch.
+     * Currently the only way the launch can trigger the alternate configuration
+     * is via dry-run/darklaunch.
+     * 
+ * + * .google.cloud.orgpolicy.v2.AlternatePolicySpec alternate = 3; + * + * @return The alternate. + */ + public com.google.cloud.orgpolicy.v2.AlternatePolicySpec getAlternate() { + if (alternateBuilder_ == null) { + return alternate_ == null + ? com.google.cloud.orgpolicy.v2.AlternatePolicySpec.getDefaultInstance() + : alternate_; + } else { + return alternateBuilder_.getMessage(); + } + } + /** + * + * + *
+     * An alternate policy configuration that will be used instead of the baseline
+     * policy configurations as determined by the launch.
+     * Currently the only way the launch can trigger the alternate configuration
+     * is via dry-run/darklaunch.
+     * 
+ * + * .google.cloud.orgpolicy.v2.AlternatePolicySpec alternate = 3; + */ + public Builder setAlternate(com.google.cloud.orgpolicy.v2.AlternatePolicySpec value) { + if (alternateBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + alternate_ = value; + onChanged(); + } else { + alternateBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * An alternate policy configuration that will be used instead of the baseline
+     * policy configurations as determined by the launch.
+     * Currently the only way the launch can trigger the alternate configuration
+     * is via dry-run/darklaunch.
+     * 
+ * + * .google.cloud.orgpolicy.v2.AlternatePolicySpec alternate = 3; + */ + public Builder setAlternate( + com.google.cloud.orgpolicy.v2.AlternatePolicySpec.Builder builderForValue) { + if (alternateBuilder_ == null) { + alternate_ = builderForValue.build(); + onChanged(); + } else { + alternateBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * An alternate policy configuration that will be used instead of the baseline
+     * policy configurations as determined by the launch.
+     * Currently the only way the launch can trigger the alternate configuration
+     * is via dry-run/darklaunch.
+     * 
+ * + * .google.cloud.orgpolicy.v2.AlternatePolicySpec alternate = 3; + */ + public Builder mergeAlternate(com.google.cloud.orgpolicy.v2.AlternatePolicySpec value) { + if (alternateBuilder_ == null) { + if (alternate_ != null) { + alternate_ = + com.google.cloud.orgpolicy.v2.AlternatePolicySpec.newBuilder(alternate_) + .mergeFrom(value) + .buildPartial(); + } else { + alternate_ = value; + } + onChanged(); + } else { + alternateBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * An alternate policy configuration that will be used instead of the baseline
+     * policy configurations as determined by the launch.
+     * Currently the only way the launch can trigger the alternate configuration
+     * is via dry-run/darklaunch.
+     * 
+ * + * .google.cloud.orgpolicy.v2.AlternatePolicySpec alternate = 3; + */ + public Builder clearAlternate() { + if (alternateBuilder_ == null) { + alternate_ = null; + onChanged(); + } else { + alternate_ = null; + alternateBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * An alternate policy configuration that will be used instead of the baseline
+     * policy configurations as determined by the launch.
+     * Currently the only way the launch can trigger the alternate configuration
+     * is via dry-run/darklaunch.
+     * 
+ * + * .google.cloud.orgpolicy.v2.AlternatePolicySpec alternate = 3; + */ + public com.google.cloud.orgpolicy.v2.AlternatePolicySpec.Builder getAlternateBuilder() { + + onChanged(); + return getAlternateFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * An alternate policy configuration that will be used instead of the baseline
+     * policy configurations as determined by the launch.
+     * Currently the only way the launch can trigger the alternate configuration
+     * is via dry-run/darklaunch.
+     * 
+ * + * .google.cloud.orgpolicy.v2.AlternatePolicySpec alternate = 3; + */ + public com.google.cloud.orgpolicy.v2.AlternatePolicySpecOrBuilder getAlternateOrBuilder() { + if (alternateBuilder_ != null) { + return alternateBuilder_.getMessageOrBuilder(); + } else { + return alternate_ == null + ? com.google.cloud.orgpolicy.v2.AlternatePolicySpec.getDefaultInstance() + : alternate_; + } + } + /** + * + * + *
+     * An alternate policy configuration that will be used instead of the baseline
+     * policy configurations as determined by the launch.
+     * Currently the only way the launch can trigger the alternate configuration
+     * is via dry-run/darklaunch.
+     * 
+ * + * .google.cloud.orgpolicy.v2.AlternatePolicySpec alternate = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.AlternatePolicySpec, + com.google.cloud.orgpolicy.v2.AlternatePolicySpec.Builder, + com.google.cloud.orgpolicy.v2.AlternatePolicySpecOrBuilder> + getAlternateFieldBuilder() { + if (alternateBuilder_ == null) { + alternateBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.AlternatePolicySpec, + com.google.cloud.orgpolicy.v2.AlternatePolicySpec.Builder, + com.google.cloud.orgpolicy.v2.AlternatePolicySpecOrBuilder>( + getAlternate(), getParentForChildren(), isClean()); + alternate_ = null; + } + return alternateBuilder_; + } + + @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.cloud.orgpolicy.v2.Policy) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.Policy) + private static final com.google.cloud.orgpolicy.v2.Policy DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.Policy(); + } + + public static com.google.cloud.orgpolicy.v2.Policy getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Policy parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Policy(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.Policy getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/PolicyName.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/PolicyName.java new file mode 100644 index 0000000..c0f1ec0 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/PolicyName.java @@ -0,0 +1,368 @@ +/* + * 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. + */ + +package com.google.cloud.orgpolicy.v2; + +import com.google.api.core.BetaApi; +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.pathtemplate.ValidationException; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class PolicyName implements ResourceName { + private static final PathTemplate PROJECT_POLICY = + PathTemplate.createWithoutUrlEncoding("projects/{project}/policies/{policy}"); + private static final PathTemplate FOLDER_POLICY = + PathTemplate.createWithoutUrlEncoding("folders/{folder}/policies/{policy}"); + private static final PathTemplate ORGANIZATION_POLICY = + PathTemplate.createWithoutUrlEncoding("organizations/{organization}/policies/{policy}"); + private volatile Map fieldValuesMap; + private PathTemplate pathTemplate; + private String fixedValue; + private final String project; + private final String policy; + private final String folder; + private final String organization; + + @Deprecated + protected PolicyName() { + project = null; + policy = null; + folder = null; + organization = null; + } + + private PolicyName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + policy = Preconditions.checkNotNull(builder.getPolicy()); + folder = null; + organization = null; + pathTemplate = PROJECT_POLICY; + } + + private PolicyName(FolderPolicyBuilder builder) { + folder = Preconditions.checkNotNull(builder.getFolder()); + policy = Preconditions.checkNotNull(builder.getPolicy()); + project = null; + organization = null; + pathTemplate = FOLDER_POLICY; + } + + private PolicyName(OrganizationPolicyBuilder builder) { + organization = Preconditions.checkNotNull(builder.getOrganization()); + policy = Preconditions.checkNotNull(builder.getPolicy()); + project = null; + folder = null; + pathTemplate = ORGANIZATION_POLICY; + } + + public String getProject() { + return project; + } + + public String getPolicy() { + return policy; + } + + public String getFolder() { + return folder; + } + + public String getOrganization() { + return organization; + } + + public static Builder newBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static Builder newProjectPolicyBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static FolderPolicyBuilder newFolderPolicyBuilder() { + return new FolderPolicyBuilder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static OrganizationPolicyBuilder newOrganizationPolicyBuilder() { + return new OrganizationPolicyBuilder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static PolicyName of(String project, String policy) { + return newBuilder().setProject(project).setPolicy(policy).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static PolicyName ofProjectPolicyName(String project, String policy) { + return newBuilder().setProject(project).setPolicy(policy).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static PolicyName ofFolderPolicyName(String folder, String policy) { + return newFolderPolicyBuilder().setFolder(folder).setPolicy(policy).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static PolicyName ofOrganizationPolicyName(String organization, String policy) { + return newOrganizationPolicyBuilder().setOrganization(organization).setPolicy(policy).build(); + } + + public static String format(String project, String policy) { + return newBuilder().setProject(project).setPolicy(policy).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatProjectPolicyName(String project, String policy) { + return newBuilder().setProject(project).setPolicy(policy).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatFolderPolicyName(String folder, String policy) { + return newFolderPolicyBuilder().setFolder(folder).setPolicy(policy).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatOrganizationPolicyName(String organization, String policy) { + return newOrganizationPolicyBuilder() + .setOrganization(organization) + .setPolicy(policy) + .build() + .toString(); + } + + public static PolicyName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + if (PROJECT_POLICY.matches(formattedString)) { + Map matchMap = PROJECT_POLICY.match(formattedString); + return ofProjectPolicyName(matchMap.get("project"), matchMap.get("policy")); + } else if (FOLDER_POLICY.matches(formattedString)) { + Map matchMap = FOLDER_POLICY.match(formattedString); + return ofFolderPolicyName(matchMap.get("folder"), matchMap.get("policy")); + } else if (ORGANIZATION_POLICY.matches(formattedString)) { + Map matchMap = ORGANIZATION_POLICY.match(formattedString); + return ofOrganizationPolicyName(matchMap.get("organization"), matchMap.get("policy")); + } + throw new ValidationException("PolicyName.parse: formattedString not in valid format"); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (PolicyName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_POLICY.matches(formattedString) + || FOLDER_POLICY.matches(formattedString) + || ORGANIZATION_POLICY.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (policy != null) { + fieldMapBuilder.put("policy", policy); + } + if (folder != null) { + fieldMapBuilder.put("folder", folder); + } + if (organization != null) { + fieldMapBuilder.put("organization", organization); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + PolicyName that = ((PolicyName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.policy, that.policy) + && Objects.equals(this.folder, that.folder) + && Objects.equals(this.organization, that.organization); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(policy); + h *= 1000003; + h ^= Objects.hashCode(folder); + h *= 1000003; + h ^= Objects.hashCode(organization); + return h; + } + + /** Builder for projects/{project}/policies/{policy}. */ + public static class Builder { + private String project; + private String policy; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getPolicy() { + return policy; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setPolicy(String policy) { + this.policy = policy; + return this; + } + + private Builder(PolicyName policyName) { + Preconditions.checkArgument( + Objects.equals(policyName.pathTemplate, PROJECT_POLICY), + "toBuilder is only supported when PolicyName has the pattern of projects/{project}/policies/{policy}"); + project = policyName.project; + policy = policyName.policy; + } + + public PolicyName build() { + return new PolicyName(this); + } + } + + /** Builder for folders/{folder}/policies/{policy}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class FolderPolicyBuilder { + private String folder; + private String policy; + + protected FolderPolicyBuilder() {} + + public String getFolder() { + return folder; + } + + public String getPolicy() { + return policy; + } + + public FolderPolicyBuilder setFolder(String folder) { + this.folder = folder; + return this; + } + + public FolderPolicyBuilder setPolicy(String policy) { + this.policy = policy; + return this; + } + + public PolicyName build() { + return new PolicyName(this); + } + } + + /** Builder for organizations/{organization}/policies/{policy}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class OrganizationPolicyBuilder { + private String organization; + private String policy; + + protected OrganizationPolicyBuilder() {} + + public String getOrganization() { + return organization; + } + + public String getPolicy() { + return policy; + } + + public OrganizationPolicyBuilder setOrganization(String organization) { + this.organization = organization; + return this; + } + + public OrganizationPolicyBuilder setPolicy(String policy) { + this.policy = policy; + return this; + } + + public PolicyName build() { + return new PolicyName(this); + } + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/PolicyOrBuilder.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/PolicyOrBuilder.java new file mode 100644 index 0000000..b89333d --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/PolicyOrBuilder.java @@ -0,0 +1,147 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +public interface PolicyOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.Policy) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Immutable. The resource name of the Policy. Must be one of the following
+   * forms, where constraint_name is the name of the constraint which this
+   * Policy configures:
+   * * `projects/{project_number}/policies/{constraint_name}`
+   * * `folders/{folder_id}/policies/{constraint_name}`
+   * * `organizations/{organization_id}/policies/{constraint_name}`
+   * For example, "projects/123/policies/compute.disableSerialPortAccess".
+   * Note: `projects/{project_id}/policies/{constraint_name}` is also an
+   * acceptable name for API requests, but responses will return the name using
+   * the equivalent project number.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Immutable. The resource name of the Policy. Must be one of the following
+   * forms, where constraint_name is the name of the constraint which this
+   * Policy configures:
+   * * `projects/{project_number}/policies/{constraint_name}`
+   * * `folders/{folder_id}/policies/{constraint_name}`
+   * * `organizations/{organization_id}/policies/{constraint_name}`
+   * For example, "projects/123/policies/compute.disableSerialPortAccess".
+   * Note: `projects/{project_id}/policies/{constraint_name}` is also an
+   * acceptable name for API requests, but responses will return the name using
+   * the equivalent project number.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IMMUTABLE]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Basic information about the Organization Policy.
+   * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + * + * @return Whether the spec field is set. + */ + boolean hasSpec(); + /** + * + * + *
+   * Basic information about the Organization Policy.
+   * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + * + * @return The spec. + */ + com.google.cloud.orgpolicy.v2.PolicySpec getSpec(); + /** + * + * + *
+   * Basic information about the Organization Policy.
+   * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec spec = 2; + */ + com.google.cloud.orgpolicy.v2.PolicySpecOrBuilder getSpecOrBuilder(); + + /** + * + * + *
+   * An alternate policy configuration that will be used instead of the baseline
+   * policy configurations as determined by the launch.
+   * Currently the only way the launch can trigger the alternate configuration
+   * is via dry-run/darklaunch.
+   * 
+ * + * .google.cloud.orgpolicy.v2.AlternatePolicySpec alternate = 3; + * + * @return Whether the alternate field is set. + */ + boolean hasAlternate(); + /** + * + * + *
+   * An alternate policy configuration that will be used instead of the baseline
+   * policy configurations as determined by the launch.
+   * Currently the only way the launch can trigger the alternate configuration
+   * is via dry-run/darklaunch.
+   * 
+ * + * .google.cloud.orgpolicy.v2.AlternatePolicySpec alternate = 3; + * + * @return The alternate. + */ + com.google.cloud.orgpolicy.v2.AlternatePolicySpec getAlternate(); + /** + * + * + *
+   * An alternate policy configuration that will be used instead of the baseline
+   * policy configurations as determined by the launch.
+   * Currently the only way the launch can trigger the alternate configuration
+   * is via dry-run/darklaunch.
+   * 
+ * + * .google.cloud.orgpolicy.v2.AlternatePolicySpec alternate = 3; + */ + com.google.cloud.orgpolicy.v2.AlternatePolicySpecOrBuilder getAlternateOrBuilder(); +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/PolicySpec.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/PolicySpec.java new file mode 100644 index 0000000..93b9fc1 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/PolicySpec.java @@ -0,0 +1,4700 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +/** + * + * + *
+ * Defines a Cloud Organization `PolicySpec` which is used to specify
+ * `Constraints` for configurations of Cloud Platform resources.
+ * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.PolicySpec} + */ +public final class PolicySpec extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.PolicySpec) + PolicySpecOrBuilder { + private static final long serialVersionUID = 0L; + // Use PolicySpec.newBuilder() to construct. + private PolicySpec(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PolicySpec() { + etag_ = ""; + rules_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PolicySpec(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private PolicySpec( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + + etag_ = s; + break; + } + case 18: + { + com.google.protobuf.Timestamp.Builder subBuilder = null; + if (updateTime_ != null) { + subBuilder = updateTime_.toBuilder(); + } + updateTime_ = + input.readMessage(com.google.protobuf.Timestamp.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(updateTime_); + updateTime_ = subBuilder.buildPartial(); + } + + break; + } + case 26: + { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + rules_ = + new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + rules_.add( + input.readMessage( + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.parser(), + extensionRegistry)); + break; + } + case 32: + { + inheritFromParent_ = input.readBool(); + break; + } + case 40: + { + reset_ = input.readBool(); + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + rules_ = java.util.Collections.unmodifiableList(rules_); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_PolicySpec_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_PolicySpec_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.PolicySpec.class, + com.google.cloud.orgpolicy.v2.PolicySpec.Builder.class); + } + + public interface PolicyRuleOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.PolicySpec.PolicyRule) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * List of values to be used for this PolicyRule. This field can be set
+     * only in Policies for list constraints.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues values = 1; + * + * @return Whether the values field is set. + */ + boolean hasValues(); + /** + * + * + *
+     * List of values to be used for this PolicyRule. This field can be set
+     * only in Policies for list constraints.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues values = 1; + * + * @return The values. + */ + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues getValues(); + /** + * + * + *
+     * List of values to be used for this PolicyRule. This field can be set
+     * only in Policies for list constraints.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues values = 1; + */ + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValuesOrBuilder getValuesOrBuilder(); + + /** + * + * + *
+     * Setting this to true means that all values are allowed. This field can
+     * be set only in Policies for list constraints.
+     * 
+ * + * bool allow_all = 2; + * + * @return The allowAll. + */ + boolean getAllowAll(); + + /** + * + * + *
+     * Setting this to true means that all values are denied. This field can
+     * be set only in Policies for list constraints.
+     * 
+ * + * bool deny_all = 3; + * + * @return The denyAll. + */ + boolean getDenyAll(); + + /** + * + * + *
+     * If `true`, then the `Policy` is enforced. If `false`, then any
+     * configuration is acceptable.
+     * This field can be set only in Policies for boolean constraints.
+     * 
+ * + * bool enforce = 4; + * + * @return The enforce. + */ + boolean getEnforce(); + + /** + * + * + *
+     * A condition which determines whether this rule is used
+     * in the evaluation of the policy. When set, the `expression` field in
+     * the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
+     * or "&&" operators. Each subexpression must be of the form
+     * "resource.matchLabels(key_name, value_name)",
+     * where key_name and value_name are the resource names for Label Keys
+     * and Values. These names are available from the Label Manager Service. An
+     * example expression is:
+     * "resource.matchLabels('labelKeys/123, 'labelValues/456')".
+     * 
+ * + * .google.type.Expr condition = 5; + * + * @return Whether the condition field is set. + */ + boolean hasCondition(); + /** + * + * + *
+     * A condition which determines whether this rule is used
+     * in the evaluation of the policy. When set, the `expression` field in
+     * the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
+     * or "&&" operators. Each subexpression must be of the form
+     * "resource.matchLabels(key_name, value_name)",
+     * where key_name and value_name are the resource names for Label Keys
+     * and Values. These names are available from the Label Manager Service. An
+     * example expression is:
+     * "resource.matchLabels('labelKeys/123, 'labelValues/456')".
+     * 
+ * + * .google.type.Expr condition = 5; + * + * @return The condition. + */ + com.google.type.Expr getCondition(); + /** + * + * + *
+     * A condition which determines whether this rule is used
+     * in the evaluation of the policy. When set, the `expression` field in
+     * the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
+     * or "&&" operators. Each subexpression must be of the form
+     * "resource.matchLabels(key_name, value_name)",
+     * where key_name and value_name are the resource names for Label Keys
+     * and Values. These names are available from the Label Manager Service. An
+     * example expression is:
+     * "resource.matchLabels('labelKeys/123, 'labelValues/456')".
+     * 
+ * + * .google.type.Expr condition = 5; + */ + com.google.type.ExprOrBuilder getConditionOrBuilder(); + + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.KindCase getKindCase(); + } + /** + * + * + *
+   * A rule used to express this policy.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.PolicySpec.PolicyRule} + */ + public static final class PolicyRule extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.PolicySpec.PolicyRule) + PolicyRuleOrBuilder { + private static final long serialVersionUID = 0L; + // Use PolicyRule.newBuilder() to construct. + private PolicyRule(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PolicyRule() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PolicyRule(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private PolicyRule( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues.Builder + subBuilder = null; + if (kindCase_ == 1) { + subBuilder = + ((com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) kind_) + .toBuilder(); + } + kind_ = + input.readMessage( + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues.parser(), + extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom( + (com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) kind_); + kind_ = subBuilder.buildPartial(); + } + kindCase_ = 1; + break; + } + case 16: + { + kindCase_ = 2; + kind_ = input.readBool(); + break; + } + case 24: + { + kindCase_ = 3; + kind_ = input.readBool(); + break; + } + case 32: + { + kindCase_ = 4; + kind_ = input.readBool(); + break; + } + case 42: + { + com.google.type.Expr.Builder subBuilder = null; + if (condition_ != null) { + subBuilder = condition_.toBuilder(); + } + condition_ = input.readMessage(com.google.type.Expr.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(condition_); + condition_ = subBuilder.buildPartial(); + } + + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.class, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.Builder.class); + } + + public interface StringValuesOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+       * List of values allowed at this resource.
+       * 
+ * + * repeated string allowed_values = 1; + * + * @return A list containing the allowedValues. + */ + java.util.List getAllowedValuesList(); + /** + * + * + *
+       * List of values allowed at this resource.
+       * 
+ * + * repeated string allowed_values = 1; + * + * @return The count of allowedValues. + */ + int getAllowedValuesCount(); + /** + * + * + *
+       * List of values allowed at this resource.
+       * 
+ * + * repeated string allowed_values = 1; + * + * @param index The index of the element to return. + * @return The allowedValues at the given index. + */ + java.lang.String getAllowedValues(int index); + /** + * + * + *
+       * List of values allowed at this resource.
+       * 
+ * + * repeated string allowed_values = 1; + * + * @param index The index of the value to return. + * @return The bytes of the allowedValues at the given index. + */ + com.google.protobuf.ByteString getAllowedValuesBytes(int index); + + /** + * + * + *
+       * List of values denied at this resource.
+       * 
+ * + * repeated string denied_values = 2; + * + * @return A list containing the deniedValues. + */ + java.util.List getDeniedValuesList(); + /** + * + * + *
+       * List of values denied at this resource.
+       * 
+ * + * repeated string denied_values = 2; + * + * @return The count of deniedValues. + */ + int getDeniedValuesCount(); + /** + * + * + *
+       * List of values denied at this resource.
+       * 
+ * + * repeated string denied_values = 2; + * + * @param index The index of the element to return. + * @return The deniedValues at the given index. + */ + java.lang.String getDeniedValues(int index); + /** + * + * + *
+       * List of values denied at this resource.
+       * 
+ * + * repeated string denied_values = 2; + * + * @param index The index of the value to return. + * @return The bytes of the deniedValues at the given index. + */ + com.google.protobuf.ByteString getDeniedValuesBytes(int index); + } + /** + * + * + *
+     * A message that holds specific allowed and denied values.
+     * This message can define specific values and subtrees of Cloud Resource
+     * Manager resource hierarchy (`Organizations`, `Folders`, `Projects`) that
+     * are allowed or denied. This is achieved by using the `under:` and
+     * optional `is:` prefixes.
+     * The `under:` prefix is used to denote resource subtree values.
+     * The `is:` prefix is used to denote specific values, and is required only
+     * if the value contains a ":". Values prefixed with "is:" are treated the
+     * same as values with no prefix.
+     * Ancestry subtrees must be in one of the following formats:
+     *     - "projects/<project-id>", e.g. "projects/tokyo-rain-123"
+     *     - "folders/<folder-id>", e.g. "folders/1234"
+     *     - "organizations/<organization-id>", e.g. "organizations/1234"
+     * The `supports_under` field of the associated `Constraint`  defines
+     * whether ancestry prefixes can be used.
+     * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues} + */ + public static final class StringValues extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) + StringValuesOrBuilder { + private static final long serialVersionUID = 0L; + // Use StringValues.newBuilder() to construct. + private StringValues(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private StringValues() { + allowedValues_ = com.google.protobuf.LazyStringArrayList.EMPTY; + deniedValues_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new StringValues(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private StringValues( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + allowedValues_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + allowedValues_.add(s); + break; + } + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000002) != 0)) { + deniedValues_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000002; + } + deniedValues_.add(s); + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + allowedValues_ = allowedValues_.getUnmodifiableView(); + } + if (((mutable_bitField0_ & 0x00000002) != 0)) { + deniedValues_ = deniedValues_.getUnmodifiableView(); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_StringValues_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_StringValues_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues.class, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues.Builder.class); + } + + public static final int ALLOWED_VALUES_FIELD_NUMBER = 1; + private com.google.protobuf.LazyStringList allowedValues_; + /** + * + * + *
+       * List of values allowed at this resource.
+       * 
+ * + * repeated string allowed_values = 1; + * + * @return A list containing the allowedValues. + */ + public com.google.protobuf.ProtocolStringList getAllowedValuesList() { + return allowedValues_; + } + /** + * + * + *
+       * List of values allowed at this resource.
+       * 
+ * + * repeated string allowed_values = 1; + * + * @return The count of allowedValues. + */ + public int getAllowedValuesCount() { + return allowedValues_.size(); + } + /** + * + * + *
+       * List of values allowed at this resource.
+       * 
+ * + * repeated string allowed_values = 1; + * + * @param index The index of the element to return. + * @return The allowedValues at the given index. + */ + public java.lang.String getAllowedValues(int index) { + return allowedValues_.get(index); + } + /** + * + * + *
+       * List of values allowed at this resource.
+       * 
+ * + * repeated string allowed_values = 1; + * + * @param index The index of the value to return. + * @return The bytes of the allowedValues at the given index. + */ + public com.google.protobuf.ByteString getAllowedValuesBytes(int index) { + return allowedValues_.getByteString(index); + } + + public static final int DENIED_VALUES_FIELD_NUMBER = 2; + private com.google.protobuf.LazyStringList deniedValues_; + /** + * + * + *
+       * List of values denied at this resource.
+       * 
+ * + * repeated string denied_values = 2; + * + * @return A list containing the deniedValues. + */ + public com.google.protobuf.ProtocolStringList getDeniedValuesList() { + return deniedValues_; + } + /** + * + * + *
+       * List of values denied at this resource.
+       * 
+ * + * repeated string denied_values = 2; + * + * @return The count of deniedValues. + */ + public int getDeniedValuesCount() { + return deniedValues_.size(); + } + /** + * + * + *
+       * List of values denied at this resource.
+       * 
+ * + * repeated string denied_values = 2; + * + * @param index The index of the element to return. + * @return The deniedValues at the given index. + */ + public java.lang.String getDeniedValues(int index) { + return deniedValues_.get(index); + } + /** + * + * + *
+       * List of values denied at this resource.
+       * 
+ * + * repeated string denied_values = 2; + * + * @param index The index of the value to return. + * @return The bytes of the deniedValues at the given index. + */ + public com.google.protobuf.ByteString getDeniedValuesBytes(int index) { + return deniedValues_.getByteString(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 < allowedValues_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, allowedValues_.getRaw(i)); + } + for (int i = 0; i < deniedValues_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, deniedValues_.getRaw(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < allowedValues_.size(); i++) { + dataSize += computeStringSizeNoTag(allowedValues_.getRaw(i)); + } + size += dataSize; + size += 1 * getAllowedValuesList().size(); + } + { + int dataSize = 0; + for (int i = 0; i < deniedValues_.size(); i++) { + dataSize += computeStringSizeNoTag(deniedValues_.getRaw(i)); + } + size += dataSize; + size += 1 * getDeniedValuesList().size(); + } + size += unknownFields.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.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues other = + (com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) obj; + + if (!getAllowedValuesList().equals(other.getAllowedValuesList())) return false; + if (!getDeniedValuesList().equals(other.getDeniedValuesList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getAllowedValuesCount() > 0) { + hash = (37 * hash) + ALLOWED_VALUES_FIELD_NUMBER; + hash = (53 * hash) + getAllowedValuesList().hashCode(); + } + if (getDeniedValuesCount() > 0) { + hash = (37 * hash) + DENIED_VALUES_FIELD_NUMBER; + hash = (53 * hash) + getDeniedValuesList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues 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.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues 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.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues + 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.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues 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.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues 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; + } + /** + * + * + *
+       * A message that holds specific allowed and denied values.
+       * This message can define specific values and subtrees of Cloud Resource
+       * Manager resource hierarchy (`Organizations`, `Folders`, `Projects`) that
+       * are allowed or denied. This is achieved by using the `under:` and
+       * optional `is:` prefixes.
+       * The `under:` prefix is used to denote resource subtree values.
+       * The `is:` prefix is used to denote specific values, and is required only
+       * if the value contains a ":". Values prefixed with "is:" are treated the
+       * same as values with no prefix.
+       * Ancestry subtrees must be in one of the following formats:
+       *     - "projects/<project-id>", e.g. "projects/tokyo-rain-123"
+       *     - "folders/<folder-id>", e.g. "folders/1234"
+       *     - "organizations/<organization-id>", e.g. "organizations/1234"
+       * The `supports_under` field of the associated `Constraint`  defines
+       * whether ancestry prefixes can be used.
+       * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValuesOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_StringValues_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_StringValues_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues.class, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues.Builder.class); + } + + // Construct using + // com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + allowedValues_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + deniedValues_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_StringValues_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues + getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues build() { + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues buildPartial() { + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues result = + new com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues(this); + int from_bitField0_ = bitField0_; + if (((bitField0_ & 0x00000001) != 0)) { + allowedValues_ = allowedValues_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.allowedValues_ = allowedValues_; + if (((bitField0_ & 0x00000002) != 0)) { + deniedValues_ = deniedValues_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.deniedValues_ = deniedValues_; + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) { + return mergeFrom( + (com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues other) { + if (other + == com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues + .getDefaultInstance()) return this; + if (!other.allowedValues_.isEmpty()) { + if (allowedValues_.isEmpty()) { + allowedValues_ = other.allowedValues_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureAllowedValuesIsMutable(); + allowedValues_.addAll(other.allowedValues_); + } + onChanged(); + } + if (!other.deniedValues_.isEmpty()) { + if (deniedValues_.isEmpty()) { + deniedValues_ = other.deniedValues_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureDeniedValuesIsMutable(); + deniedValues_.addAll(other.deniedValues_); + } + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) + e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private com.google.protobuf.LazyStringList allowedValues_ = + com.google.protobuf.LazyStringArrayList.EMPTY; + + private void ensureAllowedValuesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + allowedValues_ = new com.google.protobuf.LazyStringArrayList(allowedValues_); + bitField0_ |= 0x00000001; + } + } + /** + * + * + *
+         * List of values allowed at this resource.
+         * 
+ * + * repeated string allowed_values = 1; + * + * @return A list containing the allowedValues. + */ + public com.google.protobuf.ProtocolStringList getAllowedValuesList() { + return allowedValues_.getUnmodifiableView(); + } + /** + * + * + *
+         * List of values allowed at this resource.
+         * 
+ * + * repeated string allowed_values = 1; + * + * @return The count of allowedValues. + */ + public int getAllowedValuesCount() { + return allowedValues_.size(); + } + /** + * + * + *
+         * List of values allowed at this resource.
+         * 
+ * + * repeated string allowed_values = 1; + * + * @param index The index of the element to return. + * @return The allowedValues at the given index. + */ + public java.lang.String getAllowedValues(int index) { + return allowedValues_.get(index); + } + /** + * + * + *
+         * List of values allowed at this resource.
+         * 
+ * + * repeated string allowed_values = 1; + * + * @param index The index of the value to return. + * @return The bytes of the allowedValues at the given index. + */ + public com.google.protobuf.ByteString getAllowedValuesBytes(int index) { + return allowedValues_.getByteString(index); + } + /** + * + * + *
+         * List of values allowed at this resource.
+         * 
+ * + * repeated string allowed_values = 1; + * + * @param index The index to set the value at. + * @param value The allowedValues to set. + * @return This builder for chaining. + */ + public Builder setAllowedValues(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureAllowedValuesIsMutable(); + allowedValues_.set(index, value); + onChanged(); + return this; + } + /** + * + * + *
+         * List of values allowed at this resource.
+         * 
+ * + * repeated string allowed_values = 1; + * + * @param value The allowedValues to add. + * @return This builder for chaining. + */ + public Builder addAllowedValues(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureAllowedValuesIsMutable(); + allowedValues_.add(value); + onChanged(); + return this; + } + /** + * + * + *
+         * List of values allowed at this resource.
+         * 
+ * + * repeated string allowed_values = 1; + * + * @param values The allowedValues to add. + * @return This builder for chaining. + */ + public Builder addAllAllowedValues(java.lang.Iterable values) { + ensureAllowedValuesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, allowedValues_); + onChanged(); + return this; + } + /** + * + * + *
+         * List of values allowed at this resource.
+         * 
+ * + * repeated string allowed_values = 1; + * + * @return This builder for chaining. + */ + public Builder clearAllowedValues() { + allowedValues_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+         * List of values allowed at this resource.
+         * 
+ * + * repeated string allowed_values = 1; + * + * @param value The bytes of the allowedValues to add. + * @return This builder for chaining. + */ + public Builder addAllowedValuesBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureAllowedValuesIsMutable(); + allowedValues_.add(value); + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringList deniedValues_ = + com.google.protobuf.LazyStringArrayList.EMPTY; + + private void ensureDeniedValuesIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + deniedValues_ = new com.google.protobuf.LazyStringArrayList(deniedValues_); + bitField0_ |= 0x00000002; + } + } + /** + * + * + *
+         * List of values denied at this resource.
+         * 
+ * + * repeated string denied_values = 2; + * + * @return A list containing the deniedValues. + */ + public com.google.protobuf.ProtocolStringList getDeniedValuesList() { + return deniedValues_.getUnmodifiableView(); + } + /** + * + * + *
+         * List of values denied at this resource.
+         * 
+ * + * repeated string denied_values = 2; + * + * @return The count of deniedValues. + */ + public int getDeniedValuesCount() { + return deniedValues_.size(); + } + /** + * + * + *
+         * List of values denied at this resource.
+         * 
+ * + * repeated string denied_values = 2; + * + * @param index The index of the element to return. + * @return The deniedValues at the given index. + */ + public java.lang.String getDeniedValues(int index) { + return deniedValues_.get(index); + } + /** + * + * + *
+         * List of values denied at this resource.
+         * 
+ * + * repeated string denied_values = 2; + * + * @param index The index of the value to return. + * @return The bytes of the deniedValues at the given index. + */ + public com.google.protobuf.ByteString getDeniedValuesBytes(int index) { + return deniedValues_.getByteString(index); + } + /** + * + * + *
+         * List of values denied at this resource.
+         * 
+ * + * repeated string denied_values = 2; + * + * @param index The index to set the value at. + * @param value The deniedValues to set. + * @return This builder for chaining. + */ + public Builder setDeniedValues(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureDeniedValuesIsMutable(); + deniedValues_.set(index, value); + onChanged(); + return this; + } + /** + * + * + *
+         * List of values denied at this resource.
+         * 
+ * + * repeated string denied_values = 2; + * + * @param value The deniedValues to add. + * @return This builder for chaining. + */ + public Builder addDeniedValues(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureDeniedValuesIsMutable(); + deniedValues_.add(value); + onChanged(); + return this; + } + /** + * + * + *
+         * List of values denied at this resource.
+         * 
+ * + * repeated string denied_values = 2; + * + * @param values The deniedValues to add. + * @return This builder for chaining. + */ + public Builder addAllDeniedValues(java.lang.Iterable values) { + ensureDeniedValuesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, deniedValues_); + onChanged(); + return this; + } + /** + * + * + *
+         * List of values denied at this resource.
+         * 
+ * + * repeated string denied_values = 2; + * + * @return This builder for chaining. + */ + public Builder clearDeniedValues() { + deniedValues_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * + * + *
+         * List of values denied at this resource.
+         * 
+ * + * repeated string denied_values = 2; + * + * @param value The bytes of the deniedValues to add. + * @return This builder for chaining. + */ + public Builder addDeniedValuesBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureDeniedValuesIsMutable(); + deniedValues_.add(value); + 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.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) + private static final com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues(); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public StringValues parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new StringValues(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int kindCase_ = 0; + private java.lang.Object kind_; + + public enum KindCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + VALUES(1), + ALLOW_ALL(2), + DENY_ALL(3), + ENFORCE(4), + KIND_NOT_SET(0); + private final int value; + + private KindCase(int value) { + this.value = value; + } + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static KindCase valueOf(int value) { + return forNumber(value); + } + + public static KindCase forNumber(int value) { + switch (value) { + case 1: + return VALUES; + case 2: + return ALLOW_ALL; + case 3: + return DENY_ALL; + case 4: + return ENFORCE; + case 0: + return KIND_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public KindCase getKindCase() { + return KindCase.forNumber(kindCase_); + } + + public static final int VALUES_FIELD_NUMBER = 1; + /** + * + * + *
+     * List of values to be used for this PolicyRule. This field can be set
+     * only in Policies for list constraints.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues values = 1; + * + * @return Whether the values field is set. + */ + @java.lang.Override + public boolean hasValues() { + return kindCase_ == 1; + } + /** + * + * + *
+     * List of values to be used for this PolicyRule. This field can be set
+     * only in Policies for list constraints.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues values = 1; + * + * @return The values. + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues getValues() { + if (kindCase_ == 1) { + return (com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) kind_; + } + return com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues.getDefaultInstance(); + } + /** + * + * + *
+     * List of values to be used for this PolicyRule. This field can be set
+     * only in Policies for list constraints.
+     * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues values = 1; + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValuesOrBuilder + getValuesOrBuilder() { + if (kindCase_ == 1) { + return (com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) kind_; + } + return com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues.getDefaultInstance(); + } + + public static final int ALLOW_ALL_FIELD_NUMBER = 2; + /** + * + * + *
+     * Setting this to true means that all values are allowed. This field can
+     * be set only in Policies for list constraints.
+     * 
+ * + * bool allow_all = 2; + * + * @return The allowAll. + */ + @java.lang.Override + public boolean getAllowAll() { + if (kindCase_ == 2) { + return (java.lang.Boolean) kind_; + } + return false; + } + + public static final int DENY_ALL_FIELD_NUMBER = 3; + /** + * + * + *
+     * Setting this to true means that all values are denied. This field can
+     * be set only in Policies for list constraints.
+     * 
+ * + * bool deny_all = 3; + * + * @return The denyAll. + */ + @java.lang.Override + public boolean getDenyAll() { + if (kindCase_ == 3) { + return (java.lang.Boolean) kind_; + } + return false; + } + + public static final int ENFORCE_FIELD_NUMBER = 4; + /** + * + * + *
+     * If `true`, then the `Policy` is enforced. If `false`, then any
+     * configuration is acceptable.
+     * This field can be set only in Policies for boolean constraints.
+     * 
+ * + * bool enforce = 4; + * + * @return The enforce. + */ + @java.lang.Override + public boolean getEnforce() { + if (kindCase_ == 4) { + return (java.lang.Boolean) kind_; + } + return false; + } + + public static final int CONDITION_FIELD_NUMBER = 5; + private com.google.type.Expr condition_; + /** + * + * + *
+     * A condition which determines whether this rule is used
+     * in the evaluation of the policy. When set, the `expression` field in
+     * the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
+     * or "&&" operators. Each subexpression must be of the form
+     * "resource.matchLabels(key_name, value_name)",
+     * where key_name and value_name are the resource names for Label Keys
+     * and Values. These names are available from the Label Manager Service. An
+     * example expression is:
+     * "resource.matchLabels('labelKeys/123, 'labelValues/456')".
+     * 
+ * + * .google.type.Expr condition = 5; + * + * @return Whether the condition field is set. + */ + @java.lang.Override + public boolean hasCondition() { + return condition_ != null; + } + /** + * + * + *
+     * A condition which determines whether this rule is used
+     * in the evaluation of the policy. When set, the `expression` field in
+     * the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
+     * or "&&" operators. Each subexpression must be of the form
+     * "resource.matchLabels(key_name, value_name)",
+     * where key_name and value_name are the resource names for Label Keys
+     * and Values. These names are available from the Label Manager Service. An
+     * example expression is:
+     * "resource.matchLabels('labelKeys/123, 'labelValues/456')".
+     * 
+ * + * .google.type.Expr condition = 5; + * + * @return The condition. + */ + @java.lang.Override + public com.google.type.Expr getCondition() { + return condition_ == null ? com.google.type.Expr.getDefaultInstance() : condition_; + } + /** + * + * + *
+     * A condition which determines whether this rule is used
+     * in the evaluation of the policy. When set, the `expression` field in
+     * the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
+     * or "&&" operators. Each subexpression must be of the form
+     * "resource.matchLabels(key_name, value_name)",
+     * where key_name and value_name are the resource names for Label Keys
+     * and Values. These names are available from the Label Manager Service. An
+     * example expression is:
+     * "resource.matchLabels('labelKeys/123, 'labelValues/456')".
+     * 
+ * + * .google.type.Expr condition = 5; + */ + @java.lang.Override + public com.google.type.ExprOrBuilder getConditionOrBuilder() { + return getCondition(); + } + + 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 (kindCase_ == 1) { + output.writeMessage( + 1, (com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) kind_); + } + if (kindCase_ == 2) { + output.writeBool(2, (boolean) ((java.lang.Boolean) kind_)); + } + if (kindCase_ == 3) { + output.writeBool(3, (boolean) ((java.lang.Boolean) kind_)); + } + if (kindCase_ == 4) { + output.writeBool(4, (boolean) ((java.lang.Boolean) kind_)); + } + if (condition_ != null) { + output.writeMessage(5, getCondition()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (kindCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 1, (com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) kind_); + } + if (kindCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeBoolSize( + 2, (boolean) ((java.lang.Boolean) kind_)); + } + if (kindCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeBoolSize( + 3, (boolean) ((java.lang.Boolean) kind_)); + } + if (kindCase_ == 4) { + size += + com.google.protobuf.CodedOutputStream.computeBoolSize( + 4, (boolean) ((java.lang.Boolean) kind_)); + } + if (condition_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getCondition()); + } + size += unknownFields.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.cloud.orgpolicy.v2.PolicySpec.PolicyRule)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule other = + (com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule) obj; + + if (hasCondition() != other.hasCondition()) return false; + if (hasCondition()) { + if (!getCondition().equals(other.getCondition())) return false; + } + if (!getKindCase().equals(other.getKindCase())) return false; + switch (kindCase_) { + case 1: + if (!getValues().equals(other.getValues())) return false; + break; + case 2: + if (getAllowAll() != other.getAllowAll()) return false; + break; + case 3: + if (getDenyAll() != other.getDenyAll()) return false; + break; + case 4: + if (getEnforce() != other.getEnforce()) return false; + break; + case 0: + default: + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasCondition()) { + hash = (37 * hash) + CONDITION_FIELD_NUMBER; + hash = (53 * hash) + getCondition().hashCode(); + } + switch (kindCase_) { + case 1: + hash = (37 * hash) + VALUES_FIELD_NUMBER; + hash = (53 * hash) + getValues().hashCode(); + break; + case 2: + hash = (37 * hash) + ALLOW_ALL_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getAllowAll()); + break; + case 3: + hash = (37 * hash) + DENY_ALL_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getDenyAll()); + break; + case 4: + hash = (37 * hash) + ENFORCE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getEnforce()); + break; + case 0: + default: + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule 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.cloud.orgpolicy.v2.PolicySpec.PolicyRule parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule 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.cloud.orgpolicy.v2.PolicySpec.PolicyRule parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule 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.cloud.orgpolicy.v2.PolicySpec.PolicyRule parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule 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.cloud.orgpolicy.v2.PolicySpec.PolicyRule 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; + } + /** + * + * + *
+     * A rule used to express this policy.
+     * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.PolicySpec.PolicyRule} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.PolicySpec.PolicyRule) + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRuleOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.class, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + if (conditionBuilder_ == null) { + condition_ = null; + } else { + condition_ = null; + conditionBuilder_ = null; + } + kindCase_ = 0; + kind_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_PolicySpec_PolicyRule_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule build() { + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule buildPartial() { + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule result = + new com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule(this); + if (kindCase_ == 1) { + if (valuesBuilder_ == null) { + result.kind_ = kind_; + } else { + result.kind_ = valuesBuilder_.build(); + } + } + if (kindCase_ == 2) { + result.kind_ = kind_; + } + if (kindCase_ == 3) { + result.kind_ = kind_; + } + if (kindCase_ == 4) { + result.kind_ = kind_; + } + if (conditionBuilder_ == null) { + result.condition_ = condition_; + } else { + result.condition_ = conditionBuilder_.build(); + } + result.kindCase_ = kindCase_; + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.PolicySpec.PolicyRule) { + return mergeFrom((com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule other) { + if (other == com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.getDefaultInstance()) + return this; + if (other.hasCondition()) { + mergeCondition(other.getCondition()); + } + switch (other.getKindCase()) { + case VALUES: + { + mergeValues(other.getValues()); + break; + } + case ALLOW_ALL: + { + setAllowAll(other.getAllowAll()); + break; + } + case DENY_ALL: + { + setDenyAll(other.getDenyAll()); + break; + } + case ENFORCE: + { + setEnforce(other.getEnforce()); + break; + } + case KIND_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int kindCase_ = 0; + private java.lang.Object kind_; + + public KindCase getKindCase() { + return KindCase.forNumber(kindCase_); + } + + public Builder clearKind() { + kindCase_ = 0; + kind_ = null; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues.Builder, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValuesOrBuilder> + valuesBuilder_; + /** + * + * + *
+       * List of values to be used for this PolicyRule. This field can be set
+       * only in Policies for list constraints.
+       * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues values = 1; + * + * @return Whether the values field is set. + */ + @java.lang.Override + public boolean hasValues() { + return kindCase_ == 1; + } + /** + * + * + *
+       * List of values to be used for this PolicyRule. This field can be set
+       * only in Policies for list constraints.
+       * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues values = 1; + * + * @return The values. + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues getValues() { + if (valuesBuilder_ == null) { + if (kindCase_ == 1) { + return (com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) kind_; + } + return com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues + .getDefaultInstance(); + } else { + if (kindCase_ == 1) { + return valuesBuilder_.getMessage(); + } + return com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues + .getDefaultInstance(); + } + } + /** + * + * + *
+       * List of values to be used for this PolicyRule. This field can be set
+       * only in Policies for list constraints.
+       * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues values = 1; + */ + public Builder setValues( + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues value) { + if (valuesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + kind_ = value; + onChanged(); + } else { + valuesBuilder_.setMessage(value); + } + kindCase_ = 1; + return this; + } + /** + * + * + *
+       * List of values to be used for this PolicyRule. This field can be set
+       * only in Policies for list constraints.
+       * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues values = 1; + */ + public Builder setValues( + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues.Builder + builderForValue) { + if (valuesBuilder_ == null) { + kind_ = builderForValue.build(); + onChanged(); + } else { + valuesBuilder_.setMessage(builderForValue.build()); + } + kindCase_ = 1; + return this; + } + /** + * + * + *
+       * List of values to be used for this PolicyRule. This field can be set
+       * only in Policies for list constraints.
+       * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues values = 1; + */ + public Builder mergeValues( + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues value) { + if (valuesBuilder_ == null) { + if (kindCase_ == 1 + && kind_ + != com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues + .getDefaultInstance()) { + kind_ = + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues.newBuilder( + (com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) kind_) + .mergeFrom(value) + .buildPartial(); + } else { + kind_ = value; + } + onChanged(); + } else { + if (kindCase_ == 1) { + valuesBuilder_.mergeFrom(value); + } + valuesBuilder_.setMessage(value); + } + kindCase_ = 1; + return this; + } + /** + * + * + *
+       * List of values to be used for this PolicyRule. This field can be set
+       * only in Policies for list constraints.
+       * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues values = 1; + */ + public Builder clearValues() { + if (valuesBuilder_ == null) { + if (kindCase_ == 1) { + kindCase_ = 0; + kind_ = null; + onChanged(); + } + } else { + if (kindCase_ == 1) { + kindCase_ = 0; + kind_ = null; + } + valuesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+       * List of values to be used for this PolicyRule. This field can be set
+       * only in Policies for list constraints.
+       * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues values = 1; + */ + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues.Builder + getValuesBuilder() { + return getValuesFieldBuilder().getBuilder(); + } + /** + * + * + *
+       * List of values to be used for this PolicyRule. This field can be set
+       * only in Policies for list constraints.
+       * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues values = 1; + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValuesOrBuilder + getValuesOrBuilder() { + if ((kindCase_ == 1) && (valuesBuilder_ != null)) { + return valuesBuilder_.getMessageOrBuilder(); + } else { + if (kindCase_ == 1) { + return (com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) kind_; + } + return com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues + .getDefaultInstance(); + } + } + /** + * + * + *
+       * List of values to be used for this PolicyRule. This field can be set
+       * only in Policies for list constraints.
+       * 
+ * + * .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues values = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues.Builder, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValuesOrBuilder> + getValuesFieldBuilder() { + if (valuesBuilder_ == null) { + if (!(kindCase_ == 1)) { + kind_ = + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues + .getDefaultInstance(); + } + valuesBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues.Builder, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValuesOrBuilder>( + (com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues) kind_, + getParentForChildren(), + isClean()); + kind_ = null; + } + kindCase_ = 1; + onChanged(); + ; + return valuesBuilder_; + } + + /** + * + * + *
+       * Setting this to true means that all values are allowed. This field can
+       * be set only in Policies for list constraints.
+       * 
+ * + * bool allow_all = 2; + * + * @return The allowAll. + */ + public boolean getAllowAll() { + if (kindCase_ == 2) { + return (java.lang.Boolean) kind_; + } + return false; + } + /** + * + * + *
+       * Setting this to true means that all values are allowed. This field can
+       * be set only in Policies for list constraints.
+       * 
+ * + * bool allow_all = 2; + * + * @param value The allowAll to set. + * @return This builder for chaining. + */ + public Builder setAllowAll(boolean value) { + kindCase_ = 2; + kind_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * Setting this to true means that all values are allowed. This field can
+       * be set only in Policies for list constraints.
+       * 
+ * + * bool allow_all = 2; + * + * @return This builder for chaining. + */ + public Builder clearAllowAll() { + if (kindCase_ == 2) { + kindCase_ = 0; + kind_ = null; + onChanged(); + } + return this; + } + + /** + * + * + *
+       * Setting this to true means that all values are denied. This field can
+       * be set only in Policies for list constraints.
+       * 
+ * + * bool deny_all = 3; + * + * @return The denyAll. + */ + public boolean getDenyAll() { + if (kindCase_ == 3) { + return (java.lang.Boolean) kind_; + } + return false; + } + /** + * + * + *
+       * Setting this to true means that all values are denied. This field can
+       * be set only in Policies for list constraints.
+       * 
+ * + * bool deny_all = 3; + * + * @param value The denyAll to set. + * @return This builder for chaining. + */ + public Builder setDenyAll(boolean value) { + kindCase_ = 3; + kind_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * Setting this to true means that all values are denied. This field can
+       * be set only in Policies for list constraints.
+       * 
+ * + * bool deny_all = 3; + * + * @return This builder for chaining. + */ + public Builder clearDenyAll() { + if (kindCase_ == 3) { + kindCase_ = 0; + kind_ = null; + onChanged(); + } + return this; + } + + /** + * + * + *
+       * If `true`, then the `Policy` is enforced. If `false`, then any
+       * configuration is acceptable.
+       * This field can be set only in Policies for boolean constraints.
+       * 
+ * + * bool enforce = 4; + * + * @return The enforce. + */ + public boolean getEnforce() { + if (kindCase_ == 4) { + return (java.lang.Boolean) kind_; + } + return false; + } + /** + * + * + *
+       * If `true`, then the `Policy` is enforced. If `false`, then any
+       * configuration is acceptable.
+       * This field can be set only in Policies for boolean constraints.
+       * 
+ * + * bool enforce = 4; + * + * @param value The enforce to set. + * @return This builder for chaining. + */ + public Builder setEnforce(boolean value) { + kindCase_ = 4; + kind_ = value; + onChanged(); + return this; + } + /** + * + * + *
+       * If `true`, then the `Policy` is enforced. If `false`, then any
+       * configuration is acceptable.
+       * This field can be set only in Policies for boolean constraints.
+       * 
+ * + * bool enforce = 4; + * + * @return This builder for chaining. + */ + public Builder clearEnforce() { + if (kindCase_ == 4) { + kindCase_ = 0; + kind_ = null; + onChanged(); + } + return this; + } + + private com.google.type.Expr condition_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.type.Expr, com.google.type.Expr.Builder, com.google.type.ExprOrBuilder> + conditionBuilder_; + /** + * + * + *
+       * A condition which determines whether this rule is used
+       * in the evaluation of the policy. When set, the `expression` field in
+       * the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
+       * or "&&" operators. Each subexpression must be of the form
+       * "resource.matchLabels(key_name, value_name)",
+       * where key_name and value_name are the resource names for Label Keys
+       * and Values. These names are available from the Label Manager Service. An
+       * example expression is:
+       * "resource.matchLabels('labelKeys/123, 'labelValues/456')".
+       * 
+ * + * .google.type.Expr condition = 5; + * + * @return Whether the condition field is set. + */ + public boolean hasCondition() { + return conditionBuilder_ != null || condition_ != null; + } + /** + * + * + *
+       * A condition which determines whether this rule is used
+       * in the evaluation of the policy. When set, the `expression` field in
+       * the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
+       * or "&&" operators. Each subexpression must be of the form
+       * "resource.matchLabels(key_name, value_name)",
+       * where key_name and value_name are the resource names for Label Keys
+       * and Values. These names are available from the Label Manager Service. An
+       * example expression is:
+       * "resource.matchLabels('labelKeys/123, 'labelValues/456')".
+       * 
+ * + * .google.type.Expr condition = 5; + * + * @return The condition. + */ + public com.google.type.Expr getCondition() { + if (conditionBuilder_ == null) { + return condition_ == null ? com.google.type.Expr.getDefaultInstance() : condition_; + } else { + return conditionBuilder_.getMessage(); + } + } + /** + * + * + *
+       * A condition which determines whether this rule is used
+       * in the evaluation of the policy. When set, the `expression` field in
+       * the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
+       * or "&&" operators. Each subexpression must be of the form
+       * "resource.matchLabels(key_name, value_name)",
+       * where key_name and value_name are the resource names for Label Keys
+       * and Values. These names are available from the Label Manager Service. An
+       * example expression is:
+       * "resource.matchLabels('labelKeys/123, 'labelValues/456')".
+       * 
+ * + * .google.type.Expr condition = 5; + */ + public Builder setCondition(com.google.type.Expr value) { + if (conditionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + condition_ = value; + onChanged(); + } else { + conditionBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+       * A condition which determines whether this rule is used
+       * in the evaluation of the policy. When set, the `expression` field in
+       * the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
+       * or "&&" operators. Each subexpression must be of the form
+       * "resource.matchLabels(key_name, value_name)",
+       * where key_name and value_name are the resource names for Label Keys
+       * and Values. These names are available from the Label Manager Service. An
+       * example expression is:
+       * "resource.matchLabels('labelKeys/123, 'labelValues/456')".
+       * 
+ * + * .google.type.Expr condition = 5; + */ + public Builder setCondition(com.google.type.Expr.Builder builderForValue) { + if (conditionBuilder_ == null) { + condition_ = builderForValue.build(); + onChanged(); + } else { + conditionBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+       * A condition which determines whether this rule is used
+       * in the evaluation of the policy. When set, the `expression` field in
+       * the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
+       * or "&&" operators. Each subexpression must be of the form
+       * "resource.matchLabels(key_name, value_name)",
+       * where key_name and value_name are the resource names for Label Keys
+       * and Values. These names are available from the Label Manager Service. An
+       * example expression is:
+       * "resource.matchLabels('labelKeys/123, 'labelValues/456')".
+       * 
+ * + * .google.type.Expr condition = 5; + */ + public Builder mergeCondition(com.google.type.Expr value) { + if (conditionBuilder_ == null) { + if (condition_ != null) { + condition_ = + com.google.type.Expr.newBuilder(condition_).mergeFrom(value).buildPartial(); + } else { + condition_ = value; + } + onChanged(); + } else { + conditionBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+       * A condition which determines whether this rule is used
+       * in the evaluation of the policy. When set, the `expression` field in
+       * the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
+       * or "&&" operators. Each subexpression must be of the form
+       * "resource.matchLabels(key_name, value_name)",
+       * where key_name and value_name are the resource names for Label Keys
+       * and Values. These names are available from the Label Manager Service. An
+       * example expression is:
+       * "resource.matchLabels('labelKeys/123, 'labelValues/456')".
+       * 
+ * + * .google.type.Expr condition = 5; + */ + public Builder clearCondition() { + if (conditionBuilder_ == null) { + condition_ = null; + onChanged(); + } else { + condition_ = null; + conditionBuilder_ = null; + } + + return this; + } + /** + * + * + *
+       * A condition which determines whether this rule is used
+       * in the evaluation of the policy. When set, the `expression` field in
+       * the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
+       * or "&&" operators. Each subexpression must be of the form
+       * "resource.matchLabels(key_name, value_name)",
+       * where key_name and value_name are the resource names for Label Keys
+       * and Values. These names are available from the Label Manager Service. An
+       * example expression is:
+       * "resource.matchLabels('labelKeys/123, 'labelValues/456')".
+       * 
+ * + * .google.type.Expr condition = 5; + */ + public com.google.type.Expr.Builder getConditionBuilder() { + + onChanged(); + return getConditionFieldBuilder().getBuilder(); + } + /** + * + * + *
+       * A condition which determines whether this rule is used
+       * in the evaluation of the policy. When set, the `expression` field in
+       * the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
+       * or "&&" operators. Each subexpression must be of the form
+       * "resource.matchLabels(key_name, value_name)",
+       * where key_name and value_name are the resource names for Label Keys
+       * and Values. These names are available from the Label Manager Service. An
+       * example expression is:
+       * "resource.matchLabels('labelKeys/123, 'labelValues/456')".
+       * 
+ * + * .google.type.Expr condition = 5; + */ + public com.google.type.ExprOrBuilder getConditionOrBuilder() { + if (conditionBuilder_ != null) { + return conditionBuilder_.getMessageOrBuilder(); + } else { + return condition_ == null ? com.google.type.Expr.getDefaultInstance() : condition_; + } + } + /** + * + * + *
+       * A condition which determines whether this rule is used
+       * in the evaluation of the policy. When set, the `expression` field in
+       * the `Expr' must include from 1 to 10 subexpressions, joined by the "||"
+       * or "&&" operators. Each subexpression must be of the form
+       * "resource.matchLabels(key_name, value_name)",
+       * where key_name and value_name are the resource names for Label Keys
+       * and Values. These names are available from the Label Manager Service. An
+       * example expression is:
+       * "resource.matchLabels('labelKeys/123, 'labelValues/456')".
+       * 
+ * + * .google.type.Expr condition = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.type.Expr, com.google.type.Expr.Builder, com.google.type.ExprOrBuilder> + getConditionFieldBuilder() { + if (conditionBuilder_ == null) { + conditionBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.type.Expr, + com.google.type.Expr.Builder, + com.google.type.ExprOrBuilder>(getCondition(), getParentForChildren(), isClean()); + condition_ = null; + } + return conditionBuilder_; + } + + @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.cloud.orgpolicy.v2.PolicySpec.PolicyRule) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.PolicySpec.PolicyRule) + private static final com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule(); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PolicyRule parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PolicyRule(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.PolicySpec.PolicyRule getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public static final int ETAG_FIELD_NUMBER = 1; + private volatile java.lang.Object etag_; + /** + * + * + *
+   * An opaque tag indicating the current version of the `Policy`, used for
+   * concurrency control.
+   * This field is ignored if used in a `CreatePolicy` request.
+   * When the `Policy` is returned from either a `GetPolicy` or a
+   * `ListPolicies` request, this `etag` indicates the version of the
+   * current `Policy` to use when executing a read-modify-write loop.
+   * When the `Policy` is returned from a `GetEffectivePolicy` request, the
+   * `etag` will be unset.
+   * 
+ * + * string etag = 1; + * + * @return The etag. + */ + @java.lang.Override + public java.lang.String getEtag() { + java.lang.Object ref = etag_; + 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(); + etag_ = s; + return s; + } + } + /** + * + * + *
+   * An opaque tag indicating the current version of the `Policy`, used for
+   * concurrency control.
+   * This field is ignored if used in a `CreatePolicy` request.
+   * When the `Policy` is returned from either a `GetPolicy` or a
+   * `ListPolicies` request, this `etag` indicates the version of the
+   * current `Policy` to use when executing a read-modify-write loop.
+   * When the `Policy` is returned from a `GetEffectivePolicy` request, the
+   * `etag` will be unset.
+   * 
+ * + * string etag = 1; + * + * @return The bytes for etag. + */ + @java.lang.Override + public com.google.protobuf.ByteString getEtagBytes() { + java.lang.Object ref = etag_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + etag_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int UPDATE_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp updateTime_; + /** + * + * + *
+   * Output only. The time stamp this was previously updated. This
+   * represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
+   * made for that `Policy`.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + @java.lang.Override + public boolean hasUpdateTime() { + return updateTime_ != null; + } + /** + * + * + *
+   * Output only. The time stamp this was previously updated. This
+   * represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
+   * made for that `Policy`.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getUpdateTime() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + /** + * + * + *
+   * Output only. The time stamp this was previously updated. This
+   * represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
+   * made for that `Policy`.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + return getUpdateTime(); + } + + public static final int RULES_FIELD_NUMBER = 3; + private java.util.List rules_; + /** + * + * + *
+   * Up to 10 PolicyRules are allowed.
+   * In Policies for boolean constraints, the following requirements apply:
+   *   - There must be one and only one PolicyRule where condition is unset.
+   *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+   *     of the PolicyRule without a condition.
+   *   - During policy evaluation, PolicyRules with conditions that are
+   *     true for a target resource take precedence.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + @java.lang.Override + public java.util.List getRulesList() { + return rules_; + } + /** + * + * + *
+   * Up to 10 PolicyRules are allowed.
+   * In Policies for boolean constraints, the following requirements apply:
+   *   - There must be one and only one PolicyRule where condition is unset.
+   *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+   *     of the PolicyRule without a condition.
+   *   - During policy evaluation, PolicyRules with conditions that are
+   *     true for a target resource take precedence.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + @java.lang.Override + public java.util.List + getRulesOrBuilderList() { + return rules_; + } + /** + * + * + *
+   * Up to 10 PolicyRules are allowed.
+   * In Policies for boolean constraints, the following requirements apply:
+   *   - There must be one and only one PolicyRule where condition is unset.
+   *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+   *     of the PolicyRule without a condition.
+   *   - During policy evaluation, PolicyRules with conditions that are
+   *     true for a target resource take precedence.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + @java.lang.Override + public int getRulesCount() { + return rules_.size(); + } + /** + * + * + *
+   * Up to 10 PolicyRules are allowed.
+   * In Policies for boolean constraints, the following requirements apply:
+   *   - There must be one and only one PolicyRule where condition is unset.
+   *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+   *     of the PolicyRule without a condition.
+   *   - During policy evaluation, PolicyRules with conditions that are
+   *     true for a target resource take precedence.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule getRules(int index) { + return rules_.get(index); + } + /** + * + * + *
+   * Up to 10 PolicyRules are allowed.
+   * In Policies for boolean constraints, the following requirements apply:
+   *   - There must be one and only one PolicyRule where condition is unset.
+   *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+   *     of the PolicyRule without a condition.
+   *   - During policy evaluation, PolicyRules with conditions that are
+   *     true for a target resource take precedence.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRuleOrBuilder getRulesOrBuilder(int index) { + return rules_.get(index); + } + + public static final int INHERIT_FROM_PARENT_FIELD_NUMBER = 4; + private boolean inheritFromParent_; + /** + * + * + *
+   * Determines the inheritance behavior for this `Policy`.
+   * If `inherit_from_parent` is true, PolicyRules set higher up in the
+   * hierarchy (up to the closest root) are inherited and present in the
+   * effective policy. If it is false, then no rules are inherited, and this
+   * Policy becomes the new root for evaluation.
+   * This field can be set only for Policies which configure list constraints.
+   * 
+ * + * bool inherit_from_parent = 4; + * + * @return The inheritFromParent. + */ + @java.lang.Override + public boolean getInheritFromParent() { + return inheritFromParent_; + } + + public static final int RESET_FIELD_NUMBER = 5; + private boolean reset_; + /** + * + * + *
+   * Ignores policies set above this resource and restores the
+   * `constraint_default` enforcement behavior of the specific `Constraint` at
+   * this resource.
+   * This field can be set in policies for either list or boolean
+   * constraints. If set, `rules` must be empty and `inherit_from_parent`
+   * must be set to false.
+   * 
+ * + * bool reset = 5; + * + * @return The reset. + */ + @java.lang.Override + public boolean getReset() { + return reset_; + } + + 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 (!getEtagBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, etag_); + } + if (updateTime_ != null) { + output.writeMessage(2, getUpdateTime()); + } + for (int i = 0; i < rules_.size(); i++) { + output.writeMessage(3, rules_.get(i)); + } + if (inheritFromParent_ != false) { + output.writeBool(4, inheritFromParent_); + } + if (reset_ != false) { + output.writeBool(5, reset_); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getEtagBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, etag_); + } + if (updateTime_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateTime()); + } + for (int i = 0; i < rules_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, rules_.get(i)); + } + if (inheritFromParent_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(4, inheritFromParent_); + } + if (reset_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(5, reset_); + } + size += unknownFields.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.cloud.orgpolicy.v2.PolicySpec)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.PolicySpec other = (com.google.cloud.orgpolicy.v2.PolicySpec) obj; + + if (!getEtag().equals(other.getEtag())) return false; + if (hasUpdateTime() != other.hasUpdateTime()) return false; + if (hasUpdateTime()) { + if (!getUpdateTime().equals(other.getUpdateTime())) return false; + } + if (!getRulesList().equals(other.getRulesList())) return false; + if (getInheritFromParent() != other.getInheritFromParent()) return false; + if (getReset() != other.getReset()) return false; + if (!unknownFields.equals(other.unknownFields)) 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) + ETAG_FIELD_NUMBER; + hash = (53 * hash) + getEtag().hashCode(); + if (hasUpdateTime()) { + hash = (37 * hash) + UPDATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getUpdateTime().hashCode(); + } + if (getRulesCount() > 0) { + hash = (37 * hash) + RULES_FIELD_NUMBER; + hash = (53 * hash) + getRulesList().hashCode(); + } + hash = (37 * hash) + INHERIT_FROM_PARENT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getInheritFromParent()); + hash = (37 * hash) + RESET_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getReset()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec 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.cloud.orgpolicy.v2.PolicySpec parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec 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.cloud.orgpolicy.v2.PolicySpec parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec 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.cloud.orgpolicy.v2.PolicySpec parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec 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.cloud.orgpolicy.v2.PolicySpec 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 a Cloud Organization `PolicySpec` which is used to specify
+   * `Constraints` for configurations of Cloud Platform resources.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.PolicySpec} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.PolicySpec) + com.google.cloud.orgpolicy.v2.PolicySpecOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_PolicySpec_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_PolicySpec_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.PolicySpec.class, + com.google.cloud.orgpolicy.v2.PolicySpec.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.PolicySpec.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getRulesFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + etag_ = ""; + + if (updateTimeBuilder_ == null) { + updateTime_ = null; + } else { + updateTime_ = null; + updateTimeBuilder_ = null; + } + if (rulesBuilder_ == null) { + rules_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + rulesBuilder_.clear(); + } + inheritFromParent_ = false; + + reset_ = false; + + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_PolicySpec_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.PolicySpec.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec build() { + com.google.cloud.orgpolicy.v2.PolicySpec result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicySpec buildPartial() { + com.google.cloud.orgpolicy.v2.PolicySpec result = + new com.google.cloud.orgpolicy.v2.PolicySpec(this); + int from_bitField0_ = bitField0_; + result.etag_ = etag_; + if (updateTimeBuilder_ == null) { + result.updateTime_ = updateTime_; + } else { + result.updateTime_ = updateTimeBuilder_.build(); + } + if (rulesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + rules_ = java.util.Collections.unmodifiableList(rules_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.rules_ = rules_; + } else { + result.rules_ = rulesBuilder_.build(); + } + result.inheritFromParent_ = inheritFromParent_; + result.reset_ = reset_; + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.PolicySpec) { + return mergeFrom((com.google.cloud.orgpolicy.v2.PolicySpec) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.PolicySpec other) { + if (other == com.google.cloud.orgpolicy.v2.PolicySpec.getDefaultInstance()) return this; + if (!other.getEtag().isEmpty()) { + etag_ = other.etag_; + onChanged(); + } + if (other.hasUpdateTime()) { + mergeUpdateTime(other.getUpdateTime()); + } + if (rulesBuilder_ == null) { + if (!other.rules_.isEmpty()) { + if (rules_.isEmpty()) { + rules_ = other.rules_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureRulesIsMutable(); + rules_.addAll(other.rules_); + } + onChanged(); + } + } else { + if (!other.rules_.isEmpty()) { + if (rulesBuilder_.isEmpty()) { + rulesBuilder_.dispose(); + rulesBuilder_ = null; + rules_ = other.rules_; + bitField0_ = (bitField0_ & ~0x00000001); + rulesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getRulesFieldBuilder() + : null; + } else { + rulesBuilder_.addAllMessages(other.rules_); + } + } + } + if (other.getInheritFromParent() != false) { + setInheritFromParent(other.getInheritFromParent()); + } + if (other.getReset() != false) { + setReset(other.getReset()); + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.PolicySpec parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.google.cloud.orgpolicy.v2.PolicySpec) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private java.lang.Object etag_ = ""; + /** + * + * + *
+     * An opaque tag indicating the current version of the `Policy`, used for
+     * concurrency control.
+     * This field is ignored if used in a `CreatePolicy` request.
+     * When the `Policy` is returned from either a `GetPolicy` or a
+     * `ListPolicies` request, this `etag` indicates the version of the
+     * current `Policy` to use when executing a read-modify-write loop.
+     * When the `Policy` is returned from a `GetEffectivePolicy` request, the
+     * `etag` will be unset.
+     * 
+ * + * string etag = 1; + * + * @return The etag. + */ + public java.lang.String getEtag() { + java.lang.Object ref = etag_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + etag_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * An opaque tag indicating the current version of the `Policy`, used for
+     * concurrency control.
+     * This field is ignored if used in a `CreatePolicy` request.
+     * When the `Policy` is returned from either a `GetPolicy` or a
+     * `ListPolicies` request, this `etag` indicates the version of the
+     * current `Policy` to use when executing a read-modify-write loop.
+     * When the `Policy` is returned from a `GetEffectivePolicy` request, the
+     * `etag` will be unset.
+     * 
+ * + * string etag = 1; + * + * @return The bytes for etag. + */ + public com.google.protobuf.ByteString getEtagBytes() { + java.lang.Object ref = etag_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + etag_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * An opaque tag indicating the current version of the `Policy`, used for
+     * concurrency control.
+     * This field is ignored if used in a `CreatePolicy` request.
+     * When the `Policy` is returned from either a `GetPolicy` or a
+     * `ListPolicies` request, this `etag` indicates the version of the
+     * current `Policy` to use when executing a read-modify-write loop.
+     * When the `Policy` is returned from a `GetEffectivePolicy` request, the
+     * `etag` will be unset.
+     * 
+ * + * string etag = 1; + * + * @param value The etag to set. + * @return This builder for chaining. + */ + public Builder setEtag(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + etag_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * An opaque tag indicating the current version of the `Policy`, used for
+     * concurrency control.
+     * This field is ignored if used in a `CreatePolicy` request.
+     * When the `Policy` is returned from either a `GetPolicy` or a
+     * `ListPolicies` request, this `etag` indicates the version of the
+     * current `Policy` to use when executing a read-modify-write loop.
+     * When the `Policy` is returned from a `GetEffectivePolicy` request, the
+     * `etag` will be unset.
+     * 
+ * + * string etag = 1; + * + * @return This builder for chaining. + */ + public Builder clearEtag() { + + etag_ = getDefaultInstance().getEtag(); + onChanged(); + return this; + } + /** + * + * + *
+     * An opaque tag indicating the current version of the `Policy`, used for
+     * concurrency control.
+     * This field is ignored if used in a `CreatePolicy` request.
+     * When the `Policy` is returned from either a `GetPolicy` or a
+     * `ListPolicies` request, this `etag` indicates the version of the
+     * current `Policy` to use when executing a read-modify-write loop.
+     * When the `Policy` is returned from a `GetEffectivePolicy` request, the
+     * `etag` will be unset.
+     * 
+ * + * string etag = 1; + * + * @param value The bytes for etag to set. + * @return This builder for chaining. + */ + public Builder setEtagBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + etag_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp updateTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + updateTimeBuilder_; + /** + * + * + *
+     * Output only. The time stamp this was previously updated. This
+     * represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
+     * made for that `Policy`.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + public boolean hasUpdateTime() { + return updateTimeBuilder_ != null || updateTime_ != null; + } + /** + * + * + *
+     * Output only. The time stamp this was previously updated. This
+     * represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
+     * made for that `Policy`.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + public com.google.protobuf.Timestamp getUpdateTime() { + if (updateTimeBuilder_ == null) { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } else { + return updateTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. The time stamp this was previously updated. This
+     * represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
+     * made for that `Policy`.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updateTime_ = value; + onChanged(); + } else { + updateTimeBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Output only. The time stamp this was previously updated. This
+     * represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
+     * made for that `Policy`.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (updateTimeBuilder_ == null) { + updateTime_ = builderForValue.build(); + onChanged(); + } else { + updateTimeBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Output only. The time stamp this was previously updated. This
+     * represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
+     * made for that `Policy`.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (updateTime_ != null) { + updateTime_ = + com.google.protobuf.Timestamp.newBuilder(updateTime_).mergeFrom(value).buildPartial(); + } else { + updateTime_ = value; + } + onChanged(); + } else { + updateTimeBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Output only. The time stamp this was previously updated. This
+     * represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
+     * made for that `Policy`.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearUpdateTime() { + if (updateTimeBuilder_ == null) { + updateTime_ = null; + onChanged(); + } else { + updateTime_ = null; + updateTimeBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Output only. The time stamp this was previously updated. This
+     * represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
+     * made for that `Policy`.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getUpdateTimeBuilder() { + + onChanged(); + return getUpdateTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. The time stamp this was previously updated. This
+     * represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
+     * made for that `Policy`.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + if (updateTimeBuilder_ != null) { + return updateTimeBuilder_.getMessageOrBuilder(); + } else { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } + } + /** + * + * + *
+     * Output only. The time stamp this was previously updated. This
+     * represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
+     * made for that `Policy`.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getUpdateTimeFieldBuilder() { + if (updateTimeBuilder_ == null) { + updateTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getUpdateTime(), getParentForChildren(), isClean()); + updateTime_ = null; + } + return updateTimeBuilder_; + } + + private java.util.List rules_ = + java.util.Collections.emptyList(); + + private void ensureRulesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + rules_ = + new java.util.ArrayList(rules_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.Builder, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRuleOrBuilder> + rulesBuilder_; + + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public java.util.List getRulesList() { + if (rulesBuilder_ == null) { + return java.util.Collections.unmodifiableList(rules_); + } else { + return rulesBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public int getRulesCount() { + if (rulesBuilder_ == null) { + return rules_.size(); + } else { + return rulesBuilder_.getCount(); + } + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule getRules(int index) { + if (rulesBuilder_ == null) { + return rules_.get(index); + } else { + return rulesBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public Builder setRules(int index, com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.set(index, value); + onChanged(); + } else { + rulesBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public Builder setRules( + int index, com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.set(index, builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public Builder addRules(com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.add(value); + onChanged(); + } else { + rulesBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public Builder addRules(int index, com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule value) { + if (rulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureRulesIsMutable(); + rules_.add(index, value); + onChanged(); + } else { + rulesBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public Builder addRules( + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.add(builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public Builder addRules( + int index, com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.Builder builderForValue) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.add(index, builderForValue.build()); + onChanged(); + } else { + rulesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public Builder addAllRules( + java.lang.Iterable values) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, rules_); + onChanged(); + } else { + rulesBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public Builder clearRules() { + if (rulesBuilder_ == null) { + rules_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + rulesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public Builder removeRules(int index) { + if (rulesBuilder_ == null) { + ensureRulesIsMutable(); + rules_.remove(index); + onChanged(); + } else { + rulesBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.Builder getRulesBuilder(int index) { + return getRulesFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRuleOrBuilder getRulesOrBuilder( + int index) { + if (rulesBuilder_ == null) { + return rules_.get(index); + } else { + return rulesBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public java.util.List + getRulesOrBuilderList() { + if (rulesBuilder_ != null) { + return rulesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(rules_); + } + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.Builder addRulesBuilder() { + return getRulesFieldBuilder() + .addBuilder(com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.getDefaultInstance()); + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.Builder addRulesBuilder(int index) { + return getRulesFieldBuilder() + .addBuilder( + index, com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.getDefaultInstance()); + } + /** + * + * + *
+     * Up to 10 PolicyRules are allowed.
+     * In Policies for boolean constraints, the following requirements apply:
+     *   - There must be one and only one PolicyRule where condition is unset.
+     *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+     *     of the PolicyRule without a condition.
+     *   - During policy evaluation, PolicyRules with conditions that are
+     *     true for a target resource take precedence.
+     * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + public java.util.List + getRulesBuilderList() { + return getRulesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.Builder, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRuleOrBuilder> + getRulesFieldBuilder() { + if (rulesBuilder_ == null) { + rulesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.Builder, + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRuleOrBuilder>( + rules_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + rules_ = null; + } + return rulesBuilder_; + } + + private boolean inheritFromParent_; + /** + * + * + *
+     * Determines the inheritance behavior for this `Policy`.
+     * If `inherit_from_parent` is true, PolicyRules set higher up in the
+     * hierarchy (up to the closest root) are inherited and present in the
+     * effective policy. If it is false, then no rules are inherited, and this
+     * Policy becomes the new root for evaluation.
+     * This field can be set only for Policies which configure list constraints.
+     * 
+ * + * bool inherit_from_parent = 4; + * + * @return The inheritFromParent. + */ + @java.lang.Override + public boolean getInheritFromParent() { + return inheritFromParent_; + } + /** + * + * + *
+     * Determines the inheritance behavior for this `Policy`.
+     * If `inherit_from_parent` is true, PolicyRules set higher up in the
+     * hierarchy (up to the closest root) are inherited and present in the
+     * effective policy. If it is false, then no rules are inherited, and this
+     * Policy becomes the new root for evaluation.
+     * This field can be set only for Policies which configure list constraints.
+     * 
+ * + * bool inherit_from_parent = 4; + * + * @param value The inheritFromParent to set. + * @return This builder for chaining. + */ + public Builder setInheritFromParent(boolean value) { + + inheritFromParent_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Determines the inheritance behavior for this `Policy`.
+     * If `inherit_from_parent` is true, PolicyRules set higher up in the
+     * hierarchy (up to the closest root) are inherited and present in the
+     * effective policy. If it is false, then no rules are inherited, and this
+     * Policy becomes the new root for evaluation.
+     * This field can be set only for Policies which configure list constraints.
+     * 
+ * + * bool inherit_from_parent = 4; + * + * @return This builder for chaining. + */ + public Builder clearInheritFromParent() { + + inheritFromParent_ = false; + onChanged(); + return this; + } + + private boolean reset_; + /** + * + * + *
+     * Ignores policies set above this resource and restores the
+     * `constraint_default` enforcement behavior of the specific `Constraint` at
+     * this resource.
+     * This field can be set in policies for either list or boolean
+     * constraints. If set, `rules` must be empty and `inherit_from_parent`
+     * must be set to false.
+     * 
+ * + * bool reset = 5; + * + * @return The reset. + */ + @java.lang.Override + public boolean getReset() { + return reset_; + } + /** + * + * + *
+     * Ignores policies set above this resource and restores the
+     * `constraint_default` enforcement behavior of the specific `Constraint` at
+     * this resource.
+     * This field can be set in policies for either list or boolean
+     * constraints. If set, `rules` must be empty and `inherit_from_parent`
+     * must be set to false.
+     * 
+ * + * bool reset = 5; + * + * @param value The reset to set. + * @return This builder for chaining. + */ + public Builder setReset(boolean value) { + + reset_ = value; + onChanged(); + return this; + } + /** + * + * + *
+     * Ignores policies set above this resource and restores the
+     * `constraint_default` enforcement behavior of the specific `Constraint` at
+     * this resource.
+     * This field can be set in policies for either list or boolean
+     * constraints. If set, `rules` must be empty and `inherit_from_parent`
+     * must be set to false.
+     * 
+ * + * bool reset = 5; + * + * @return This builder for chaining. + */ + public Builder clearReset() { + + reset_ = false; + 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.cloud.orgpolicy.v2.PolicySpec) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.PolicySpec) + private static final com.google.cloud.orgpolicy.v2.PolicySpec DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.PolicySpec(); + } + + public static com.google.cloud.orgpolicy.v2.PolicySpec getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PolicySpec parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new PolicySpec(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.PolicySpec getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/PolicySpecOrBuilder.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/PolicySpecOrBuilder.java new file mode 100644 index 0000000..a248432 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/PolicySpecOrBuilder.java @@ -0,0 +1,226 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +public interface PolicySpecOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.PolicySpec) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * An opaque tag indicating the current version of the `Policy`, used for
+   * concurrency control.
+   * This field is ignored if used in a `CreatePolicy` request.
+   * When the `Policy` is returned from either a `GetPolicy` or a
+   * `ListPolicies` request, this `etag` indicates the version of the
+   * current `Policy` to use when executing a read-modify-write loop.
+   * When the `Policy` is returned from a `GetEffectivePolicy` request, the
+   * `etag` will be unset.
+   * 
+ * + * string etag = 1; + * + * @return The etag. + */ + java.lang.String getEtag(); + /** + * + * + *
+   * An opaque tag indicating the current version of the `Policy`, used for
+   * concurrency control.
+   * This field is ignored if used in a `CreatePolicy` request.
+   * When the `Policy` is returned from either a `GetPolicy` or a
+   * `ListPolicies` request, this `etag` indicates the version of the
+   * current `Policy` to use when executing a read-modify-write loop.
+   * When the `Policy` is returned from a `GetEffectivePolicy` request, the
+   * `etag` will be unset.
+   * 
+ * + * string etag = 1; + * + * @return The bytes for etag. + */ + com.google.protobuf.ByteString getEtagBytes(); + + /** + * + * + *
+   * Output only. The time stamp this was previously updated. This
+   * represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
+   * made for that `Policy`.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + boolean hasUpdateTime(); + /** + * + * + *
+   * Output only. The time stamp this was previously updated. This
+   * represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
+   * made for that `Policy`.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + com.google.protobuf.Timestamp getUpdateTime(); + /** + * + * + *
+   * Output only. The time stamp this was previously updated. This
+   * represents the last time a call to `CreatePolicy` or `UpdatePolicy` was
+   * made for that `Policy`.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder(); + + /** + * + * + *
+   * Up to 10 PolicyRules are allowed.
+   * In Policies for boolean constraints, the following requirements apply:
+   *   - There must be one and only one PolicyRule where condition is unset.
+   *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+   *     of the PolicyRule without a condition.
+   *   - During policy evaluation, PolicyRules with conditions that are
+   *     true for a target resource take precedence.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + java.util.List getRulesList(); + /** + * + * + *
+   * Up to 10 PolicyRules are allowed.
+   * In Policies for boolean constraints, the following requirements apply:
+   *   - There must be one and only one PolicyRule where condition is unset.
+   *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+   *     of the PolicyRule without a condition.
+   *   - During policy evaluation, PolicyRules with conditions that are
+   *     true for a target resource take precedence.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRule getRules(int index); + /** + * + * + *
+   * Up to 10 PolicyRules are allowed.
+   * In Policies for boolean constraints, the following requirements apply:
+   *   - There must be one and only one PolicyRule where condition is unset.
+   *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+   *     of the PolicyRule without a condition.
+   *   - During policy evaluation, PolicyRules with conditions that are
+   *     true for a target resource take precedence.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + int getRulesCount(); + /** + * + * + *
+   * Up to 10 PolicyRules are allowed.
+   * In Policies for boolean constraints, the following requirements apply:
+   *   - There must be one and only one PolicyRule where condition is unset.
+   *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+   *     of the PolicyRule without a condition.
+   *   - During policy evaluation, PolicyRules with conditions that are
+   *     true for a target resource take precedence.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + java.util.List + getRulesOrBuilderList(); + /** + * + * + *
+   * Up to 10 PolicyRules are allowed.
+   * In Policies for boolean constraints, the following requirements apply:
+   *   - There must be one and only one PolicyRule where condition is unset.
+   *   - BooleanPolicyRules with conditions must set `enforced` to the opposite
+   *     of the PolicyRule without a condition.
+   *   - During policy evaluation, PolicyRules with conditions that are
+   *     true for a target resource take precedence.
+   * 
+ * + * repeated .google.cloud.orgpolicy.v2.PolicySpec.PolicyRule rules = 3; + */ + com.google.cloud.orgpolicy.v2.PolicySpec.PolicyRuleOrBuilder getRulesOrBuilder(int index); + + /** + * + * + *
+   * Determines the inheritance behavior for this `Policy`.
+   * If `inherit_from_parent` is true, PolicyRules set higher up in the
+   * hierarchy (up to the closest root) are inherited and present in the
+   * effective policy. If it is false, then no rules are inherited, and this
+   * Policy becomes the new root for evaluation.
+   * This field can be set only for Policies which configure list constraints.
+   * 
+ * + * bool inherit_from_parent = 4; + * + * @return The inheritFromParent. + */ + boolean getInheritFromParent(); + + /** + * + * + *
+   * Ignores policies set above this resource and restores the
+   * `constraint_default` enforcement behavior of the specific `Constraint` at
+   * this resource.
+   * This field can be set in policies for either list or boolean
+   * constraints. If set, `rules` must be empty and `inherit_from_parent`
+   * must be set to false.
+   * 
+ * + * bool reset = 5; + * + * @return The reset. + */ + boolean getReset(); +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ProjectName.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ProjectName.java new file mode 100644 index 0000000..4aca9fa --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/ProjectName.java @@ -0,0 +1,168 @@ +/* + * 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. + */ + +package com.google.cloud.orgpolicy.v2; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class ProjectName implements ResourceName { + private static final PathTemplate PROJECT = + PathTemplate.createWithoutUrlEncoding("projects/{project}"); + private volatile Map fieldValuesMap; + private final String project; + + @Deprecated + protected ProjectName() { + project = null; + } + + private ProjectName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + } + + public String getProject() { + return project; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static ProjectName of(String project) { + return newBuilder().setProject(project).build(); + } + + public static String format(String project) { + return newBuilder().setProject(project).build().toString(); + } + + public static ProjectName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT.validatedMatch( + formattedString, "ProjectName.parse: formattedString not in valid format"); + return of(matchMap.get("project")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (ProjectName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT.instantiate("project", project); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + ProjectName that = ((ProjectName) o); + return Objects.equals(this.project, that.project); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + return h; + } + + /** Builder for projects/{project}. */ + public static class Builder { + private String project; + + protected Builder() {} + + public String getProject() { + return project; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + private Builder(ProjectName projectName) { + project = projectName.project; + } + + public ProjectName build() { + return new ProjectName(this); + } + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/UpdatePolicyRequest.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/UpdatePolicyRequest.java new file mode 100644 index 0000000..02622a9 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/UpdatePolicyRequest.java @@ -0,0 +1,745 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +/** + * + * + *
+ * The request sent to the [UpdatePolicyRequest]
+ * [google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy] method.
+ * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.UpdatePolicyRequest} + */ +public final class UpdatePolicyRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.cloud.orgpolicy.v2.UpdatePolicyRequest) + UpdatePolicyRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use UpdatePolicyRequest.newBuilder() to construct. + private UpdatePolicyRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private UpdatePolicyRequest() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new UpdatePolicyRequest(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return this.unknownFields; + } + + private UpdatePolicyRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.cloud.orgpolicy.v2.Policy.Builder subBuilder = null; + if (policy_ != null) { + subBuilder = policy_.toBuilder(); + } + policy_ = + input.readMessage( + com.google.cloud.orgpolicy.v2.Policy.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(policy_); + policy_ = subBuilder.buildPartial(); + } + + break; + } + default: + { + if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_UpdatePolicyRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_UpdatePolicyRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest.class, + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest.Builder.class); + } + + public static final int POLICY_FIELD_NUMBER = 1; + private com.google.cloud.orgpolicy.v2.Policy policy_; + /** + * + * + *
+   * Required. `Policy` to update.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the policy field is set. + */ + @java.lang.Override + public boolean hasPolicy() { + return policy_ != null; + } + /** + * + * + *
+   * Required. `Policy` to update.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The policy. + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.Policy getPolicy() { + return policy_ == null ? com.google.cloud.orgpolicy.v2.Policy.getDefaultInstance() : policy_; + } + /** + * + * + *
+   * Required. `Policy` to update.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.cloud.orgpolicy.v2.PolicyOrBuilder getPolicyOrBuilder() { + return getPolicy(); + } + + 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 (policy_ != null) { + output.writeMessage(1, getPolicy()); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (policy_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getPolicy()); + } + size += unknownFields.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.cloud.orgpolicy.v2.UpdatePolicyRequest)) { + return super.equals(obj); + } + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest other = + (com.google.cloud.orgpolicy.v2.UpdatePolicyRequest) obj; + + if (hasPolicy() != other.hasPolicy()) return false; + if (hasPolicy()) { + if (!getPolicy().equals(other.getPolicy())) return false; + } + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasPolicy()) { + hash = (37 * hash) + POLICY_FIELD_NUMBER; + hash = (53 * hash) + getPolicy().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.cloud.orgpolicy.v2.UpdatePolicyRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.UpdatePolicyRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.UpdatePolicyRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.UpdatePolicyRequest 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.cloud.orgpolicy.v2.UpdatePolicyRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.cloud.orgpolicy.v2.UpdatePolicyRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.cloud.orgpolicy.v2.UpdatePolicyRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.UpdatePolicyRequest 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.cloud.orgpolicy.v2.UpdatePolicyRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.UpdatePolicyRequest 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.cloud.orgpolicy.v2.UpdatePolicyRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.cloud.orgpolicy.v2.UpdatePolicyRequest 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.cloud.orgpolicy.v2.UpdatePolicyRequest 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; + } + /** + * + * + *
+   * The request sent to the [UpdatePolicyRequest]
+   * [google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy] method.
+   * 
+ * + * Protobuf type {@code google.cloud.orgpolicy.v2.UpdatePolicyRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.cloud.orgpolicy.v2.UpdatePolicyRequest) + com.google.cloud.orgpolicy.v2.UpdatePolicyRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_UpdatePolicyRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_UpdatePolicyRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest.class, + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest.Builder.class); + } + + // Construct using com.google.cloud.orgpolicy.v2.UpdatePolicyRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {} + } + + @java.lang.Override + public Builder clear() { + super.clear(); + if (policyBuilder_ == null) { + policy_ = null; + } else { + policy_ = null; + policyBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.cloud.orgpolicy.v2.OrgPolicyProto + .internal_static_google_cloud_orgpolicy_v2_UpdatePolicyRequest_descriptor; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.UpdatePolicyRequest getDefaultInstanceForType() { + return com.google.cloud.orgpolicy.v2.UpdatePolicyRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.UpdatePolicyRequest build() { + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.cloud.orgpolicy.v2.UpdatePolicyRequest buildPartial() { + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest result = + new com.google.cloud.orgpolicy.v2.UpdatePolicyRequest(this); + if (policyBuilder_ == null) { + result.policy_ = policy_; + } else { + result.policy_ = policyBuilder_.build(); + } + onBuilt(); + return result; + } + + @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.cloud.orgpolicy.v2.UpdatePolicyRequest) { + return mergeFrom((com.google.cloud.orgpolicy.v2.UpdatePolicyRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.cloud.orgpolicy.v2.UpdatePolicyRequest other) { + if (other == com.google.cloud.orgpolicy.v2.UpdatePolicyRequest.getDefaultInstance()) + return this; + if (other.hasPolicy()) { + mergePolicy(other.getPolicy()); + } + this.mergeUnknownFields(other.unknownFields); + 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 { + com.google.cloud.orgpolicy.v2.UpdatePolicyRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = + (com.google.cloud.orgpolicy.v2.UpdatePolicyRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.cloud.orgpolicy.v2.Policy policy_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Policy, + com.google.cloud.orgpolicy.v2.Policy.Builder, + com.google.cloud.orgpolicy.v2.PolicyOrBuilder> + policyBuilder_; + /** + * + * + *
+     * Required. `Policy` to update.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the policy field is set. + */ + public boolean hasPolicy() { + return policyBuilder_ != null || policy_ != null; + } + /** + * + * + *
+     * Required. `Policy` to update.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The policy. + */ + public com.google.cloud.orgpolicy.v2.Policy getPolicy() { + if (policyBuilder_ == null) { + return policy_ == null + ? com.google.cloud.orgpolicy.v2.Policy.getDefaultInstance() + : policy_; + } else { + return policyBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. `Policy` to update.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setPolicy(com.google.cloud.orgpolicy.v2.Policy value) { + if (policyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + policy_ = value; + onChanged(); + } else { + policyBuilder_.setMessage(value); + } + + return this; + } + /** + * + * + *
+     * Required. `Policy` to update.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setPolicy(com.google.cloud.orgpolicy.v2.Policy.Builder builderForValue) { + if (policyBuilder_ == null) { + policy_ = builderForValue.build(); + onChanged(); + } else { + policyBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * + * + *
+     * Required. `Policy` to update.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergePolicy(com.google.cloud.orgpolicy.v2.Policy value) { + if (policyBuilder_ == null) { + if (policy_ != null) { + policy_ = + com.google.cloud.orgpolicy.v2.Policy.newBuilder(policy_) + .mergeFrom(value) + .buildPartial(); + } else { + policy_ = value; + } + onChanged(); + } else { + policyBuilder_.mergeFrom(value); + } + + return this; + } + /** + * + * + *
+     * Required. `Policy` to update.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearPolicy() { + if (policyBuilder_ == null) { + policy_ = null; + onChanged(); + } else { + policy_ = null; + policyBuilder_ = null; + } + + return this; + } + /** + * + * + *
+     * Required. `Policy` to update.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.cloud.orgpolicy.v2.Policy.Builder getPolicyBuilder() { + + onChanged(); + return getPolicyFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. `Policy` to update.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.cloud.orgpolicy.v2.PolicyOrBuilder getPolicyOrBuilder() { + if (policyBuilder_ != null) { + return policyBuilder_.getMessageOrBuilder(); + } else { + return policy_ == null + ? com.google.cloud.orgpolicy.v2.Policy.getDefaultInstance() + : policy_; + } + } + /** + * + * + *
+     * Required. `Policy` to update.
+     * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Policy, + com.google.cloud.orgpolicy.v2.Policy.Builder, + com.google.cloud.orgpolicy.v2.PolicyOrBuilder> + getPolicyFieldBuilder() { + if (policyBuilder_ == null) { + policyBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.cloud.orgpolicy.v2.Policy, + com.google.cloud.orgpolicy.v2.Policy.Builder, + com.google.cloud.orgpolicy.v2.PolicyOrBuilder>( + getPolicy(), getParentForChildren(), isClean()); + policy_ = null; + } + return policyBuilder_; + } + + @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.cloud.orgpolicy.v2.UpdatePolicyRequest) + } + + // @@protoc_insertion_point(class_scope:google.cloud.orgpolicy.v2.UpdatePolicyRequest) + private static final com.google.cloud.orgpolicy.v2.UpdatePolicyRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.cloud.orgpolicy.v2.UpdatePolicyRequest(); + } + + public static com.google.cloud.orgpolicy.v2.UpdatePolicyRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public UpdatePolicyRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new UpdatePolicyRequest(input, extensionRegistry); + } + }; + + 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.cloud.orgpolicy.v2.UpdatePolicyRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/UpdatePolicyRequestOrBuilder.java b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/UpdatePolicyRequestOrBuilder.java new file mode 100644 index 0000000..4342453 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/java/com/google/cloud/orgpolicy/v2/UpdatePolicyRequestOrBuilder.java @@ -0,0 +1,63 @@ +/* + * 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/cloud/orgpolicy/v2/orgpolicy.proto + +package com.google.cloud.orgpolicy.v2; + +public interface UpdatePolicyRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.cloud.orgpolicy.v2.UpdatePolicyRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. `Policy` to update.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the policy field is set. + */ + boolean hasPolicy(); + /** + * + * + *
+   * Required. `Policy` to update.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The policy. + */ + com.google.cloud.orgpolicy.v2.Policy getPolicy(); + /** + * + * + *
+   * Required. `Policy` to update.
+   * 
+ * + * .google.cloud.orgpolicy.v2.Policy policy = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.cloud.orgpolicy.v2.PolicyOrBuilder getPolicyOrBuilder(); +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/proto/google/cloud/orgpolicy/v2/constraint.proto b/proto-google-cloud-orgpolicy-v2/src/main/proto/google/cloud/orgpolicy/v2/constraint.proto new file mode 100644 index 0000000..a9051ac --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/proto/google/cloud/orgpolicy/v2/constraint.proto @@ -0,0 +1,127 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.orgpolicy.v2; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.OrgPolicy.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/orgpolicy/v2;orgpolicy"; +option java_multiple_files = true; +option java_outer_classname = "ConstraintProto"; +option java_package = "com.google.cloud.orgpolicy.v2"; +option php_namespace = "Google\\Cloud\\OrgPolicy\\V2"; +option ruby_package = "Google::Cloud::OrgPolicy::V2"; + +// A `constraint` describes a way to restrict resource's configuration. For +// example, you could enforce a constraint that controls which cloud services +// can be activated across an organization, or whether a Compute Engine instance +// can have serial port connections established. `Constraints` can be configured +// by the organization's policy adminstrator to fit the needs of the organzation +// by setting a `policy` that includes `constraints` at different locations in +// the organization's resource hierarchy. Policies are inherited down the +// resource hierarchy from higher levels, but can also be overridden. For +// details about the inheritance rules please read about +// [`policies`][google.cloud.OrgPolicy.v2.Policy]. +// +// `Constraints` have a default behavior determined by the `constraint_default` +// field, which is the enforcement behavior that is used in the absence of a +// `policy` being defined or inherited for the resource in question. +message Constraint { + option (google.api.resource) = { + type: "orgpolicy.googleapis.com/Constraint" + pattern: "projects/{project}/constraints/{constraint}" + pattern: "folders/{folder}/constraints/{constraint}" + pattern: "organizations/{organization}/constraints/{constraint}" + }; + + // A `Constraint` that allows or disallows a list of string values, which are + // configured by an Organization's policy administrator with a `Policy`. + message ListConstraint { + // Indicates whether values grouped into categories can be used in + // `Policy.allowed_values` and `Policy.denied_values`. For example, + // `"in:Python"` would match any value in the 'Python' group. + bool supports_in = 1; + + // Indicates whether subtrees of Cloud Resource Manager resource hierarchy + // can be used in `Policy.allowed_values` and `Policy.denied_values`. For + // example, `"under:folders/123"` would match any resource under the + // 'folders/123' folder. + bool supports_under = 2; + } + + // A `Constraint` that is either enforced or not. + // + // For example a constraint `constraints/compute.disableSerialPortAccess`. + // If it is enforced on a VM instance, serial port connections will not be + // opened to that instance. + message BooleanConstraint { + + } + + // Specifies the default behavior in the absence of any `Policy` for the + // `Constraint`. This must not be `CONSTRAINT_DEFAULT_UNSPECIFIED`. + // + // Immutable after creation. + enum ConstraintDefault { + // This is only used for distinguishing unset values and should never be + // used. + CONSTRAINT_DEFAULT_UNSPECIFIED = 0; + + // Indicate that all values are allowed for list constraints. + // Indicate that enforcement is off for boolean constraints. + ALLOW = 1; + + // Indicate that all values are denied for list constraints. + // Indicate that enforcement is on for boolean constraints. + DENY = 2; + } + + // Immutable. The resource name of the Constraint. Must be in one of + // the following forms: + // * `projects/{project_number}/constraints/{constraint_name}` + // * `folders/{folder_id}/constraints/{constraint_name}` + // * `organizations/{organization_id}/constraints/{constraint_name}` + // + // For example, "/projects/123/constraints/compute.disableSerialPortAccess". + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // The human readable name. + // + // Mutable. + string display_name = 2; + + // Detailed description of what this `Constraint` controls as well as how and + // where it is enforced. + // + // Mutable. + string description = 3; + + // The evaluation behavior of this constraint in the absence of 'Policy'. + ConstraintDefault constraint_default = 4; + + // The type of restrictions for this `Constraint`. + // + // Immutable after creation. + oneof constraint_type { + // Defines this constraint as being a ListConstraint. + ListConstraint list_constraint = 5; + + // Defines this constraint as being a BooleanConstraint. + BooleanConstraint boolean_constraint = 6; + } +} diff --git a/proto-google-cloud-orgpolicy-v2/src/main/proto/google/cloud/orgpolicy/v2/orgpolicy.proto b/proto-google-cloud-orgpolicy-v2/src/main/proto/google/cloud/orgpolicy/v2/orgpolicy.proto new file mode 100644 index 0000000..2b2bb47 --- /dev/null +++ b/proto-google-cloud-orgpolicy-v2/src/main/proto/google/cloud/orgpolicy/v2/orgpolicy.proto @@ -0,0 +1,479 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.cloud.orgpolicy.v2; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/orgpolicy/v2/constraint.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/expr.proto"; + +option csharp_namespace = "Google.Cloud.OrgPolicy.V2"; +option go_package = "google.golang.org/genproto/googleapis/cloud/orgpolicy/v2;orgpolicy"; +option java_multiple_files = true; +option java_outer_classname = "OrgPolicyProto"; +option java_package = "com.google.cloud.orgpolicy.v2"; +option php_namespace = "Google\\Cloud\\OrgPolicy\\V2"; +option ruby_package = "Google::Cloud::OrgPolicy::V2"; + +// An interface for managing organization policies. +// +// The Cloud Org Policy service provides a simple mechanism for organizations to +// restrict the allowed configurations across their entire Cloud Resource +// hierarchy. +// +// You can use a `policy` to configure restrictions in Cloud resources. For +// example, you can enforce a `policy` that restricts which Google +// Cloud Platform APIs can be activated in a certain part of your resource +// hierarchy, or prevents serial port access to VM instances in a particular +// folder. +// +// `Policies` are inherited down through the resource hierarchy. A `policy` +// applied to a parent resource automatically applies to all its child resources +// unless overridden with a `policy` lower in the hierarchy. +// +// A `constraint` defines an aspect of a resource's configuration that can be +// controlled by an organization's policy administrator. `Policies` are a +// collection of `constraints` that defines their allowable configuration on a +// particular resource and its child resources. +service OrgPolicy { + option (google.api.default_host) = "orgpolicy.googleapis.com"; + option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform"; + + // Lists `Constraints` that could be applied on the specified resource. + rpc ListConstraints(ListConstraintsRequest) returns (ListConstraintsResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*}/constraints" + additional_bindings { + get: "/v2/{parent=folders/*}/constraints" + } + additional_bindings { + get: "/v2/{parent=organizations/*}/constraints" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Retrieves all of the `Policies` that exist on a particular resource. + rpc ListPolicies(ListPoliciesRequest) returns (ListPoliciesResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*}/policies" + additional_bindings { + get: "/v2/{parent=folders/*}/policies" + } + additional_bindings { + get: "/v2/{parent=organizations/*}/policies" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a `Policy` on a resource. + // + // If no `Policy` is set on the resource, NOT_FOUND is returned. The + // `etag` value can be used with `UpdatePolicy()` to update a + // `Policy` during read-modify-write. + rpc GetPolicy(GetPolicyRequest) returns (Policy) { + option (google.api.http) = { + get: "/v2/{name=projects/*/policies/*}" + additional_bindings { + get: "/v2/{name=folders/*/policies/*}" + } + additional_bindings { + get: "/v2/{name=organizations/*/policies/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Gets the effective `Policy` on a resource. This is the result of merging + // `Policies` in the resource hierarchy and evaluating conditions. The + // returned `Policy` will not have an `etag` or `condition` set because it is + // a computed `Policy` across multiple resources. + // Subtrees of Resource Manager resource hierarchy with 'under:' prefix will + // not be expanded. + rpc GetEffectivePolicy(GetEffectivePolicyRequest) returns (Policy) { + option (google.api.http) = { + get: "/v2/{name=projects/*/policies/*}:getEffectivePolicy" + additional_bindings { + get: "/v2/{name=folders/*/policies/*}:getEffectivePolicy" + } + additional_bindings { + get: "/v2/{name=organizations/*/policies/*}:getEffectivePolicy" + } + }; + option (google.api.method_signature) = "name"; + } + + // Creates a Policy. + // + // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + // constraint does not exist. + // Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the + // policy already exists on the given Cloud resource. + rpc CreatePolicy(CreatePolicyRequest) returns (Policy) { + option (google.api.http) = { + post: "/v2/{parent=projects/*}/policies" + body: "policy" + additional_bindings { + post: "/v2/{parent=folders/*}/policies" + body: "policy" + } + additional_bindings { + post: "/v2/{parent=organizations/*}/policies" + body: "policy" + } + }; + option (google.api.method_signature) = "parent,policy"; + } + + // Updates a Policy. + // + // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + // constraint or the policy do not exist. + // Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag + // supplied in the request does not match the persisted etag of the policy + // + // Note: the supplied policy will perform a full overwrite of all + // fields. + rpc UpdatePolicy(UpdatePolicyRequest) returns (Policy) { + option (google.api.http) = { + patch: "/v2/{policy.name=projects/*/policies/*}" + body: "policy" + additional_bindings { + patch: "/v2/{policy.name=folders/*/policies/*}" + body: "policy" + } + additional_bindings { + patch: "/v2/{policy.name=organizations/*/policies/*}" + body: "policy" + } + }; + option (google.api.method_signature) = "policy"; + } + + // Deletes a Policy. + // + // Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the + // constraint or Org Policy does not exist. + rpc DeletePolicy(DeletePolicyRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/policies/*}" + additional_bindings { + delete: "/v2/{name=folders/*/policies/*}" + } + additional_bindings { + delete: "/v2/{name=organizations/*/policies/*}" + } + }; + option (google.api.method_signature) = "name"; + } +} + +// Defines a Cloud Organization `Policy` which is used to specify `Constraints` +// for configurations of Cloud Platform resources. +message Policy { + option (google.api.resource) = { + type: "orgpolicy.googleapis.com/Policy" + pattern: "projects/{project}/policies/{policy}" + pattern: "folders/{folder}/policies/{policy}" + pattern: "organizations/{organization}/policies/{policy}" + }; + + // Immutable. The resource name of the Policy. Must be one of the following + // forms, where constraint_name is the name of the constraint which this + // Policy configures: + // * `projects/{project_number}/policies/{constraint_name}` + // * `folders/{folder_id}/policies/{constraint_name}` + // * `organizations/{organization_id}/policies/{constraint_name}` + // + // For example, "projects/123/policies/compute.disableSerialPortAccess". + // + // Note: `projects/{project_id}/policies/{constraint_name}` is also an + // acceptable name for API requests, but responses will return the name using + // the equivalent project number. + string name = 1 [(google.api.field_behavior) = IMMUTABLE]; + + // Basic information about the Organization Policy. + PolicySpec spec = 2; + + // An alternate policy configuration that will be used instead of the baseline + // policy configurations as determined by the launch. + // Currently the only way the launch can trigger the alternate configuration + // is via dry-run/darklaunch. + AlternatePolicySpec alternate = 3; +} + +// Similar to PolicySpec but with an extra 'launch' field for launch reference. +// The PolicySpec here is specific for dry-run/darklaunch. +message AlternatePolicySpec { + // Reference to the launch that will be used while audit logging and to + // control the launch. + // Should be set only in the alternate policy. + string launch = 1; + + // Specify `Constraint` for configurations of Cloud Platform resources. + PolicySpec spec = 2; +} + +// Defines a Cloud Organization `PolicySpec` which is used to specify +// `Constraints` for configurations of Cloud Platform resources. +message PolicySpec { + // A rule used to express this policy. + message PolicyRule { + // A message that holds specific allowed and denied values. + // This message can define specific values and subtrees of Cloud Resource + // Manager resource hierarchy (`Organizations`, `Folders`, `Projects`) that + // are allowed or denied. This is achieved by using the `under:` and + // optional `is:` prefixes. + // The `under:` prefix is used to denote resource subtree values. + // The `is:` prefix is used to denote specific values, and is required only + // if the value contains a ":". Values prefixed with "is:" are treated the + // same as values with no prefix. + // Ancestry subtrees must be in one of the following formats: + // - "projects/", e.g. "projects/tokyo-rain-123" + // - "folders/", e.g. "folders/1234" + // - "organizations/", e.g. "organizations/1234" + // The `supports_under` field of the associated `Constraint` defines + // whether ancestry prefixes can be used. + message StringValues { + // List of values allowed at this resource. + repeated string allowed_values = 1; + + // List of values denied at this resource. + repeated string denied_values = 2; + } + + oneof kind { + // List of values to be used for this PolicyRule. This field can be set + // only in Policies for list constraints. + StringValues values = 1; + + // Setting this to true means that all values are allowed. This field can + // be set only in Policies for list constraints. + bool allow_all = 2; + + // Setting this to true means that all values are denied. This field can + // be set only in Policies for list constraints. + bool deny_all = 3; + + // If `true`, then the `Policy` is enforced. If `false`, then any + // configuration is acceptable. + // This field can be set only in Policies for boolean constraints. + bool enforce = 4; + } + + // A condition which determines whether this rule is used + // in the evaluation of the policy. When set, the `expression` field in + // the `Expr' must include from 1 to 10 subexpressions, joined by the "||" + // or "&&" operators. Each subexpression must be of the form + // "resource.matchLabels(key_name, value_name)", + // where key_name and value_name are the resource names for Label Keys + // and Values. These names are available from the Label Manager Service. An + // example expression is: + // "resource.matchLabels('labelKeys/123, 'labelValues/456')". + google.type.Expr condition = 5; + } + + // An opaque tag indicating the current version of the `Policy`, used for + // concurrency control. + // + // This field is ignored if used in a `CreatePolicy` request. + // + // When the `Policy` is returned from either a `GetPolicy` or a + // `ListPolicies` request, this `etag` indicates the version of the + // current `Policy` to use when executing a read-modify-write loop. + // + // When the `Policy` is returned from a `GetEffectivePolicy` request, the + // `etag` will be unset. + string etag = 1; + + // Output only. The time stamp this was previously updated. This + // represents the last time a call to `CreatePolicy` or `UpdatePolicy` was + // made for that `Policy`. + google.protobuf.Timestamp update_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Up to 10 PolicyRules are allowed. + // + // In Policies for boolean constraints, the following requirements apply: + // - There must be one and only one PolicyRule where condition is unset. + // - BooleanPolicyRules with conditions must set `enforced` to the opposite + // of the PolicyRule without a condition. + // - During policy evaluation, PolicyRules with conditions that are + // true for a target resource take precedence. + repeated PolicyRule rules = 3; + + // Determines the inheritance behavior for this `Policy`. + // + // If `inherit_from_parent` is true, PolicyRules set higher up in the + // hierarchy (up to the closest root) are inherited and present in the + // effective policy. If it is false, then no rules are inherited, and this + // Policy becomes the new root for evaluation. + // This field can be set only for Policies which configure list constraints. + bool inherit_from_parent = 4; + + // Ignores policies set above this resource and restores the + // `constraint_default` enforcement behavior of the specific `Constraint` at + // this resource. + // This field can be set in policies for either list or boolean + // constraints. If set, `rules` must be empty and `inherit_from_parent` + // must be set to false. + bool reset = 5; +} + +// The request sent to the [ListConstraints] +// [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method. +message ListConstraintsRequest { + // Required. The Cloud resource that parents the constraint. Must be in one of the + // following forms: + // * `projects/{project_number}` + // * `projects/{project_id}` + // * `folders/{folder_id}` + // * `organizations/{organization_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "orgpolicy.googleapis.com/Constraint" + } + ]; + + // Size of the pages to be returned. This is currently unsupported and will + // be ignored. The server may at any point start using this field to limit + // page size. + int32 page_size = 2; + + // Page token used to retrieve the next page. This is currently unsupported + // and will be ignored. The server may at any point start using this field. + string page_token = 3; +} + +// The response returned from the [ListConstraints] +// [google.cloud.orgpolicy.v2.OrgPolicy.ListConstraints] method. +message ListConstraintsResponse { + // The collection of constraints that are available on the targeted resource. + repeated Constraint constraints = 1; + + // Page token used to retrieve the next page. This is currently not used. + string next_page_token = 2; +} + +// The request sent to the [ListPolicies] +// [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method. +message ListPoliciesRequest { + // Required. The target Cloud resource that parents the set of constraints and policies + // that will be returned from this call. Must be in one of the following + // forms: + // * `projects/{project_number}` + // * `projects/{project_id}` + // * `folders/{folder_id}` + // * `organizations/{organization_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "orgpolicy.googleapis.com/Policy" + } + ]; + + // Size of the pages to be returned. This is currently unsupported and will + // be ignored. The server may at any point start using this field to limit + // page size. + int32 page_size = 2; + + // Page token used to retrieve the next page. This is currently unsupported + // and will be ignored. The server may at any point start using this field. + string page_token = 3; +} + +// The response returned from the [ListPolicies] +// [google.cloud.orgpolicy.v2.OrgPolicy.ListPolicies] method. It will be empty +// if no `Policies` are set on the resource. +message ListPoliciesResponse { + // All `Policies` that exist on the resource. It will be empty if no + // `Policies` are set. + repeated Policy policies = 1; + + // Page token used to retrieve the next page. This is currently not used, but + // the server may at any point start supplying a valid token. + string next_page_token = 2; +} + +// The request sent to the [GetPolicy] +// [google.cloud.orgpolicy.v2.OrgPolicy.GetPolicy] method. +message GetPolicyRequest { + // Required. Resource name of the policy. See `Policy` for naming requirements. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "orgpolicy.googleapis.com/Policy" + } + ]; +} + +// The request sent to the [GetEffectivePolicy] +// [google.cloud.orgpolicy.v2.OrgPolicy.GetEffectivePolicy] method. +message GetEffectivePolicyRequest { + // Required. The effective policy to compute. See `Policy` for naming rules. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "orgpolicy.googleapis.com/Policy" + } + ]; +} + +// The request sent to the [CreatePolicyRequest] +// [google.cloud.orgpolicy.v2.OrgPolicy.CreatePolicy] method. +message CreatePolicyRequest { + // Required. The Cloud resource that will parent the new Policy. Must be in one of the + // following forms: + // * `projects/{project_number}` + // * `projects/{project_id}` + // * `folders/{folder_id}` + // * `organizations/{organization_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "orgpolicy.googleapis.com/Policy" + } + ]; + + // Required. `Policy` to create. + Policy policy = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// The request sent to the [UpdatePolicyRequest] +// [google.cloud.orgpolicy.v2.OrgPolicy.UpdatePolicy] method. +message UpdatePolicyRequest { + // Required. `Policy` to update. + Policy policy = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The request sent to the [DeletePolicy] +// [google.cloud.orgpolicy.v2.OrgPolicy.DeletePolicy] method. +message DeletePolicyRequest { + // Required. Name of the policy to delete. + // See `Policy` for naming rules. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "orgpolicy.googleapis.com/Policy" + } + ]; +} diff --git a/synth.py b/synth.py index 536f1f4..37edad3 100644 --- a/synth.py +++ b/synth.py @@ -23,24 +23,29 @@ gapic = gcp.GAPICBazel() -for version in versions: - library = gapic.java_library( +library = gapic.java_library( service=service, - version=version, - proto_path=f'google/cloud/orgpolicy/{version}', - bazel_target=f'//google/cloud/orgpolicy/{version}:google-cloud-orgpolicy-{version}-java', - ) - library = library / f"google-cloud-orgpolicy-{version}-java" - java.fix_proto_headers(library / f"proto-google-cloud-orgpolicy-{version}-java") - s.copy( - [library / f"proto-google-cloud-orgpolicy-{version}-java/src"], - f"proto-google-cloud-orgpolicy-{version}/src", + version='v1', + proto_path=f'google/cloud/orgpolicy/v1', + bazel_target=f'//google/cloud/orgpolicy/v1:google-cloud-orgpolicy-v1-java', +) +library = library / f"google-cloud-orgpolicy-v1-java" +java.fix_proto_headers(library / f"proto-google-cloud-orgpolicy-v1-java") +s.copy( + [library / f"proto-google-cloud-orgpolicy-v1-java/src"], + f"proto-google-cloud-orgpolicy-v1/src", required=True, - ) - java.format_code(f"proto-google-cloud-orgpolicy-{version}/src") +) +java.format_code(f"proto-google-cloud-orgpolicy-v1/src") + +java.pregenerated_library( + service=service, + version='v2', + path=f'google/cloud/{service}/v2', +) java.common_templates(excludes=[ - 'README.md', - 'samples/*', - '.github/workflows/samples.yaml', + 'README.md', + 'samples/*', + '.github/workflows/samples.yaml', ]) diff --git a/versions.txt b/versions.txt index 89cebb2..5d98f29 100644 --- a/versions.txt +++ b/versions.txt @@ -1,4 +1,7 @@ # Format: # module:released-version:current-version +google-cloud-orgpolicy:1.0.11:1.0.12-SNAPSHOT proto-google-cloud-orgpolicy-v1:1.0.11:1.0.12-SNAPSHOT +proto-google-cloud-orgpolicy-v2:1.0.11:1.0.12-SNAPSHOT +grpc-google-cloud-orgpolicy-v2:1.0.11:1.0.12-SNAPSHOT