From 42bb99e10f860353a5ed700b7e422aa67c8ba980 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Fri, 19 Feb 2021 14:55:45 -0800 Subject: [PATCH 1/9] changes without context autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. --- .../v1/ContainerAnalysisClient.java | 252 +++++++++++++++-- .../v1/ContainerAnalysisSettings.java | 33 +-- .../containeranalysis/v1/package-info.java | 18 +- .../v1/stub/ContainerAnalysisStub.java | 11 +- .../stub/ContainerAnalysisStubSettings.java | 99 +++---- .../GrpcContainerAnalysisCallableFactory.java | 42 +-- .../v1/stub/GrpcContainerAnalysisStub.java | 28 +- .../v1/ContainerAnalysisClientTest.java | 257 ++++-------------- .../v1/MockContainerAnalysis.java | 6 +- .../v1/MockContainerAnalysisImpl.java | 22 +- .../containeranalysis/v1/ProjectName.java | 86 +++--- synth.metadata | 2 +- 12 files changed, 442 insertions(+), 414 deletions(-) diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java index 1ed88581..8219bfbd 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.google.cloud.devtools.containeranalysis.v1; import com.google.api.core.BetaApi; @@ -36,7 +35,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS. +// AUTO-GENERATED DOCUMENTATION AND SERVICE /** * Service Description: Retrieves analysis results of Cloud components such as Docker container * images. The Container Analysis API is an implementation of the [Grafeas](https://grafeas.io) API. @@ -53,7 +52,17 @@ *

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

Note: close() needs to be called on the ContainerAnalysisClient object to clean up resources + *

+ * 
+ * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+ *   ResourceName resource = ProjectName.of("[PROJECT]");
+ *   Policy policy = Policy.newBuilder().build();
+ *   Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
+ * }
+ * 
+ * 
+ * + *

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

To customize credentials: * - *

{@code
+ * 
+ * 
  * ContainerAnalysisSettings containerAnalysisSettings =
  *     ContainerAnalysisSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
  * ContainerAnalysisClient containerAnalysisClient =
  *     ContainerAnalysisClient.create(containerAnalysisSettings);
- * }
+ * + *
* - *

To customize the endpoint: + * To customize the endpoint: * - *

{@code
+ * 
+ * 
  * ContainerAnalysisSettings containerAnalysisSettings =
  *     ContainerAnalysisSettings.newBuilder().setEndpoint(myEndpoint).build();
  * ContainerAnalysisClient containerAnalysisClient =
  *     ContainerAnalysisClient.create(containerAnalysisSettings);
- * }
- * - *

Please refer to the GitHub repository's samples for more quickstart code snippets. + * + *

*/ -@Generated("by gapic-generator-java") +@Generated("by gapic-generator") +@BetaApi public class ContainerAnalysisClient implements BackgroundResource { private final ContainerAnalysisSettings settings; private final ContainerAnalysisStub stub; @@ -131,7 +143,7 @@ public static final ContainerAnalysisClient create(ContainerAnalysisSettings set /** * Constructs an instance of ContainerAnalysisClient, using the given stub for making calls. This - * is for advanced usage - prefer using create(ContainerAnalysisSettings). + * is for advanced usage - prefer to use ContainerAnalysisSettings}. */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ContainerAnalysisClient create(ContainerAnalysisStub stub) { @@ -163,7 +175,7 @@ public ContainerAnalysisStub getStub() { return stub; } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Sets the access control policy on the specified note or occurrence. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -172,6 +184,16 @@ public ContainerAnalysisStub getStub() { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ResourceName resource = ProjectName.of("[PROJECT]");
+   *   Policy policy = Policy.newBuilder().build();
+   *   Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
+   * }
+   * 
+ * * @param resource REQUIRED: The resource for which the policy is being specified. See the * operation documentation for the appropriate value for this field. * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the @@ -188,7 +210,7 @@ public final Policy setIamPolicy(ResourceName resource, Policy policy) { return setIamPolicy(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Sets the access control policy on the specified note or occurrence. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -197,6 +219,16 @@ public final Policy setIamPolicy(ResourceName resource, Policy policy) { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ResourceName resource = ProjectName.of("[PROJECT]");
+   *   Policy policy = Policy.newBuilder().build();
+   *   Policy response = containerAnalysisClient.setIamPolicy(resource.toString(), policy);
+   * }
+   * 
+ * * @param resource REQUIRED: The resource for which the policy is being specified. See the * operation documentation for the appropriate value for this field. * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the @@ -210,7 +242,7 @@ public final Policy setIamPolicy(String resource, Policy policy) { return setIamPolicy(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Sets the access control policy on the specified note or occurrence. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -219,6 +251,20 @@ public final Policy setIamPolicy(String resource, Policy policy) { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ResourceName resource = ProjectName.of("[PROJECT]");
+   *   Policy policy = Policy.newBuilder().build();
+   *   SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
+   *     .setResource(resource.toString())
+   *     .setPolicy(policy)
+   *     .build();
+   *   Policy response = containerAnalysisClient.setIamPolicy(request);
+   * }
+   * 
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -226,7 +272,7 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) { return setIamPolicyCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Sets the access control policy on the specified note or occurrence. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -236,12 +282,26 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) { * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ResourceName resource = ProjectName.of("[PROJECT]");
+   *   Policy policy = Policy.newBuilder().build();
+   *   SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
+   *     .setResource(resource.toString())
+   *     .setPolicy(policy)
+   *     .build();
+   *   ApiFuture<Policy> future = containerAnalysisClient.setIamPolicyCallable().futureCall(request);
+   *   // Do something
+   *   Policy response = future.get();
+   * }
+   * 
*/ public final UnaryCallable setIamPolicyCallable() { return stub.setIamPolicyCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Gets the access control policy for a note or an occurrence resource. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -250,6 +310,15 @@ public final UnaryCallable setIamPolicyCallable() { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ResourceName resource = ProjectName.of("[PROJECT]");
+   *   Policy response = containerAnalysisClient.getIamPolicy(resource);
+   * }
+   * 
+ * * @param resource REQUIRED: The resource for which the policy is being requested. See the * operation documentation for the appropriate value for this field. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -262,7 +331,7 @@ public final Policy getIamPolicy(ResourceName resource) { return getIamPolicy(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Gets the access control policy for a note or an occurrence resource. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -271,6 +340,15 @@ public final Policy getIamPolicy(ResourceName resource) { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ResourceName resource = ProjectName.of("[PROJECT]");
+   *   Policy response = containerAnalysisClient.getIamPolicy(resource.toString());
+   * }
+   * 
+ * * @param resource REQUIRED: The resource for which the policy is being requested. See the * operation documentation for the appropriate value for this field. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -280,7 +358,7 @@ public final Policy getIamPolicy(String resource) { return getIamPolicy(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Gets the access control policy for a note or an occurrence resource. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -289,6 +367,18 @@ public final Policy getIamPolicy(String resource) { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ResourceName resource = ProjectName.of("[PROJECT]");
+   *   GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
+   *     .setResource(resource.toString())
+   *     .build();
+   *   Policy response = containerAnalysisClient.getIamPolicy(request);
+   * }
+   * 
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -296,7 +386,7 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) { return getIamPolicyCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Gets the access control policy for a note or an occurrence resource. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -306,12 +396,24 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) { * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ResourceName resource = ProjectName.of("[PROJECT]");
+   *   GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
+   *     .setResource(resource.toString())
+   *     .build();
+   *   ApiFuture<Policy> future = containerAnalysisClient.getIamPolicyCallable().futureCall(request);
+   *   // Do something
+   *   Policy response = future.get();
+   * }
+   * 
*/ public final UnaryCallable getIamPolicyCallable() { return stub.getIamPolicyCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Returns the permissions that a caller has on the specified note or occurrence. Requires list * permission on the project (for example, `containeranalysis.notes.list`). @@ -319,6 +421,16 @@ public final UnaryCallable getIamPolicyCallable() { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ResourceName resource = ProjectName.of("[PROJECT]");
+   *   List<String> permissions = new ArrayList<>();
+   *   TestIamPermissionsResponse response = containerAnalysisClient.testIamPermissions(resource, permissions);
+   * }
+   * 
+ * * @param resource REQUIRED: The resource for which the policy detail is being requested. See the * operation documentation for the appropriate value for this field. * @param permissions The set of permissions to check for the `resource`. Permissions with @@ -336,7 +448,7 @@ public final TestIamPermissionsResponse testIamPermissions( return testIamPermissions(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Returns the permissions that a caller has on the specified note or occurrence. Requires list * permission on the project (for example, `containeranalysis.notes.list`). @@ -344,6 +456,16 @@ public final TestIamPermissionsResponse testIamPermissions( *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ResourceName resource = ProjectName.of("[PROJECT]");
+   *   List<String> permissions = new ArrayList<>();
+   *   TestIamPermissionsResponse response = containerAnalysisClient.testIamPermissions(resource.toString(), permissions);
+   * }
+   * 
+ * * @param resource REQUIRED: The resource for which the policy detail is being requested. See the * operation documentation for the appropriate value for this field. * @param permissions The set of permissions to check for the `resource`. Permissions with @@ -361,7 +483,7 @@ public final TestIamPermissionsResponse testIamPermissions( return testIamPermissions(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Returns the permissions that a caller has on the specified note or occurrence. Requires list * permission on the project (for example, `containeranalysis.notes.list`). @@ -369,6 +491,20 @@ public final TestIamPermissionsResponse testIamPermissions( *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ResourceName resource = ProjectName.of("[PROJECT]");
+   *   List<String> permissions = new ArrayList<>();
+   *   TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
+   *     .setResource(resource.toString())
+   *     .addAllPermissions(permissions)
+   *     .build();
+   *   TestIamPermissionsResponse response = containerAnalysisClient.testIamPermissions(request);
+   * }
+   * 
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -376,7 +512,7 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq return testIamPermissionsCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Returns the permissions that a caller has on the specified note or occurrence. Requires list * permission on the project (for example, `containeranalysis.notes.list`). @@ -385,16 +521,40 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ResourceName resource = ProjectName.of("[PROJECT]");
+   *   List<String> permissions = new ArrayList<>();
+   *   TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
+   *     .setResource(resource.toString())
+   *     .addAllPermissions(permissions)
+   *     .build();
+   *   ApiFuture<TestIamPermissionsResponse> future = containerAnalysisClient.testIamPermissionsCallable().futureCall(request);
+   *   // Do something
+   *   TestIamPermissionsResponse response = future.get();
+   * }
+   * 
*/ public final UnaryCallable testIamPermissionsCallable() { return stub.testIamPermissionsCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Gets a summary of the number and severity of occurrences. * + *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   String filter = "";
+   *   VulnerabilityOccurrencesSummary response = containerAnalysisClient.getVulnerabilityOccurrencesSummary(parent, filter);
+   * }
+   * 
+ * * @param parent The name of the project to get a vulnerability summary for in the form of * `projects/[PROJECT_ID]`. * @param filter The filter expression. @@ -410,10 +570,20 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary( return getVulnerabilityOccurrencesSummary(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Gets a summary of the number and severity of occurrences. * + *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   String filter = "";
+   *   VulnerabilityOccurrencesSummary response = containerAnalysisClient.getVulnerabilityOccurrencesSummary(parent.toString(), filter);
+   * }
+   * 
+ * * @param parent The name of the project to get a vulnerability summary for in the form of * `projects/[PROJECT_ID]`. * @param filter The filter expression. @@ -429,10 +599,22 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary( return getVulnerabilityOccurrencesSummary(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Gets a summary of the number and severity of occurrences. * + *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   GetVulnerabilityOccurrencesSummaryRequest request = GetVulnerabilityOccurrencesSummaryRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   VulnerabilityOccurrencesSummary response = containerAnalysisClient.getVulnerabilityOccurrencesSummary(request);
+   * }
+   * 
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -441,11 +623,23 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary( return getVulnerabilityOccurrencesSummaryCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD. + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Gets a summary of the number and severity of occurrences. * *

Sample code: + * + *


+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   GetVulnerabilityOccurrencesSummaryRequest request = GetVulnerabilityOccurrencesSummaryRequest.newBuilder()
+   *     .setParent(parent.toString())
+   *     .build();
+   *   ApiFuture<VulnerabilityOccurrencesSummary> future = containerAnalysisClient.getVulnerabilityOccurrencesSummaryCallable().futureCall(request);
+   *   // Do something
+   *   VulnerabilityOccurrencesSummary response = future.get();
+   * }
+   * 
*/ public final UnaryCallable< GetVulnerabilityOccurrencesSummaryRequest, VulnerabilityOccurrencesSummary> diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisSettings.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisSettings.java index 3b04fe4b..ec36003b 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisSettings.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.google.cloud.devtools.containeranalysis.v1; import com.google.api.core.ApiFunction; @@ -38,7 +37,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS. +// AUTO-GENERATED DOCUMENTATION AND CLASS /** * Settings class to configure an instance of {@link ContainerAnalysisClient}. * @@ -56,24 +55,23 @@ * *

For example, to set the total timeout of setIamPolicy to 30 seconds: * - *

{@code
+ * 
+ * 
  * ContainerAnalysisSettings.Builder containerAnalysisSettingsBuilder =
  *     ContainerAnalysisSettings.newBuilder();
  * containerAnalysisSettingsBuilder
  *     .setIamPolicySettings()
  *     .setRetrySettings(
- *         containerAnalysisSettingsBuilder
- *             .setIamPolicySettings()
- *             .getRetrySettings()
- *             .toBuilder()
+ *         containerAnalysisSettingsBuilder.setIamPolicySettings().getRetrySettings().toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
  * ContainerAnalysisSettings containerAnalysisSettings = containerAnalysisSettingsBuilder.build();
- * }
+ * + *
*/ -@Generated("by gapic-generator-java") +@Generated("by gapic-generator") +@BetaApi public class ContainerAnalysisSettings extends ClientSettings { - /** Returns the object with the settings used for calls to setIamPolicy. */ public UnaryCallSettings setIamPolicySettings() { return ((ContainerAnalysisStubSettings) getStubSettings()).setIamPolicySettings(); @@ -158,15 +156,18 @@ protected ContainerAnalysisSettings(Builder settingsBuilder) throws IOException /** Builder for ContainerAnalysisSettings. */ public static class Builder extends ClientSettings.Builder { - protected Builder() throws IOException { - this(((ClientContext) null)); + this((ClientContext) null); } protected Builder(ClientContext clientContext) { super(ContainerAnalysisStubSettings.newBuilder(clientContext)); } + private static Builder createDefault() { + return new Builder(ContainerAnalysisStubSettings.newBuilder()); + } + protected Builder(ContainerAnalysisSettings settings) { super(settings.getStubSettings().toBuilder()); } @@ -175,15 +176,11 @@ protected Builder(ContainerAnalysisStubSettings.Builder stubSettings) { super(stubSettings); } - private static Builder createDefault() { - return new Builder(ContainerAnalysisStubSettings.newBuilder()); - } - public ContainerAnalysisStubSettings.Builder getStubSettingsBuilder() { return ((ContainerAnalysisStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception'. + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/package-info.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/package-info.java index 20d05f6c..0a2831fd 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/package-info.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/package-info.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -15,7 +15,9 @@ */ /** - * The interfaces provided are listed below, along with usage samples. + * A client to Container Analysis API. + * + *

The interfaces provided are listed below, along with usage samples. * *

======================= ContainerAnalysisClient ======================= * @@ -32,8 +34,18 @@ * to that note. * *

Sample for ContainerAnalysisClient: + * + *

+ * 
+ * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+ *   ResourceName resource = ProjectName.of("[PROJECT]");
+ *   Policy policy = Policy.newBuilder().build();
+ *   Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
+ * }
+ * 
+ * 
*/ -@Generated("by gapic-generator-java") +@Generated("by gapic-generator") package com.google.cloud.devtools.containeranalysis.v1; import javax.annotation.Generated; diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStub.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStub.java index ae74efb2..7577d06a 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStub.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.google.cloud.devtools.containeranalysis.v1.stub; +import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.UnaryCallable; import com.google.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest; @@ -27,13 +27,14 @@ import com.google.iam.v1.TestIamPermissionsResponse; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS. +// AUTO-GENERATED DOCUMENTATION AND CLASS /** - * Base stub class for the ContainerAnalysis service API. + * Base stub class for Container Analysis API. * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator-java") +@Generated("by gapic-generator") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") public abstract class ContainerAnalysisStub implements BackgroundResource { public UnaryCallable setIamPolicyCallable() { diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStubSettings.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStubSettings.java index afe8a91d..980c85bb 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStubSettings.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStubSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.google.cloud.devtools.containeranalysis.v1.stub; import com.google.api.core.ApiFunction; @@ -47,7 +46,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS. +// AUTO-GENERATED DOCUMENTATION AND CLASS /** * Settings class to configure an instance of {@link ContainerAnalysisStub}. * @@ -65,23 +64,22 @@ * *

For example, to set the total timeout of setIamPolicy to 30 seconds: * - *

{@code
+ * 
+ * 
  * ContainerAnalysisStubSettings.Builder containerAnalysisSettingsBuilder =
  *     ContainerAnalysisStubSettings.newBuilder();
  * containerAnalysisSettingsBuilder
  *     .setIamPolicySettings()
  *     .setRetrySettings(
- *         containerAnalysisSettingsBuilder
- *             .setIamPolicySettings()
- *             .getRetrySettings()
- *             .toBuilder()
+ *         containerAnalysisSettingsBuilder.setIamPolicySettings().getRetrySettings().toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * ContainerAnalysisStubSettings containerAnalysisSettings =
- *     containerAnalysisSettingsBuilder.build();
- * }
+ * ContainerAnalysisStubSettings containerAnalysisSettings = containerAnalysisSettingsBuilder.build(); + * + *
*/ -@Generated("by gapic-generator-java") +@Generated("by gapic-generator") +@BetaApi public class ContainerAnalysisStubSettings extends StubSettings { /** The default scopes of the service. */ private static final ImmutableList DEFAULT_SERVICE_SCOPES = @@ -124,10 +122,10 @@ public ContainerAnalysisStub createStub() throws IOException { .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcContainerAnalysisStub.create(this); + } else { + throw new UnsupportedOperationException( + "Transport not supported: " + getTransportChannelProvider().getTransportName()); } - throw new UnsupportedOperationException( - String.format( - "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } /** Returns a builder for the default ExecutorProvider for this service. */ @@ -197,6 +195,7 @@ protected ContainerAnalysisStubSettings(Builder settingsBuilder) throws IOExcept /** Builder for ContainerAnalysisStubSettings. */ public static class Builder extends StubSettings.Builder { private final ImmutableList> unaryMethodSettingsBuilders; + private final UnaryCallSettings.Builder setIamPolicySettings; private final UnaryCallSettings.Builder getIamPolicySettings; private final UnaryCallSettings.Builder @@ -204,15 +203,16 @@ public static class Builder extends StubSettings.Builder getVulnerabilityOccurrencesSummarySettings; + private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; static { ImmutableMap.Builder> definitions = ImmutableMap.builder(); - definitions.put( - "no_retry_0_codes", ImmutableSet.copyOf(Lists.newArrayList())); definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); + definitions.put( + "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -221,6 +221,8 @@ public static class Builder extends StubSettings.Builder definitions = ImmutableMap.builder(); RetrySettings settings = null; + settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); + definitions.put("no_retry_params", settings); settings = RetrySettings.newBuilder() .setInitialRpcTimeout(Duration.ofMillis(30000L)) @@ -228,22 +230,23 @@ public static class Builder extends StubSettings.Builder>of( - setIamPolicySettings, - getIamPolicySettings, - testIamPermissionsSettings, - getVulnerabilityOccurrencesSummarySettings); + initDefaults(this); } private static Builder createDefault() { - Builder builder = new Builder(((ClientContext) null)); - + Builder builder = new Builder((ClientContext) null); builder.setTransportChannelProvider(defaultTransportChannelProvider()); builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); - return initDefaults(builder); } private static Builder initDefaults(Builder builder) { + builder .setIamPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); builder .getIamPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); builder .testIamPermissionsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); builder .getVulnerabilityOccurrencesSummarySettings() @@ -307,7 +293,24 @@ private static Builder initDefaults(Builder builder) { return builder; } - // NEXT_MAJOR_VER: remove 'throws Exception'. + protected Builder(ContainerAnalysisStubSettings settings) { + super(settings); + + setIamPolicySettings = settings.setIamPolicySettings.toBuilder(); + getIamPolicySettings = settings.getIamPolicySettings.toBuilder(); + testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder(); + getVulnerabilityOccurrencesSummarySettings = + settings.getVulnerabilityOccurrencesSummarySettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + setIamPolicySettings, + getIamPolicySettings, + testIamPermissionsSettings, + getVulnerabilityOccurrencesSummarySettings); + } + + // NEXT_MAJOR_VER: remove 'throws Exception' /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisCallableFactory.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisCallableFactory.java index 9b8cb871..10889167 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisCallableFactory.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisCallableFactory.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.google.cloud.devtools.containeranalysis.v1.stub; +import com.google.api.core.BetaApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -31,19 +31,18 @@ import com.google.api.gax.rpc.StreamingCallSettings; import com.google.api.gax.rpc.UnaryCallSettings; import com.google.api.gax.rpc.UnaryCallable; -import com.google.longrunning.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS. +// AUTO-GENERATED DOCUMENTATION AND CLASS /** - * gRPC callable factory implementation for the ContainerAnalysis service API. + * gRPC callable factory implementation for Container Analysis API. * *

This class is for advanced usage. */ -@Generated("by gapic-generator-java") +@Generated("by gapic-generator") +@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public class GrpcContainerAnalysisCallableFactory implements GrpcStubCallableFactory { - @Override public UnaryCallable createUnaryCallable( GrpcCallSettings grpcCallSettings, @@ -56,58 +55,61 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings callSettings, + PagedCallSettings pagedCallSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); + return GrpcCallableFactory.createPagedCallable( + grpcCallSettings, pagedCallSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings callSettings, + BatchingCallSettings batchingCallSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, callSettings, clientContext); + grpcCallSettings, batchingCallSettings, clientContext); } + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") @Override public OperationCallable createOperationCallable( - GrpcCallSettings grpcCallSettings, - OperationCallSettings callSettings, + GrpcCallSettings grpcCallSettings, + OperationCallSettings operationCallSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, callSettings, clientContext, operationsStub); + grpcCallSettings, operationCallSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings callSettings, + StreamingCallSettings streamingCallSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, callSettings, clientContext); + grpcCallSettings, streamingCallSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings callSettings, + ServerStreamingCallSettings streamingCallSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, callSettings, clientContext); + grpcCallSettings, streamingCallSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings callSettings, + StreamingCallSettings streamingCallSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, callSettings, clientContext); + grpcCallSettings, streamingCallSettings, clientContext); } } diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java index 8bca88c1..1d0cfe8a 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.google.cloud.devtools.containeranalysis.v1.stub; +import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -31,7 +31,6 @@ import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; import com.google.iam.v1.TestIamPermissionsResponse; -import com.google.longrunning.stub.GrpcOperationsStub; import io.grpc.MethodDescriptor; import io.grpc.protobuf.ProtoUtils; import java.io.IOException; @@ -39,14 +38,16 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS. +// AUTO-GENERATED DOCUMENTATION AND CLASS /** - * gRPC stub implementation for the ContainerAnalysis service API. + * gRPC stub implementation for Container Analysis API. * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator-java") +@Generated("by gapic-generator") +@BetaApi("A restructuring of stub classes is planned, so this may break in the future") public class GrpcContainerAnalysisStub extends ContainerAnalysisStub { + private static final MethodDescriptor setIamPolicyMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -54,7 +55,6 @@ public class GrpcContainerAnalysisStub extends ContainerAnalysisStub { .setRequestMarshaller(ProtoUtils.marshaller(SetIamPolicyRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) .build(); - private static final MethodDescriptor getIamPolicyMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -62,7 +62,6 @@ public class GrpcContainerAnalysisStub extends ContainerAnalysisStub { .setRequestMarshaller(ProtoUtils.marshaller(GetIamPolicyRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) .build(); - private static final MethodDescriptor testIamPermissionsMethodDescriptor = MethodDescriptor.newBuilder() @@ -74,7 +73,6 @@ public class GrpcContainerAnalysisStub extends ContainerAnalysisStub { .setResponseMarshaller( ProtoUtils.marshaller(TestIamPermissionsResponse.getDefaultInstance())) .build(); - private static final MethodDescriptor< GetVulnerabilityOccurrencesSummaryRequest, VulnerabilityOccurrencesSummary> getVulnerabilityOccurrencesSummaryMethodDescriptor = @@ -91,6 +89,8 @@ public class GrpcContainerAnalysisStub extends ContainerAnalysisStub { ProtoUtils.marshaller(VulnerabilityOccurrencesSummary.getDefaultInstance())) .build(); + private final BackgroundResource backgroundResources; + private final UnaryCallable setIamPolicyCallable; private final UnaryCallable getIamPolicyCallable; private final UnaryCallable @@ -99,8 +99,6 @@ public class GrpcContainerAnalysisStub extends ContainerAnalysisStub { GetVulnerabilityOccurrencesSummaryRequest, VulnerabilityOccurrencesSummary> getVulnerabilityOccurrencesSummaryCallable; - private final BackgroundResource backgroundResources; - private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcContainerAnalysisStub create(ContainerAnalysisStubSettings settings) @@ -141,7 +139,6 @@ protected GrpcContainerAnalysisStub( GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; - this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings setIamPolicyTransportSettings = GrpcCallSettings.newBuilder() @@ -218,12 +215,7 @@ public Map extract( settings.getVulnerabilityOccurrencesSummarySettings(), clientContext); - this.backgroundResources = - new BackgroundResourceAggregation(clientContext.getBackgroundResources()); - } - - public GrpcOperationsStub getOperationsStub() { - return operationsStub; + backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } public UnaryCallable setIamPolicyCallable() { diff --git a/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClientTest.java b/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClientTest.java index b7f12bc7..e246db6a 100644 --- a/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClientTest.java +++ b/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClientTest.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.google.cloud.devtools.containeranalysis.v1; import com.google.api.gax.core.NoCredentialsProvider; @@ -27,7 +26,6 @@ import com.google.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest; import com.google.containeranalysis.v1.ProjectName; import com.google.containeranalysis.v1.VulnerabilityOccurrencesSummary; -import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; @@ -35,13 +33,14 @@ import com.google.iam.v1.TestIamPermissionsResponse; import com.google.protobuf.AbstractMessage; import com.google.protobuf.ByteString; +import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Objects; import java.util.UUID; -import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -49,31 +48,31 @@ import org.junit.BeforeClass; import org.junit.Test; -@Generated("by gapic-generator-java") +@javax.annotation.Generated("by GAPIC") public class ContainerAnalysisClientTest { - private static MockServiceHelper mockServiceHelper; - private ContainerAnalysisClient client; private static MockContainerAnalysis mockContainerAnalysis; + private static MockServiceHelper serviceHelper; + private ContainerAnalysisClient client; private LocalChannelProvider channelProvider; @BeforeClass public static void startStaticServer() { mockContainerAnalysis = new MockContainerAnalysis(); - mockServiceHelper = + serviceHelper = new MockServiceHelper( UUID.randomUUID().toString(), Arrays.asList(mockContainerAnalysis)); - mockServiceHelper.start(); + serviceHelper.start(); } @AfterClass public static void stopServer() { - mockServiceHelper.stop(); + serviceHelper.stop(); } @Before public void setUp() throws IOException { - mockServiceHelper.reset(); - channelProvider = mockServiceHelper.createChannelProvider(); + serviceHelper.reset(); + channelProvider = serviceHelper.createChannelProvider(); ContainerAnalysisSettings settings = ContainerAnalysisSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -88,13 +87,11 @@ public void tearDown() throws Exception { } @Test - public void setIamPolicyTest() throws Exception { - Policy expectedResponse = - Policy.newBuilder() - .setVersion(351608024) - .addAllBindings(new ArrayList()) - .setEtag(ByteString.EMPTY) - .build(); + @SuppressWarnings("all") + public void setIamPolicyTest() { + int version = 351608024; + ByteString etag = ByteString.copyFromUtf8("21"); + Policy expectedResponse = Policy.newBuilder().setVersion(version).setEtag(etag).build(); mockContainerAnalysis.addResponse(expectedResponse); ResourceName resource = ProjectName.of("[PROJECT]"); @@ -105,9 +102,9 @@ public void setIamPolicyTest() throws Exception { List actualRequests = mockContainerAnalysis.getRequests(); Assert.assertEquals(1, actualRequests.size()); - SetIamPolicyRequest actualRequest = ((SetIamPolicyRequest) actualRequests.get(0)); + SetIamPolicyRequest actualRequest = (SetIamPolicyRequest) actualRequests.get(0); - Assert.assertEquals(resource.toString(), actualRequest.getResource()); + Assert.assertEquals(Objects.toString(resource), Objects.toString(actualRequest.getResource())); Assert.assertEquals(policy, actualRequest.getPolicy()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -116,71 +113,28 @@ public void setIamPolicyTest() throws Exception { } @Test + @SuppressWarnings("all") public void setIamPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockContainerAnalysis.addException(exception); try { ResourceName resource = ProjectName.of("[PROJECT]"); Policy policy = Policy.newBuilder().build(); - client.setIamPolicy(resource, policy); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception. - } - } - - @Test - public void setIamPolicyTest2() throws Exception { - Policy expectedResponse = - Policy.newBuilder() - .setVersion(351608024) - .addAllBindings(new ArrayList()) - .setEtag(ByteString.EMPTY) - .build(); - mockContainerAnalysis.addResponse(expectedResponse); - - String resource = "resource-341064690"; - Policy policy = Policy.newBuilder().build(); - - Policy actualResponse = client.setIamPolicy(resource, policy); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockContainerAnalysis.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - SetIamPolicyRequest actualRequest = ((SetIamPolicyRequest) actualRequests.get(0)); - - Assert.assertEquals(resource, actualRequest.getResource()); - Assert.assertEquals(policy, actualRequest.getPolicy()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void setIamPolicyExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockContainerAnalysis.addException(exception); - try { - String resource = "resource-341064690"; - Policy policy = Policy.newBuilder().build(); client.setIamPolicy(resource, policy); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception. + // Expected exception } } @Test - public void getIamPolicyTest() throws Exception { - Policy expectedResponse = - Policy.newBuilder() - .setVersion(351608024) - .addAllBindings(new ArrayList()) - .setEtag(ByteString.EMPTY) - .build(); + @SuppressWarnings("all") + public void getIamPolicyTest() { + int version = 351608024; + ByteString etag = ByteString.copyFromUtf8("21"); + Policy expectedResponse = Policy.newBuilder().setVersion(version).setEtag(etag).build(); mockContainerAnalysis.addResponse(expectedResponse); ResourceName resource = ProjectName.of("[PROJECT]"); @@ -190,9 +144,9 @@ public void getIamPolicyTest() throws Exception { List actualRequests = mockContainerAnalysis.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0)); + GetIamPolicyRequest actualRequest = (GetIamPolicyRequest) actualRequests.get(0); - Assert.assertEquals(resource.toString(), actualRequest.getResource()); + Assert.assertEquals(Objects.toString(resource), Objects.toString(actualRequest.getResource())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -200,63 +154,25 @@ public void getIamPolicyTest() throws Exception { } @Test + @SuppressWarnings("all") public void getIamPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockContainerAnalysis.addException(exception); try { ResourceName resource = ProjectName.of("[PROJECT]"); - client.getIamPolicy(resource); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception. - } - } - - @Test - public void getIamPolicyTest2() throws Exception { - Policy expectedResponse = - Policy.newBuilder() - .setVersion(351608024) - .addAllBindings(new ArrayList()) - .setEtag(ByteString.EMPTY) - .build(); - mockContainerAnalysis.addResponse(expectedResponse); - - String resource = "resource-341064690"; - - Policy actualResponse = client.getIamPolicy(resource); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockContainerAnalysis.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0)); - Assert.assertEquals(resource, actualRequest.getResource()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void getIamPolicyExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockContainerAnalysis.addException(exception); - - try { - String resource = "resource-341064690"; client.getIamPolicy(resource); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception. + // Expected exception } } @Test - public void testIamPermissionsTest() throws Exception { - TestIamPermissionsResponse expectedResponse = - TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + @SuppressWarnings("all") + public void testIamPermissionsTest() { + TestIamPermissionsResponse expectedResponse = TestIamPermissionsResponse.newBuilder().build(); mockContainerAnalysis.addResponse(expectedResponse); ResourceName resource = ProjectName.of("[PROJECT]"); @@ -267,9 +183,9 @@ public void testIamPermissionsTest() throws Exception { List actualRequests = mockContainerAnalysis.getRequests(); Assert.assertEquals(1, actualRequests.size()); - TestIamPermissionsRequest actualRequest = ((TestIamPermissionsRequest) actualRequests.get(0)); + TestIamPermissionsRequest actualRequest = (TestIamPermissionsRequest) actualRequests.get(0); - Assert.assertEquals(resource.toString(), actualRequest.getResource()); + Assert.assertEquals(Objects.toString(resource), Objects.toString(actualRequest.getResource())); Assert.assertEquals(permissions, actualRequest.getPermissionsList()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -278,65 +194,27 @@ public void testIamPermissionsTest() throws Exception { } @Test + @SuppressWarnings("all") public void testIamPermissionsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockContainerAnalysis.addException(exception); try { ResourceName resource = ProjectName.of("[PROJECT]"); List permissions = new ArrayList<>(); - client.testIamPermissions(resource, permissions); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception. - } - } - - @Test - public void testIamPermissionsTest2() throws Exception { - TestIamPermissionsResponse expectedResponse = - TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); - mockContainerAnalysis.addResponse(expectedResponse); - - String resource = "resource-341064690"; - List permissions = new ArrayList<>(); - - TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockContainerAnalysis.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - TestIamPermissionsRequest actualRequest = ((TestIamPermissionsRequest) actualRequests.get(0)); - Assert.assertEquals(resource, actualRequest.getResource()); - Assert.assertEquals(permissions, actualRequest.getPermissionsList()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void testIamPermissionsExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockContainerAnalysis.addException(exception); - - try { - String resource = "resource-341064690"; - List permissions = new ArrayList<>(); client.testIamPermissions(resource, permissions); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception. + // Expected exception } } @Test - public void getVulnerabilityOccurrencesSummaryTest() throws Exception { + @SuppressWarnings("all") + public void getVulnerabilityOccurrencesSummaryTest() { VulnerabilityOccurrencesSummary expectedResponse = - VulnerabilityOccurrencesSummary.newBuilder() - .addAllCounts(new ArrayList()) - .build(); + VulnerabilityOccurrencesSummary.newBuilder().build(); mockContainerAnalysis.addResponse(expectedResponse); ProjectName parent = ProjectName.of("[PROJECT]"); @@ -349,9 +227,9 @@ public void getVulnerabilityOccurrencesSummaryTest() throws Exception { List actualRequests = mockContainerAnalysis.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetVulnerabilityOccurrencesSummaryRequest actualRequest = - ((GetVulnerabilityOccurrencesSummaryRequest) actualRequests.get(0)); + (GetVulnerabilityOccurrencesSummaryRequest) actualRequests.get(0); - Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent())); Assert.assertEquals(filter, actualRequest.getFilter()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -360,60 +238,19 @@ public void getVulnerabilityOccurrencesSummaryTest() throws Exception { } @Test + @SuppressWarnings("all") public void getVulnerabilityOccurrencesSummaryExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); mockContainerAnalysis.addException(exception); try { ProjectName parent = ProjectName.of("[PROJECT]"); String filter = "filter-1274492040"; - client.getVulnerabilityOccurrencesSummary(parent, filter); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception. - } - } - - @Test - public void getVulnerabilityOccurrencesSummaryTest2() throws Exception { - VulnerabilityOccurrencesSummary expectedResponse = - VulnerabilityOccurrencesSummary.newBuilder() - .addAllCounts(new ArrayList()) - .build(); - mockContainerAnalysis.addResponse(expectedResponse); - - String parent = "parent-995424086"; - String filter = "filter-1274492040"; - - VulnerabilityOccurrencesSummary actualResponse = - client.getVulnerabilityOccurrencesSummary(parent, filter); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockContainerAnalysis.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - GetVulnerabilityOccurrencesSummaryRequest actualRequest = - ((GetVulnerabilityOccurrencesSummaryRequest) actualRequests.get(0)); - Assert.assertEquals(parent, actualRequest.getParent()); - Assert.assertEquals(filter, actualRequest.getFilter()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - public void getVulnerabilityOccurrencesSummaryExceptionTest2() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); - mockContainerAnalysis.addException(exception); - - try { - String parent = "parent-995424086"; - String filter = "filter-1274492040"; client.getVulnerabilityOccurrencesSummary(parent, filter); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception. + // Expected exception } } } diff --git a/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysis.java b/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysis.java index a64fe61e..5d45f6ab 100644 --- a/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysis.java +++ b/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysis.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.google.cloud.devtools.containeranalysis.v1; import com.google.api.core.BetaApi; @@ -21,10 +20,9 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; -import javax.annotation.Generated; +@javax.annotation.Generated("by GAPIC") @BetaApi -@Generated("by gapic-generator-java") public class MockContainerAnalysis implements MockGrpcService { private final MockContainerAnalysisImpl serviceImpl; diff --git a/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysisImpl.java b/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysisImpl.java index ee65fb5d..f890c448 100644 --- a/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysisImpl.java +++ b/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysisImpl.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.google.cloud.devtools.containeranalysis.v1; import com.google.api.core.BetaApi; @@ -31,10 +30,9 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; -import javax.annotation.Generated; +@javax.annotation.Generated("by GAPIC") @BetaApi -@Generated("by gapic-generator-java") public class MockContainerAnalysisImpl extends ContainerAnalysisImplBase { private List requests; private Queue responses; @@ -70,10 +68,10 @@ public void setIamPolicy(SetIamPolicyRequest request, StreamObserver res Object response = responses.remove(); if (response instanceof Policy) { requests.add(request); - responseObserver.onNext(((Policy) response)); + responseObserver.onNext((Policy) response); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); + responseObserver.onError((Exception) response); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -84,10 +82,10 @@ public void getIamPolicy(GetIamPolicyRequest request, StreamObserver res Object response = responses.remove(); if (response instanceof Policy) { requests.add(request); - responseObserver.onNext(((Policy) response)); + responseObserver.onNext((Policy) response); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); + responseObserver.onError((Exception) response); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -100,10 +98,10 @@ public void testIamPermissions( Object response = responses.remove(); if (response instanceof TestIamPermissionsResponse) { requests.add(request); - responseObserver.onNext(((TestIamPermissionsResponse) response)); + responseObserver.onNext((TestIamPermissionsResponse) response); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); + responseObserver.onError((Exception) response); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -116,10 +114,10 @@ public void getVulnerabilityOccurrencesSummary( Object response = responses.remove(); if (response instanceof VulnerabilityOccurrencesSummary) { requests.add(request); - responseObserver.onNext(((VulnerabilityOccurrencesSummary) response)); + responseObserver.onNext((VulnerabilityOccurrencesSummary) response); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError(((Exception) response)); + responseObserver.onError((Exception) response); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } diff --git a/proto-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ProjectName.java b/proto-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ProjectName.java index 2c6f990e..651c4994 100644 --- a/proto-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ProjectName.java +++ b/proto-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ProjectName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -23,25 +23,17 @@ 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") +/** AUTO-GENERATED DOCUMENTATION AND CLASS */ +@javax.annotation.Generated("by GAPIC protoc plugin") public class ProjectName implements ResourceName { - private static final PathTemplate PROJECT = + + private static final PathTemplate PATH_TEMPLATE = PathTemplate.createWithoutUrlEncoding("projects/{project}"); - private volatile Map fieldValuesMap; - private final String project; - @Deprecated - protected ProjectName() { - project = null; - } + private volatile Map fieldValuesMap; - private ProjectName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - } + private final String project; public String getProject() { return project; @@ -55,6 +47,10 @@ public Builder toBuilder() { return new Builder(this); } + private ProjectName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + } + public static ProjectName of(String project) { return newBuilder().setProject(project).build(); } @@ -68,7 +64,7 @@ public static ProjectName parse(String formattedString) { return null; } Map matchMap = - PROJECT.validatedMatch( + PATH_TEMPLATE.validatedMatch( formattedString, "ProjectName.parse: formattedString not in valid format"); return of(matchMap.get("project")); } @@ -82,7 +78,7 @@ public static List parseList(List formattedStrings) { } public static List toStringList(List values) { - List list = new ArrayList<>(values.size()); + List list = new ArrayList(values.size()); for (ProjectName value : values) { if (value == null) { list.add(""); @@ -94,18 +90,15 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PROJECT.matches(formattedString); + return PATH_TEMPLATE.matches(formattedString); } - @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (project != null) { - fieldMapBuilder.put("project", project); - } + fieldMapBuilder.put("project", project); fieldValuesMap = fieldMapBuilder.build(); } } @@ -119,34 +112,13 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PROJECT.instantiate("project", project); - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o != null || getClass() == o.getClass()) { - ProjectName that = ((ProjectName) o); - return Objects.equals(this.project, that.project); - } - return false; + return PATH_TEMPLATE.instantiate("project", project); } - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= Objects.hashCode(project); - return h; - } - - /** Builder for projects/{project}. */ + /** Builder for ProjectName. */ public static class Builder { - private String project; - protected Builder() {} + private String project; public String getProject() { return project; @@ -157,6 +129,8 @@ public Builder setProject(String project) { return this; } + private Builder() {} + private Builder(ProjectName projectName) { project = projectName.project; } @@ -165,4 +139,24 @@ public ProjectName build() { return new ProjectName(this); } } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof ProjectName) { + ProjectName that = (ProjectName) o; + return (this.project.equals(that.project)); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= project.hashCode(); + return h; + } } diff --git a/synth.metadata b/synth.metadata index 989fd3b1..7fb5aa58 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/java-containeranalysis.git", - "sha": "6b9f88aad1d512c8080f797768dd05660630047d" + "sha": "76a20e87ca73b574ae8e7d15cd94eeae6ea0ce82" } }, { From e7b7300207d4f97d495200e7c2f1fbf34043aadb Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Fri, 19 Feb 2021 15:04:16 -0800 Subject: [PATCH 2/9] chore: Remove spurious build warnings by deleting--include_source_info from .bazelrc Committer: @miraleung PiperOrigin-RevId: 344134135 Source-Author: Google APIs Source-Date: Tue Nov 24 14:38:21 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: b11a87f3b54be3a5e42c15020ee1e0781f86da90 Source-Link: https://github.com/googleapis/googleapis/commit/b11a87f3b54be3a5e42c15020ee1e0781f86da90 --- .../v1/ContainerAnalysisGrpc.java | 286 ++---------------- synth.metadata | 4 +- 2 files changed, 23 insertions(+), 267 deletions(-) diff --git a/grpc-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ContainerAnalysisGrpc.java b/grpc-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ContainerAnalysisGrpc.java index a3dac85d..e3906e67 100644 --- a/grpc-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ContainerAnalysisGrpc.java +++ b/grpc-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ContainerAnalysisGrpc.java @@ -22,23 +22,7 @@ import static io.grpc.stub.ServerCalls.asyncUnaryCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; -/** - * - * - *
- * Retrieves analysis results of Cloud components such as Docker container
- * images. The Container Analysis API is an implementation of the
- * [Grafeas](https://grafeas.io) API.
- * Analysis results are stored as a series of occurrences. An `Occurrence`
- * contains information about a specific analysis instance on a resource. An
- * occurrence refers to a `Note`. A note contains details describing the
- * analysis and is generally stored in a separate project, called a `Provider`.
- * Multiple occurrences can refer to the same note.
- * For example, an SSL vulnerability could affect multiple images. In this case,
- * there would be one note for the vulnerability and an occurrence for each
- * image with the vulnerability referring to that note.
- * 
- */ +/** */ @javax.annotation.Generated( value = "by gRPC proto compiler", comments = "Source: google/devtools/containeranalysis/v1/containeranalysis.proto") @@ -267,75 +251,24 @@ public ContainerAnalysisFutureStub newStub( return ContainerAnalysisFutureStub.newStub(factory, channel); } - /** - * - * - *
-   * Retrieves analysis results of Cloud components such as Docker container
-   * images. The Container Analysis API is an implementation of the
-   * [Grafeas](https://grafeas.io) API.
-   * Analysis results are stored as a series of occurrences. An `Occurrence`
-   * contains information about a specific analysis instance on a resource. An
-   * occurrence refers to a `Note`. A note contains details describing the
-   * analysis and is generally stored in a separate project, called a `Provider`.
-   * Multiple occurrences can refer to the same note.
-   * For example, an SSL vulnerability could affect multiple images. In this case,
-   * there would be one note for the vulnerability and an occurrence for each
-   * image with the vulnerability referring to that note.
-   * 
- */ + /** */ public abstract static class ContainerAnalysisImplBase implements io.grpc.BindableService { - /** - * - * - *
-     * Sets the access control policy on the specified note or occurrence.
-     * Requires `containeranalysis.notes.setIamPolicy` or
-     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
-     * a note or an occurrence, respectively.
-     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
-     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
-     * occurrences.
-     * 
- */ + /** */ public void setIamPolicy( com.google.iam.v1.SetIamPolicyRequest request, io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getSetIamPolicyMethod(), responseObserver); } - /** - * - * - *
-     * Gets the access control policy for a note or an occurrence resource.
-     * Requires `containeranalysis.notes.setIamPolicy` or
-     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
-     * a note or occurrence, respectively.
-     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
-     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
-     * occurrences.
-     * 
- */ + /** */ public void getIamPolicy( com.google.iam.v1.GetIamPolicyRequest request, io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getGetIamPolicyMethod(), responseObserver); } - /** - * - * - *
-     * Returns the permissions that a caller has on the specified note or
-     * occurrence. Requires list permission on the project (for example,
-     * `containeranalysis.notes.list`).
-     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
-     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
-     * occurrences.
-     * 
- */ + /** */ public void testIamPermissions( com.google.iam.v1.TestIamPermissionsRequest request, io.grpc.stub.StreamObserver @@ -343,13 +276,7 @@ public void testIamPermissions( asyncUnimplementedUnaryCall(getTestIamPermissionsMethod(), responseObserver); } - /** - * - * - *
-     * Gets a summary of the number and severity of occurrences.
-     * 
- */ + /** */ public void getVulnerabilityOccurrencesSummary( com.google.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest request, io.grpc.stub.StreamObserver @@ -390,23 +317,7 @@ public final io.grpc.ServerServiceDefinition bindService() { } } - /** - * - * - *
-   * Retrieves analysis results of Cloud components such as Docker container
-   * images. The Container Analysis API is an implementation of the
-   * [Grafeas](https://grafeas.io) API.
-   * Analysis results are stored as a series of occurrences. An `Occurrence`
-   * contains information about a specific analysis instance on a resource. An
-   * occurrence refers to a `Note`. A note contains details describing the
-   * analysis and is generally stored in a separate project, called a `Provider`.
-   * Multiple occurrences can refer to the same note.
-   * For example, an SSL vulnerability could affect multiple images. In this case,
-   * there would be one note for the vulnerability and an occurrence for each
-   * image with the vulnerability referring to that note.
-   * 
- */ + /** */ public static final class ContainerAnalysisStub extends io.grpc.stub.AbstractAsyncStub { private ContainerAnalysisStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { @@ -419,19 +330,7 @@ protected ContainerAnalysisStub build( return new ContainerAnalysisStub(channel, callOptions); } - /** - * - * - *
-     * Sets the access control policy on the specified note or occurrence.
-     * Requires `containeranalysis.notes.setIamPolicy` or
-     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
-     * a note or an occurrence, respectively.
-     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
-     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
-     * occurrences.
-     * 
- */ + /** */ public void setIamPolicy( com.google.iam.v1.SetIamPolicyRequest request, io.grpc.stub.StreamObserver responseObserver) { @@ -441,19 +340,7 @@ public void setIamPolicy( responseObserver); } - /** - * - * - *
-     * Gets the access control policy for a note or an occurrence resource.
-     * Requires `containeranalysis.notes.setIamPolicy` or
-     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
-     * a note or occurrence, respectively.
-     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
-     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
-     * occurrences.
-     * 
- */ + /** */ public void getIamPolicy( com.google.iam.v1.GetIamPolicyRequest request, io.grpc.stub.StreamObserver responseObserver) { @@ -463,18 +350,7 @@ public void getIamPolicy( responseObserver); } - /** - * - * - *
-     * Returns the permissions that a caller has on the specified note or
-     * occurrence. Requires list permission on the project (for example,
-     * `containeranalysis.notes.list`).
-     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
-     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
-     * occurrences.
-     * 
- */ + /** */ public void testIamPermissions( com.google.iam.v1.TestIamPermissionsRequest request, io.grpc.stub.StreamObserver @@ -485,13 +361,7 @@ public void testIamPermissions( responseObserver); } - /** - * - * - *
-     * Gets a summary of the number and severity of occurrences.
-     * 
- */ + /** */ public void getVulnerabilityOccurrencesSummary( com.google.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest request, io.grpc.stub.StreamObserver @@ -503,23 +373,7 @@ public void getVulnerabilityOccurrencesSummary( } } - /** - * - * - *
-   * Retrieves analysis results of Cloud components such as Docker container
-   * images. The Container Analysis API is an implementation of the
-   * [Grafeas](https://grafeas.io) API.
-   * Analysis results are stored as a series of occurrences. An `Occurrence`
-   * contains information about a specific analysis instance on a resource. An
-   * occurrence refers to a `Note`. A note contains details describing the
-   * analysis and is generally stored in a separate project, called a `Provider`.
-   * Multiple occurrences can refer to the same note.
-   * For example, an SSL vulnerability could affect multiple images. In this case,
-   * there would be one note for the vulnerability and an occurrence for each
-   * image with the vulnerability referring to that note.
-   * 
- */ + /** */ public static final class ContainerAnalysisBlockingStub extends io.grpc.stub.AbstractBlockingStub { private ContainerAnalysisBlockingStub( @@ -533,65 +387,24 @@ protected ContainerAnalysisBlockingStub build( return new ContainerAnalysisBlockingStub(channel, callOptions); } - /** - * - * - *
-     * Sets the access control policy on the specified note or occurrence.
-     * Requires `containeranalysis.notes.setIamPolicy` or
-     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
-     * a note or an occurrence, respectively.
-     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
-     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
-     * occurrences.
-     * 
- */ + /** */ public com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request) { return blockingUnaryCall(getChannel(), getSetIamPolicyMethod(), getCallOptions(), request); } - /** - * - * - *
-     * Gets the access control policy for a note or an occurrence resource.
-     * Requires `containeranalysis.notes.setIamPolicy` or
-     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
-     * a note or occurrence, respectively.
-     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
-     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
-     * occurrences.
-     * 
- */ + /** */ public com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request) { return blockingUnaryCall(getChannel(), getGetIamPolicyMethod(), getCallOptions(), request); } - /** - * - * - *
-     * Returns the permissions that a caller has on the specified note or
-     * occurrence. Requires list permission on the project (for example,
-     * `containeranalysis.notes.list`).
-     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
-     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
-     * occurrences.
-     * 
- */ + /** */ public com.google.iam.v1.TestIamPermissionsResponse testIamPermissions( com.google.iam.v1.TestIamPermissionsRequest request) { return blockingUnaryCall( getChannel(), getTestIamPermissionsMethod(), getCallOptions(), request); } - /** - * - * - *
-     * Gets a summary of the number and severity of occurrences.
-     * 
- */ + /** */ public com.google.containeranalysis.v1.VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary( com.google.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest request) { @@ -600,23 +413,7 @@ public com.google.iam.v1.TestIamPermissionsResponse testIamPermissions( } } - /** - * - * - *
-   * Retrieves analysis results of Cloud components such as Docker container
-   * images. The Container Analysis API is an implementation of the
-   * [Grafeas](https://grafeas.io) API.
-   * Analysis results are stored as a series of occurrences. An `Occurrence`
-   * contains information about a specific analysis instance on a resource. An
-   * occurrence refers to a `Note`. A note contains details describing the
-   * analysis and is generally stored in a separate project, called a `Provider`.
-   * Multiple occurrences can refer to the same note.
-   * For example, an SSL vulnerability could affect multiple images. In this case,
-   * there would be one note for the vulnerability and an occurrence for each
-   * image with the vulnerability referring to that note.
-   * 
- */ + /** */ public static final class ContainerAnalysisFutureStub extends io.grpc.stub.AbstractFutureStub { private ContainerAnalysisFutureStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { @@ -629,56 +426,21 @@ protected ContainerAnalysisFutureStub build( return new ContainerAnalysisFutureStub(channel, callOptions); } - /** - * - * - *
-     * Sets the access control policy on the specified note or occurrence.
-     * Requires `containeranalysis.notes.setIamPolicy` or
-     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
-     * a note or an occurrence, respectively.
-     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
-     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
-     * occurrences.
-     * 
- */ + /** */ public com.google.common.util.concurrent.ListenableFuture setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request) { return futureUnaryCall( getChannel().newCall(getSetIamPolicyMethod(), getCallOptions()), request); } - /** - * - * - *
-     * Gets the access control policy for a note or an occurrence resource.
-     * Requires `containeranalysis.notes.setIamPolicy` or
-     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
-     * a note or occurrence, respectively.
-     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
-     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
-     * occurrences.
-     * 
- */ + /** */ public com.google.common.util.concurrent.ListenableFuture getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request) { return futureUnaryCall( getChannel().newCall(getGetIamPolicyMethod(), getCallOptions()), request); } - /** - * - * - *
-     * Returns the permissions that a caller has on the specified note or
-     * occurrence. Requires list permission on the project (for example,
-     * `containeranalysis.notes.list`).
-     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
-     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
-     * occurrences.
-     * 
- */ + /** */ public com.google.common.util.concurrent.ListenableFuture< com.google.iam.v1.TestIamPermissionsResponse> testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request) { @@ -686,13 +448,7 @@ protected ContainerAnalysisFutureStub build( getChannel().newCall(getTestIamPermissionsMethod(), getCallOptions()), request); } - /** - * - * - *
-     * Gets a summary of the number and severity of occurrences.
-     * 
- */ + /** */ public com.google.common.util.concurrent.ListenableFuture< com.google.containeranalysis.v1.VulnerabilityOccurrencesSummary> getVulnerabilityOccurrencesSummary( diff --git a/synth.metadata b/synth.metadata index 7fb5aa58..9212040f 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "cb7fc620590382a4a2ea6ffdf6f51ae0e77bbbb5", - "internalRef": "334682521" + "sha": "b11a87f3b54be3a5e42c15020ee1e0781f86da90", + "internalRef": "344134135" } }, { From 7619aebd7803967702c0c638ed4a982dd3b2cf3b Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Fri, 19 Feb 2021 15:06:45 -0800 Subject: [PATCH 3/9] chore: Undo removal of --include_source_info from .bazelrc Committer: @miraleung PiperOrigin-RevId: 345067549 Source-Author: Google APIs Source-Date: Tue Dec 1 11:49:14 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: 8cfc6c874574b649b4524a4ef6a0651533325a84 Source-Link: https://github.com/googleapis/googleapis/commit/8cfc6c874574b649b4524a4ef6a0651533325a84 --- .../v1/ContainerAnalysisGrpc.java | 286 ++++++++++++++++-- synth.metadata | 4 +- 2 files changed, 267 insertions(+), 23 deletions(-) diff --git a/grpc-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ContainerAnalysisGrpc.java b/grpc-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ContainerAnalysisGrpc.java index e3906e67..a3dac85d 100644 --- a/grpc-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ContainerAnalysisGrpc.java +++ b/grpc-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ContainerAnalysisGrpc.java @@ -22,7 +22,23 @@ import static io.grpc.stub.ServerCalls.asyncUnaryCall; import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; -/** */ +/** + * + * + *
+ * Retrieves analysis results of Cloud components such as Docker container
+ * images. The Container Analysis API is an implementation of the
+ * [Grafeas](https://grafeas.io) API.
+ * Analysis results are stored as a series of occurrences. An `Occurrence`
+ * contains information about a specific analysis instance on a resource. An
+ * occurrence refers to a `Note`. A note contains details describing the
+ * analysis and is generally stored in a separate project, called a `Provider`.
+ * Multiple occurrences can refer to the same note.
+ * For example, an SSL vulnerability could affect multiple images. In this case,
+ * there would be one note for the vulnerability and an occurrence for each
+ * image with the vulnerability referring to that note.
+ * 
+ */ @javax.annotation.Generated( value = "by gRPC proto compiler", comments = "Source: google/devtools/containeranalysis/v1/containeranalysis.proto") @@ -251,24 +267,75 @@ public ContainerAnalysisFutureStub newStub( return ContainerAnalysisFutureStub.newStub(factory, channel); } - /** */ + /** + * + * + *
+   * Retrieves analysis results of Cloud components such as Docker container
+   * images. The Container Analysis API is an implementation of the
+   * [Grafeas](https://grafeas.io) API.
+   * Analysis results are stored as a series of occurrences. An `Occurrence`
+   * contains information about a specific analysis instance on a resource. An
+   * occurrence refers to a `Note`. A note contains details describing the
+   * analysis and is generally stored in a separate project, called a `Provider`.
+   * Multiple occurrences can refer to the same note.
+   * For example, an SSL vulnerability could affect multiple images. In this case,
+   * there would be one note for the vulnerability and an occurrence for each
+   * image with the vulnerability referring to that note.
+   * 
+ */ public abstract static class ContainerAnalysisImplBase implements io.grpc.BindableService { - /** */ + /** + * + * + *
+     * Sets the access control policy on the specified note or occurrence.
+     * Requires `containeranalysis.notes.setIamPolicy` or
+     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
+     * a note or an occurrence, respectively.
+     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
+     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
+     * occurrences.
+     * 
+ */ public void setIamPolicy( com.google.iam.v1.SetIamPolicyRequest request, io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getSetIamPolicyMethod(), responseObserver); } - /** */ + /** + * + * + *
+     * Gets the access control policy for a note or an occurrence resource.
+     * Requires `containeranalysis.notes.setIamPolicy` or
+     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
+     * a note or occurrence, respectively.
+     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
+     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
+     * occurrences.
+     * 
+ */ public void getIamPolicy( com.google.iam.v1.GetIamPolicyRequest request, io.grpc.stub.StreamObserver responseObserver) { asyncUnimplementedUnaryCall(getGetIamPolicyMethod(), responseObserver); } - /** */ + /** + * + * + *
+     * Returns the permissions that a caller has on the specified note or
+     * occurrence. Requires list permission on the project (for example,
+     * `containeranalysis.notes.list`).
+     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
+     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
+     * occurrences.
+     * 
+ */ public void testIamPermissions( com.google.iam.v1.TestIamPermissionsRequest request, io.grpc.stub.StreamObserver @@ -276,7 +343,13 @@ public void testIamPermissions( asyncUnimplementedUnaryCall(getTestIamPermissionsMethod(), responseObserver); } - /** */ + /** + * + * + *
+     * Gets a summary of the number and severity of occurrences.
+     * 
+ */ public void getVulnerabilityOccurrencesSummary( com.google.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest request, io.grpc.stub.StreamObserver @@ -317,7 +390,23 @@ public final io.grpc.ServerServiceDefinition bindService() { } } - /** */ + /** + * + * + *
+   * Retrieves analysis results of Cloud components such as Docker container
+   * images. The Container Analysis API is an implementation of the
+   * [Grafeas](https://grafeas.io) API.
+   * Analysis results are stored as a series of occurrences. An `Occurrence`
+   * contains information about a specific analysis instance on a resource. An
+   * occurrence refers to a `Note`. A note contains details describing the
+   * analysis and is generally stored in a separate project, called a `Provider`.
+   * Multiple occurrences can refer to the same note.
+   * For example, an SSL vulnerability could affect multiple images. In this case,
+   * there would be one note for the vulnerability and an occurrence for each
+   * image with the vulnerability referring to that note.
+   * 
+ */ public static final class ContainerAnalysisStub extends io.grpc.stub.AbstractAsyncStub { private ContainerAnalysisStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { @@ -330,7 +419,19 @@ protected ContainerAnalysisStub build( return new ContainerAnalysisStub(channel, callOptions); } - /** */ + /** + * + * + *
+     * Sets the access control policy on the specified note or occurrence.
+     * Requires `containeranalysis.notes.setIamPolicy` or
+     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
+     * a note or an occurrence, respectively.
+     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
+     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
+     * occurrences.
+     * 
+ */ public void setIamPolicy( com.google.iam.v1.SetIamPolicyRequest request, io.grpc.stub.StreamObserver responseObserver) { @@ -340,7 +441,19 @@ public void setIamPolicy( responseObserver); } - /** */ + /** + * + * + *
+     * Gets the access control policy for a note or an occurrence resource.
+     * Requires `containeranalysis.notes.setIamPolicy` or
+     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
+     * a note or occurrence, respectively.
+     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
+     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
+     * occurrences.
+     * 
+ */ public void getIamPolicy( com.google.iam.v1.GetIamPolicyRequest request, io.grpc.stub.StreamObserver responseObserver) { @@ -350,7 +463,18 @@ public void getIamPolicy( responseObserver); } - /** */ + /** + * + * + *
+     * Returns the permissions that a caller has on the specified note or
+     * occurrence. Requires list permission on the project (for example,
+     * `containeranalysis.notes.list`).
+     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
+     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
+     * occurrences.
+     * 
+ */ public void testIamPermissions( com.google.iam.v1.TestIamPermissionsRequest request, io.grpc.stub.StreamObserver @@ -361,7 +485,13 @@ public void testIamPermissions( responseObserver); } - /** */ + /** + * + * + *
+     * Gets a summary of the number and severity of occurrences.
+     * 
+ */ public void getVulnerabilityOccurrencesSummary( com.google.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest request, io.grpc.stub.StreamObserver @@ -373,7 +503,23 @@ public void getVulnerabilityOccurrencesSummary( } } - /** */ + /** + * + * + *
+   * Retrieves analysis results of Cloud components such as Docker container
+   * images. The Container Analysis API is an implementation of the
+   * [Grafeas](https://grafeas.io) API.
+   * Analysis results are stored as a series of occurrences. An `Occurrence`
+   * contains information about a specific analysis instance on a resource. An
+   * occurrence refers to a `Note`. A note contains details describing the
+   * analysis and is generally stored in a separate project, called a `Provider`.
+   * Multiple occurrences can refer to the same note.
+   * For example, an SSL vulnerability could affect multiple images. In this case,
+   * there would be one note for the vulnerability and an occurrence for each
+   * image with the vulnerability referring to that note.
+   * 
+ */ public static final class ContainerAnalysisBlockingStub extends io.grpc.stub.AbstractBlockingStub { private ContainerAnalysisBlockingStub( @@ -387,24 +533,65 @@ protected ContainerAnalysisBlockingStub build( return new ContainerAnalysisBlockingStub(channel, callOptions); } - /** */ + /** + * + * + *
+     * Sets the access control policy on the specified note or occurrence.
+     * Requires `containeranalysis.notes.setIamPolicy` or
+     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
+     * a note or an occurrence, respectively.
+     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
+     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
+     * occurrences.
+     * 
+ */ public com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request) { return blockingUnaryCall(getChannel(), getSetIamPolicyMethod(), getCallOptions(), request); } - /** */ + /** + * + * + *
+     * Gets the access control policy for a note or an occurrence resource.
+     * Requires `containeranalysis.notes.setIamPolicy` or
+     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
+     * a note or occurrence, respectively.
+     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
+     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
+     * occurrences.
+     * 
+ */ public com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request) { return blockingUnaryCall(getChannel(), getGetIamPolicyMethod(), getCallOptions(), request); } - /** */ + /** + * + * + *
+     * Returns the permissions that a caller has on the specified note or
+     * occurrence. Requires list permission on the project (for example,
+     * `containeranalysis.notes.list`).
+     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
+     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
+     * occurrences.
+     * 
+ */ public com.google.iam.v1.TestIamPermissionsResponse testIamPermissions( com.google.iam.v1.TestIamPermissionsRequest request) { return blockingUnaryCall( getChannel(), getTestIamPermissionsMethod(), getCallOptions(), request); } - /** */ + /** + * + * + *
+     * Gets a summary of the number and severity of occurrences.
+     * 
+ */ public com.google.containeranalysis.v1.VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary( com.google.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest request) { @@ -413,7 +600,23 @@ public com.google.iam.v1.TestIamPermissionsResponse testIamPermissions( } } - /** */ + /** + * + * + *
+   * Retrieves analysis results of Cloud components such as Docker container
+   * images. The Container Analysis API is an implementation of the
+   * [Grafeas](https://grafeas.io) API.
+   * Analysis results are stored as a series of occurrences. An `Occurrence`
+   * contains information about a specific analysis instance on a resource. An
+   * occurrence refers to a `Note`. A note contains details describing the
+   * analysis and is generally stored in a separate project, called a `Provider`.
+   * Multiple occurrences can refer to the same note.
+   * For example, an SSL vulnerability could affect multiple images. In this case,
+   * there would be one note for the vulnerability and an occurrence for each
+   * image with the vulnerability referring to that note.
+   * 
+ */ public static final class ContainerAnalysisFutureStub extends io.grpc.stub.AbstractFutureStub { private ContainerAnalysisFutureStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { @@ -426,21 +629,56 @@ protected ContainerAnalysisFutureStub build( return new ContainerAnalysisFutureStub(channel, callOptions); } - /** */ + /** + * + * + *
+     * Sets the access control policy on the specified note or occurrence.
+     * Requires `containeranalysis.notes.setIamPolicy` or
+     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
+     * a note or an occurrence, respectively.
+     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
+     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
+     * occurrences.
+     * 
+ */ public com.google.common.util.concurrent.ListenableFuture setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request) { return futureUnaryCall( getChannel().newCall(getSetIamPolicyMethod(), getCallOptions()), request); } - /** */ + /** + * + * + *
+     * Gets the access control policy for a note or an occurrence resource.
+     * Requires `containeranalysis.notes.setIamPolicy` or
+     * `containeranalysis.occurrences.setIamPolicy` permission if the resource is
+     * a note or occurrence, respectively.
+     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
+     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
+     * occurrences.
+     * 
+ */ public com.google.common.util.concurrent.ListenableFuture getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request) { return futureUnaryCall( getChannel().newCall(getGetIamPolicyMethod(), getCallOptions()), request); } - /** */ + /** + * + * + *
+     * Returns the permissions that a caller has on the specified note or
+     * occurrence. Requires list permission on the project (for example,
+     * `containeranalysis.notes.list`).
+     * The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for
+     * notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for
+     * occurrences.
+     * 
+ */ public com.google.common.util.concurrent.ListenableFuture< com.google.iam.v1.TestIamPermissionsResponse> testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request) { @@ -448,7 +686,13 @@ protected ContainerAnalysisFutureStub build( getChannel().newCall(getTestIamPermissionsMethod(), getCallOptions()), request); } - /** */ + /** + * + * + *
+     * Gets a summary of the number and severity of occurrences.
+     * 
+ */ public com.google.common.util.concurrent.ListenableFuture< com.google.containeranalysis.v1.VulnerabilityOccurrencesSummary> getVulnerabilityOccurrencesSummary( diff --git a/synth.metadata b/synth.metadata index 9212040f..a50988a0 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "b11a87f3b54be3a5e42c15020ee1e0781f86da90", - "internalRef": "344134135" + "sha": "8cfc6c874574b649b4524a4ef6a0651533325a84", + "internalRef": "345067549" } }, { From 23b35c470156f20d0e1a3fed4cc5bbc3a8d0d758 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Fri, 19 Feb 2021 15:08:09 -0800 Subject: [PATCH 4/9] chore: migrate containeranalysis to the Java microgenerator Committer: @miraleung PiperOrigin-RevId: 345310543 Source-Author: Google APIs Source-Date: Wed Dec 2 14:14:40 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: 4faa4a762126eb80db988e92065f25d628356c87 Source-Link: https://github.com/googleapis/googleapis/commit/4faa4a762126eb80db988e92065f25d628356c87 --- .../v1/ContainerAnalysisClient.java | 260 +++--------------- .../v1/ContainerAnalysisSettings.java | 33 ++- .../containeranalysis/v1/package-info.java | 18 +- .../v1/stub/ContainerAnalysisStub.java | 9 +- .../stub/ContainerAnalysisStubSettings.java | 98 ++++--- .../GrpcContainerAnalysisCallableFactory.java | 40 ++- .../v1/stub/GrpcContainerAnalysisStub.java | 38 ++- .../v1/ContainerAnalysisClientTest.java | 257 +++++++++++++---- .../v1/MockContainerAnalysis.java | 6 +- .../v1/MockContainerAnalysisImpl.java | 22 +- .../containeranalysis/v1/ProjectName.java | 92 ++++--- synth.metadata | 4 +- 12 files changed, 421 insertions(+), 456 deletions(-) diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java index 8219bfbd..f215b632 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.devtools.containeranalysis.v1; import com.google.api.core.BetaApi; @@ -32,10 +33,11 @@ import io.grafeas.v1.GrafeasClient; import java.io.IOException; import java.util.List; +import java.util.Objects; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND SERVICE +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Service Description: Retrieves analysis results of Cloud components such as Docker container * images. The Container Analysis API is an implementation of the [Grafeas](https://grafeas.io) API. @@ -52,17 +54,7 @@ *

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

- * 
- * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
- *   ResourceName resource = ProjectName.of("[PROJECT]");
- *   Policy policy = Policy.newBuilder().build();
- *   Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
- * }
- * 
- * 
- * - *

Note: close() needs to be called on the containerAnalysisClient object to clean up resources + *

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

To customize credentials: * - *

- * 
+ * 
{@code
  * ContainerAnalysisSettings containerAnalysisSettings =
  *     ContainerAnalysisSettings.newBuilder()
  *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
  *         .build();
  * ContainerAnalysisClient containerAnalysisClient =
  *     ContainerAnalysisClient.create(containerAnalysisSettings);
- * 
- * 
+ * }
* - * To customize the endpoint: + *

To customize the endpoint: * - *

- * 
+ * 
{@code
  * ContainerAnalysisSettings containerAnalysisSettings =
  *     ContainerAnalysisSettings.newBuilder().setEndpoint(myEndpoint).build();
  * ContainerAnalysisClient containerAnalysisClient =
  *     ContainerAnalysisClient.create(containerAnalysisSettings);
- * 
- * 
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@Generated("by gapic-generator") @BetaApi +@Generated("by gapic-generator") public class ContainerAnalysisClient implements BackgroundResource { private final ContainerAnalysisSettings settings; private final ContainerAnalysisStub stub; @@ -143,7 +133,7 @@ public static final ContainerAnalysisClient create(ContainerAnalysisSettings set /** * Constructs an instance of ContainerAnalysisClient, using the given stub for making calls. This - * is for advanced usage - prefer to use ContainerAnalysisSettings}. + * is for advanced usage - prefer using create(ContainerAnalysisSettings). */ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final ContainerAnalysisClient create(ContainerAnalysisStub stub) { @@ -175,7 +165,7 @@ public ContainerAnalysisStub getStub() { return stub; } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Sets the access control policy on the specified note or occurrence. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -184,16 +174,6 @@ public ContainerAnalysisStub getStub() { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * - *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ResourceName resource = ProjectName.of("[PROJECT]");
-   *   Policy policy = Policy.newBuilder().build();
-   *   Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
-   * }
-   * 
- * * @param resource REQUIRED: The resource for which the policy is being specified. See the * operation documentation for the appropriate value for this field. * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the @@ -204,13 +184,13 @@ public ContainerAnalysisStub getStub() { public final Policy setIamPolicy(ResourceName resource, Policy policy) { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() - .setResource(resource == null ? null : resource.toString()) + .setResource(Objects.isNull(resource) ? null : resource.toString()) .setPolicy(policy) .build(); return setIamPolicy(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Sets the access control policy on the specified note or occurrence. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -219,16 +199,6 @@ public final Policy setIamPolicy(ResourceName resource, Policy policy) { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * - *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ResourceName resource = ProjectName.of("[PROJECT]");
-   *   Policy policy = Policy.newBuilder().build();
-   *   Policy response = containerAnalysisClient.setIamPolicy(resource.toString(), policy);
-   * }
-   * 
- * * @param resource REQUIRED: The resource for which the policy is being specified. See the * operation documentation for the appropriate value for this field. * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the @@ -242,7 +212,7 @@ public final Policy setIamPolicy(String resource, Policy policy) { return setIamPolicy(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Sets the access control policy on the specified note or occurrence. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -251,20 +221,6 @@ public final Policy setIamPolicy(String resource, Policy policy) { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * - *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ResourceName resource = ProjectName.of("[PROJECT]");
-   *   Policy policy = Policy.newBuilder().build();
-   *   SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .setPolicy(policy)
-   *     .build();
-   *   Policy response = containerAnalysisClient.setIamPolicy(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -272,7 +228,7 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) { return setIamPolicyCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Sets the access control policy on the specified note or occurrence. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -282,26 +238,12 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) { * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ResourceName resource = ProjectName.of("[PROJECT]");
-   *   Policy policy = Policy.newBuilder().build();
-   *   SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .setPolicy(policy)
-   *     .build();
-   *   ApiFuture<Policy> future = containerAnalysisClient.setIamPolicyCallable().futureCall(request);
-   *   // Do something
-   *   Policy response = future.get();
-   * }
-   * 
*/ public final UnaryCallable setIamPolicyCallable() { return stub.setIamPolicyCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets the access control policy for a note or an occurrence resource. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -310,15 +252,6 @@ public final UnaryCallable setIamPolicyCallable() { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * - *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ResourceName resource = ProjectName.of("[PROJECT]");
-   *   Policy response = containerAnalysisClient.getIamPolicy(resource);
-   * }
-   * 
- * * @param resource REQUIRED: The resource for which the policy is being requested. See the * operation documentation for the appropriate value for this field. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -326,12 +259,12 @@ public final UnaryCallable setIamPolicyCallable() { public final Policy getIamPolicy(ResourceName resource) { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() - .setResource(resource == null ? null : resource.toString()) + .setResource(Objects.isNull(resource) ? null : resource.toString()) .build(); return getIamPolicy(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets the access control policy for a note or an occurrence resource. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -340,15 +273,6 @@ public final Policy getIamPolicy(ResourceName resource) { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * - *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ResourceName resource = ProjectName.of("[PROJECT]");
-   *   Policy response = containerAnalysisClient.getIamPolicy(resource.toString());
-   * }
-   * 
- * * @param resource REQUIRED: The resource for which the policy is being requested. See the * operation documentation for the appropriate value for this field. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -358,7 +282,7 @@ public final Policy getIamPolicy(String resource) { return getIamPolicy(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets the access control policy for a note or an occurrence resource. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -367,18 +291,6 @@ public final Policy getIamPolicy(String resource) { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * - *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ResourceName resource = ProjectName.of("[PROJECT]");
-   *   GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .build();
-   *   Policy response = containerAnalysisClient.getIamPolicy(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -386,7 +298,7 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) { return getIamPolicyCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets the access control policy for a note or an occurrence resource. Requires * `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` @@ -396,24 +308,12 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) { * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ResourceName resource = ProjectName.of("[PROJECT]");
-   *   GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .build();
-   *   ApiFuture<Policy> future = containerAnalysisClient.getIamPolicyCallable().futureCall(request);
-   *   // Do something
-   *   Policy response = future.get();
-   * }
-   * 
*/ public final UnaryCallable getIamPolicyCallable() { return stub.getIamPolicyCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the permissions that a caller has on the specified note or occurrence. Requires list * permission on the project (for example, `containeranalysis.notes.list`). @@ -421,16 +321,6 @@ public final UnaryCallable getIamPolicyCallable() { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * - *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ResourceName resource = ProjectName.of("[PROJECT]");
-   *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsResponse response = containerAnalysisClient.testIamPermissions(resource, permissions);
-   * }
-   * 
- * * @param resource REQUIRED: The resource for which the policy detail is being requested. See the * operation documentation for the appropriate value for this field. * @param permissions The set of permissions to check for the `resource`. Permissions with @@ -442,13 +332,13 @@ public final TestIamPermissionsResponse testIamPermissions( ResourceName resource, List permissions) { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() - .setResource(resource == null ? null : resource.toString()) + .setResource(Objects.isNull(resource) ? null : resource.toString()) .addAllPermissions(permissions) .build(); return testIamPermissions(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the permissions that a caller has on the specified note or occurrence. Requires list * permission on the project (for example, `containeranalysis.notes.list`). @@ -456,16 +346,6 @@ public final TestIamPermissionsResponse testIamPermissions( *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * - *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ResourceName resource = ProjectName.of("[PROJECT]");
-   *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsResponse response = containerAnalysisClient.testIamPermissions(resource.toString(), permissions);
-   * }
-   * 
- * * @param resource REQUIRED: The resource for which the policy detail is being requested. See the * operation documentation for the appropriate value for this field. * @param permissions The set of permissions to check for the `resource`. Permissions with @@ -483,7 +363,7 @@ public final TestIamPermissionsResponse testIamPermissions( return testIamPermissions(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the permissions that a caller has on the specified note or occurrence. Requires list * permission on the project (for example, `containeranalysis.notes.list`). @@ -491,20 +371,6 @@ public final TestIamPermissionsResponse testIamPermissions( *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * - *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ResourceName resource = ProjectName.of("[PROJECT]");
-   *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .addAllPermissions(permissions)
-   *     .build();
-   *   TestIamPermissionsResponse response = containerAnalysisClient.testIamPermissions(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -512,7 +378,7 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq return testIamPermissionsCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Returns the permissions that a caller has on the specified note or occurrence. Requires list * permission on the project (for example, `containeranalysis.notes.list`). @@ -521,40 +387,16 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ResourceName resource = ProjectName.of("[PROJECT]");
-   *   List<String> permissions = new ArrayList<>();
-   *   TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
-   *     .setResource(resource.toString())
-   *     .addAllPermissions(permissions)
-   *     .build();
-   *   ApiFuture<TestIamPermissionsResponse> future = containerAnalysisClient.testIamPermissionsCallable().futureCall(request);
-   *   // Do something
-   *   TestIamPermissionsResponse response = future.get();
-   * }
-   * 
*/ public final UnaryCallable testIamPermissionsCallable() { return stub.testIamPermissionsCallable(); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a summary of the number and severity of occurrences. * - *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   String filter = "";
-   *   VulnerabilityOccurrencesSummary response = containerAnalysisClient.getVulnerabilityOccurrencesSummary(parent, filter);
-   * }
-   * 
- * * @param parent The name of the project to get a vulnerability summary for in the form of * `projects/[PROJECT_ID]`. * @param filter The filter expression. @@ -564,26 +406,16 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary( ProjectName parent, String filter) { GetVulnerabilityOccurrencesSummaryRequest request = GetVulnerabilityOccurrencesSummaryRequest.newBuilder() - .setParent(parent == null ? null : parent.toString()) + .setParent(Objects.isNull(parent) ? null : parent.toString()) .setFilter(filter) .build(); return getVulnerabilityOccurrencesSummary(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a summary of the number and severity of occurrences. * - *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   String filter = "";
-   *   VulnerabilityOccurrencesSummary response = containerAnalysisClient.getVulnerabilityOccurrencesSummary(parent.toString(), filter);
-   * }
-   * 
- * * @param parent The name of the project to get a vulnerability summary for in the form of * `projects/[PROJECT_ID]`. * @param filter The filter expression. @@ -599,22 +431,10 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary( return getVulnerabilityOccurrencesSummary(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a summary of the number and severity of occurrences. * - *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   GetVulnerabilityOccurrencesSummaryRequest request = GetVulnerabilityOccurrencesSummaryRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   VulnerabilityOccurrencesSummary response = containerAnalysisClient.getVulnerabilityOccurrencesSummary(request);
-   * }
-   * 
- * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -623,23 +443,11 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary( return getVulnerabilityOccurrencesSummaryCallable().call(request); } - // AUTO-GENERATED DOCUMENTATION AND METHOD + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Gets a summary of the number and severity of occurrences. * *

Sample code: - * - *


-   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
-   *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   GetVulnerabilityOccurrencesSummaryRequest request = GetVulnerabilityOccurrencesSummaryRequest.newBuilder()
-   *     .setParent(parent.toString())
-   *     .build();
-   *   ApiFuture<VulnerabilityOccurrencesSummary> future = containerAnalysisClient.getVulnerabilityOccurrencesSummaryCallable().futureCall(request);
-   *   // Do something
-   *   VulnerabilityOccurrencesSummary response = future.get();
-   * }
-   * 
*/ public final UnaryCallable< GetVulnerabilityOccurrencesSummaryRequest, VulnerabilityOccurrencesSummary> diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisSettings.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisSettings.java index ec36003b..3b04fe4b 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisSettings.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.devtools.containeranalysis.v1; import com.google.api.core.ApiFunction; @@ -37,7 +38,7 @@ import java.util.List; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link ContainerAnalysisClient}. * @@ -55,23 +56,24 @@ * *

For example, to set the total timeout of setIamPolicy to 30 seconds: * - *

- * 
+ * 
{@code
  * ContainerAnalysisSettings.Builder containerAnalysisSettingsBuilder =
  *     ContainerAnalysisSettings.newBuilder();
  * containerAnalysisSettingsBuilder
  *     .setIamPolicySettings()
  *     .setRetrySettings(
- *         containerAnalysisSettingsBuilder.setIamPolicySettings().getRetrySettings().toBuilder()
+ *         containerAnalysisSettingsBuilder
+ *             .setIamPolicySettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
  * ContainerAnalysisSettings containerAnalysisSettings = containerAnalysisSettingsBuilder.build();
- * 
- * 
+ * }
*/ -@Generated("by gapic-generator") -@BetaApi +@Generated("by gapic-generator-java") public class ContainerAnalysisSettings extends ClientSettings { + /** Returns the object with the settings used for calls to setIamPolicy. */ public UnaryCallSettings setIamPolicySettings() { return ((ContainerAnalysisStubSettings) getStubSettings()).setIamPolicySettings(); @@ -156,18 +158,15 @@ protected ContainerAnalysisSettings(Builder settingsBuilder) throws IOException /** Builder for ContainerAnalysisSettings. */ public static class Builder extends ClientSettings.Builder { + protected Builder() throws IOException { - this((ClientContext) null); + this(((ClientContext) null)); } protected Builder(ClientContext clientContext) { super(ContainerAnalysisStubSettings.newBuilder(clientContext)); } - private static Builder createDefault() { - return new Builder(ContainerAnalysisStubSettings.newBuilder()); - } - protected Builder(ContainerAnalysisSettings settings) { super(settings.getStubSettings().toBuilder()); } @@ -176,11 +175,15 @@ protected Builder(ContainerAnalysisStubSettings.Builder stubSettings) { super(stubSettings); } + private static Builder createDefault() { + return new Builder(ContainerAnalysisStubSettings.newBuilder()); + } + public ContainerAnalysisStubSettings.Builder getStubSettingsBuilder() { return ((ContainerAnalysisStubSettings.Builder) getStubSettings()); } - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/package-info.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/package-info.java index 0a2831fd..20d05f6c 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/package-info.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/package-info.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -15,9 +15,7 @@ */ /** - * A client to Container Analysis API. - * - *

The interfaces provided are listed below, along with usage samples. + * The interfaces provided are listed below, along with usage samples. * *

======================= ContainerAnalysisClient ======================= * @@ -34,18 +32,8 @@ * to that note. * *

Sample for ContainerAnalysisClient: - * - *

- * 
- * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
- *   ResourceName resource = ProjectName.of("[PROJECT]");
- *   Policy policy = Policy.newBuilder().build();
- *   Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
- * }
- * 
- * 
*/ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") package com.google.cloud.devtools.containeranalysis.v1; import javax.annotation.Generated; diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStub.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStub.java index 7577d06a..39290c52 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStub.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.devtools.containeranalysis.v1.stub; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.rpc.UnaryCallable; import com.google.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest; @@ -27,14 +27,13 @@ import com.google.iam.v1.TestIamPermissionsResponse; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * Base stub class for Container Analysis API. + * Base stub class for the ContainerAnalysis service API. * *

This class is for advanced usage and reflects the underlying API directly. */ @Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") public abstract class ContainerAnalysisStub implements BackgroundResource { public UnaryCallable setIamPolicyCallable() { diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStubSettings.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStubSettings.java index 980c85bb..30a8e779 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStubSettings.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStubSettings.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.devtools.containeranalysis.v1.stub; import com.google.api.core.ApiFunction; @@ -46,7 +47,7 @@ import javax.annotation.Generated; import org.threeten.bp.Duration; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** * Settings class to configure an instance of {@link ContainerAnalysisStub}. * @@ -64,22 +65,24 @@ * *

For example, to set the total timeout of setIamPolicy to 30 seconds: * - *

- * 
+ * 
{@code
  * ContainerAnalysisStubSettings.Builder containerAnalysisSettingsBuilder =
  *     ContainerAnalysisStubSettings.newBuilder();
  * containerAnalysisSettingsBuilder
  *     .setIamPolicySettings()
  *     .setRetrySettings(
- *         containerAnalysisSettingsBuilder.setIamPolicySettings().getRetrySettings().toBuilder()
+ *         containerAnalysisSettingsBuilder
+ *             .setIamPolicySettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
- * ContainerAnalysisStubSettings containerAnalysisSettings = containerAnalysisSettingsBuilder.build();
- * 
- * 
+ * ContainerAnalysisStubSettings containerAnalysisSettings = + * containerAnalysisSettingsBuilder.build(); + * }
*/ -@Generated("by gapic-generator") @BetaApi +@Generated("by gapic-generator-java") public class ContainerAnalysisStubSettings extends StubSettings { /** The default scopes of the service. */ private static final ImmutableList DEFAULT_SERVICE_SCOPES = @@ -122,10 +125,10 @@ public ContainerAnalysisStub createStub() throws IOException { .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcContainerAnalysisStub.create(this); - } else { - throw new UnsupportedOperationException( - "Transport not supported: " + getTransportChannelProvider().getTransportName()); } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); } /** Returns a builder for the default ExecutorProvider for this service. */ @@ -195,7 +198,6 @@ protected ContainerAnalysisStubSettings(Builder settingsBuilder) throws IOExcept /** Builder for ContainerAnalysisStubSettings. */ public static class Builder extends StubSettings.Builder { private final ImmutableList> unaryMethodSettingsBuilders; - private final UnaryCallSettings.Builder setIamPolicySettings; private final UnaryCallSettings.Builder getIamPolicySettings; private final UnaryCallSettings.Builder @@ -203,16 +205,15 @@ public static class Builder extends StubSettings.Builder getVulnerabilityOccurrencesSummarySettings; - private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; static { ImmutableMap.Builder> definitions = ImmutableMap.builder(); - definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); definitions.put( - "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); + "no_retry_0_codes", ImmutableSet.copyOf(Lists.newArrayList())); + definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); RETRYABLE_CODE_DEFINITIONS = definitions.build(); } @@ -221,8 +222,6 @@ public static class Builder extends StubSettings.Builder definitions = ImmutableMap.builder(); RetrySettings settings = null; - settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); - definitions.put("no_retry_params", settings); settings = RetrySettings.newBuilder() .setInitialRpcTimeout(Duration.ofMillis(30000L)) @@ -230,23 +229,22 @@ public static class Builder extends StubSettings.Builder>of( + setIamPolicySettings, + getIamPolicySettings, + testIamPermissionsSettings, + getVulnerabilityOccurrencesSummarySettings); + } + private static Builder createDefault() { - Builder builder = new Builder((ClientContext) null); + Builder builder = new Builder(((ClientContext) null)); + builder.setTransportChannelProvider(defaultTransportChannelProvider()); builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); builder.setEndpoint(getDefaultEndpoint()); + return initDefaults(builder); } private static Builder initDefaults(Builder builder) { - builder .setIamPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); builder .getIamPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); builder .testIamPermissionsSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) - .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); builder .getVulnerabilityOccurrencesSummarySettings() @@ -293,24 +308,7 @@ private static Builder initDefaults(Builder builder) { return builder; } - protected Builder(ContainerAnalysisStubSettings settings) { - super(settings); - - setIamPolicySettings = settings.setIamPolicySettings.toBuilder(); - getIamPolicySettings = settings.getIamPolicySettings.toBuilder(); - testIamPermissionsSettings = settings.testIamPermissionsSettings.toBuilder(); - getVulnerabilityOccurrencesSummarySettings = - settings.getVulnerabilityOccurrencesSummarySettings.toBuilder(); - - unaryMethodSettingsBuilders = - ImmutableList.>of( - setIamPolicySettings, - getIamPolicySettings, - testIamPermissionsSettings, - getVulnerabilityOccurrencesSummarySettings); - } - - // NEXT_MAJOR_VER: remove 'throws Exception' + // NEXT_MAJOR_VER: remove 'throws Exception'. /** * Applies the given settings updater function to all of the unary API methods in this service. * diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisCallableFactory.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisCallableFactory.java index 10889167..266236b6 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisCallableFactory.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisCallableFactory.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.devtools.containeranalysis.v1.stub; -import com.google.api.core.BetaApi; import com.google.api.gax.grpc.GrpcCallSettings; import com.google.api.gax.grpc.GrpcCallableFactory; import com.google.api.gax.grpc.GrpcStubCallableFactory; @@ -31,18 +31,19 @@ import com.google.api.gax.rpc.StreamingCallSettings; import com.google.api.gax.rpc.UnaryCallSettings; import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; import com.google.longrunning.stub.OperationsStub; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC callable factory implementation for Container Analysis API. + * gRPC callable factory implementation for the ContainerAnalysis service API. * *

This class is for advanced usage. */ @Generated("by gapic-generator") -@BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public class GrpcContainerAnalysisCallableFactory implements GrpcStubCallableFactory { + @Override public UnaryCallable createUnaryCallable( GrpcCallSettings grpcCallSettings, @@ -55,61 +56,58 @@ public UnaryCallable createUnaryCalla public UnaryCallable createPagedCallable( GrpcCallSettings grpcCallSettings, - PagedCallSettings pagedCallSettings, + PagedCallSettings callSettings, ClientContext clientContext) { - return GrpcCallableFactory.createPagedCallable( - grpcCallSettings, pagedCallSettings, clientContext); + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); } @Override public UnaryCallable createBatchingCallable( GrpcCallSettings grpcCallSettings, - BatchingCallSettings batchingCallSettings, + BatchingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBatchingCallable( - grpcCallSettings, batchingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } - @BetaApi( - "The surface for long-running operations is not stable yet and may change in the future.") @Override public OperationCallable createOperationCallable( - GrpcCallSettings grpcCallSettings, - OperationCallSettings operationCallSettings, + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, ClientContext clientContext, OperationsStub operationsStub) { return GrpcCallableFactory.createOperationCallable( - grpcCallSettings, operationCallSettings, clientContext, operationsStub); + grpcCallSettings, callSettings, clientContext, operationsStub); } @Override public BidiStreamingCallable createBidiStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createBidiStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ServerStreamingCallable createServerStreamingCallable( GrpcCallSettings grpcCallSettings, - ServerStreamingCallSettings streamingCallSettings, + ServerStreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createServerStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } @Override public ClientStreamingCallable createClientStreamingCallable( GrpcCallSettings grpcCallSettings, - StreamingCallSettings streamingCallSettings, + StreamingCallSettings callSettings, ClientContext clientContext) { return GrpcCallableFactory.createClientStreamingCallable( - grpcCallSettings, streamingCallSettings, clientContext); + grpcCallSettings, callSettings, clientContext); } } diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java index 1d0cfe8a..2b950a3b 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.devtools.containeranalysis.v1.stub; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.core.BackgroundResourceAggregation; import com.google.api.gax.grpc.GrpcCallSettings; @@ -31,6 +31,7 @@ import com.google.iam.v1.SetIamPolicyRequest; import com.google.iam.v1.TestIamPermissionsRequest; import com.google.iam.v1.TestIamPermissionsResponse; +import com.google.longrunning.stub.GrpcOperationsStub; import io.grpc.MethodDescriptor; import io.grpc.protobuf.ProtoUtils; import java.io.IOException; @@ -38,16 +39,14 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Generated; -// AUTO-GENERATED DOCUMENTATION AND CLASS +// AUTO-GENERATED DOCUMENTATION AND CLASS. /** - * gRPC stub implementation for Container Analysis API. + * gRPC stub implementation for the ContainerAnalysis service API. * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") -@BetaApi("A restructuring of stub classes is planned, so this may break in the future") +@Generated("by gapic-generator-java") public class GrpcContainerAnalysisStub extends ContainerAnalysisStub { - private static final MethodDescriptor setIamPolicyMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -55,6 +54,7 @@ public class GrpcContainerAnalysisStub extends ContainerAnalysisStub { .setRequestMarshaller(ProtoUtils.marshaller(SetIamPolicyRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) .build(); + private static final MethodDescriptor getIamPolicyMethodDescriptor = MethodDescriptor.newBuilder() .setType(MethodDescriptor.MethodType.UNARY) @@ -62,6 +62,7 @@ public class GrpcContainerAnalysisStub extends ContainerAnalysisStub { .setRequestMarshaller(ProtoUtils.marshaller(GetIamPolicyRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Policy.getDefaultInstance())) .build(); + private static final MethodDescriptor testIamPermissionsMethodDescriptor = MethodDescriptor.newBuilder() @@ -73,6 +74,7 @@ public class GrpcContainerAnalysisStub extends ContainerAnalysisStub { .setResponseMarshaller( ProtoUtils.marshaller(TestIamPermissionsResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor< GetVulnerabilityOccurrencesSummaryRequest, VulnerabilityOccurrencesSummary> getVulnerabilityOccurrencesSummaryMethodDescriptor = @@ -89,8 +91,6 @@ public class GrpcContainerAnalysisStub extends ContainerAnalysisStub { ProtoUtils.marshaller(VulnerabilityOccurrencesSummary.getDefaultInstance())) .build(); - private final BackgroundResource backgroundResources; - private final UnaryCallable setIamPolicyCallable; private final UnaryCallable getIamPolicyCallable; private final UnaryCallable @@ -99,6 +99,8 @@ public class GrpcContainerAnalysisStub extends ContainerAnalysisStub { GetVulnerabilityOccurrencesSummaryRequest, VulnerabilityOccurrencesSummary> getVulnerabilityOccurrencesSummaryCallable; + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; private final GrpcStubCallableFactory callableFactory; public static final GrpcContainerAnalysisStub create(ContainerAnalysisStubSettings settings) @@ -118,27 +120,18 @@ public static final GrpcContainerAnalysisStub create( ContainerAnalysisStubSettings.newBuilder().build(), clientContext, callableFactory); } - /** - * Constructs an instance of GrpcContainerAnalysisStub, 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 GrpcContainerAnalysisStub( ContainerAnalysisStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new GrpcContainerAnalysisCallableFactory()); } - /** - * Constructs an instance of GrpcContainerAnalysisStub, 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 GrpcContainerAnalysisStub( ContainerAnalysisStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); GrpcCallSettings setIamPolicyTransportSettings = GrpcCallSettings.newBuilder() @@ -215,7 +208,12 @@ public Map extract( settings.getVulnerabilityOccurrencesSummarySettings(), clientContext); - backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; } public UnaryCallable setIamPolicyCallable() { diff --git a/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClientTest.java b/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClientTest.java index e246db6a..b7f12bc7 100644 --- a/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClientTest.java +++ b/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClientTest.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.devtools.containeranalysis.v1; import com.google.api.gax.core.NoCredentialsProvider; @@ -26,6 +27,7 @@ import com.google.containeranalysis.v1.GetVulnerabilityOccurrencesSummaryRequest; import com.google.containeranalysis.v1.ProjectName; import com.google.containeranalysis.v1.VulnerabilityOccurrencesSummary; +import com.google.iam.v1.Binding; import com.google.iam.v1.GetIamPolicyRequest; import com.google.iam.v1.Policy; import com.google.iam.v1.SetIamPolicyRequest; @@ -33,14 +35,13 @@ import com.google.iam.v1.TestIamPermissionsResponse; import com.google.protobuf.AbstractMessage; import com.google.protobuf.ByteString; -import io.grpc.Status; import io.grpc.StatusRuntimeException; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Objects; import java.util.UUID; +import javax.annotation.Generated; import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; @@ -48,31 +49,31 @@ import org.junit.BeforeClass; import org.junit.Test; -@javax.annotation.Generated("by GAPIC") +@Generated("by gapic-generator-java") public class ContainerAnalysisClientTest { - private static MockContainerAnalysis mockContainerAnalysis; - private static MockServiceHelper serviceHelper; + private static MockServiceHelper mockServiceHelper; private ContainerAnalysisClient client; + private static MockContainerAnalysis mockContainerAnalysis; private LocalChannelProvider channelProvider; @BeforeClass public static void startStaticServer() { mockContainerAnalysis = new MockContainerAnalysis(); - serviceHelper = + mockServiceHelper = new MockServiceHelper( UUID.randomUUID().toString(), Arrays.asList(mockContainerAnalysis)); - serviceHelper.start(); + mockServiceHelper.start(); } @AfterClass public static void stopServer() { - serviceHelper.stop(); + mockServiceHelper.stop(); } @Before public void setUp() throws IOException { - serviceHelper.reset(); - channelProvider = serviceHelper.createChannelProvider(); + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); ContainerAnalysisSettings settings = ContainerAnalysisSettings.newBuilder() .setTransportChannelProvider(channelProvider) @@ -87,11 +88,13 @@ public void tearDown() throws Exception { } @Test - @SuppressWarnings("all") - public void setIamPolicyTest() { - int version = 351608024; - ByteString etag = ByteString.copyFromUtf8("21"); - Policy expectedResponse = Policy.newBuilder().setVersion(version).setEtag(etag).build(); + public void setIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); mockContainerAnalysis.addResponse(expectedResponse); ResourceName resource = ProjectName.of("[PROJECT]"); @@ -102,9 +105,9 @@ public void setIamPolicyTest() { List actualRequests = mockContainerAnalysis.getRequests(); Assert.assertEquals(1, actualRequests.size()); - SetIamPolicyRequest actualRequest = (SetIamPolicyRequest) actualRequests.get(0); + SetIamPolicyRequest actualRequest = ((SetIamPolicyRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(resource), Objects.toString(actualRequest.getResource())); + Assert.assertEquals(resource.toString(), actualRequest.getResource()); Assert.assertEquals(policy, actualRequest.getPolicy()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -113,28 +116,71 @@ public void setIamPolicyTest() { } @Test - @SuppressWarnings("all") public void setIamPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockContainerAnalysis.addException(exception); try { ResourceName resource = ProjectName.of("[PROJECT]"); Policy policy = Policy.newBuilder().build(); + client.setIamPolicy(resource, policy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void setIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockContainerAnalysis.addResponse(expectedResponse); + + String resource = "resource-341064690"; + Policy policy = Policy.newBuilder().build(); + + Policy actualResponse = client.setIamPolicy(resource, policy); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockContainerAnalysis.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + SetIamPolicyRequest actualRequest = ((SetIamPolicyRequest) actualRequests.get(0)); + + Assert.assertEquals(resource, actualRequest.getResource()); + Assert.assertEquals(policy, actualRequest.getPolicy()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void setIamPolicyExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockContainerAnalysis.addException(exception); + try { + String resource = "resource-341064690"; + Policy policy = Policy.newBuilder().build(); client.setIamPolicy(resource, policy); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getIamPolicyTest() { - int version = 351608024; - ByteString etag = ByteString.copyFromUtf8("21"); - Policy expectedResponse = Policy.newBuilder().setVersion(version).setEtag(etag).build(); + public void getIamPolicyTest() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); mockContainerAnalysis.addResponse(expectedResponse); ResourceName resource = ProjectName.of("[PROJECT]"); @@ -144,9 +190,9 @@ public void getIamPolicyTest() { List actualRequests = mockContainerAnalysis.getRequests(); Assert.assertEquals(1, actualRequests.size()); - GetIamPolicyRequest actualRequest = (GetIamPolicyRequest) actualRequests.get(0); + GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(resource), Objects.toString(actualRequest.getResource())); + Assert.assertEquals(resource.toString(), actualRequest.getResource()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -154,25 +200,63 @@ public void getIamPolicyTest() { } @Test - @SuppressWarnings("all") public void getIamPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockContainerAnalysis.addException(exception); try { ResourceName resource = ProjectName.of("[PROJECT]"); + client.getIamPolicy(resource); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIamPolicyTest2() throws Exception { + Policy expectedResponse = + Policy.newBuilder() + .setVersion(351608024) + .addAllBindings(new ArrayList()) + .setEtag(ByteString.EMPTY) + .build(); + mockContainerAnalysis.addResponse(expectedResponse); + + String resource = "resource-341064690"; + + Policy actualResponse = client.getIamPolicy(resource); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockContainerAnalysis.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0)); + Assert.assertEquals(resource, actualRequest.getResource()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getIamPolicyExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockContainerAnalysis.addException(exception); + + try { + String resource = "resource-341064690"; client.getIamPolicy(resource); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void testIamPermissionsTest() { - TestIamPermissionsResponse expectedResponse = TestIamPermissionsResponse.newBuilder().build(); + public void testIamPermissionsTest() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); mockContainerAnalysis.addResponse(expectedResponse); ResourceName resource = ProjectName.of("[PROJECT]"); @@ -183,9 +267,9 @@ public void testIamPermissionsTest() { List actualRequests = mockContainerAnalysis.getRequests(); Assert.assertEquals(1, actualRequests.size()); - TestIamPermissionsRequest actualRequest = (TestIamPermissionsRequest) actualRequests.get(0); + TestIamPermissionsRequest actualRequest = ((TestIamPermissionsRequest) actualRequests.get(0)); - Assert.assertEquals(Objects.toString(resource), Objects.toString(actualRequest.getResource())); + Assert.assertEquals(resource.toString(), actualRequest.getResource()); Assert.assertEquals(permissions, actualRequest.getPermissionsList()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -194,27 +278,65 @@ public void testIamPermissionsTest() { } @Test - @SuppressWarnings("all") public void testIamPermissionsExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockContainerAnalysis.addException(exception); try { ResourceName resource = ProjectName.of("[PROJECT]"); List permissions = new ArrayList<>(); + client.testIamPermissions(resource, permissions); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void testIamPermissionsTest2() throws Exception { + TestIamPermissionsResponse expectedResponse = + TestIamPermissionsResponse.newBuilder().addAllPermissions(new ArrayList()).build(); + mockContainerAnalysis.addResponse(expectedResponse); + + String resource = "resource-341064690"; + List permissions = new ArrayList<>(); + + TestIamPermissionsResponse actualResponse = client.testIamPermissions(resource, permissions); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockContainerAnalysis.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + TestIamPermissionsRequest actualRequest = ((TestIamPermissionsRequest) actualRequests.get(0)); + Assert.assertEquals(resource, actualRequest.getResource()); + Assert.assertEquals(permissions, actualRequest.getPermissionsList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void testIamPermissionsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockContainerAnalysis.addException(exception); + + try { + String resource = "resource-341064690"; + List permissions = new ArrayList<>(); client.testIamPermissions(resource, permissions); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } @Test - @SuppressWarnings("all") - public void getVulnerabilityOccurrencesSummaryTest() { + public void getVulnerabilityOccurrencesSummaryTest() throws Exception { VulnerabilityOccurrencesSummary expectedResponse = - VulnerabilityOccurrencesSummary.newBuilder().build(); + VulnerabilityOccurrencesSummary.newBuilder() + .addAllCounts(new ArrayList()) + .build(); mockContainerAnalysis.addResponse(expectedResponse); ProjectName parent = ProjectName.of("[PROJECT]"); @@ -227,9 +349,9 @@ public void getVulnerabilityOccurrencesSummaryTest() { List actualRequests = mockContainerAnalysis.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetVulnerabilityOccurrencesSummaryRequest actualRequest = - (GetVulnerabilityOccurrencesSummaryRequest) actualRequests.get(0); + ((GetVulnerabilityOccurrencesSummaryRequest) actualRequests.get(0)); - Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent())); + Assert.assertEquals(parent.toString(), actualRequest.getParent()); Assert.assertEquals(filter, actualRequest.getFilter()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -238,19 +360,60 @@ public void getVulnerabilityOccurrencesSummaryTest() { } @Test - @SuppressWarnings("all") public void getVulnerabilityOccurrencesSummaryExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); mockContainerAnalysis.addException(exception); try { ProjectName parent = ProjectName.of("[PROJECT]"); String filter = "filter-1274492040"; + client.getVulnerabilityOccurrencesSummary(parent, filter); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVulnerabilityOccurrencesSummaryTest2() throws Exception { + VulnerabilityOccurrencesSummary expectedResponse = + VulnerabilityOccurrencesSummary.newBuilder() + .addAllCounts(new ArrayList()) + .build(); + mockContainerAnalysis.addResponse(expectedResponse); + + String parent = "parent-995424086"; + String filter = "filter-1274492040"; + + VulnerabilityOccurrencesSummary actualResponse = + client.getVulnerabilityOccurrencesSummary(parent, filter); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockContainerAnalysis.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetVulnerabilityOccurrencesSummaryRequest actualRequest = + ((GetVulnerabilityOccurrencesSummaryRequest) actualRequests.get(0)); + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(filter, actualRequest.getFilter()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getVulnerabilityOccurrencesSummaryExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockContainerAnalysis.addException(exception); + + try { + String parent = "parent-995424086"; + String filter = "filter-1274492040"; client.getVulnerabilityOccurrencesSummary(parent, filter); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { - // Expected exception + // Expected exception. } } } diff --git a/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysis.java b/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysis.java index 5d45f6ab..a64fe61e 100644 --- a/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysis.java +++ b/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysis.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.devtools.containeranalysis.v1; import com.google.api.core.BetaApi; @@ -20,9 +21,10 @@ import com.google.protobuf.AbstractMessage; import io.grpc.ServerServiceDefinition; import java.util.List; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockContainerAnalysis implements MockGrpcService { private final MockContainerAnalysisImpl serviceImpl; diff --git a/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysisImpl.java b/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysisImpl.java index f890c448..ee65fb5d 100644 --- a/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysisImpl.java +++ b/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysisImpl.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.google.cloud.devtools.containeranalysis.v1; import com.google.api.core.BetaApi; @@ -30,9 +31,10 @@ import java.util.LinkedList; import java.util.List; import java.util.Queue; +import javax.annotation.Generated; -@javax.annotation.Generated("by GAPIC") @BetaApi +@Generated("by gapic-generator-java") public class MockContainerAnalysisImpl extends ContainerAnalysisImplBase { private List requests; private Queue responses; @@ -68,10 +70,10 @@ public void setIamPolicy(SetIamPolicyRequest request, StreamObserver res Object response = responses.remove(); if (response instanceof Policy) { requests.add(request); - responseObserver.onNext((Policy) response); + responseObserver.onNext(((Policy) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -82,10 +84,10 @@ public void getIamPolicy(GetIamPolicyRequest request, StreamObserver res Object response = responses.remove(); if (response instanceof Policy) { requests.add(request); - responseObserver.onNext((Policy) response); + responseObserver.onNext(((Policy) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -98,10 +100,10 @@ public void testIamPermissions( Object response = responses.remove(); if (response instanceof TestIamPermissionsResponse) { requests.add(request); - responseObserver.onNext((TestIamPermissionsResponse) response); + responseObserver.onNext(((TestIamPermissionsResponse) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } @@ -114,10 +116,10 @@ public void getVulnerabilityOccurrencesSummary( Object response = responses.remove(); if (response instanceof VulnerabilityOccurrencesSummary) { requests.add(request); - responseObserver.onNext((VulnerabilityOccurrencesSummary) response); + responseObserver.onNext(((VulnerabilityOccurrencesSummary) response)); responseObserver.onCompleted(); } else if (response instanceof Exception) { - responseObserver.onError((Exception) response); + responseObserver.onError(((Exception) response)); } else { responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); } diff --git a/proto-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ProjectName.java b/proto-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ProjectName.java index 651c4994..33640438 100644 --- a/proto-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ProjectName.java +++ b/proto-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ProjectName.java @@ -5,7 +5,7 @@ * 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 + * 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, @@ -23,18 +23,26 @@ 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 */ -@javax.annotation.Generated("by GAPIC protoc plugin") +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") public class ProjectName implements ResourceName { - - private static final PathTemplate PATH_TEMPLATE = + private static final PathTemplate PROJECT = PathTemplate.createWithoutUrlEncoding("projects/{project}"); - private volatile Map fieldValuesMap; - private final String project; + @Deprecated + protected ProjectName() { + project = null; + } + + private ProjectName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + } + public String getProject() { return project; } @@ -47,10 +55,6 @@ public Builder toBuilder() { return new Builder(this); } - private ProjectName(Builder builder) { - project = Preconditions.checkNotNull(builder.getProject()); - } - public static ProjectName of(String project) { return newBuilder().setProject(project).build(); } @@ -64,7 +68,7 @@ public static ProjectName parse(String formattedString) { return null; } Map matchMap = - PATH_TEMPLATE.validatedMatch( + PROJECT.validatedMatch( formattedString, "ProjectName.parse: formattedString not in valid format"); return of(matchMap.get("project")); } @@ -78,9 +82,9 @@ public static List parseList(List formattedStrings) { } public static List toStringList(List values) { - List list = new ArrayList(values.size()); + List list = new ArrayList<>(values.size()); for (ProjectName value : values) { - if (value == null) { + if (Objects.isNull(value)) { list.add(""); } else { list.add(value.toString()); @@ -90,15 +94,18 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT.matches(formattedString); } + @Override public Map getFieldValuesMap() { - if (fieldValuesMap == null) { + if (Objects.isNull(fieldValuesMap)) { synchronized (this) { - if (fieldValuesMap == null) { + if (Objects.isNull(fieldValuesMap)) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); + if (!Objects.isNull(project)) { + fieldMapBuilder.put("project", project); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -112,14 +119,35 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate("project", project); + return PROJECT.instantiate("project", project); } - /** Builder for ProjectName. */ - public static class Builder { + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null || getClass() == o.getClass()) { + ProjectName that = ((ProjectName) o); + return Objects.equals(this.project, that.project); + } + return false; + } + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + return h; + } + + /** Builder for projects/{project}. */ + public static class Builder { private String project; + protected Builder() {} + public String getProject() { return project; } @@ -129,8 +157,6 @@ public Builder setProject(String project) { return this; } - private Builder() {} - private Builder(ProjectName projectName) { project = projectName.project; } @@ -139,24 +165,4 @@ public ProjectName build() { return new ProjectName(this); } } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof ProjectName) { - ProjectName that = (ProjectName) o; - return (this.project.equals(that.project)); - } - return false; - } - - @Override - public int hashCode() { - int h = 1; - h *= 1000003; - h ^= project.hashCode(); - return h; - } } diff --git a/synth.metadata b/synth.metadata index a50988a0..d1e31197 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "8cfc6c874574b649b4524a4ef6a0651533325a84", - "internalRef": "345067549" + "sha": "4faa4a762126eb80db988e92065f25d628356c87", + "internalRef": "345310543" } }, { From dee8e3f30b04183d81006c3f9fee30652f74bc76 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Fri, 19 Feb 2021 15:10:29 -0800 Subject: [PATCH 5/9] fix: Update gapic-generator-java to 0.0.7 Committer: @miraleung PiperOrigin-RevId: 345476969 Source-Author: Google APIs Source-Date: Thu Dec 3 10:07:32 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: 7be2c821dd88109038c55c89f7dd48f092eeab9d Source-Link: https://github.com/googleapis/googleapis/commit/7be2c821dd88109038c55c89f7dd48f092eeab9d --- .../containeranalysis/v1/ContainerAnalysisClient.java | 9 ++++----- .../com/google/containeranalysis/v1/ProjectName.java | 8 ++++---- synth.metadata | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java index f215b632..d76f1289 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java @@ -33,7 +33,6 @@ import io.grafeas.v1.GrafeasClient; import java.io.IOException; import java.util.List; -import java.util.Objects; import java.util.concurrent.TimeUnit; import javax.annotation.Generated; @@ -184,7 +183,7 @@ public ContainerAnalysisStub getStub() { public final Policy setIamPolicy(ResourceName resource, Policy policy) { SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder() - .setResource(Objects.isNull(resource) ? null : resource.toString()) + .setResource(resource == null ? null : resource.toString()) .setPolicy(policy) .build(); return setIamPolicy(request); @@ -259,7 +258,7 @@ public final UnaryCallable setIamPolicyCallable() { public final Policy getIamPolicy(ResourceName resource) { GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder() - .setResource(Objects.isNull(resource) ? null : resource.toString()) + .setResource(resource == null ? null : resource.toString()) .build(); return getIamPolicy(request); } @@ -332,7 +331,7 @@ public final TestIamPermissionsResponse testIamPermissions( ResourceName resource, List permissions) { TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder() - .setResource(Objects.isNull(resource) ? null : resource.toString()) + .setResource(resource == null ? null : resource.toString()) .addAllPermissions(permissions) .build(); return testIamPermissions(request); @@ -406,7 +405,7 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary( ProjectName parent, String filter) { GetVulnerabilityOccurrencesSummaryRequest request = GetVulnerabilityOccurrencesSummaryRequest.newBuilder() - .setParent(Objects.isNull(parent) ? null : parent.toString()) + .setParent(parent == null ? null : parent.toString()) .setFilter(filter) .build(); return getVulnerabilityOccurrencesSummary(request); diff --git a/proto-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ProjectName.java b/proto-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ProjectName.java index 33640438..2c6f990e 100644 --- a/proto-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ProjectName.java +++ b/proto-google-cloud-containeranalysis-v1/src/main/java/com/google/containeranalysis/v1/ProjectName.java @@ -84,7 +84,7 @@ public static List parseList(List formattedStrings) { public static List toStringList(List values) { List list = new ArrayList<>(values.size()); for (ProjectName value : values) { - if (Objects.isNull(value)) { + if (value == null) { list.add(""); } else { list.add(value.toString()); @@ -99,11 +99,11 @@ public static boolean isParsableFrom(String formattedString) { @Override public Map getFieldValuesMap() { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { synchronized (this) { - if (Objects.isNull(fieldValuesMap)) { + if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - if (!Objects.isNull(project)) { + if (project != null) { fieldMapBuilder.put("project", project); } fieldValuesMap = fieldMapBuilder.build(); diff --git a/synth.metadata b/synth.metadata index d1e31197..5e530775 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "4faa4a762126eb80db988e92065f25d628356c87", - "internalRef": "345310543" + "sha": "7be2c821dd88109038c55c89f7dd48f092eeab9d", + "internalRef": "345476969" } }, { From 25a17aa1b81711ad134a5b08bebce54dfd224487 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Fri, 19 Feb 2021 15:15:06 -0800 Subject: [PATCH 6/9] chore: update gapic-generator-java to 0.0.9 Committer: @miraleung PiperOrigin-RevId: 346372957 Source-Author: Google APIs Source-Date: Tue Dec 8 11:37:30 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: 857f70daef9f4c38f042fb3dfb7b8423ae18fd19 Source-Link: https://github.com/googleapis/googleapis/commit/857f70daef9f4c38f042fb3dfb7b8423ae18fd19 --- .../v1/stub/GrpcContainerAnalysisStub.java | 10 ++++++++++ synth.metadata | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java index 2b950a3b..8bca88c1 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java @@ -120,11 +120,21 @@ public static final GrpcContainerAnalysisStub create( ContainerAnalysisStubSettings.newBuilder().build(), clientContext, callableFactory); } + /** + * Constructs an instance of GrpcContainerAnalysisStub, 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 GrpcContainerAnalysisStub( ContainerAnalysisStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new GrpcContainerAnalysisCallableFactory()); } + /** + * Constructs an instance of GrpcContainerAnalysisStub, 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 GrpcContainerAnalysisStub( ContainerAnalysisStubSettings settings, ClientContext clientContext, diff --git a/synth.metadata b/synth.metadata index 5e530775..1f0c02ec 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "7be2c821dd88109038c55c89f7dd48f092eeab9d", - "internalRef": "345476969" + "sha": "857f70daef9f4c38f042fb3dfb7b8423ae18fd19", + "internalRef": "346372957" } }, { From 9538d98d2197ca902f24d7aa013d76c024b7e560 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Fri, 19 Feb 2021 15:17:48 -0800 Subject: [PATCH 7/9] chore: update gapic-generator-java to 0.0.18 Committer: @miraleung PiperOrigin-RevId: 350949863 Source-Author: Google APIs Source-Date: Sat Jan 9 14:01:49 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 91e206bcfeaf8948ea03fe3cb1b7616108496cd3 Source-Link: https://github.com/googleapis/googleapis/commit/91e206bcfeaf8948ea03fe3cb1b7616108496cd3 --- .../containeranalysis/v1/ContainerAnalysisClient.java | 3 +-- .../containeranalysis/v1/stub/ContainerAnalysisStub.java | 2 +- .../v1/stub/ContainerAnalysisStubSettings.java | 1 - .../v1/stub/GrpcContainerAnalysisCallableFactory.java | 2 +- synth.metadata | 4 ++-- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java index d76f1289..1ed88581 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java @@ -102,8 +102,7 @@ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ -@BetaApi -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class ContainerAnalysisClient implements BackgroundResource { private final ContainerAnalysisSettings settings; private final ContainerAnalysisStub stub; diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStub.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStub.java index 39290c52..ae74efb2 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStub.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStub.java @@ -33,7 +33,7 @@ * *

This class is for advanced usage and reflects the underlying API directly. */ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public abstract class ContainerAnalysisStub implements BackgroundResource { public UnaryCallable setIamPolicyCallable() { diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStubSettings.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStubSettings.java index 30a8e779..afe8a91d 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStubSettings.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/ContainerAnalysisStubSettings.java @@ -81,7 +81,6 @@ * containerAnalysisSettingsBuilder.build(); * } */ -@BetaApi @Generated("by gapic-generator-java") public class ContainerAnalysisStubSettings extends StubSettings { /** The default scopes of the service. */ diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisCallableFactory.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisCallableFactory.java index 266236b6..9b8cb871 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisCallableFactory.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisCallableFactory.java @@ -41,7 +41,7 @@ * *

This class is for advanced usage. */ -@Generated("by gapic-generator") +@Generated("by gapic-generator-java") public class GrpcContainerAnalysisCallableFactory implements GrpcStubCallableFactory { @Override diff --git a/synth.metadata b/synth.metadata index 1f0c02ec..85b7b26f 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "857f70daef9f4c38f042fb3dfb7b8423ae18fd19", - "internalRef": "346372957" + "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", + "internalRef": "350949863" } }, { From 24a1973eb67b7a7a5722de8299a99d1d7dac3fec Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Fri, 19 Feb 2021 15:24:24 -0800 Subject: [PATCH 8/9] feat: generate sample code in the Java microgenerator Committer: @miraleung PiperOrigin-RevId: 356341083 Source-Author: Google APIs Source-Date: Mon Feb 8 13:33:28 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: 8d8c008e56f1af31d57f75561e0f1848ffb29eeb Source-Link: https://github.com/googleapis/googleapis/commit/8d8c008e56f1af31d57f75561e0f1848ffb29eeb --- .../v1/ContainerAnalysisClient.java | 197 ++++++++++++++++++ .../containeranalysis/v1/package-info.java | 8 + synth.metadata | 4 +- 3 files changed, 207 insertions(+), 2 deletions(-) diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java index 1ed88581..bf4e0adb 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/ContainerAnalysisClient.java @@ -53,6 +53,14 @@ *

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

{@code
+ * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+ *   ResourceName resource = ProjectName.of("[PROJECT]");
+ *   Policy policy = Policy.newBuilder().build();
+ *   Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
+ * }
+ * }
+ * *

Note: close() needs to be called on the ContainerAnalysisClient object to clean up resources * such as threads. In the example above, try-with-resources is used, which automatically calls * close(). @@ -172,6 +180,16 @@ public ContainerAnalysisStub getStub() { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ResourceName resource = ProjectName.of("[PROJECT]");
+   *   Policy policy = Policy.newBuilder().build();
+   *   Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
+   * }
+   * }
+ * * @param resource REQUIRED: The resource for which the policy is being specified. See the * operation documentation for the appropriate value for this field. * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the @@ -197,6 +215,16 @@ public final Policy setIamPolicy(ResourceName resource, Policy policy) { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   String resource = ProjectName.of("[PROJECT]").toString();
+   *   Policy policy = Policy.newBuilder().build();
+   *   Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
+   * }
+   * }
+ * * @param resource REQUIRED: The resource for which the policy is being specified. See the * operation documentation for the appropriate value for this field. * @param policy REQUIRED: The complete policy to be applied to the `resource`. The size of the @@ -219,6 +247,19 @@ public final Policy setIamPolicy(String resource, Policy policy) { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   SetIamPolicyRequest request =
+   *       SetIamPolicyRequest.newBuilder()
+   *           .setResource(ProjectName.of("[PROJECT]").toString())
+   *           .setPolicy(Policy.newBuilder().build())
+   *           .build();
+   *   Policy response = containerAnalysisClient.setIamPolicy(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -236,6 +277,19 @@ public final Policy setIamPolicy(SetIamPolicyRequest request) { * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   SetIamPolicyRequest request =
+   *       SetIamPolicyRequest.newBuilder()
+   *           .setResource(ProjectName.of("[PROJECT]").toString())
+   *           .setPolicy(Policy.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = containerAnalysisClient.setIamPolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
*/ public final UnaryCallable setIamPolicyCallable() { return stub.setIamPolicyCallable(); @@ -250,6 +304,15 @@ public final UnaryCallable setIamPolicyCallable() { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ResourceName resource = ProjectName.of("[PROJECT]");
+   *   Policy response = containerAnalysisClient.getIamPolicy(resource);
+   * }
+   * }
+ * * @param resource REQUIRED: The resource for which the policy is being requested. See the * operation documentation for the appropriate value for this field. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -271,6 +334,15 @@ public final Policy getIamPolicy(ResourceName resource) { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   String resource = ProjectName.of("[PROJECT]").toString();
+   *   Policy response = containerAnalysisClient.getIamPolicy(resource);
+   * }
+   * }
+ * * @param resource REQUIRED: The resource for which the policy is being requested. See the * operation documentation for the appropriate value for this field. * @throws com.google.api.gax.rpc.ApiException if the remote call fails @@ -289,6 +361,19 @@ public final Policy getIamPolicy(String resource) { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   GetIamPolicyRequest request =
+   *       GetIamPolicyRequest.newBuilder()
+   *           .setResource(ProjectName.of("[PROJECT]").toString())
+   *           .setOptions(GetPolicyOptions.newBuilder().build())
+   *           .build();
+   *   Policy response = containerAnalysisClient.getIamPolicy(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -306,6 +391,19 @@ public final Policy getIamPolicy(GetIamPolicyRequest request) { * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   GetIamPolicyRequest request =
+   *       GetIamPolicyRequest.newBuilder()
+   *           .setResource(ProjectName.of("[PROJECT]").toString())
+   *           .setOptions(GetPolicyOptions.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = containerAnalysisClient.getIamPolicyCallable().futureCall(request);
+   *   // Do something.
+   *   Policy response = future.get();
+   * }
+   * }
*/ public final UnaryCallable getIamPolicyCallable() { return stub.getIamPolicyCallable(); @@ -319,6 +417,17 @@ public final UnaryCallable getIamPolicyCallable() { *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ResourceName resource = ProjectName.of("[PROJECT]");
+   *   List permissions = new ArrayList<>();
+   *   TestIamPermissionsResponse response =
+   *       containerAnalysisClient.testIamPermissions(resource, permissions);
+   * }
+   * }
+ * * @param resource REQUIRED: The resource for which the policy detail is being requested. See the * operation documentation for the appropriate value for this field. * @param permissions The set of permissions to check for the `resource`. Permissions with @@ -344,6 +453,17 @@ public final TestIamPermissionsResponse testIamPermissions( *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   String resource = ProjectName.of("[PROJECT]").toString();
+   *   List permissions = new ArrayList<>();
+   *   TestIamPermissionsResponse response =
+   *       containerAnalysisClient.testIamPermissions(resource, permissions);
+   * }
+   * }
+ * * @param resource REQUIRED: The resource for which the policy detail is being requested. See the * operation documentation for the appropriate value for this field. * @param permissions The set of permissions to check for the `resource`. Permissions with @@ -369,6 +489,19 @@ public final TestIamPermissionsResponse testIamPermissions( *

The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * + *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   TestIamPermissionsRequest request =
+   *       TestIamPermissionsRequest.newBuilder()
+   *           .setResource(ProjectName.of("[PROJECT]").toString())
+   *           .addAllPermissions(new ArrayList())
+   *           .build();
+   *   TestIamPermissionsResponse response = containerAnalysisClient.testIamPermissions(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -385,6 +518,20 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq * `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences. * *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   TestIamPermissionsRequest request =
+   *       TestIamPermissionsRequest.newBuilder()
+   *           .setResource(ProjectName.of("[PROJECT]").toString())
+   *           .addAllPermissions(new ArrayList())
+   *           .build();
+   *   ApiFuture future =
+   *       containerAnalysisClient.testIamPermissionsCallable().futureCall(request);
+   *   // Do something.
+   *   TestIamPermissionsResponse response = future.get();
+   * }
+   * }
*/ public final UnaryCallable testIamPermissionsCallable() { @@ -395,6 +542,17 @@ public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsReq /** * Gets a summary of the number and severity of occurrences. * + *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   String filter = "filter-1274492040";
+   *   VulnerabilityOccurrencesSummary response =
+   *       containerAnalysisClient.getVulnerabilityOccurrencesSummary(parent, filter);
+   * }
+   * }
+ * * @param parent The name of the project to get a vulnerability summary for in the form of * `projects/[PROJECT_ID]`. * @param filter The filter expression. @@ -414,6 +572,17 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary( /** * Gets a summary of the number and severity of occurrences. * + *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   String parent = ProjectName.of("[PROJECT]").toString();
+   *   String filter = "filter-1274492040";
+   *   VulnerabilityOccurrencesSummary response =
+   *       containerAnalysisClient.getVulnerabilityOccurrencesSummary(parent, filter);
+   * }
+   * }
+ * * @param parent The name of the project to get a vulnerability summary for in the form of * `projects/[PROJECT_ID]`. * @param filter The filter expression. @@ -433,6 +602,20 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary( /** * Gets a summary of the number and severity of occurrences. * + *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   GetVulnerabilityOccurrencesSummaryRequest request =
+   *       GetVulnerabilityOccurrencesSummaryRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .build();
+   *   VulnerabilityOccurrencesSummary response =
+   *       containerAnalysisClient.getVulnerabilityOccurrencesSummary(request);
+   * }
+   * }
+ * * @param request The request object containing all of the parameters for the API call. * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ @@ -446,6 +629,20 @@ public final VulnerabilityOccurrencesSummary getVulnerabilityOccurrencesSummary( * Gets a summary of the number and severity of occurrences. * *

Sample code: + * + *

{@code
+   * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+   *   GetVulnerabilityOccurrencesSummaryRequest request =
+   *       GetVulnerabilityOccurrencesSummaryRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .build();
+   *   ApiFuture future =
+   *       containerAnalysisClient.getVulnerabilityOccurrencesSummaryCallable().futureCall(request);
+   *   // Do something.
+   *   VulnerabilityOccurrencesSummary response = future.get();
+   * }
+   * }
*/ public final UnaryCallable< GetVulnerabilityOccurrencesSummaryRequest, VulnerabilityOccurrencesSummary> diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/package-info.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/package-info.java index 20d05f6c..597ebd66 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/package-info.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/package-info.java @@ -32,6 +32,14 @@ * to that note. * *

Sample for ContainerAnalysisClient: + * + *

{@code
+ * try (ContainerAnalysisClient containerAnalysisClient = ContainerAnalysisClient.create()) {
+ *   ResourceName resource = ProjectName.of("[PROJECT]");
+ *   Policy policy = Policy.newBuilder().build();
+ *   Policy response = containerAnalysisClient.setIamPolicy(resource, policy);
+ * }
+ * }
*/ @Generated("by gapic-generator-java") package com.google.cloud.devtools.containeranalysis.v1; diff --git a/synth.metadata b/synth.metadata index 85b7b26f..82599296 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "91e206bcfeaf8948ea03fe3cb1b7616108496cd3", - "internalRef": "350949863" + "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", + "internalRef": "356341083" } }, { From 9258cee6f84324cc8358440aeee532e21e2a4bc2 Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Fri, 19 Feb 2021 15:27:02 -0800 Subject: [PATCH 9/9] chore: update gapic-generator-java to 0.0.20 Committer: @miraleung PiperOrigin-RevId: 357800868 Source-Author: Google APIs Source-Date: Tue Feb 16 14:06:04 2021 -0800 Source-Repo: googleapis/googleapis Source-Sha: e8bc4471a88ac5f60defe3ed436f517174e59ba0 Source-Link: https://github.com/googleapis/googleapis/commit/e8bc4471a88ac5f60defe3ed436f517174e59ba0 --- .../v1/stub/GrpcContainerAnalysisStub.java | 4 +++ .../v1/MockContainerAnalysisImpl.java | 32 ++++++++++++++++--- synth.metadata | 4 +-- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java index 8bca88c1..051df17e 100644 --- a/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java +++ b/google-cloud-containeranalysis/src/main/java/com/google/cloud/devtools/containeranalysis/v1/stub/GrpcContainerAnalysisStub.java @@ -226,19 +226,23 @@ public GrpcOperationsStub getOperationsStub() { return operationsStub; } + @Override public UnaryCallable setIamPolicyCallable() { return setIamPolicyCallable; } + @Override public UnaryCallable getIamPolicyCallable() { return getIamPolicyCallable; } + @Override public UnaryCallable testIamPermissionsCallable() { return testIamPermissionsCallable; } + @Override public UnaryCallable getVulnerabilityOccurrencesSummaryCallable() { return getVulnerabilityOccurrencesSummaryCallable; diff --git a/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysisImpl.java b/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysisImpl.java index ee65fb5d..936c608a 100644 --- a/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysisImpl.java +++ b/google-cloud-containeranalysis/src/test/java/com/google/cloud/devtools/containeranalysis/v1/MockContainerAnalysisImpl.java @@ -75,7 +75,13 @@ public void setIamPolicy(SetIamPolicyRequest request, StreamObserver res } else if (response instanceof Exception) { responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method SetIamPolicy, expected %s or %s", + response.getClass().getName(), + Policy.class.getName(), + Exception.class.getName()))); } } @@ -89,7 +95,13 @@ public void getIamPolicy(GetIamPolicyRequest request, StreamObserver res } else if (response instanceof Exception) { responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetIamPolicy, expected %s or %s", + response.getClass().getName(), + Policy.class.getName(), + Exception.class.getName()))); } } @@ -105,7 +117,13 @@ public void testIamPermissions( } else if (response instanceof Exception) { responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method TestIamPermissions, expected %s or %s", + response.getClass().getName(), + TestIamPermissionsResponse.class.getName(), + Exception.class.getName()))); } } @@ -121,7 +139,13 @@ public void getVulnerabilityOccurrencesSummary( } else if (response instanceof Exception) { responseObserver.onError(((Exception) response)); } else { - responseObserver.onError(new IllegalArgumentException("Unrecognized response type")); + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetVulnerabilityOccurrencesSummary, expected %s or %s", + response.getClass().getName(), + VulnerabilityOccurrencesSummary.class.getName(), + Exception.class.getName()))); } } } diff --git a/synth.metadata b/synth.metadata index 82599296..84c1cba3 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,8 +11,8 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "8d8c008e56f1af31d57f75561e0f1848ffb29eeb", - "internalRef": "356341083" + "sha": "e8bc4471a88ac5f60defe3ed436f517174e59ba0", + "internalRef": "357800868" } }, {