From 6de4ad03536cc94539d99794cb27671fe6b1aee9 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Mon, 20 Apr 2020 14:50:33 -0700 Subject: [PATCH] feat(regen): removes deprecated FeedName methods from v1p2beta1 client (#157) * chore: enable gapicv2 for asset/v1p2beta1 API Committer: @miraleung PiperOrigin-RevId: 306281797 Source-Author: Google APIs Source-Date: Mon Apr 13 12:09:03 2020 -0700 Source-Repo: googleapis/googleapis Source-Sha: 0feb08065d91d6deebffef3019751f0619a72140 Source-Link: https://github.com/googleapis/googleapis/commit/0feb08065d91d6deebffef3019751f0619a72140 * chore: enable gapicv2 for asset/v1p4beta1 API Committer: @miraleung PiperOrigin-RevId: 306282838 Source-Author: Google APIs Source-Date: Mon Apr 13 12:13:42 2020 -0700 Source-Repo: googleapis/googleapis Source-Sha: 4efd71279f0781579ced60c374336ce1b8b8cea8 Source-Link: https://github.com/googleapis/googleapis/commit/4efd71279f0781579ced60c374336ce1b8b8cea8 * chore: enable gapicv2 for asset/v1beta1 API Committer: @miraleung PiperOrigin-RevId: 306283252 Source-Author: Google APIs Source-Date: Mon Apr 13 12:15:47 2020 -0700 Source-Repo: googleapis/googleapis Source-Sha: a34f4eb96a94bfd5b3e7f8de253db28d0a3e9237 Source-Link: https://github.com/googleapis/googleapis/commit/a34f4eb96a94bfd5b3e7f8de253db28d0a3e9237 * chore: allow breaking change to v1p2beta1 client Co-authored-by: Jeff Ching --- .../clirr-ignored-differences.xml | 9 + .../asset/v1beta1/AssetServiceClient.java | 24 +- .../cloud/asset/v1beta1/package-info.java | 6 +- .../asset/v1p2beta1/AssetServiceClient.java | 238 +++++++++--------- .../asset/v1p2beta1/AssetServiceSettings.java | 26 +- .../cloud/asset/v1p2beta1/package-info.java | 4 +- .../v1p2beta1/stub/AssetServiceStub.java | 8 +- .../stub/AssetServiceStubSettings.java | 56 ++--- .../v1p2beta1/stub/GrpcAssetServiceStub.java | 56 ++--- .../asset/v1p4beta1/AssetServiceClient.java | 100 ++++---- .../asset/v1p4beta1/AssetServiceSettings.java | 24 +- .../v1p4beta1/stub/AssetServiceStub.java | 10 +- .../stub/AssetServiceStubSettings.java | 52 ++-- .../v1p4beta1/stub/GrpcAssetServiceStub.java | 64 ++--- .../asset/v1beta1/AssetServiceClientTest.java | 31 +-- .../v1p2beta1/AssetServiceClientTest.java | 96 +++---- .../v1p4beta1/AssetServiceClientTest.java | 88 +++---- .../cloud/asset/v1p2beta1/FeedName.java | 229 +++++++++++++++-- synth.metadata | 20 +- 19 files changed, 656 insertions(+), 485 deletions(-) create mode 100644 google-cloud-asset/clirr-ignored-differences.xml diff --git a/google-cloud-asset/clirr-ignored-differences.xml b/google-cloud-asset/clirr-ignored-differences.xml new file mode 100644 index 000000000..d73021994 --- /dev/null +++ b/google-cloud-asset/clirr-ignored-differences.xml @@ -0,0 +1,9 @@ + + + + + 7002 + com/google/cloud/asset/v1p2beta1/AssetServiceClient + java.lang.String *FeedName(*) + + diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1beta1/AssetServiceClient.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1beta1/AssetServiceClient.java index aa4ee82e0..5fb3b776a 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1beta1/AssetServiceClient.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1beta1/AssetServiceClient.java @@ -38,13 +38,9 @@ *
  * 
  * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
- *   ProjectName parent = ProjectName.of("[PROJECT]");
- *   ContentType contentType = ContentType.CONTENT_TYPE_UNSPECIFIED;
- *   TimeWindow readTimeWindow = TimeWindow.newBuilder().build();
+ *   String parent = "";
  *   BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder()
  *     .setParent(parent.toString())
- *     .setContentType(contentType)
- *     .setReadTimeWindow(readTimeWindow)
  *     .build();
  *   BatchGetAssetsHistoryResponse response = assetServiceClient.batchGetAssetsHistory(request);
  * }
@@ -178,7 +174,7 @@ public final OperationsClient getOperationsClient() {
    *
    * 

    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   String parent = "";
    *   OutputConfig outputConfig = OutputConfig.newBuilder().build();
    *   ExportAssetsRequest request = ExportAssetsRequest.newBuilder()
    *     .setParent(parent.toString())
@@ -209,7 +205,7 @@ public final OperationFuture exportAs
    *
    * 

    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   String parent = "";
    *   OutputConfig outputConfig = OutputConfig.newBuilder().build();
    *   ExportAssetsRequest request = ExportAssetsRequest.newBuilder()
    *     .setParent(parent.toString())
@@ -238,7 +234,7 @@ public final OperationFuture exportAs
    *
    * 

    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   String parent = "";
    *   OutputConfig outputConfig = OutputConfig.newBuilder().build();
    *   ExportAssetsRequest request = ExportAssetsRequest.newBuilder()
    *     .setParent(parent.toString())
@@ -266,13 +262,9 @@ public final UnaryCallable exportAssetsCallable(
    *
    * 

    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   ContentType contentType = ContentType.CONTENT_TYPE_UNSPECIFIED;
-   *   TimeWindow readTimeWindow = TimeWindow.newBuilder().build();
+   *   String parent = "";
    *   BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder()
    *     .setParent(parent.toString())
-   *     .setContentType(contentType)
-   *     .setReadTimeWindow(readTimeWindow)
    *     .build();
    *   BatchGetAssetsHistoryResponse response = assetServiceClient.batchGetAssetsHistory(request);
    * }
@@ -298,13 +290,9 @@ public final BatchGetAssetsHistoryResponse batchGetAssetsHistory(
    *
    * 

    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   ProjectName parent = ProjectName.of("[PROJECT]");
-   *   ContentType contentType = ContentType.CONTENT_TYPE_UNSPECIFIED;
-   *   TimeWindow readTimeWindow = TimeWindow.newBuilder().build();
+   *   String parent = "";
    *   BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder()
    *     .setParent(parent.toString())
-   *     .setContentType(contentType)
-   *     .setReadTimeWindow(readTimeWindow)
    *     .build();
    *   ApiFuture<BatchGetAssetsHistoryResponse> future = assetServiceClient.batchGetAssetsHistoryCallable().futureCall(request);
    *   // Do something
diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1beta1/package-info.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1beta1/package-info.java
index 410f0b5a8..2872d8126 100644
--- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1beta1/package-info.java
+++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1beta1/package-info.java
@@ -28,13 +28,9 @@
  * 
  * 
  * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
- *   ProjectName parent = ProjectName.of("[PROJECT]");
- *   ContentType contentType = ContentType.CONTENT_TYPE_UNSPECIFIED;
- *   TimeWindow readTimeWindow = TimeWindow.newBuilder().build();
+ *   String parent = "";
  *   BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder()
  *     .setParent(parent.toString())
- *     .setContentType(contentType)
- *     .setReadTimeWindow(readTimeWindow)
  *     .build();
  *   BatchGetAssetsHistoryResponse response = assetServiceClient.batchGetAssetsHistory(request);
  * }
diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/AssetServiceClient.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/AssetServiceClient.java
index f1f0cb921..8ae3e42b9 100644
--- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/AssetServiceClient.java
+++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/AssetServiceClient.java
@@ -18,7 +18,6 @@
 import com.google.api.core.BetaApi;
 import com.google.api.gax.core.BackgroundResource;
 import com.google.api.gax.rpc.UnaryCallable;
-import com.google.api.pathtemplate.PathTemplate;
 import com.google.cloud.asset.v1p2beta1.stub.AssetServiceStub;
 import com.google.cloud.asset.v1p2beta1.stub.AssetServiceStubSettings;
 import com.google.protobuf.Empty;
@@ -36,8 +35,8 @@
  * 
  * 
  * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
- *   String parent = "";
- *   Feed response = assetServiceClient.createFeed(parent);
+ *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+ *   assetServiceClient.deleteFeed(name);
  * }
  * 
  * 
@@ -98,41 +97,6 @@ public class AssetServiceClient implements BackgroundResource { private final AssetServiceSettings settings; private final AssetServiceStub stub; - private static final PathTemplate FEED_PATH_TEMPLATE = - PathTemplate.createWithoutUrlEncoding("projects/{project}/feeds/{feed}"); - - /** - * Formats a string containing the fully-qualified path to represent a feed resource. - * - * @deprecated Use the {@link FeedName} class instead. - */ - @Deprecated - public static final String formatFeedName(String project, String feed) { - return FEED_PATH_TEMPLATE.instantiate( - "project", project, - "feed", feed); - } - - /** - * Parses the project from the given fully-qualified path which represents a feed resource. - * - * @deprecated Use the {@link FeedName} class instead. - */ - @Deprecated - public static final String parseProjectFromFeedName(String feedName) { - return FEED_PATH_TEMPLATE.parse(feedName).get("project"); - } - - /** - * Parses the feed from the given fully-qualified path which represents a feed resource. - * - * @deprecated Use the {@link FeedName} class instead. - */ - @Deprecated - public static final String parseFeedFromFeedName(String feedName) { - return FEED_PATH_TEMPLATE.parse(feedName).get("feed"); - } - /** Constructs an instance of AssetServiceClient with default settings. */ public static final AssetServiceClient create() throws IOException { return create(AssetServiceSettings.newBuilder().build()); @@ -180,6 +144,98 @@ public AssetServiceStub getStub() { return stub; } + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes an asset feed. + * + *

Sample code: + * + *


+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   assetServiceClient.deleteFeed(name);
+   * }
+   * 
+ * + * @param name Required. The name of the feed and it must be in the format of: + * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id + * organizations/organization_number/feeds/feed_id + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteFeed(FeedName name) { + DeleteFeedRequest request = + DeleteFeedRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deleteFeed(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes an asset feed. + * + *

Sample code: + * + *


+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   assetServiceClient.deleteFeed(name.toString());
+   * }
+   * 
+ * + * @param name Required. The name of the feed and it must be in the format of: + * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id + * organizations/organization_number/feeds/feed_id + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteFeed(String name) { + DeleteFeedRequest request = DeleteFeedRequest.newBuilder().setName(name).build(); + deleteFeed(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes an asset feed. + * + *

Sample code: + * + *


+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   DeleteFeedRequest request = DeleteFeedRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   assetServiceClient.deleteFeed(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteFeed(DeleteFeedRequest request) { + deleteFeedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Deletes an asset feed. + * + *

Sample code: + * + *


+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   DeleteFeedRequest request = DeleteFeedRequest.newBuilder()
+   *     .setName(name.toString())
+   *     .build();
+   *   ApiFuture<Void> future = assetServiceClient.deleteFeedCallable().futureCall(request);
+   *   // Do something
+   *   future.get();
+   * }
+   * 
+ */ + public final UnaryCallable deleteFeedCallable() { + return stub.deleteFeedCallable(); + } + // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Creates a feed in a parent project/folder/organization to listen to its asset updates. @@ -265,8 +321,32 @@ public final UnaryCallable createFeedCallable() { * *

    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   String formattedName = AssetServiceClient.formatFeedName("[PROJECT]", "[FEED]");
-   *   Feed response = assetServiceClient.getFeed(formattedName);
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   Feed response = assetServiceClient.getFeed(name);
+   * }
+   * 
+ * + * @param name Required. The name of the Feed and it must be in the format of: + * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id + * organizations/organization_number/feeds/feed_id + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Feed getFeed(FeedName name) { + GetFeedRequest request = + GetFeedRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getFeed(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Gets details about an asset feed. + * + *

Sample code: + * + *


+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+   *   Feed response = assetServiceClient.getFeed(name.toString());
    * }
    * 
* @@ -276,7 +356,6 @@ public final UnaryCallable createFeedCallable() { * @throws com.google.api.gax.rpc.ApiException if the remote call fails */ public final Feed getFeed(String name) { - FEED_PATH_TEMPLATE.validate(name, "getFeed"); GetFeedRequest request = GetFeedRequest.newBuilder().setName(name).build(); return getFeed(request); } @@ -289,9 +368,9 @@ public final Feed getFeed(String name) { * *

    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   String formattedName = AssetServiceClient.formatFeedName("[PROJECT]", "[FEED]");
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
    *   GetFeedRequest request = GetFeedRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   Feed response = assetServiceClient.getFeed(request);
    * }
@@ -312,9 +391,9 @@ public final Feed getFeed(GetFeedRequest request) {
    *
    * 

    * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   String formattedName = AssetServiceClient.formatFeedName("[PROJECT]", "[FEED]");
+   *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
    *   GetFeedRequest request = GetFeedRequest.newBuilder()
-   *     .setName(formattedName)
+   *     .setName(name.toString())
    *     .build();
    *   ApiFuture<Feed> future = assetServiceClient.getFeedCallable().futureCall(request);
    *   // Do something
@@ -466,75 +545,6 @@ public final UnaryCallable updateFeedCallable() {
     return stub.updateFeedCallable();
   }
 
-  // AUTO-GENERATED DOCUMENTATION AND METHOD
-  /**
-   * Deletes an asset feed.
-   *
-   * 

Sample code: - * - *


-   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   String formattedName = AssetServiceClient.formatFeedName("[PROJECT]", "[FEED]");
-   *   assetServiceClient.deleteFeed(formattedName);
-   * }
-   * 
- * - * @param name Required. The name of the feed and it must be in the format of: - * projects/project_number/feeds/feed_id folders/folder_number/feeds/feed_id - * organizations/organization_number/feeds/feed_id - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteFeed(String name) { - FEED_PATH_TEMPLATE.validate(name, "deleteFeed"); - DeleteFeedRequest request = DeleteFeedRequest.newBuilder().setName(name).build(); - deleteFeed(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes an asset feed. - * - *

Sample code: - * - *


-   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   String formattedName = AssetServiceClient.formatFeedName("[PROJECT]", "[FEED]");
-   *   DeleteFeedRequest request = DeleteFeedRequest.newBuilder()
-   *     .setName(formattedName)
-   *     .build();
-   *   assetServiceClient.deleteFeed(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final void deleteFeed(DeleteFeedRequest request) { - deleteFeedCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Deletes an asset feed. - * - *

Sample code: - * - *


-   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   String formattedName = AssetServiceClient.formatFeedName("[PROJECT]", "[FEED]");
-   *   DeleteFeedRequest request = DeleteFeedRequest.newBuilder()
-   *     .setName(formattedName)
-   *     .build();
-   *   ApiFuture<Void> future = assetServiceClient.deleteFeedCallable().futureCall(request);
-   *   // Do something
-   *   future.get();
-   * }
-   * 
- */ - public final UnaryCallable deleteFeedCallable() { - return stub.deleteFeedCallable(); - } - @Override public final void close() { stub.close(); diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/AssetServiceSettings.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/AssetServiceSettings.java index 38136ca65..3b3daa8f6 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/AssetServiceSettings.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/AssetServiceSettings.java @@ -46,16 +46,16 @@ *

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

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

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

  * 
  * AssetServiceSettings.Builder assetServiceSettingsBuilder =
  *     AssetServiceSettings.newBuilder();
  * assetServiceSettingsBuilder
- *     .createFeedSettings()
+ *     .deleteFeedSettings()
  *     .setRetrySettings(
- *         assetServiceSettingsBuilder.createFeedSettings().getRetrySettings().toBuilder()
+ *         assetServiceSettingsBuilder.deleteFeedSettings().getRetrySettings().toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
  * AssetServiceSettings assetServiceSettings = assetServiceSettingsBuilder.build();
@@ -65,6 +65,11 @@
 @Generated("by gapic-generator")
 @BetaApi
 public class AssetServiceSettings extends ClientSettings {
+  /** Returns the object with the settings used for calls to deleteFeed. */
+  public UnaryCallSettings deleteFeedSettings() {
+    return ((AssetServiceStubSettings) getStubSettings()).deleteFeedSettings();
+  }
+
   /** Returns the object with the settings used for calls to createFeed. */
   public UnaryCallSettings createFeedSettings() {
     return ((AssetServiceStubSettings) getStubSettings()).createFeedSettings();
@@ -85,11 +90,6 @@ public UnaryCallSettings updateFeedSettings() {
     return ((AssetServiceStubSettings) getStubSettings()).updateFeedSettings();
   }
 
-  /** Returns the object with the settings used for calls to deleteFeed. */
-  public UnaryCallSettings deleteFeedSettings() {
-    return ((AssetServiceStubSettings) getStubSettings()).deleteFeedSettings();
-  }
-
   public static final AssetServiceSettings create(AssetServiceStubSettings stub)
       throws IOException {
     return new AssetServiceSettings.Builder(stub.toBuilder()).build();
@@ -187,6 +187,11 @@ public Builder applyToAllUnaryMethods(
       return this;
     }
 
+    /** Returns the builder for the settings used for calls to deleteFeed. */
+    public UnaryCallSettings.Builder deleteFeedSettings() {
+      return getStubSettingsBuilder().deleteFeedSettings();
+    }
+
     /** Returns the builder for the settings used for calls to createFeed. */
     public UnaryCallSettings.Builder createFeedSettings() {
       return getStubSettingsBuilder().createFeedSettings();
@@ -207,11 +212,6 @@ public UnaryCallSettings.Builder updateFeedSettings() {
       return getStubSettingsBuilder().updateFeedSettings();
     }
 
-    /** Returns the builder for the settings used for calls to deleteFeed. */
-    public UnaryCallSettings.Builder deleteFeedSettings() {
-      return getStubSettingsBuilder().deleteFeedSettings();
-    }
-
     @Override
     public AssetServiceSettings build() throws IOException {
       return new AssetServiceSettings(this);
diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/package-info.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/package-info.java
index 2398e0eae..1a798323b 100644
--- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/package-info.java
+++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/package-info.java
@@ -28,8 +28,8 @@
  * 
  * 
  * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
- *   String parent = "";
- *   Feed response = assetServiceClient.createFeed(parent);
+ *   FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]");
+ *   assetServiceClient.deleteFeed(name);
  * }
  * 
  * 
diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/stub/AssetServiceStub.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/stub/AssetServiceStub.java index b6daeba03..68486c0bb 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/stub/AssetServiceStub.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/stub/AssetServiceStub.java @@ -38,6 +38,10 @@ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public abstract class AssetServiceStub implements BackgroundResource { + public UnaryCallable deleteFeedCallable() { + throw new UnsupportedOperationException("Not implemented: deleteFeedCallable()"); + } + public UnaryCallable createFeedCallable() { throw new UnsupportedOperationException("Not implemented: createFeedCallable()"); } @@ -54,10 +58,6 @@ public UnaryCallable updateFeedCallable() { throw new UnsupportedOperationException("Not implemented: updateFeedCallable()"); } - public UnaryCallable deleteFeedCallable() { - throw new UnsupportedOperationException("Not implemented: deleteFeedCallable()"); - } - @Override public abstract void close(); } diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/stub/AssetServiceStubSettings.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/stub/AssetServiceStubSettings.java index 227c5d228..0f73b6251 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/stub/AssetServiceStubSettings.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/stub/AssetServiceStubSettings.java @@ -62,16 +62,16 @@ *

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

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

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

  * 
  * AssetServiceStubSettings.Builder assetServiceSettingsBuilder =
  *     AssetServiceStubSettings.newBuilder();
  * assetServiceSettingsBuilder
- *     .createFeedSettings()
+ *     .deleteFeedSettings()
  *     .setRetrySettings(
- *         assetServiceSettingsBuilder.createFeedSettings().getRetrySettings().toBuilder()
+ *         assetServiceSettingsBuilder.deleteFeedSettings().getRetrySettings().toBuilder()
  *             .setTotalTimeout(Duration.ofSeconds(30))
  *             .build());
  * AssetServiceStubSettings assetServiceSettings = assetServiceSettingsBuilder.build();
@@ -85,11 +85,16 @@ public class AssetServiceStubSettings extends StubSettings DEFAULT_SERVICE_SCOPES =
       ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build();
 
+  private final UnaryCallSettings deleteFeedSettings;
   private final UnaryCallSettings createFeedSettings;
   private final UnaryCallSettings getFeedSettings;
   private final UnaryCallSettings listFeedsSettings;
   private final UnaryCallSettings updateFeedSettings;
-  private final UnaryCallSettings deleteFeedSettings;
+
+  /** Returns the object with the settings used for calls to deleteFeed. */
+  public UnaryCallSettings deleteFeedSettings() {
+    return deleteFeedSettings;
+  }
 
   /** Returns the object with the settings used for calls to createFeed. */
   public UnaryCallSettings createFeedSettings() {
@@ -111,11 +116,6 @@ public UnaryCallSettings updateFeedSettings() {
     return updateFeedSettings;
   }
 
-  /** Returns the object with the settings used for calls to deleteFeed. */
-  public UnaryCallSettings deleteFeedSettings() {
-    return deleteFeedSettings;
-  }
-
   @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
   public AssetServiceStub createStub() throws IOException {
     if (getTransportChannelProvider()
@@ -185,22 +185,22 @@ public Builder toBuilder() {
   protected AssetServiceStubSettings(Builder settingsBuilder) throws IOException {
     super(settingsBuilder);
 
+    deleteFeedSettings = settingsBuilder.deleteFeedSettings().build();
     createFeedSettings = settingsBuilder.createFeedSettings().build();
     getFeedSettings = settingsBuilder.getFeedSettings().build();
     listFeedsSettings = settingsBuilder.listFeedsSettings().build();
     updateFeedSettings = settingsBuilder.updateFeedSettings().build();
-    deleteFeedSettings = settingsBuilder.deleteFeedSettings().build();
   }
 
   /** Builder for AssetServiceStubSettings. */
   public static class Builder extends StubSettings.Builder {
     private final ImmutableList> unaryMethodSettingsBuilders;
 
+    private final UnaryCallSettings.Builder deleteFeedSettings;
     private final UnaryCallSettings.Builder createFeedSettings;
     private final UnaryCallSettings.Builder getFeedSettings;
     private final UnaryCallSettings.Builder listFeedsSettings;
     private final UnaryCallSettings.Builder updateFeedSettings;
-    private final UnaryCallSettings.Builder deleteFeedSettings;
 
     private static final ImmutableMap>
         RETRYABLE_CODE_DEFINITIONS;
@@ -243,6 +243,8 @@ protected Builder() {
     protected Builder(ClientContext clientContext) {
       super(clientContext);
 
+      deleteFeedSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
+
       createFeedSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
 
       getFeedSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
@@ -251,15 +253,13 @@ protected Builder(ClientContext clientContext) {
 
       updateFeedSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
 
-      deleteFeedSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
-
       unaryMethodSettingsBuilders =
           ImmutableList.>of(
+              deleteFeedSettings,
               createFeedSettings,
               getFeedSettings,
               listFeedsSettings,
-              updateFeedSettings,
-              deleteFeedSettings);
+              updateFeedSettings);
 
       initDefaults(this);
     }
@@ -275,6 +275,11 @@ private static Builder createDefault() {
 
     private static Builder initDefaults(Builder builder) {
 
+      builder
+          .deleteFeedSettings()
+          .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
+          .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
+
       builder
           .createFeedSettings()
           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
@@ -295,30 +300,25 @@ private static Builder initDefaults(Builder builder) {
           .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent"))
           .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
 
-      builder
-          .deleteFeedSettings()
-          .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
-          .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
-
       return builder;
     }
 
     protected Builder(AssetServiceStubSettings settings) {
       super(settings);
 
+      deleteFeedSettings = settings.deleteFeedSettings.toBuilder();
       createFeedSettings = settings.createFeedSettings.toBuilder();
       getFeedSettings = settings.getFeedSettings.toBuilder();
       listFeedsSettings = settings.listFeedsSettings.toBuilder();
       updateFeedSettings = settings.updateFeedSettings.toBuilder();
-      deleteFeedSettings = settings.deleteFeedSettings.toBuilder();
 
       unaryMethodSettingsBuilders =
           ImmutableList.>of(
+              deleteFeedSettings,
               createFeedSettings,
               getFeedSettings,
               listFeedsSettings,
-              updateFeedSettings,
-              deleteFeedSettings);
+              updateFeedSettings);
     }
 
     // NEXT_MAJOR_VER: remove 'throws Exception'
@@ -337,6 +337,11 @@ public Builder applyToAllUnaryMethods(
       return unaryMethodSettingsBuilders;
     }
 
+    /** Returns the builder for the settings used for calls to deleteFeed. */
+    public UnaryCallSettings.Builder deleteFeedSettings() {
+      return deleteFeedSettings;
+    }
+
     /** Returns the builder for the settings used for calls to createFeed. */
     public UnaryCallSettings.Builder createFeedSettings() {
       return createFeedSettings;
@@ -357,11 +362,6 @@ public UnaryCallSettings.Builder updateFeedSettings() {
       return updateFeedSettings;
     }
 
-    /** Returns the builder for the settings used for calls to deleteFeed. */
-    public UnaryCallSettings.Builder deleteFeedSettings() {
-      return deleteFeedSettings;
-    }
-
     @Override
     public AssetServiceStubSettings build() throws IOException {
       return new AssetServiceStubSettings(this);
diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/stub/GrpcAssetServiceStub.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/stub/GrpcAssetServiceStub.java
index 810beeefc..e22835979 100644
--- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/stub/GrpcAssetServiceStub.java
+++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p2beta1/stub/GrpcAssetServiceStub.java
@@ -49,6 +49,13 @@
 @BetaApi("A restructuring of stub classes is planned, so this may break in the future")
 public class GrpcAssetServiceStub extends AssetServiceStub {
 
+  private static final MethodDescriptor deleteFeedMethodDescriptor =
+      MethodDescriptor.newBuilder()
+          .setType(MethodDescriptor.MethodType.UNARY)
+          .setFullMethodName("google.cloud.asset.v1p2beta1.AssetService/DeleteFeed")
+          .setRequestMarshaller(ProtoUtils.marshaller(DeleteFeedRequest.getDefaultInstance()))
+          .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
+          .build();
   private static final MethodDescriptor createFeedMethodDescriptor =
       MethodDescriptor.newBuilder()
           .setType(MethodDescriptor.MethodType.UNARY)
@@ -78,21 +85,14 @@ public class GrpcAssetServiceStub extends AssetServiceStub {
           .setRequestMarshaller(ProtoUtils.marshaller(UpdateFeedRequest.getDefaultInstance()))
           .setResponseMarshaller(ProtoUtils.marshaller(Feed.getDefaultInstance()))
           .build();
-  private static final MethodDescriptor deleteFeedMethodDescriptor =
-      MethodDescriptor.newBuilder()
-          .setType(MethodDescriptor.MethodType.UNARY)
-          .setFullMethodName("google.cloud.asset.v1p2beta1.AssetService/DeleteFeed")
-          .setRequestMarshaller(ProtoUtils.marshaller(DeleteFeedRequest.getDefaultInstance()))
-          .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
-          .build();
 
   private final BackgroundResource backgroundResources;
 
+  private final UnaryCallable deleteFeedCallable;
   private final UnaryCallable createFeedCallable;
   private final UnaryCallable getFeedCallable;
   private final UnaryCallable listFeedsCallable;
   private final UnaryCallable updateFeedCallable;
-  private final UnaryCallable deleteFeedCallable;
 
   private final GrpcStubCallableFactory callableFactory;
 
@@ -133,6 +133,19 @@ protected GrpcAssetServiceStub(
       throws IOException {
     this.callableFactory = callableFactory;
 
+    GrpcCallSettings deleteFeedTransportSettings =
+        GrpcCallSettings.newBuilder()
+            .setMethodDescriptor(deleteFeedMethodDescriptor)
+            .setParamsExtractor(
+                new RequestParamsExtractor() {
+                  @Override
+                  public Map extract(DeleteFeedRequest request) {
+                    ImmutableMap.Builder params = ImmutableMap.builder();
+                    params.put("name", String.valueOf(request.getName()));
+                    return params.build();
+                  }
+                })
+            .build();
     GrpcCallSettings createFeedTransportSettings =
         GrpcCallSettings.newBuilder()
             .setMethodDescriptor(createFeedMethodDescriptor)
@@ -185,20 +198,10 @@ public Map extract(UpdateFeedRequest request) {
                   }
                 })
             .build();
-    GrpcCallSettings deleteFeedTransportSettings =
-        GrpcCallSettings.newBuilder()
-            .setMethodDescriptor(deleteFeedMethodDescriptor)
-            .setParamsExtractor(
-                new RequestParamsExtractor() {
-                  @Override
-                  public Map extract(DeleteFeedRequest request) {
-                    ImmutableMap.Builder params = ImmutableMap.builder();
-                    params.put("name", String.valueOf(request.getName()));
-                    return params.build();
-                  }
-                })
-            .build();
 
+    this.deleteFeedCallable =
+        callableFactory.createUnaryCallable(
+            deleteFeedTransportSettings, settings.deleteFeedSettings(), clientContext);
     this.createFeedCallable =
         callableFactory.createUnaryCallable(
             createFeedTransportSettings, settings.createFeedSettings(), clientContext);
@@ -211,13 +214,14 @@ public Map extract(DeleteFeedRequest request) {
     this.updateFeedCallable =
         callableFactory.createUnaryCallable(
             updateFeedTransportSettings, settings.updateFeedSettings(), clientContext);
-    this.deleteFeedCallable =
-        callableFactory.createUnaryCallable(
-            deleteFeedTransportSettings, settings.deleteFeedSettings(), clientContext);
 
     backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources());
   }
 
+  public UnaryCallable deleteFeedCallable() {
+    return deleteFeedCallable;
+  }
+
   public UnaryCallable createFeedCallable() {
     return createFeedCallable;
   }
@@ -234,10 +238,6 @@ public UnaryCallable updateFeedCallable() {
     return updateFeedCallable;
   }
 
-  public UnaryCallable deleteFeedCallable() {
-    return deleteFeedCallable;
-  }
-
   @Override
   public final void close() {
     shutdown();
diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/AssetServiceClient.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/AssetServiceClient.java
index 757bbdeaa..406cca26c 100644
--- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/AssetServiceClient.java
+++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/AssetServiceClient.java
@@ -163,56 +163,6 @@ public final OperationsClient getOperationsClient() {
     return operationsClient;
   }
 
-  // AUTO-GENERATED DOCUMENTATION AND METHOD
-  /**
-   * Analyzes IAM policies based on the specified request. Returns a list of
-   * [IamPolicyAnalysisResult][google.cloud.asset.v1p4beta1.IamPolicyAnalysisResult] matching the
-   * request.
-   *
-   * 

Sample code: - * - *


-   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   IamPolicyAnalysisQuery analysisQuery = IamPolicyAnalysisQuery.newBuilder().build();
-   *   AnalyzeIamPolicyRequest request = AnalyzeIamPolicyRequest.newBuilder()
-   *     .setAnalysisQuery(analysisQuery)
-   *     .build();
-   *   AnalyzeIamPolicyResponse response = assetServiceClient.analyzeIamPolicy(request);
-   * }
-   * 
- * - * @param request The request object containing all of the parameters for the API call. - * @throws com.google.api.gax.rpc.ApiException if the remote call fails - */ - public final AnalyzeIamPolicyResponse analyzeIamPolicy(AnalyzeIamPolicyRequest request) { - return analyzeIamPolicyCallable().call(request); - } - - // AUTO-GENERATED DOCUMENTATION AND METHOD - /** - * Analyzes IAM policies based on the specified request. Returns a list of - * [IamPolicyAnalysisResult][google.cloud.asset.v1p4beta1.IamPolicyAnalysisResult] matching the - * request. - * - *

Sample code: - * - *


-   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
-   *   IamPolicyAnalysisQuery analysisQuery = IamPolicyAnalysisQuery.newBuilder().build();
-   *   AnalyzeIamPolicyRequest request = AnalyzeIamPolicyRequest.newBuilder()
-   *     .setAnalysisQuery(analysisQuery)
-   *     .build();
-   *   ApiFuture<AnalyzeIamPolicyResponse> future = assetServiceClient.analyzeIamPolicyCallable().futureCall(request);
-   *   // Do something
-   *   AnalyzeIamPolicyResponse response = future.get();
-   * }
-   * 
- */ - public final UnaryCallable - analyzeIamPolicyCallable() { - return stub.analyzeIamPolicyCallable(); - } - // AUTO-GENERATED DOCUMENTATION AND METHOD /** * Exports IAM policy analysis based on the specified request. This API implements the @@ -301,6 +251,56 @@ public final AnalyzeIamPolicyResponse analyzeIamPolicy(AnalyzeIamPolicyRequest r return stub.exportIamPolicyAnalysisCallable(); } + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Analyzes IAM policies based on the specified request. Returns a list of + * [IamPolicyAnalysisResult][google.cloud.asset.v1p4beta1.IamPolicyAnalysisResult] matching the + * request. + * + *

Sample code: + * + *


+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   IamPolicyAnalysisQuery analysisQuery = IamPolicyAnalysisQuery.newBuilder().build();
+   *   AnalyzeIamPolicyRequest request = AnalyzeIamPolicyRequest.newBuilder()
+   *     .setAnalysisQuery(analysisQuery)
+   *     .build();
+   *   AnalyzeIamPolicyResponse response = assetServiceClient.analyzeIamPolicy(request);
+   * }
+   * 
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final AnalyzeIamPolicyResponse analyzeIamPolicy(AnalyzeIamPolicyRequest request) { + return analyzeIamPolicyCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD + /** + * Analyzes IAM policies based on the specified request. Returns a list of + * [IamPolicyAnalysisResult][google.cloud.asset.v1p4beta1.IamPolicyAnalysisResult] matching the + * request. + * + *

Sample code: + * + *


+   * try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
+   *   IamPolicyAnalysisQuery analysisQuery = IamPolicyAnalysisQuery.newBuilder().build();
+   *   AnalyzeIamPolicyRequest request = AnalyzeIamPolicyRequest.newBuilder()
+   *     .setAnalysisQuery(analysisQuery)
+   *     .build();
+   *   ApiFuture<AnalyzeIamPolicyResponse> future = assetServiceClient.analyzeIamPolicyCallable().futureCall(request);
+   *   // Do something
+   *   AnalyzeIamPolicyResponse response = future.get();
+   * }
+   * 
+ */ + public final UnaryCallable + analyzeIamPolicyCallable() { + return stub.analyzeIamPolicyCallable(); + } + @Override public final void close() { stub.close(); diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/AssetServiceSettings.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/AssetServiceSettings.java index d8d73ed66..5d804a218 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/AssetServiceSettings.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/AssetServiceSettings.java @@ -66,12 +66,6 @@ @Generated("by gapic-generator") @BetaApi public class AssetServiceSettings extends ClientSettings { - /** Returns the object with the settings used for calls to analyzeIamPolicy. */ - public UnaryCallSettings - analyzeIamPolicySettings() { - return ((AssetServiceStubSettings) getStubSettings()).analyzeIamPolicySettings(); - } - /** Returns the object with the settings used for calls to exportIamPolicyAnalysis. */ public UnaryCallSettings exportIamPolicyAnalysisSettings() { @@ -90,6 +84,12 @@ public class AssetServiceSettings extends ClientSettings { .exportIamPolicyAnalysisOperationSettings(); } + /** Returns the object with the settings used for calls to analyzeIamPolicy. */ + public UnaryCallSettings + analyzeIamPolicySettings() { + return ((AssetServiceStubSettings) getStubSettings()).analyzeIamPolicySettings(); + } + public static final AssetServiceSettings create(AssetServiceStubSettings stub) throws IOException { return new AssetServiceSettings.Builder(stub.toBuilder()).build(); @@ -187,12 +187,6 @@ public Builder applyToAllUnaryMethods( return this; } - /** Returns the builder for the settings used for calls to analyzeIamPolicy. */ - public UnaryCallSettings.Builder - analyzeIamPolicySettings() { - return getStubSettingsBuilder().analyzeIamPolicySettings(); - } - /** Returns the builder for the settings used for calls to exportIamPolicyAnalysis. */ public UnaryCallSettings.Builder exportIamPolicyAnalysisSettings() { @@ -210,6 +204,12 @@ public Builder applyToAllUnaryMethods( return getStubSettingsBuilder().exportIamPolicyAnalysisOperationSettings(); } + /** Returns the builder for the settings used for calls to analyzeIamPolicy. */ + public UnaryCallSettings.Builder + analyzeIamPolicySettings() { + return getStubSettingsBuilder().analyzeIamPolicySettings(); + } + @Override public AssetServiceSettings build() throws IOException { return new AssetServiceSettings(this); diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/stub/AssetServiceStub.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/stub/AssetServiceStub.java index e446003d8..78a7284fd 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/stub/AssetServiceStub.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/stub/AssetServiceStub.java @@ -42,11 +42,6 @@ public OperationsStub getOperationsStub() { throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); } - public UnaryCallable - analyzeIamPolicyCallable() { - throw new UnsupportedOperationException("Not implemented: analyzeIamPolicyCallable()"); - } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable< ExportIamPolicyAnalysisRequest, @@ -62,6 +57,11 @@ public OperationsStub getOperationsStub() { throw new UnsupportedOperationException("Not implemented: exportIamPolicyAnalysisCallable()"); } + public UnaryCallable + analyzeIamPolicyCallable() { + throw new UnsupportedOperationException("Not implemented: analyzeIamPolicyCallable()"); + } + @Override public abstract void close(); } diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/stub/AssetServiceStubSettings.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/stub/AssetServiceStubSettings.java index aee9b623b..115b3d806 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/stub/AssetServiceStubSettings.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/stub/AssetServiceStubSettings.java @@ -86,8 +86,6 @@ public class AssetServiceStubSettings extends StubSettings DEFAULT_SERVICE_SCOPES = ImmutableList.builder().add("https://www.googleapis.com/auth/cloud-platform").build(); - private final UnaryCallSettings - analyzeIamPolicySettings; private final UnaryCallSettings exportIamPolicyAnalysisSettings; private final OperationCallSettings< @@ -95,12 +93,8 @@ public class AssetServiceStubSettings extends StubSettings exportIamPolicyAnalysisOperationSettings; - - /** Returns the object with the settings used for calls to analyzeIamPolicy. */ - public UnaryCallSettings - analyzeIamPolicySettings() { - return analyzeIamPolicySettings; - } + private final UnaryCallSettings + analyzeIamPolicySettings; /** Returns the object with the settings used for calls to exportIamPolicyAnalysis. */ public UnaryCallSettings @@ -118,6 +112,12 @@ public class AssetServiceStubSettings extends StubSettings + analyzeIamPolicySettings() { + return analyzeIamPolicySettings; + } + @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public AssetServiceStub createStub() throws IOException { if (getTransportChannelProvider() @@ -187,18 +187,16 @@ public Builder toBuilder() { protected AssetServiceStubSettings(Builder settingsBuilder) throws IOException { super(settingsBuilder); - analyzeIamPolicySettings = settingsBuilder.analyzeIamPolicySettings().build(); exportIamPolicyAnalysisSettings = settingsBuilder.exportIamPolicyAnalysisSettings().build(); exportIamPolicyAnalysisOperationSettings = settingsBuilder.exportIamPolicyAnalysisOperationSettings().build(); + analyzeIamPolicySettings = settingsBuilder.analyzeIamPolicySettings().build(); } /** Builder for AssetServiceStubSettings. */ public static class Builder extends StubSettings.Builder { private final ImmutableList> unaryMethodSettingsBuilders; - private final UnaryCallSettings.Builder - analyzeIamPolicySettings; private final UnaryCallSettings.Builder exportIamPolicyAnalysisSettings; private final OperationCallSettings.Builder< @@ -206,6 +204,8 @@ public static class Builder extends StubSettings.Builder exportIamPolicyAnalysisOperationSettings; + private final UnaryCallSettings.Builder + analyzeIamPolicySettings; private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -248,15 +248,15 @@ protected Builder() { protected Builder(ClientContext clientContext) { super(clientContext); - analyzeIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); - exportIamPolicyAnalysisSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); exportIamPolicyAnalysisOperationSettings = OperationCallSettings.newBuilder(); + analyzeIamPolicySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + unaryMethodSettingsBuilders = ImmutableList.>of( - analyzeIamPolicySettings, exportIamPolicyAnalysisSettings); + exportIamPolicyAnalysisSettings, analyzeIamPolicySettings); initDefaults(this); } @@ -273,13 +273,13 @@ private static Builder createDefault() { private static Builder initDefaults(Builder builder) { builder - .analyzeIamPolicySettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) + .exportIamPolicyAnalysisSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); builder - .exportIamPolicyAnalysisSettings() - .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("non_idempotent")) + .analyzeIamPolicySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default")); builder .exportIamPolicyAnalysisOperationSettings() @@ -313,14 +313,14 @@ private static Builder initDefaults(Builder builder) { protected Builder(AssetServiceStubSettings settings) { super(settings); - analyzeIamPolicySettings = settings.analyzeIamPolicySettings.toBuilder(); exportIamPolicyAnalysisSettings = settings.exportIamPolicyAnalysisSettings.toBuilder(); exportIamPolicyAnalysisOperationSettings = settings.exportIamPolicyAnalysisOperationSettings.toBuilder(); + analyzeIamPolicySettings = settings.analyzeIamPolicySettings.toBuilder(); unaryMethodSettingsBuilders = ImmutableList.>of( - analyzeIamPolicySettings, exportIamPolicyAnalysisSettings); + exportIamPolicyAnalysisSettings, analyzeIamPolicySettings); } // NEXT_MAJOR_VER: remove 'throws Exception' @@ -339,12 +339,6 @@ public Builder applyToAllUnaryMethods( return unaryMethodSettingsBuilders; } - /** Returns the builder for the settings used for calls to analyzeIamPolicy. */ - public UnaryCallSettings.Builder - analyzeIamPolicySettings() { - return analyzeIamPolicySettings; - } - /** Returns the builder for the settings used for calls to exportIamPolicyAnalysis. */ public UnaryCallSettings.Builder exportIamPolicyAnalysisSettings() { @@ -362,6 +356,12 @@ public Builder applyToAllUnaryMethods( return exportIamPolicyAnalysisOperationSettings; } + /** Returns the builder for the settings used for calls to analyzeIamPolicy. */ + public UnaryCallSettings.Builder + analyzeIamPolicySettings() { + return analyzeIamPolicySettings; + } + @Override public AssetServiceStubSettings build() throws IOException { return new AssetServiceStubSettings(this); diff --git a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/stub/GrpcAssetServiceStub.java b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/stub/GrpcAssetServiceStub.java index 0a0314fe9..b55eb8077 100644 --- a/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/stub/GrpcAssetServiceStub.java +++ b/google-cloud-asset/src/main/java/com/google/cloud/asset/v1p4beta1/stub/GrpcAssetServiceStub.java @@ -48,16 +48,6 @@ @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public class GrpcAssetServiceStub extends AssetServiceStub { - private static final MethodDescriptor - analyzeIamPolicyMethodDescriptor = - MethodDescriptor.newBuilder() - .setType(MethodDescriptor.MethodType.UNARY) - .setFullMethodName("google.cloud.asset.v1p4beta1.AssetService/AnalyzeIamPolicy") - .setRequestMarshaller( - ProtoUtils.marshaller(AnalyzeIamPolicyRequest.getDefaultInstance())) - .setResponseMarshaller( - ProtoUtils.marshaller(AnalyzeIamPolicyResponse.getDefaultInstance())) - .build(); private static final MethodDescriptor exportIamPolicyAnalysisMethodDescriptor = MethodDescriptor.newBuilder() @@ -68,12 +58,20 @@ public class GrpcAssetServiceStub extends AssetServiceStub { ProtoUtils.marshaller(ExportIamPolicyAnalysisRequest.getDefaultInstance())) .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) .build(); + private static final MethodDescriptor + analyzeIamPolicyMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.cloud.asset.v1p4beta1.AssetService/AnalyzeIamPolicy") + .setRequestMarshaller( + ProtoUtils.marshaller(AnalyzeIamPolicyRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(AnalyzeIamPolicyResponse.getDefaultInstance())) + .build(); private final BackgroundResource backgroundResources; private final GrpcOperationsStub operationsStub; - private final UnaryCallable - analyzeIamPolicyCallable; private final UnaryCallable exportIamPolicyAnalysisCallable; private final OperationCallable< @@ -81,6 +79,8 @@ public class GrpcAssetServiceStub extends AssetServiceStub { ExportIamPolicyAnalysisResponse, ExportIamPolicyAnalysisRequest> exportIamPolicyAnalysisOperationCallable; + private final UnaryCallable + analyzeIamPolicyCallable; private final GrpcStubCallableFactory callableFactory; @@ -122,14 +122,14 @@ protected GrpcAssetServiceStub( this.callableFactory = callableFactory; this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); - GrpcCallSettings - analyzeIamPolicyTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(analyzeIamPolicyMethodDescriptor) + GrpcCallSettings + exportIamPolicyAnalysisTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(exportIamPolicyAnalysisMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { + new RequestParamsExtractor() { @Override - public Map extract(AnalyzeIamPolicyRequest request) { + public Map extract(ExportIamPolicyAnalysisRequest request) { ImmutableMap.Builder params = ImmutableMap.builder(); params.put( "analysis_query.parent", @@ -138,14 +138,14 @@ public Map extract(AnalyzeIamPolicyRequest request) { } }) .build(); - GrpcCallSettings - exportIamPolicyAnalysisTransportSettings = - GrpcCallSettings.newBuilder() - .setMethodDescriptor(exportIamPolicyAnalysisMethodDescriptor) + GrpcCallSettings + analyzeIamPolicyTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(analyzeIamPolicyMethodDescriptor) .setParamsExtractor( - new RequestParamsExtractor() { + new RequestParamsExtractor() { @Override - public Map extract(ExportIamPolicyAnalysisRequest request) { + public Map extract(AnalyzeIamPolicyRequest request) { ImmutableMap.Builder params = ImmutableMap.builder(); params.put( "analysis_query.parent", @@ -155,9 +155,6 @@ public Map extract(ExportIamPolicyAnalysisRequest request) { }) .build(); - this.analyzeIamPolicyCallable = - callableFactory.createUnaryCallable( - analyzeIamPolicyTransportSettings, settings.analyzeIamPolicySettings(), clientContext); this.exportIamPolicyAnalysisCallable = callableFactory.createUnaryCallable( exportIamPolicyAnalysisTransportSettings, @@ -169,6 +166,9 @@ public Map extract(ExportIamPolicyAnalysisRequest request) { settings.exportIamPolicyAnalysisOperationSettings(), clientContext, this.operationsStub); + this.analyzeIamPolicyCallable = + callableFactory.createUnaryCallable( + analyzeIamPolicyTransportSettings, settings.analyzeIamPolicySettings(), clientContext); backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } @@ -178,11 +178,6 @@ public GrpcOperationsStub getOperationsStub() { return operationsStub; } - public UnaryCallable - analyzeIamPolicyCallable() { - return analyzeIamPolicyCallable; - } - @BetaApi("The surface for use by generated code is not stable yet and may change in the future.") public OperationCallable< ExportIamPolicyAnalysisRequest, @@ -197,6 +192,11 @@ public GrpcOperationsStub getOperationsStub() { return exportIamPolicyAnalysisCallable; } + public UnaryCallable + analyzeIamPolicyCallable() { + return analyzeIamPolicyCallable; + } + @Override public final void close() { shutdown(); diff --git a/google-cloud-asset/src/test/java/com/google/cloud/asset/v1beta1/AssetServiceClientTest.java b/google-cloud-asset/src/test/java/com/google/cloud/asset/v1beta1/AssetServiceClientTest.java index 99841c828..164f52be1 100644 --- a/google-cloud-asset/src/test/java/com/google/cloud/asset/v1beta1/AssetServiceClientTest.java +++ b/google-cloud-asset/src/test/java/com/google/cloud/asset/v1beta1/AssetServiceClientTest.java @@ -31,6 +31,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.List; +import java.util.Objects; import java.util.UUID; import java.util.concurrent.ExecutionException; import org.junit.After; @@ -90,7 +91,7 @@ public void exportAssetsTest() throws Exception { .build(); mockAssetService.addResponse(resultOperation); - ProjectName parent = ProjectName.of("[PROJECT]"); + String parent = "parent-995424086"; OutputConfig outputConfig = OutputConfig.newBuilder().build(); ExportAssetsRequest request = ExportAssetsRequest.newBuilder() @@ -105,7 +106,7 @@ public void exportAssetsTest() throws Exception { Assert.assertEquals(1, actualRequests.size()); ExportAssetsRequest actualRequest = (ExportAssetsRequest) actualRequests.get(0); - Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent())); + Assert.assertEquals(Objects.toString(parent), Objects.toString(actualRequest.getParent())); Assert.assertEquals(outputConfig, actualRequest.getOutputConfig()); Assert.assertTrue( channelProvider.isHeaderSent( @@ -120,7 +121,7 @@ public void exportAssetsExceptionTest() throws Exception { mockAssetService.addException(exception); try { - ProjectName parent = ProjectName.of("[PROJECT]"); + String parent = "parent-995424086"; OutputConfig outputConfig = OutputConfig.newBuilder().build(); ExportAssetsRequest request = ExportAssetsRequest.newBuilder() @@ -144,15 +145,9 @@ public void batchGetAssetsHistoryTest() { BatchGetAssetsHistoryResponse.newBuilder().build(); mockAssetService.addResponse(expectedResponse); - ProjectName parent = ProjectName.of("[PROJECT]"); - ContentType contentType = ContentType.CONTENT_TYPE_UNSPECIFIED; - TimeWindow readTimeWindow = TimeWindow.newBuilder().build(); + String parent = "parent-995424086"; BatchGetAssetsHistoryRequest request = - BatchGetAssetsHistoryRequest.newBuilder() - .setParent(parent.toString()) - .setContentType(contentType) - .setReadTimeWindow(readTimeWindow) - .build(); + BatchGetAssetsHistoryRequest.newBuilder().setParent(parent.toString()).build(); BatchGetAssetsHistoryResponse actualResponse = client.batchGetAssetsHistory(request); Assert.assertEquals(expectedResponse, actualResponse); @@ -162,9 +157,7 @@ public void batchGetAssetsHistoryTest() { BatchGetAssetsHistoryRequest actualRequest = (BatchGetAssetsHistoryRequest) actualRequests.get(0); - Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent())); - Assert.assertEquals(contentType, actualRequest.getContentType()); - Assert.assertEquals(readTimeWindow, actualRequest.getReadTimeWindow()); + Assert.assertEquals(Objects.toString(parent), Objects.toString(actualRequest.getParent())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -178,15 +171,9 @@ public void batchGetAssetsHistoryExceptionTest() throws Exception { mockAssetService.addException(exception); try { - ProjectName parent = ProjectName.of("[PROJECT]"); - ContentType contentType = ContentType.CONTENT_TYPE_UNSPECIFIED; - TimeWindow readTimeWindow = TimeWindow.newBuilder().build(); + String parent = "parent-995424086"; BatchGetAssetsHistoryRequest request = - BatchGetAssetsHistoryRequest.newBuilder() - .setParent(parent.toString()) - .setContentType(contentType) - .setReadTimeWindow(readTimeWindow) - .build(); + BatchGetAssetsHistoryRequest.newBuilder().setParent(parent.toString()).build(); client.batchGetAssetsHistory(request); Assert.fail("No exception raised"); diff --git a/google-cloud-asset/src/test/java/com/google/cloud/asset/v1p2beta1/AssetServiceClientTest.java b/google-cloud-asset/src/test/java/com/google/cloud/asset/v1p2beta1/AssetServiceClientTest.java index a713511d0..e336ec2e0 100644 --- a/google-cloud-asset/src/test/java/com/google/cloud/asset/v1p2beta1/AssetServiceClientTest.java +++ b/google-cloud-asset/src/test/java/com/google/cloud/asset/v1p2beta1/AssetServiceClientTest.java @@ -75,11 +75,48 @@ public void tearDown() throws Exception { client.close(); } + @Test + @SuppressWarnings("all") + public void deleteFeedTest() { + Empty expectedResponse = Empty.newBuilder().build(); + mockAssetService.addResponse(expectedResponse); + + FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]"); + + client.deleteFeed(name); + + List actualRequests = mockAssetService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteFeedRequest actualRequest = (DeleteFeedRequest) actualRequests.get(0); + + Assert.assertEquals(name, FeedName.parse(actualRequest.getName())); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void deleteFeedExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockAssetService.addException(exception); + + try { + FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]"); + + client.deleteFeed(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } + @Test @SuppressWarnings("all") public void createFeedTest() { - String name = "name3373707"; - Feed expectedResponse = Feed.newBuilder().setName(name).build(); + FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]"); + Feed expectedResponse = Feed.newBuilder().setName(name.toString()).build(); mockAssetService.addResponse(expectedResponse); String parent = "parent-995424086"; @@ -117,20 +154,20 @@ public void createFeedExceptionTest() throws Exception { @Test @SuppressWarnings("all") public void getFeedTest() { - String name2 = "name2-1052831874"; - Feed expectedResponse = Feed.newBuilder().setName(name2).build(); + FeedName name2 = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]"); + Feed expectedResponse = Feed.newBuilder().setName(name2.toString()).build(); mockAssetService.addResponse(expectedResponse); - String formattedName = AssetServiceClient.formatFeedName("[PROJECT]", "[FEED]"); + FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]"); - Feed actualResponse = client.getFeed(formattedName); + Feed actualResponse = client.getFeed(name); Assert.assertEquals(expectedResponse, actualResponse); List actualRequests = mockAssetService.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetFeedRequest actualRequest = (GetFeedRequest) actualRequests.get(0); - Assert.assertEquals(formattedName, actualRequest.getName()); + Assert.assertEquals(name, FeedName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), @@ -144,9 +181,9 @@ public void getFeedExceptionTest() throws Exception { mockAssetService.addException(exception); try { - String formattedName = AssetServiceClient.formatFeedName("[PROJECT]", "[FEED]"); + FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]"); - client.getFeed(formattedName); + client.getFeed(name); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { // Expected exception @@ -194,8 +231,8 @@ public void listFeedsExceptionTest() throws Exception { @Test @SuppressWarnings("all") public void updateFeedTest() { - String name = "name3373707"; - Feed expectedResponse = Feed.newBuilder().setName(name).build(); + FeedName name = FeedName.ofProjectFeedName("[PROJECT]", "[FEED]"); + Feed expectedResponse = Feed.newBuilder().setName(name.toString()).build(); mockAssetService.addResponse(expectedResponse); Feed feed = Feed.newBuilder().build(); @@ -229,41 +266,4 @@ public void updateFeedExceptionTest() throws Exception { // Expected exception } } - - @Test - @SuppressWarnings("all") - public void deleteFeedTest() { - Empty expectedResponse = Empty.newBuilder().build(); - mockAssetService.addResponse(expectedResponse); - - String formattedName = AssetServiceClient.formatFeedName("[PROJECT]", "[FEED]"); - - client.deleteFeed(formattedName); - - List actualRequests = mockAssetService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - DeleteFeedRequest actualRequest = (DeleteFeedRequest) actualRequests.get(0); - - Assert.assertEquals(formattedName, actualRequest.getName()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void deleteFeedExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockAssetService.addException(exception); - - try { - String formattedName = AssetServiceClient.formatFeedName("[PROJECT]", "[FEED]"); - - client.deleteFeed(formattedName); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } } diff --git a/google-cloud-asset/src/test/java/com/google/cloud/asset/v1p4beta1/AssetServiceClientTest.java b/google-cloud-asset/src/test/java/com/google/cloud/asset/v1p4beta1/AssetServiceClientTest.java index 4cd070f39..68d2aa9a4 100644 --- a/google-cloud-asset/src/test/java/com/google/cloud/asset/v1p4beta1/AssetServiceClientTest.java +++ b/google-cloud-asset/src/test/java/com/google/cloud/asset/v1p4beta1/AssetServiceClientTest.java @@ -78,50 +78,6 @@ public void tearDown() throws Exception { client.close(); } - @Test - @SuppressWarnings("all") - public void analyzeIamPolicyTest() { - boolean fullyExplored = true; - AnalyzeIamPolicyResponse expectedResponse = - AnalyzeIamPolicyResponse.newBuilder().setFullyExplored(fullyExplored).build(); - mockAssetService.addResponse(expectedResponse); - - IamPolicyAnalysisQuery analysisQuery = IamPolicyAnalysisQuery.newBuilder().build(); - AnalyzeIamPolicyRequest request = - AnalyzeIamPolicyRequest.newBuilder().setAnalysisQuery(analysisQuery).build(); - - AnalyzeIamPolicyResponse actualResponse = client.analyzeIamPolicy(request); - Assert.assertEquals(expectedResponse, actualResponse); - - List actualRequests = mockAssetService.getRequests(); - Assert.assertEquals(1, actualRequests.size()); - AnalyzeIamPolicyRequest actualRequest = (AnalyzeIamPolicyRequest) actualRequests.get(0); - - Assert.assertEquals(analysisQuery, actualRequest.getAnalysisQuery()); - Assert.assertTrue( - channelProvider.isHeaderSent( - ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), - GaxGrpcProperties.getDefaultApiClientHeaderPattern())); - } - - @Test - @SuppressWarnings("all") - public void analyzeIamPolicyExceptionTest() throws Exception { - StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); - mockAssetService.addException(exception); - - try { - IamPolicyAnalysisQuery analysisQuery = IamPolicyAnalysisQuery.newBuilder().build(); - AnalyzeIamPolicyRequest request = - AnalyzeIamPolicyRequest.newBuilder().setAnalysisQuery(analysisQuery).build(); - - client.analyzeIamPolicy(request); - Assert.fail("No exception raised"); - } catch (InvalidArgumentException e) { - // Expected exception - } - } - @Test @SuppressWarnings("all") public void exportIamPolicyAnalysisTest() throws Exception { @@ -184,4 +140,48 @@ public void exportIamPolicyAnalysisExceptionTest() throws Exception { Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); } } + + @Test + @SuppressWarnings("all") + public void analyzeIamPolicyTest() { + boolean fullyExplored = true; + AnalyzeIamPolicyResponse expectedResponse = + AnalyzeIamPolicyResponse.newBuilder().setFullyExplored(fullyExplored).build(); + mockAssetService.addResponse(expectedResponse); + + IamPolicyAnalysisQuery analysisQuery = IamPolicyAnalysisQuery.newBuilder().build(); + AnalyzeIamPolicyRequest request = + AnalyzeIamPolicyRequest.newBuilder().setAnalysisQuery(analysisQuery).build(); + + AnalyzeIamPolicyResponse actualResponse = client.analyzeIamPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockAssetService.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + AnalyzeIamPolicyRequest actualRequest = (AnalyzeIamPolicyRequest) actualRequests.get(0); + + Assert.assertEquals(analysisQuery, actualRequest.getAnalysisQuery()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + @SuppressWarnings("all") + public void analyzeIamPolicyExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT); + mockAssetService.addException(exception); + + try { + IamPolicyAnalysisQuery analysisQuery = IamPolicyAnalysisQuery.newBuilder().build(); + AnalyzeIamPolicyRequest request = + AnalyzeIamPolicyRequest.newBuilder().setAnalysisQuery(analysisQuery).build(); + + client.analyzeIamPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception + } + } } diff --git a/proto-google-cloud-asset-v1p2beta1/src/main/java/com/google/cloud/asset/v1p2beta1/FeedName.java b/proto-google-cloud-asset-v1p2beta1/src/main/java/com/google/cloud/asset/v1p2beta1/FeedName.java index 20de7cefc..bfd40a599 100644 --- a/proto-google-cloud-asset-v1p2beta1/src/main/java/com/google/cloud/asset/v1p2beta1/FeedName.java +++ b/proto-google-cloud-asset-v1p2beta1/src/main/java/com/google/cloud/asset/v1p2beta1/FeedName.java @@ -16,25 +16,39 @@ package com.google.cloud.asset.v1p2beta1; +import com.google.api.core.BetaApi; import com.google.api.pathtemplate.PathTemplate; +import com.google.api.pathtemplate.ValidationException; import com.google.api.resourcenames.ResourceName; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; /** AUTO-GENERATED DOCUMENTATION AND CLASS */ @javax.annotation.Generated("by GAPIC protoc plugin") public class FeedName implements ResourceName { - private static final PathTemplate PATH_TEMPLATE = + @Deprecated + protected FeedName() {} + + private static final PathTemplate PROJECT_FEED_PATH_TEMPLATE = PathTemplate.createWithoutUrlEncoding("projects/{project}/feeds/{feed}"); + private static final PathTemplate FOLDER_FEED_PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding("folders/{folder}/feeds/{feed}"); + private static final PathTemplate ORGANIZATION_FEED_PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding("organizations/{organization}/feeds/{feed}"); private volatile Map fieldValuesMap; + private PathTemplate pathTemplate; + private String fixedValue; - private final String project; - private final String feed; + private String project; + private String feed; + private String folder; + private String organization; public String getProject() { return project; @@ -44,35 +58,112 @@ public String getFeed() { return feed; } - public static Builder newBuilder() { - return new Builder(); + public String getFolder() { + return folder; } - public Builder toBuilder() { - return new Builder(this); + public String getOrganization() { + return organization; } private FeedName(Builder builder) { project = Preconditions.checkNotNull(builder.getProject()); feed = Preconditions.checkNotNull(builder.getFeed()); + pathTemplate = PROJECT_FEED_PATH_TEMPLATE; + } + + private FeedName(FolderFeedBuilder builder) { + folder = Preconditions.checkNotNull(builder.getFolder()); + feed = Preconditions.checkNotNull(builder.getFeed()); + pathTemplate = FOLDER_FEED_PATH_TEMPLATE; + } + + private FeedName(OrganizationFeedBuilder builder) { + organization = Preconditions.checkNotNull(builder.getOrganization()); + feed = Preconditions.checkNotNull(builder.getFeed()); + pathTemplate = ORGANIZATION_FEED_PATH_TEMPLATE; + } + + public static Builder newBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static Builder newProjectFeedBuilder() { + return new Builder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static FolderFeedBuilder newFolderFeedBuilder() { + return new FolderFeedBuilder(); + } + + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static OrganizationFeedBuilder newOrganizationFeedBuilder() { + return new OrganizationFeedBuilder(); + } + + public Builder toBuilder() { + return new Builder(this); } public static FeedName of(String project, String feed) { - return newBuilder().setProject(project).setFeed(feed).build(); + return newProjectFeedBuilder().setProject(project).setFeed(feed).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static FeedName ofProjectFeedName(String project, String feed) { + return newProjectFeedBuilder().setProject(project).setFeed(feed).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static FeedName ofFolderFeedName(String folder, String feed) { + return newFolderFeedBuilder().setFolder(folder).setFeed(feed).build(); + } + + @BetaApi("The static create methods are not stable yet and may be changed in the future.") + public static FeedName ofOrganizationFeedName(String organization, String feed) { + return newOrganizationFeedBuilder().setOrganization(organization).setFeed(feed).build(); } public static String format(String project, String feed) { return newBuilder().setProject(project).setFeed(feed).build().toString(); } + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatProjectFeedName(String project, String feed) { + return newBuilder().setProject(project).setFeed(feed).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatFolderFeedName(String folder, String feed) { + return newFolderFeedBuilder().setFolder(folder).setFeed(feed).build().toString(); + } + + @BetaApi("The static format methods are not stable yet and may be changed in the future.") + public static String formatOrganizationFeedName(String organization, String feed) { + return newOrganizationFeedBuilder() + .setOrganization(organization) + .setFeed(feed) + .build() + .toString(); + } + public static FeedName parse(String formattedString) { if (formattedString.isEmpty()) { return null; } - Map matchMap = - PATH_TEMPLATE.validatedMatch( - formattedString, "FeedName.parse: formattedString not in valid format"); - return of(matchMap.get("project"), matchMap.get("feed")); + if (PROJECT_FEED_PATH_TEMPLATE.matches(formattedString)) { + Map matchMap = PROJECT_FEED_PATH_TEMPLATE.match(formattedString); + return ofProjectFeedName(matchMap.get("project"), matchMap.get("feed")); + } else if (FOLDER_FEED_PATH_TEMPLATE.matches(formattedString)) { + Map matchMap = FOLDER_FEED_PATH_TEMPLATE.match(formattedString); + return ofFolderFeedName(matchMap.get("folder"), matchMap.get("feed")); + } else if (ORGANIZATION_FEED_PATH_TEMPLATE.matches(formattedString)) { + Map matchMap = ORGANIZATION_FEED_PATH_TEMPLATE.match(formattedString); + return ofOrganizationFeedName(matchMap.get("organization"), matchMap.get("feed")); + } + throw new ValidationException("JobName.parse: formattedString not in valid format"); } public static List parseList(List formattedStrings) { @@ -84,7 +175,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 (FeedName value : values) { if (value == null) { list.add(""); @@ -96,16 +187,29 @@ public static List toStringList(List values) { } public static boolean isParsableFrom(String formattedString) { - return PATH_TEMPLATE.matches(formattedString); + return PROJECT_FEED_PATH_TEMPLATE.matches(formattedString) + || FOLDER_FEED_PATH_TEMPLATE.matches(formattedString) + || ORGANIZATION_FEED_PATH_TEMPLATE.matches(formattedString); } + @Override public Map getFieldValuesMap() { if (fieldValuesMap == null) { synchronized (this) { if (fieldValuesMap == null) { ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); - fieldMapBuilder.put("project", project); - fieldMapBuilder.put("feed", feed); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (feed != null) { + fieldMapBuilder.put("feed", feed); + } + if (folder != null) { + fieldMapBuilder.put("folder", folder); + } + if (organization != null) { + fieldMapBuilder.put("organization", organization); + } fieldValuesMap = fieldMapBuilder.build(); } } @@ -119,15 +223,17 @@ public String getFieldValue(String fieldName) { @Override public String toString() { - return PATH_TEMPLATE.instantiate("project", project, "feed", feed); + return fixedValue != null ? fixedValue : pathTemplate.instantiate(getFieldValuesMap()); } - /** Builder for FeedName. */ + /** Builder for projects/{project}/feeds/{feed}. */ public static class Builder { private String project; private String feed; + protected Builder() {} + public String getProject() { return project; } @@ -146,9 +252,11 @@ public Builder setFeed(String feed) { return this; } - private Builder() {} - private Builder(FeedName feedName) { + Preconditions.checkArgument( + feedName.pathTemplate == PROJECT_FEED_PATH_TEMPLATE, + "toBuilder is only supported when FeedName has the pattern of " + + "projects/{project}/feeds/{feed}."); project = feedName.project; feed = feedName.feed; } @@ -158,14 +266,81 @@ public FeedName build() { } } + /** Builder for folders/{folder}/feeds/{feed}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class FolderFeedBuilder { + + private String folder; + private String feed; + + private FolderFeedBuilder() {} + + public String getFolder() { + return folder; + } + + public String getFeed() { + return feed; + } + + public FolderFeedBuilder setFolder(String folder) { + this.folder = folder; + return this; + } + + public FolderFeedBuilder setFeed(String feed) { + this.feed = feed; + return this; + } + + public FeedName build() { + return new FeedName(this); + } + } + + /** Builder for organizations/{organization}/feeds/{feed}. */ + @BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.") + public static class OrganizationFeedBuilder { + + private String organization; + private String feed; + + private OrganizationFeedBuilder() {} + + public String getOrganization() { + return organization; + } + + public String getFeed() { + return feed; + } + + public OrganizationFeedBuilder setOrganization(String organization) { + this.organization = organization; + return this; + } + + public OrganizationFeedBuilder setFeed(String feed) { + this.feed = feed; + return this; + } + + public FeedName build() { + return new FeedName(this); + } + } + @Override public boolean equals(Object o) { if (o == this) { return true; } - if (o instanceof FeedName) { + if (o != null || getClass() == o.getClass()) { FeedName that = (FeedName) o; - return (this.project.equals(that.project)) && (this.feed.equals(that.feed)); + return (Objects.equals(this.project, that.project)) + && (Objects.equals(this.feed, that.feed)) + && (Objects.equals(this.folder, that.folder)) + && (Objects.equals(this.organization, that.organization)); } return false; } @@ -174,9 +349,15 @@ public boolean equals(Object o) { public int hashCode() { int h = 1; h *= 1000003; - h ^= project.hashCode(); + h ^= Objects.hashCode(fixedValue); + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(feed); + h *= 1000003; + h ^= Objects.hashCode(folder); h *= 1000003; - h ^= feed.hashCode(); + h ^= Objects.hashCode(organization); return h; } } diff --git a/synth.metadata b/synth.metadata index 38c94900f..0bd6eb5bc 100644 --- a/synth.metadata +++ b/synth.metadata @@ -11,40 +11,40 @@ "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "fd35dc6865fa9f47f283d5a6c37c4901162007cf", - "internalRef": "305774392" + "sha": "a34f4eb96a94bfd5b3e7f8de253db28d0a3e9237", + "internalRef": "306283252" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "fd35dc6865fa9f47f283d5a6c37c4901162007cf", - "internalRef": "305774392" + "sha": "a34f4eb96a94bfd5b3e7f8de253db28d0a3e9237", + "internalRef": "306283252" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "fd35dc6865fa9f47f283d5a6c37c4901162007cf", - "internalRef": "305774392" + "sha": "a34f4eb96a94bfd5b3e7f8de253db28d0a3e9237", + "internalRef": "306283252" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "fd35dc6865fa9f47f283d5a6c37c4901162007cf", - "internalRef": "305774392" + "sha": "a34f4eb96a94bfd5b3e7f8de253db28d0a3e9237", + "internalRef": "306283252" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "fd35dc6865fa9f47f283d5a6c37c4901162007cf", - "internalRef": "305774392" + "sha": "a34f4eb96a94bfd5b3e7f8de253db28d0a3e9237", + "internalRef": "306283252" } }, {