From 77490c8557a6ea588789afc286765402ed0df0eb Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 25 Aug 2022 21:12:17 +0000 Subject: [PATCH] feat: Update the public IAM Deny v2beta API (#412) - [ ] Regenerate this pull request now. BREAKING CHANGE: remove google.api.resource_reference annotations PiperOrigin-RevId: 468493946 Source-Link: https://github.com/googleapis/googleapis/commit/fb22ccd6ce5b8d66790d71b50a3b6fe69fdc3ab0 Source-Link: https://github.com/googleapis/googleapis-gen/commit/fd818d2d7b17ade74aa84d7384e13cbe40ba320d Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZmQ4MThkMmQ3YjE3YWRlNzRhYTg0ZDczODRlMTNjYmU0MGJhMzIwZCJ9 --- java-iam/google-iam-policy/pom.xml | 16 + .../com/google/iam/v2beta/PoliciesClient.java | 125 ++--- .../google/iam/v2beta/PoliciesSettings.java | 23 +- .../com/google/iam/v2beta/gapic_metadata.json | 4 +- .../com/google/iam/v2beta/package-info.java | 2 +- .../stub/HttpJsonPoliciesCallableFactory.java | 105 ++++ .../iam/v2beta/stub/HttpJsonPoliciesStub.java | 474 ++++++++++++++++++ .../google/iam/v2beta/stub/PoliciesStub.java | 6 +- .../iam/v2beta/stub/PoliciesStubSettings.java | 52 +- .../v2beta/PoliciesClientHttpJsonTest.java | 393 +++++++++++++++ .../google/iam/v2beta/PoliciesClientTest.java | 114 +---- java-iam/proto-google-iam-v2beta/pom.xml | 8 - .../iam/v2beta/DeletePolicyRequest.java | 28 +- .../v2beta/DeletePolicyRequestOrBuilder.java | 8 +- .../java/com/google/iam/v2beta/DenyRule.java | 26 +- .../google/iam/v2beta/DenyRuleOrBuilder.java | 8 +- .../com/google/iam/v2beta/DenyRuleProto.java | 8 +- .../google/iam/v2beta/GetPolicyRequest.java | 28 +- .../iam/v2beta/GetPolicyRequestOrBuilder.java | 8 +- .../com/google/iam/v2beta/PolicyName.java | 168 ------- .../com/google/iam/v2beta/PolicyProto.java | 116 ++--- .../main/proto/google/iam/v2beta/deny.proto | 4 +- .../main/proto/google/iam/v2beta/policy.proto | 22 +- 23 files changed, 1215 insertions(+), 531 deletions(-) create mode 100644 java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/HttpJsonPoliciesCallableFactory.java create mode 100644 java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/HttpJsonPoliciesStub.java create mode 100644 java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/PoliciesClientHttpJsonTest.java delete mode 100644 java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/PolicyName.java diff --git a/java-iam/google-iam-policy/pom.xml b/java-iam/google-iam-policy/pom.xml index ea654d67d7c3..d720bd06c0b7 100644 --- a/java-iam/google-iam-policy/pom.xml +++ b/java-iam/google-iam-policy/pom.xml @@ -58,6 +58,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -77,12 +81,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesClient.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesClient.java index 582c71e42cd2..8cc89dce0128 100644 --- a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesClient.java +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.iam.v2beta.stub.PoliciesStub; import com.google.iam.v2beta.stub.PoliciesStubSettings; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; @@ -48,7 +48,7 @@ * // This snippet has been automatically generated for illustrative purposes only. * // It may require modifications to work in your environment. * try (PoliciesClient policiesClient = PoliciesClient.create()) { - * PolicyName name = PolicyName.of("[POLICY]"); + * String name = "name3373707"; * Policy response = policiesClient.getPolicy(name); * } * } @@ -101,6 +101,20 @@ * PoliciesClient policiesClient = PoliciesClient.create(policiesSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * PoliciesSettings policiesSettings =
+ *     PoliciesSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             PoliciesSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * PoliciesClient policiesClient = PoliciesClient.create(policiesSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -108,7 +122,8 @@ public class PoliciesClient implements BackgroundResource { private final PoliciesSettings settings; private final PoliciesStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of PoliciesClient with default settings. */ public static final PoliciesClient create() throws IOException { @@ -138,13 +153,17 @@ public static final PoliciesClient create(PoliciesStub stub) { protected PoliciesClient(PoliciesSettings settings) throws IOException { this.settings = settings; this.stub = ((PoliciesStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected PoliciesClient(PoliciesStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final PoliciesSettings getSettings() { @@ -159,10 +178,19 @@ public PoliciesStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Retrieves the policies of the specified kind that are attached to a resource. @@ -305,37 +333,7 @@ public final UnaryCallable listPolici * // This snippet has been automatically generated for illustrative purposes only. * // It may require modifications to work in your environment. * try (PoliciesClient policiesClient = PoliciesClient.create()) { - * PolicyName name = PolicyName.of("[POLICY]"); - * Policy response = policiesClient.getPolicy(name); - * } - * } - * - * @param name Required. The resource name of the policy to retrieve. Format: - * `policies/{attachment_point}/denypolicies/{policy_id}` - *

Use the URL-encoded full resource name, which means that the forward-slash character, - * `/`, must be written as `%2F`. For example, - * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`. - *

For organizations and folders, use the numeric ID in the full resource name. For - * projects, you can use the alphanumeric or the numeric ID. - * @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. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated for illustrative purposes only.
-   * // It may require modifications to work in your environment.
-   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
-   *   String name = PolicyName.of("[POLICY]").toString();
+   *   String name = "name3373707";
    *   Policy response = policiesClient.getPolicy(name);
    * }
    * }
@@ -364,8 +362,7 @@ public final Policy getPolicy(String name) { * // This snippet has been automatically generated for illustrative purposes only. * // It may require modifications to work in your environment. * try (PoliciesClient policiesClient = PoliciesClient.create()) { - * GetPolicyRequest request = - * GetPolicyRequest.newBuilder().setName(PolicyName.of("[POLICY]").toString()).build(); + * GetPolicyRequest request = GetPolicyRequest.newBuilder().setName("name3373707").build(); * Policy response = policiesClient.getPolicy(request); * } * } @@ -387,8 +384,7 @@ public final Policy getPolicy(GetPolicyRequest request) { * // This snippet has been automatically generated for illustrative purposes only. * // It may require modifications to work in your environment. * try (PoliciesClient policiesClient = PoliciesClient.create()) { - * GetPolicyRequest request = - * GetPolicyRequest.newBuilder().setName(PolicyName.of("[POLICY]").toString()).build(); + * GetPolicyRequest request = GetPolicyRequest.newBuilder().setName("name3373707").build(); * ApiFuture future = policiesClient.getPolicyCallable().futureCall(request); * // Do something. * Policy response = future.get(); @@ -630,37 +626,7 @@ public final UnaryCallable updatePolicyCallable( * // This snippet has been automatically generated for illustrative purposes only. * // It may require modifications to work in your environment. * try (PoliciesClient policiesClient = PoliciesClient.create()) { - * PolicyName name = PolicyName.of("[POLICY]"); - * Policy response = policiesClient.deletePolicyAsync(name).get(); - * } - * } - * - * @param name Required. The resource name of the policy to delete. Format: - * `policies/{attachment_point}/denypolicies/{policy_id}` - *

Use the URL-encoded full resource name, which means that the forward-slash character, - * `/`, must be written as `%2F`. For example, - * `policies/cloudresourcemanager.googleapis.com%2Fprojects%2Fmy-project/denypolicies/my-policy`. - *

For organizations and folders, use the numeric ID in the full resource name. For - * projects, you can use the alphanumeric or the numeric ID. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final OperationFuture deletePolicyAsync(PolicyName name) { - DeletePolicyRequest request = - DeletePolicyRequest.newBuilder().setName(name == null ? null : name.toString()).build(); - return deletePolicyAsync(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD. - /** - * Deletes a policy. This action is permanent. - * - *

Sample code: - * - *

{@code
-   * // This snippet has been automatically generated for illustrative purposes only.
-   * // It may require modifications to work in your environment.
-   * try (PoliciesClient policiesClient = PoliciesClient.create()) {
-   *   String name = PolicyName.of("[POLICY]").toString();
+   *   String name = "name3373707";
    *   Policy response = policiesClient.deletePolicyAsync(name).get();
    * }
    * }
@@ -690,10 +656,7 @@ public final OperationFuture deletePolicyAsync( * // It may require modifications to work in your environment. * try (PoliciesClient policiesClient = PoliciesClient.create()) { * DeletePolicyRequest request = - * DeletePolicyRequest.newBuilder() - * .setName(PolicyName.of("[POLICY]").toString()) - * .setEtag("etag3123477") - * .build(); + * DeletePolicyRequest.newBuilder().setName("name3373707").setEtag("etag3123477").build(); * Policy response = policiesClient.deletePolicyAsync(request).get(); * } * } @@ -717,10 +680,7 @@ public final OperationFuture deletePolicyAsync( * // It may require modifications to work in your environment. * try (PoliciesClient policiesClient = PoliciesClient.create()) { * DeletePolicyRequest request = - * DeletePolicyRequest.newBuilder() - * .setName(PolicyName.of("[POLICY]").toString()) - * .setEtag("etag3123477") - * .build(); + * DeletePolicyRequest.newBuilder().setName("name3373707").setEtag("etag3123477").build(); * OperationFuture future = * policiesClient.deletePolicyOperationCallable().futureCall(request); * // Do something. @@ -744,10 +704,7 @@ public final OperationFuture deletePolicyAsync( * // It may require modifications to work in your environment. * try (PoliciesClient policiesClient = PoliciesClient.create()) { * DeletePolicyRequest request = - * DeletePolicyRequest.newBuilder() - * .setName(PolicyName.of("[POLICY]").toString()) - * .setEtag("etag3123477") - * .build(); + * DeletePolicyRequest.newBuilder().setName("name3373707").setEtag("etag3123477").build(); * ApiFuture future = policiesClient.deletePolicyCallable().futureCall(request); * // Do something. * Operation response = future.get(); diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesSettings.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesSettings.java index 82677a3faa2b..1f9de494ef34 100644 --- a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesSettings.java +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/PoliciesSettings.java @@ -23,6 +23,7 @@ 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.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -141,11 +142,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return PoliciesStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return PoliciesStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return PoliciesStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return PoliciesStubSettings.defaultTransportChannelProvider(); } @@ -155,11 +163,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return PoliciesStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -197,6 +211,11 @@ private static Builder createDefault() { return new Builder(PoliciesStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(PoliciesStubSettings.newHttpJsonBuilder()); + } + public PoliciesStubSettings.Builder getStubSettingsBuilder() { return ((PoliciesStubSettings.Builder) getStubSettings()); } diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/gapic_metadata.json b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/gapic_metadata.json index a68bf9249a81..54136f109a7b 100644 --- a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/gapic_metadata.json +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/gapic_metadata.json @@ -14,10 +14,10 @@ "methods": ["createPolicyAsync", "createPolicyAsync", "createPolicyOperationCallable", "createPolicyCallable"] }, "DeletePolicy": { - "methods": ["deletePolicyAsync", "deletePolicyAsync", "deletePolicyAsync", "deletePolicyOperationCallable", "deletePolicyCallable"] + "methods": ["deletePolicyAsync", "deletePolicyAsync", "deletePolicyOperationCallable", "deletePolicyCallable"] }, "GetPolicy": { - "methods": ["getPolicy", "getPolicy", "getPolicy", "getPolicyCallable"] + "methods": ["getPolicy", "getPolicy", "getPolicyCallable"] }, "ListPolicies": { "methods": ["listPolicies", "listPolicies", "listPoliciesPagedCallable", "listPoliciesCallable"] diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/package-info.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/package-info.java index 1a342b28dcaa..f8f79438d286 100644 --- a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/package-info.java +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/package-info.java @@ -29,7 +29,7 @@ * // This snippet has been automatically generated for illustrative purposes only. * // It may require modifications to work in your environment. * try (PoliciesClient policiesClient = PoliciesClient.create()) { - * PolicyName name = PolicyName.of("[POLICY]"); + * String name = "name3373707"; * Policy response = policiesClient.getPolicy(name); * } * } diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/HttpJsonPoliciesCallableFactory.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/HttpJsonPoliciesCallableFactory.java new file mode 100644 index 000000000000..bc1cb4da7324 --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/HttpJsonPoliciesCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.iam.v2beta.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +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.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Policies service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonPoliciesCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/HttpJsonPoliciesStub.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/HttpJsonPoliciesStub.java new file mode 100644 index 000000000000..1329c96f57bf --- /dev/null +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/HttpJsonPoliciesStub.java @@ -0,0 +1,474 @@ +/* + * Copyright 2022 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.iam.v2beta.stub; + +import static com.google.iam.v2beta.PoliciesClient.ListPoliciesPagedResponse; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.iam.v2beta.CreatePolicyRequest; +import com.google.iam.v2beta.DeletePolicyRequest; +import com.google.iam.v2beta.GetPolicyRequest; +import com.google.iam.v2beta.ListPoliciesRequest; +import com.google.iam.v2beta.ListPoliciesResponse; +import com.google.iam.v2beta.Policy; +import com.google.iam.v2beta.PolicyOperationMetadata; +import com.google.iam.v2beta.UpdatePolicyRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Policies service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonPoliciesStub extends PoliciesStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Policy.getDescriptor()) + .add(PolicyOperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listPoliciesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v2beta.Policies/ListPolicies") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=policies/*/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListPoliciesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v2beta.Policies/GetPolicy") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=policies/*/*/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Policy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v2beta.Policies/CreatePolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{parent=policies/*/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "policyId", request.getPolicyId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("policy", request.getPolicy())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreatePolicyRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updatePolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v2beta.Policies/UpdatePolicy") + .setHttpMethod("PUT") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{policy.name=policies/*/*/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "policy.name", request.getPolicy().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("policy", request.getPolicy())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdatePolicyRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deletePolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.iam.v2beta.Policies/DeletePolicy") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v2beta/{name=policies/*/*/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "etag", request.getEtag()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeletePolicyRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable listPoliciesCallable; + private final UnaryCallable + listPoliciesPagedCallable; + private final UnaryCallable getPolicyCallable; + private final UnaryCallable createPolicyCallable; + private final OperationCallable + createPolicyOperationCallable; + private final UnaryCallable updatePolicyCallable; + private final OperationCallable + updatePolicyOperationCallable; + private final UnaryCallable deletePolicyCallable; + private final OperationCallable + deletePolicyOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonPoliciesStub create(PoliciesStubSettings settings) + throws IOException { + return new HttpJsonPoliciesStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonPoliciesStub create(ClientContext clientContext) throws IOException { + return new HttpJsonPoliciesStub( + PoliciesStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonPoliciesStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonPoliciesStub( + PoliciesStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonPoliciesStub, 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 HttpJsonPoliciesStub(PoliciesStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonPoliciesCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonPoliciesStub, 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 HttpJsonPoliciesStub( + PoliciesStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings listPoliciesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listPoliciesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updatePolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updatePolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deletePolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deletePolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + 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.createPolicyCallable = + callableFactory.createUnaryCallable( + createPolicyTransportSettings, settings.createPolicySettings(), clientContext); + this.createPolicyOperationCallable = + callableFactory.createOperationCallable( + createPolicyTransportSettings, + settings.createPolicyOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updatePolicyCallable = + callableFactory.createUnaryCallable( + updatePolicyTransportSettings, settings.updatePolicySettings(), clientContext); + this.updatePolicyOperationCallable = + callableFactory.createOperationCallable( + updatePolicyTransportSettings, + settings.updatePolicyOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deletePolicyCallable = + callableFactory.createUnaryCallable( + deletePolicyTransportSettings, settings.deletePolicySettings(), clientContext); + this.deletePolicyOperationCallable = + callableFactory.createOperationCallable( + deletePolicyTransportSettings, + settings.deletePolicyOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listPoliciesMethodDescriptor); + methodDescriptors.add(getPolicyMethodDescriptor); + methodDescriptors.add(createPolicyMethodDescriptor); + methodDescriptors.add(updatePolicyMethodDescriptor); + methodDescriptors.add(deletePolicyMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listPoliciesCallable() { + return listPoliciesCallable; + } + + @Override + public UnaryCallable listPoliciesPagedCallable() { + return listPoliciesPagedCallable; + } + + @Override + public UnaryCallable getPolicyCallable() { + return getPolicyCallable; + } + + @Override + public UnaryCallable createPolicyCallable() { + return createPolicyCallable; + } + + @Override + public OperationCallable + createPolicyOperationCallable() { + return createPolicyOperationCallable; + } + + @Override + public UnaryCallable updatePolicyCallable() { + return updatePolicyCallable; + } + + @Override + public OperationCallable + updatePolicyOperationCallable() { + return updatePolicyOperationCallable; + } + + @Override + public UnaryCallable deletePolicyCallable() { + return deletePolicyCallable; + } + + @Override + public OperationCallable + deletePolicyOperationCallable() { + return deletePolicyOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @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/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStub.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStub.java index 9b6fcaffdc23..540fa89d6a7f 100644 --- a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStub.java +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStub.java @@ -45,7 +45,11 @@ public abstract class PoliciesStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable listPoliciesPagedCallable() { diff --git a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStubSettings.java b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStubSettings.java index ce17087d8cf0..48a3936f6f94 100644 --- a/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStubSettings.java +++ b/java-iam/google-iam-policy/src/main/java/com/google/iam/v2beta/stub/PoliciesStubSettings.java @@ -28,6 +28,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -219,6 +222,11 @@ public PoliciesStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcPoliciesStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonPoliciesStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -251,29 +259,54 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + 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() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(PoliciesStubSettings.class)) .setTransportToken( GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(PoliciesStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return PoliciesStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -407,6 +440,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listPoliciesSettings() diff --git a/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/PoliciesClientHttpJsonTest.java b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/PoliciesClientHttpJsonTest.java new file mode 100644 index 000000000000..0c1623809983 --- /dev/null +++ b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/PoliciesClientHttpJsonTest.java @@ -0,0 +1,393 @@ +/* + * Copyright 2022 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.iam.v2beta; + +import static com.google.iam.v2beta.PoliciesClient.ListPoliciesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.common.collect.Lists; +import com.google.iam.v2beta.stub.HttpJsonPoliciesStub; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +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 PoliciesClientHttpJsonTest { + private static MockHttpService mockService; + private static PoliciesClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonPoliciesStub.getMethodDescriptors(), PoliciesSettings.getDefaultEndpoint()); + PoliciesSettings settings = + PoliciesSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + PoliciesSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = PoliciesClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listPoliciesTest() throws Exception { + Policy responsesElement = Policy.newBuilder().build(); + ListPoliciesResponse expectedResponse = + ListPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllPolicies(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "policies/policie-1456/policie-1456"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listPoliciesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "policies/policie-1456/policie-1456"; + client.listPolicies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "policies/policie-3260/policie-3260/policie-3260"; + + Policy actualResponse = client.getPolicy(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "policies/policie-3260/policie-3260/policie-3260"; + client.getPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createPolicyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "policies/policie-1456/policie-1456"; + Policy policy = Policy.newBuilder().build(); + String policyId = "policyId546908653"; + + Policy actualResponse = client.createPolicyAsync(parent, policy, policyId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "policies/policie-1456/policie-1456"; + Policy policy = Policy.newBuilder().build(); + String policyId = "policyId546908653"; + client.createPolicyAsync(parent, policy, policyId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updatePolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updatePolicyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + UpdatePolicyRequest request = + UpdatePolicyRequest.newBuilder() + .setPolicy( + Policy.newBuilder() + .setName("policies/policie-3260/policie-3260/policie-3260") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build()) + .build(); + + Policy actualResponse = client.updatePolicyAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updatePolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdatePolicyRequest request = + UpdatePolicyRequest.newBuilder() + .setPolicy( + Policy.newBuilder() + .setName("policies/policie-3260/policie-3260/policie-3260") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build()) + .build(); + client.updatePolicyAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deletePolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setName("name3373707") + .setUid("uid115792") + .setKind("kind3292052") + .setDisplayName("displayName1714148973") + .putAllAnnotations(new HashMap()) + .setEtag("etag3123477") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .addAllRules(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deletePolicyTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "policies/policie-3260/policie-3260/policie-3260"; + + Policy actualResponse = client.deletePolicyAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deletePolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "policies/policie-3260/policie-3260/policie-3260"; + client.deletePolicyAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/PoliciesClientTest.java b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/PoliciesClientTest.java index 419e7677414f..ba966bb1b1f2 100644 --- a/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/PoliciesClientTest.java +++ b/java-iam/google-iam-policy/src/test/java/com/google/iam/v2beta/PoliciesClientTest.java @@ -133,54 +133,7 @@ public void listPoliciesExceptionTest() throws Exception { public void getPolicyTest() throws Exception { Policy expectedResponse = Policy.newBuilder() - .setName(PolicyName.of("[POLICY]").toString()) - .setUid("uid115792") - .setKind("kind3292052") - .setDisplayName("displayName1714148973") - .putAllAnnotations(new HashMap()) - .setEtag("etag3123477") - .setCreateTime(Timestamp.newBuilder().build()) - .setUpdateTime(Timestamp.newBuilder().build()) - .setDeleteTime(Timestamp.newBuilder().build()) - .addAllRules(new ArrayList()) - .build(); - mockPolicies.addResponse(expectedResponse); - - PolicyName name = PolicyName.of("[POLICY]"); - - Policy actualResponse = client.getPolicy(name); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockPolicies.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); - mockPolicies.addException(exception); - - try { - PolicyName name = PolicyName.of("[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.of("[POLICY]").toString()) + .setName("name3373707") .setUid("uid115792") .setKind("kind3292052") .setDisplayName("displayName1714148973") @@ -210,7 +163,7 @@ public void getPolicyTest2() throws Exception { } @Test - public void getPolicyExceptionTest2() throws Exception { + public void getPolicyExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockPolicies.addException(exception); @@ -227,7 +180,7 @@ public void getPolicyExceptionTest2() throws Exception { public void createPolicyTest() throws Exception { Policy expectedResponse = Policy.newBuilder() - .setName(PolicyName.of("[POLICY]").toString()) + .setName("name3373707") .setUid("uid115792") .setKind("kind3292052") .setDisplayName("displayName1714148973") @@ -288,7 +241,7 @@ public void createPolicyExceptionTest() throws Exception { public void updatePolicyTest() throws Exception { Policy expectedResponse = Policy.newBuilder() - .setName(PolicyName.of("[POLICY]").toString()) + .setName("name3373707") .setUid("uid115792") .setKind("kind3292052") .setDisplayName("displayName1714148973") @@ -345,62 +298,7 @@ public void updatePolicyExceptionTest() throws Exception { public void deletePolicyTest() throws Exception { Policy expectedResponse = Policy.newBuilder() - .setName(PolicyName.of("[POLICY]").toString()) - .setUid("uid115792") - .setKind("kind3292052") - .setDisplayName("displayName1714148973") - .putAllAnnotations(new HashMap()) - .setEtag("etag3123477") - .setCreateTime(Timestamp.newBuilder().build()) - .setUpdateTime(Timestamp.newBuilder().build()) - .setDeleteTime(Timestamp.newBuilder().build()) - .addAllRules(new ArrayList()) - .build(); - Operation resultOperation = - Operation.newBuilder() - .setName("deletePolicyTest") - .setDone(true) - .setResponse(Any.pack(expectedResponse)) - .build(); - mockPolicies.addResponse(resultOperation); - - PolicyName name = PolicyName.of("[POLICY]"); - - Policy actualResponse = client.deletePolicyAsync(name).get(); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockPolicies.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); - mockPolicies.addException(exception); - - try { - PolicyName name = PolicyName.of("[POLICY]"); - client.deletePolicyAsync(name).get(); - Assert.fail("No exception raised"); - } catch (ExecutionException e) { - Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass()); - InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); - Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); - } - } - - @Test - public void deletePolicyTest2() throws Exception { - Policy expectedResponse = - Policy.newBuilder() - .setName(PolicyName.of("[POLICY]").toString()) + .setName("name3373707") .setUid("uid115792") .setKind("kind3292052") .setDisplayName("displayName1714148973") @@ -436,7 +334,7 @@ public void deletePolicyTest2() throws Exception { } @Test - public void deletePolicyExceptionTest2() throws Exception { + public void deletePolicyExceptionTest() throws Exception { StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockPolicies.addException(exception); diff --git a/java-iam/proto-google-iam-v2beta/pom.xml b/java-iam/proto-google-iam-v2beta/pom.xml index 28a596c9a7f6..d2d43f45f397 100644 --- a/java-iam/proto-google-iam-v2beta/pom.xml +++ b/java-iam/proto-google-iam-v2beta/pom.xml @@ -21,14 +21,6 @@ com.google.api.grpc proto-google-common-protos - - com.google.api - api-common - - - com.google.guava - guava - diff --git a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DeletePolicyRequest.java b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DeletePolicyRequest.java index a89ed24d46ae..9899a5c37fb3 100644 --- a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DeletePolicyRequest.java +++ b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DeletePolicyRequest.java @@ -136,9 +136,7 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The name. */ @@ -167,9 +165,7 @@ public java.lang.String getName() { * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for name. */ @@ -589,9 +585,7 @@ public Builder mergeFrom( * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The name. */ @@ -619,9 +613,7 @@ public java.lang.String getName() { * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for name. */ @@ -649,9 +641,7 @@ public com.google.protobuf.ByteString getNameBytes() { * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @param value The name to set. * @return This builder for chaining. @@ -678,9 +668,7 @@ public Builder setName(java.lang.String value) { * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return This builder for chaining. */ @@ -703,9 +691,7 @@ public Builder clearName() { * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @param value The bytes for name to set. * @return This builder for chaining. diff --git a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DeletePolicyRequestOrBuilder.java b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DeletePolicyRequestOrBuilder.java index 265e09064361..1b19529885f7 100644 --- a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DeletePolicyRequestOrBuilder.java +++ b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DeletePolicyRequestOrBuilder.java @@ -36,9 +36,7 @@ public interface DeletePolicyRequestOrBuilder * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The name. */ @@ -56,9 +54,7 @@ public interface DeletePolicyRequestOrBuilder * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for name. */ diff --git a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DenyRule.java b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DenyRule.java index 45707bd1aafa..d7af806bb1df 100644 --- a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DenyRule.java +++ b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DenyRule.java @@ -185,7 +185,7 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For @@ -230,7 +230,7 @@ public com.google.protobuf.ProtocolStringList getDeniedPrincipalsList() { * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For @@ -275,7 +275,7 @@ public int getDeniedPrincipalsCount() { * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For @@ -321,7 +321,7 @@ public java.lang.String getDeniedPrincipals(int index) { * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For @@ -1146,7 +1146,7 @@ private void ensureDeniedPrincipalsIsMutable() { * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For @@ -1191,7 +1191,7 @@ public com.google.protobuf.ProtocolStringList getDeniedPrincipalsList() { * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For @@ -1236,7 +1236,7 @@ public int getDeniedPrincipalsCount() { * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For @@ -1282,7 +1282,7 @@ public java.lang.String getDeniedPrincipals(int index) { * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For @@ -1328,7 +1328,7 @@ public com.google.protobuf.ByteString getDeniedPrincipalsBytes(int index) { * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For @@ -1381,7 +1381,7 @@ public Builder setDeniedPrincipals(int index, java.lang.String value) { * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For @@ -1433,7 +1433,7 @@ public Builder addDeniedPrincipals(java.lang.String value) { * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For @@ -1482,7 +1482,7 @@ public Builder addAllDeniedPrincipals(java.lang.Iterable value * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For @@ -1530,7 +1530,7 @@ public Builder clearDeniedPrincipals() { * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For diff --git a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DenyRuleOrBuilder.java b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DenyRuleOrBuilder.java index 1e318bc7a762..30258206ce27 100644 --- a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DenyRuleOrBuilder.java +++ b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DenyRuleOrBuilder.java @@ -30,7 +30,7 @@ public interface DenyRuleOrBuilder * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For @@ -73,7 +73,7 @@ public interface DenyRuleOrBuilder * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For @@ -116,7 +116,7 @@ public interface DenyRuleOrBuilder * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For @@ -160,7 +160,7 @@ public interface DenyRuleOrBuilder * The identities that are prevented from using one or more permissions on * Google Cloud resources. This field can contain the following values: * * `principalSet://goog/public:all`: A special identifier that represents - * any user who is on the internet, even if they do not have a Google + * any principal that is on the internet, even if they do not have a Google * Account or are not logged in. * * `principal://goog/subject/{email_id}`: A specific Google Account. * Includes Gmail, Cloud Identity, and Google Workspace user accounts. For diff --git a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DenyRuleProto.java b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DenyRuleProto.java index 9aa4e3a51da5..ef77af915a10 100644 --- a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DenyRuleProto.java +++ b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/DenyRuleProto.java @@ -46,9 +46,11 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "eption_principals\030\002 \003(\t\022\032\n\022denied_permis" + "sions\030\003 \003(\t\022\035\n\025exception_permissions\030\004 \003" + "(\t\022+\n\020denial_condition\030\005 \001(\0132\021.google.ty" - + "pe.ExprB^\n\025com.google.iam.v2betaB\rDenyRu" - + "leProtoP\001Z4google.golang.org/genproto/go" - + "ogleapis/iam/v2beta;iamb\006proto3" + + "pe.ExprB\222\001\n\025com.google.iam.v2betaB\rDenyR" + + "uleProtoP\001Z4google.golang.org/genproto/g" + + "oogleapis/iam/v2beta;iam\252\002\027Google.Cloud." + + "Iam.V2Beta\312\002\027Google\\Cloud\\Iam\\V2betab\006pr" + + "oto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( diff --git a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/GetPolicyRequest.java b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/GetPolicyRequest.java index e082377e5832..2775a53c7393 100644 --- a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/GetPolicyRequest.java +++ b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/GetPolicyRequest.java @@ -128,9 +128,7 @@ public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The name. */ @@ -159,9 +157,7 @@ public java.lang.String getName() { * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for name. */ @@ -507,9 +503,7 @@ public Builder mergeFrom( * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The name. */ @@ -537,9 +531,7 @@ public java.lang.String getName() { * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for name. */ @@ -567,9 +559,7 @@ public com.google.protobuf.ByteString getNameBytes() { * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @param value The name to set. * @return This builder for chaining. @@ -596,9 +586,7 @@ public Builder setName(java.lang.String value) { * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return This builder for chaining. */ @@ -621,9 +609,7 @@ public Builder clearName() { * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @param value The bytes for name to set. * @return This builder for chaining. diff --git a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/GetPolicyRequestOrBuilder.java b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/GetPolicyRequestOrBuilder.java index 483d9ef3a922..def786214b96 100644 --- a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/GetPolicyRequestOrBuilder.java +++ b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/GetPolicyRequestOrBuilder.java @@ -36,9 +36,7 @@ public interface GetPolicyRequestOrBuilder * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The name. */ @@ -56,9 +54,7 @@ public interface GetPolicyRequestOrBuilder * name. For projects, you can use the alphanumeric or the numeric ID. * * - * - * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } - * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; * * @return The bytes for name. */ diff --git a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/PolicyName.java b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/PolicyName.java deleted file mode 100644 index 15b7c14ab59c..000000000000 --- a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/PolicyName.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright 2022 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.iam.v2beta; - -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 PolicyName implements ResourceName { - private static final PathTemplate POLICY = - PathTemplate.createWithoutUrlEncoding("policies/{policy}"); - private volatile Map fieldValuesMap; - private final String policy; - - @Deprecated - protected PolicyName() { - policy = null; - } - - private PolicyName(Builder builder) { - policy = Preconditions.checkNotNull(builder.getPolicy()); - } - - public String getPolicy() { - return policy; - } - - public static Builder newBuilder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder(this); - } - - public static PolicyName of(String policy) { - return newBuilder().setPolicy(policy).build(); - } - - public static String format(String policy) { - return newBuilder().setPolicy(policy).build().toString(); - } - - public static PolicyName parse(String formattedString) { - if (formattedString.isEmpty()) { - return null; - } - Map matchMap = - POLICY.validatedMatch( - formattedString, "PolicyName.parse: formattedString not in valid format"); - return of(matchMap.get("policy")); - } - - 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 POLICY.matches(formattedString); - } - - @Override - public Map getFieldValuesMap() { - if (fieldValuesMap == null) { - synchronized (this) { - if (fieldValuesMap == null) { - ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (policy != null) { - fieldMapBuilder.put("policy", policy); - } - fieldValuesMap = fieldMapBuilder.build(); - } - } - } - return fieldValuesMap; - } - - public String getFieldValue(String fieldName) { - return getFieldValuesMap().get(fieldName); - } - - @Override - public String toString() { - return POLICY.instantiate("policy", policy); - } - - @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.policy, that.policy); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= Objects.hashCode(policy); - return h; - } - - /** Builder for policies/{policy}. */ - public static class Builder { - private String policy; - - protected Builder() {} - - public String getPolicy() { - return policy; - } - - public Builder setPolicy(String policy) { - this.policy = policy; - return this; - } - - private Builder(PolicyName policyName) { - this.policy = policyName.policy; - } - - public PolicyName build() { - return new PolicyName(this); - } - } -} diff --git a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/PolicyProto.java b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/PolicyProto.java index de498bc2140f..fd7363e93191 100644 --- a/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/PolicyProto.java +++ b/java-iam/proto-google-iam-v2beta/src/main/java/com/google/iam/v2beta/PolicyProto.java @@ -79,64 +79,62 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "\n\036google/iam/v2beta/policy.proto\022\021google" + ".iam.v2beta\032\034google/api/annotations.prot" + "o\032\027google/api/client.proto\032\037google/api/f" - + "ield_behavior.proto\032\031google/api/resource" - + ".proto\032\034google/iam/v2beta/deny.proto\032#go" - + "ogle/longrunning/operations.proto\032\037googl" - + "e/protobuf/timestamp.proto\"\334\003\n\006Policy\022\021\n" - + "\004name\030\001 \001(\tB\003\340A\005\022\020\n\003uid\030\002 \001(\tB\003\340A\005\022\021\n\004ki" - + "nd\030\003 \001(\tB\003\340A\003\022\024\n\014display_name\030\004 \001(\t\022?\n\013a" - + "nnotations\030\005 \003(\0132*.google.iam.v2beta.Pol" - + "icy.AnnotationsEntry\022\014\n\004etag\030\006 \001(\t\0224\n\013cr" - + "eate_time\030\007 \001(\0132\032.google.protobuf.Timest" - + "ampB\003\340A\003\0224\n\013update_time\030\010 \001(\0132\032.google.p" - + "rotobuf.TimestampB\003\340A\003\0224\n\013delete_time\030\t " - + "\001(\0132\032.google.protobuf.TimestampB\003\340A\003\022,\n\005" - + "rules\030\n \003(\0132\035.google.iam.v2beta.PolicyRu" - + "le\0322\n\020AnnotationsEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005v" - + "alue\030\002 \001(\t:\0028\001:1\352A.\n\031iam.googleapis.com/" - + "Policy\022\021policies/{policy}\"[\n\nPolicyRule\022" - + "0\n\tdeny_rule\030\002 \001(\0132\033.google.iam.v2beta.D" - + "enyRuleH\000\022\023\n\013description\030\001 \001(\tB\006\n\004kind\"Q" - + "\n\023ListPoliciesRequest\022\023\n\006parent\030\001 \001(\tB\003\340" - + "A\002\022\021\n\tpage_size\030\002 \001(\005\022\022\n\npage_token\030\003 \001(" - + "\t\"\\\n\024ListPoliciesResponse\022+\n\010policies\030\001 " - + "\003(\0132\031.google.iam.v2beta.Policy\022\027\n\017next_p" - + "age_token\030\002 \001(\t\"C\n\020GetPolicyRequest\022/\n\004n" - + "ame\030\001 \001(\tB!\340A\002\372A\033\n\031iam.googleapis.com/Po" - + "licy\"m\n\023CreatePolicyRequest\022\023\n\006parent\030\001 " - + "\001(\tB\003\340A\002\022.\n\006policy\030\002 \001(\0132\031.google.iam.v2" - + "beta.PolicyB\003\340A\002\022\021\n\tpolicy_id\030\003 \001(\t\"E\n\023U" - + "pdatePolicyRequest\022.\n\006policy\030\001 \001(\0132\031.goo" - + "gle.iam.v2beta.PolicyB\003\340A\002\"Y\n\023DeletePoli" - + "cyRequest\022/\n\004name\030\001 \001(\tB!\340A\002\372A\033\n\031iam.goo" - + "gleapis.com/Policy\022\021\n\004etag\030\002 \001(\tB\003\340A\001\"J\n" - + "\027PolicyOperationMetadata\022/\n\013create_time\030" - + "\001 \001(\0132\032.google.protobuf.Timestamp2\200\007\n\010Po" - + "licies\022\217\001\n\014ListPolicies\022&.google.iam.v2b" - + "eta.ListPoliciesRequest\032\'.google.iam.v2b" - + "eta.ListPoliciesResponse\".\202\323\344\223\002\037\022\035/v2bet" - + "a/{parent=policies/*/*}\332A\006parent\022y\n\tGetP" - + "olicy\022#.google.iam.v2beta.GetPolicyReque" - + "st\032\031.google.iam.v2beta.Policy\",\202\323\344\223\002\037\022\035/" - + "v2beta/{name=policies/*/*/*}\332A\004name\022\302\001\n\014" - + "CreatePolicy\022&.google.iam.v2beta.CreateP" - + "olicyRequest\032\035.google.longrunning.Operat" - + "ion\"k\202\323\344\223\002\'\"\035/v2beta/{parent=policies/*/" - + "*}:\006policy\332A\027parent,policy,policy_id\312A!\n" - + "\006Policy\022\027PolicyOperationMetadata\022\257\001\n\014Upd" - + "atePolicy\022&.google.iam.v2beta.UpdatePoli" + + "ield_behavior.proto\032\034google/iam/v2beta/d" + + "eny.proto\032#google/longrunning/operations" + + ".proto\032\037google/protobuf/timestamp.proto\"" + + "\251\003\n\006Policy\022\021\n\004name\030\001 \001(\tB\003\340A\005\022\020\n\003uid\030\002 \001" + + "(\tB\003\340A\005\022\021\n\004kind\030\003 \001(\tB\003\340A\003\022\024\n\014display_na" + + "me\030\004 \001(\t\022?\n\013annotations\030\005 \003(\0132*.google.i" + + "am.v2beta.Policy.AnnotationsEntry\022\014\n\004eta" + + "g\030\006 \001(\t\0224\n\013create_time\030\007 \001(\0132\032.google.pr" + + "otobuf.TimestampB\003\340A\003\0224\n\013update_time\030\010 \001" + + "(\0132\032.google.protobuf.TimestampB\003\340A\003\0224\n\013d" + + "elete_time\030\t \001(\0132\032.google.protobuf.Times" + + "tampB\003\340A\003\022,\n\005rules\030\n \003(\0132\035.google.iam.v2" + + "beta.PolicyRule\0322\n\020AnnotationsEntry\022\013\n\003k" + + "ey\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"[\n\nPolicyRul" + + "e\0220\n\tdeny_rule\030\002 \001(\0132\033.google.iam.v2beta" + + ".DenyRuleH\000\022\023\n\013description\030\001 \001(\tB\006\n\004kind" + + "\"Q\n\023ListPoliciesRequest\022\023\n\006parent\030\001 \001(\tB" + + "\003\340A\002\022\021\n\tpage_size\030\002 \001(\005\022\022\n\npage_token\030\003 " + + "\001(\t\"\\\n\024ListPoliciesResponse\022+\n\010policies\030" + + "\001 \003(\0132\031.google.iam.v2beta.Policy\022\027\n\017next" + + "_page_token\030\002 \001(\t\"%\n\020GetPolicyRequest\022\021\n" + + "\004name\030\001 \001(\tB\003\340A\002\"m\n\023CreatePolicyRequest\022" + + "\023\n\006parent\030\001 \001(\tB\003\340A\002\022.\n\006policy\030\002 \001(\0132\031.g" + + "oogle.iam.v2beta.PolicyB\003\340A\002\022\021\n\tpolicy_i" + + "d\030\003 \001(\t\"E\n\023UpdatePolicyRequest\022.\n\006policy" + + "\030\001 \001(\0132\031.google.iam.v2beta.PolicyB\003\340A\002\";" + + "\n\023DeletePolicyRequest\022\021\n\004name\030\001 \001(\tB\003\340A\002" + + "\022\021\n\004etag\030\002 \001(\tB\003\340A\001\"J\n\027PolicyOperationMe" + + "tadata\022/\n\013create_time\030\001 \001(\0132\032.google.pro" + + "tobuf.Timestamp2\200\007\n\010Policies\022\217\001\n\014ListPol" + + "icies\022&.google.iam.v2beta.ListPoliciesRe" + + "quest\032\'.google.iam.v2beta.ListPoliciesRe" + + "sponse\".\202\323\344\223\002\037\022\035/v2beta/{parent=policies" + + "/*/*}\332A\006parent\022y\n\tGetPolicy\022#.google.iam" + + ".v2beta.GetPolicyRequest\032\031.google.iam.v2" + + "beta.Policy\",\202\323\344\223\002\037\022\035/v2beta/{name=polic" + + "ies/*/*/*}\332A\004name\022\302\001\n\014CreatePolicy\022&.goo" + + "gle.iam.v2beta.CreatePolicyRequest\032\035.goo" + + "gle.longrunning.Operation\"k\202\323\344\223\002\'\"\035/v2be" + + "ta/{parent=policies/*/*}:\006policy\332A\027paren" + + "t,policy,policy_id\312A!\n\006Policy\022\027PolicyOpe" + + "rationMetadata\022\257\001\n\014UpdatePolicy\022&.google" + + ".iam.v2beta.UpdatePolicyRequest\032\035.google" + + ".longrunning.Operation\"X\202\323\344\223\002.\032$/v2beta/" + + "{policy.name=policies/*/*/*}:\006policy\312A!\n" + + "\006Policy\022\027PolicyOperationMetadata\022\247\001\n\014Del" + + "etePolicy\022&.google.iam.v2beta.DeletePoli" + "cyRequest\032\035.google.longrunning.Operation" - + "\"X\202\323\344\223\002.\032$/v2beta/{policy.name=policies/" - + "*/*/*}:\006policy\312A!\n\006Policy\022\027PolicyOperati" - + "onMetadata\022\247\001\n\014DeletePolicy\022&.google.iam" - + ".v2beta.DeletePolicyRequest\032\035.google.lon" - + "grunning.Operation\"P\202\323\344\223\002\037*\035/v2beta/{nam" - + "e=policies/*/*/*}\332A\004name\312A!\n\006Policy\022\027Pol" - + "icyOperationMetadata\032F\312A\022iam.googleapis." - + "com\322A.https://www.googleapis.com/auth/cl" - + "oud-platformB\\\n\025com.google.iam.v2betaB\013P" - + "olicyProtoP\001Z4google.golang.org/genproto" - + "/googleapis/iam/v2beta;iamb\006proto3" + + "\"P\202\323\344\223\002\037*\035/v2beta/{name=policies/*/*/*}\332" + + "A\004name\312A!\n\006Policy\022\027PolicyOperationMetada" + + "ta\032F\312A\022iam.googleapis.com\322A.https://www." + + "googleapis.com/auth/cloud-platformB\220\001\n\025c" + + "om.google.iam.v2betaB\013PolicyProtoP\001Z4goo" + + "gle.golang.org/genproto/googleapis/iam/v" + + "2beta;iam\252\002\027Google.Cloud.Iam.V2Beta\312\002\027Go" + + "ogle\\Cloud\\Iam\\V2betab\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -145,7 +143,6 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { com.google.api.AnnotationsProto.getDescriptor(), com.google.api.ClientProto.getDescriptor(), com.google.api.FieldBehaviorProto.getDescriptor(), - com.google.api.ResourceProto.getDescriptor(), com.google.iam.v2beta.DenyRuleProto.getDescriptor(), com.google.longrunning.OperationsProto.getDescriptor(), com.google.protobuf.TimestampProto.getDescriptor(), @@ -245,15 +242,12 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { 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); registry.add(com.google.longrunning.OperationsProto.operationInfo); 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.iam.v2beta.DenyRuleProto.getDescriptor(); com.google.longrunning.OperationsProto.getDescriptor(); com.google.protobuf.TimestampProto.getDescriptor(); diff --git a/java-iam/proto-google-iam-v2beta/src/main/proto/google/iam/v2beta/deny.proto b/java-iam/proto-google-iam-v2beta/src/main/proto/google/iam/v2beta/deny.proto index 744449273926..73ae7bbdf703 100644 --- a/java-iam/proto-google-iam-v2beta/src/main/proto/google/iam/v2beta/deny.proto +++ b/java-iam/proto-google-iam-v2beta/src/main/proto/google/iam/v2beta/deny.proto @@ -18,10 +18,12 @@ package google.iam.v2beta; import "google/type/expr.proto"; +option csharp_namespace = "Google.Cloud.Iam.V2Beta"; option go_package = "google.golang.org/genproto/googleapis/iam/v2beta;iam"; option java_multiple_files = true; option java_outer_classname = "DenyRuleProto"; option java_package = "com.google.iam.v2beta"; +option php_namespace = "Google\\Cloud\\Iam\\V2beta"; // A deny rule in an IAM deny policy. message DenyRule { @@ -29,7 +31,7 @@ message DenyRule { // Google Cloud resources. This field can contain the following values: // // * `principalSet://goog/public:all`: A special identifier that represents - // any user who is on the internet, even if they do not have a Google + // any principal that is on the internet, even if they do not have a Google // Account or are not logged in. // // * `principal://goog/subject/{email_id}`: A specific Google Account. diff --git a/java-iam/proto-google-iam-v2beta/src/main/proto/google/iam/v2beta/policy.proto b/java-iam/proto-google-iam-v2beta/src/main/proto/google/iam/v2beta/policy.proto index b3cba55e31bc..99df3db0aa58 100644 --- a/java-iam/proto-google-iam-v2beta/src/main/proto/google/iam/v2beta/policy.proto +++ b/java-iam/proto-google-iam-v2beta/src/main/proto/google/iam/v2beta/policy.proto @@ -19,15 +19,16 @@ package google.iam.v2beta; import "google/api/annotations.proto"; import "google/api/client.proto"; import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; import "google/iam/v2beta/deny.proto"; import "google/longrunning/operations.proto"; import "google/protobuf/timestamp.proto"; +option csharp_namespace = "Google.Cloud.Iam.V2Beta"; option go_package = "google.golang.org/genproto/googleapis/iam/v2beta;iam"; option java_multiple_files = true; option java_outer_classname = "PolicyProto"; option java_package = "com.google.iam.v2beta"; +option php_namespace = "Google\\Cloud\\Iam\\V2beta"; // An interface for managing Identity and Access Management (IAM) policies. service Policies { @@ -104,11 +105,6 @@ service Policies { // Data for an IAM policy. message Policy { - option (google.api.resource) = { - type: "iam.googleapis.com/Policy" - pattern: "policies/{policy}" - }; - // Immutable. The resource name of the `Policy`, which must be unique. Format: // `policies/{attachment_point}/denypolicies/{policy_id}` // @@ -219,12 +215,7 @@ message GetPolicyRequest { // // For organizations and folders, use the numeric ID in the full resource // name. For projects, you can use the alphanumeric or the numeric ID. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "iam.googleapis.com/Policy" - } - ]; + string name = 1 [(google.api.field_behavior) = REQUIRED]; } // Request message for `CreatePolicy`. @@ -274,12 +265,7 @@ message DeletePolicyRequest { // // For organizations and folders, use the numeric ID in the full resource // name. For projects, you can use the alphanumeric or the numeric ID. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "iam.googleapis.com/Policy" - } - ]; + string name = 1 [(google.api.field_behavior) = REQUIRED]; // Optional. The expected `etag` of the policy to delete. If the value does not match // the value that is stored in IAM, the request fails with a `409` error code