Skip to content

Commit 0a0b290

Browse files
authored
feat: add v1p7beta1 client (#723)
1 parent b979d6d commit 0a0b290

File tree

5 files changed

+48
-37
lines changed

5 files changed

+48
-37
lines changed

asset/src/main/java/com/example/asset/BatchGetAssetsHistoryExample.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ public static void main(String... args) throws Exception {
4242
ProjectName parent = ProjectName.of(projectId);
4343
ContentType contentType = ContentType.CONTENT_TYPE_UNSPECIFIED;
4444
TimeWindow readTimeWindow = TimeWindow.newBuilder().build();
45-
BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder()
46-
.setParent(parent.toString())
47-
.addAllAssetNames(Arrays.asList(assetNames))
48-
.setContentType(contentType)
49-
.setReadTimeWindow(readTimeWindow)
50-
.build();
45+
BatchGetAssetsHistoryRequest request =
46+
BatchGetAssetsHistoryRequest.newBuilder()
47+
.setParent(parent.toString())
48+
.addAllAssetNames(Arrays.asList(assetNames))
49+
.setContentType(contentType)
50+
.setReadTimeWindow(readTimeWindow)
51+
.build();
5152
BatchGetAssetsHistoryResponse response = client.batchGetAssetsHistory(request);
5253
System.out.println(response);
5354
}

asset/src/main/java/com/example/asset/CreateFeedExample.java

+16-12
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,26 @@
2727

2828
public class CreateFeedExample {
2929
// Create a feed
30-
public static void createFeed(
31-
String[] assetNames, String feedId, String topic, String projectId) throws Exception {
30+
public static void createFeed(String[] assetNames, String feedId, String topic, String projectId)
31+
throws Exception {
3232
// String[] assetNames = {"MY_ASSET_NAME"}
3333
// String FeedId = "MY_FEED_ID"
3434
// String topic = "projects/[PROJECT_ID]/topics/[TOPIC_NAME]"
3535
// String projectID = "MY_PROJECT_ID"
36-
Feed feed = Feed.newBuilder()
37-
.addAllAssetNames(Arrays.asList(assetNames))
38-
.setFeedOutputConfig(
39-
FeedOutputConfig.newBuilder().setPubsubDestination(
40-
PubsubDestination.newBuilder().setTopic(topic).build()).build()).build();
41-
CreateFeedRequest request = CreateFeedRequest.newBuilder()
42-
.setParent(String.format(ProjectName.of(projectId).toString()))
43-
.setFeedId(feedId)
44-
.setFeed(feed)
45-
.build();
36+
Feed feed =
37+
Feed.newBuilder()
38+
.addAllAssetNames(Arrays.asList(assetNames))
39+
.setFeedOutputConfig(
40+
FeedOutputConfig.newBuilder()
41+
.setPubsubDestination(PubsubDestination.newBuilder().setTopic(topic).build())
42+
.build())
43+
.build();
44+
CreateFeedRequest request =
45+
CreateFeedRequest.newBuilder()
46+
.setParent(String.format(ProjectName.of(projectId).toString()))
47+
.setFeedId(feedId)
48+
.setFeed(feed)
49+
.build();
4650
// Initialize client that will be used to send requests. This client only needs to be created
4751
// once, and can be reused for multiple requests. After completing all of your requests, call
4852
// the "close" method on the client to safely clean up any remaining background resources.

asset/src/main/java/com/example/asset/ListAssetsExample.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,18 @@ public static void listAssets(String projectId, String[] assetTypes, ContentType
4949
ProjectName parent = ProjectName.of(projectId);
5050

5151
// Build initial ListAssetsRequest without setting page token.
52-
ListAssetsRequest request = ListAssetsRequest.newBuilder()
53-
.setParent(parent.toString())
54-
.addAllAssetTypes(Arrays.asList(assetTypes))
55-
.setContentType(contentType)
56-
.build();
52+
ListAssetsRequest request =
53+
ListAssetsRequest.newBuilder()
54+
.setParent(parent.toString())
55+
.addAllAssetTypes(Arrays.asList(assetTypes))
56+
.setContentType(contentType)
57+
.build();
5758

5859
// Repeatedly call ListAssets until page token is empty.
5960
ListAssetsPagedResponse response = client.listAssets(request);
6061
System.out.println(response);
6162
while (!response.getNextPageToken().isEmpty()) {
62-
request = request.toBuilder()
63-
.setPageToken(response.getNextPageToken()).build();
63+
request = request.toBuilder().setPageToken(response.getNextPageToken()).build();
6464
response = client.listAssets(request);
6565
System.out.println(response);
6666
}

asset/src/main/java/com/example/asset/SearchAllResourcesExample.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ public static void searchAllResources(String scope, String query) {
5454
} catch (IOException e) {
5555
System.out.println(String.format("Failed to create client:%n%s", e.toString()));
5656
} catch (InvalidArgumentException e) {
57-
System.out.println(String.format("Invalid request:%n%s", e.toString()));
57+
System.out.println(String.format("Invalid request:%n%s", e.toString()));
5858
} catch (ApiException e) {
59-
System.out.println(String.format("Error during SearchAllResources:%n%s", e.toString()));
59+
System.out.println(String.format("Error during SearchAllResources:%n%s", e.toString()));
6060
}
6161
}
6262
}

asset/src/main/java/com/example/asset/UpdateFeedExample.java

+16-10
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,22 @@ public class UpdateFeedExample {
3030
public static void updateFeed(String feedName, String topic) throws Exception {
3131
// String feedName = "MY_FEED_NAME"
3232
// String topic = "projects/[PROJECT_ID]/topics/[TOPIC_NAME]"
33-
Feed feed = Feed.newBuilder()
34-
.setName(feedName)
35-
.setFeedOutputConfig(
36-
FeedOutputConfig.newBuilder().setPubsubDestination(
37-
PubsubDestination.newBuilder().setTopic(topic).build()).build()).build();
38-
UpdateFeedRequest request = UpdateFeedRequest.newBuilder()
39-
.setFeed(feed)
40-
.setUpdateMask(
41-
FieldMask.newBuilder().addPaths("feed_output_config.pubsub_destination.topic").build())
42-
.build();
33+
Feed feed =
34+
Feed.newBuilder()
35+
.setName(feedName)
36+
.setFeedOutputConfig(
37+
FeedOutputConfig.newBuilder()
38+
.setPubsubDestination(PubsubDestination.newBuilder().setTopic(topic).build())
39+
.build())
40+
.build();
41+
UpdateFeedRequest request =
42+
UpdateFeedRequest.newBuilder()
43+
.setFeed(feed)
44+
.setUpdateMask(
45+
FieldMask.newBuilder()
46+
.addPaths("feed_output_config.pubsub_destination.topic")
47+
.build())
48+
.build();
4349
// Initialize client that will be used to send requests. This client only needs to be created
4450
// once, and can be reused for multiple requests. After completing all of your requests, call
4551
// the "close" method on the client to safely clean up any remaining background resources.

0 commit comments

Comments
 (0)