Skip to content

Commit

Permalink
feat: add v1p7beta1 client (#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
Neenu1995 authored and anguillanneuf committed Dec 5, 2022
1 parent ea66d48 commit 4c0220e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ public static void main(String... args) throws Exception {
ProjectName parent = ProjectName.of(projectId);
ContentType contentType = ContentType.CONTENT_TYPE_UNSPECIFIED;
TimeWindow readTimeWindow = TimeWindow.newBuilder().build();
BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder()
.setParent(parent.toString())
.addAllAssetNames(Arrays.asList(assetNames))
.setContentType(contentType)
.setReadTimeWindow(readTimeWindow)
.build();
BatchGetAssetsHistoryRequest request =
BatchGetAssetsHistoryRequest.newBuilder()
.setParent(parent.toString())
.addAllAssetNames(Arrays.asList(assetNames))
.setContentType(contentType)
.setReadTimeWindow(readTimeWindow)
.build();
BatchGetAssetsHistoryResponse response = client.batchGetAssetsHistory(request);
System.out.println(response);
}
Expand Down
28 changes: 16 additions & 12 deletions asset/src/main/java/com/example/asset/CreateFeedExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,26 @@

public class CreateFeedExample {
// Create a feed
public static void createFeed(
String[] assetNames, String feedId, String topic, String projectId) throws Exception {
public static void createFeed(String[] assetNames, String feedId, String topic, String projectId)
throws Exception {
// String[] assetNames = {"MY_ASSET_NAME"}
// String FeedId = "MY_FEED_ID"
// String topic = "projects/[PROJECT_ID]/topics/[TOPIC_NAME]"
// String projectID = "MY_PROJECT_ID"
Feed feed = Feed.newBuilder()
.addAllAssetNames(Arrays.asList(assetNames))
.setFeedOutputConfig(
FeedOutputConfig.newBuilder().setPubsubDestination(
PubsubDestination.newBuilder().setTopic(topic).build()).build()).build();
CreateFeedRequest request = CreateFeedRequest.newBuilder()
.setParent(String.format(ProjectName.of(projectId).toString()))
.setFeedId(feedId)
.setFeed(feed)
.build();
Feed feed =
Feed.newBuilder()
.addAllAssetNames(Arrays.asList(assetNames))
.setFeedOutputConfig(
FeedOutputConfig.newBuilder()
.setPubsubDestination(PubsubDestination.newBuilder().setTopic(topic).build())
.build())
.build();
CreateFeedRequest request =
CreateFeedRequest.newBuilder()
.setParent(String.format(ProjectName.of(projectId).toString()))
.setFeedId(feedId)
.setFeed(feed)
.build();
// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests. After completing all of your requests, call
// the "close" method on the client to safely clean up any remaining background resources.
Expand Down
14 changes: 7 additions & 7 deletions asset/src/main/java/com/example/asset/ListAssetsExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ public static void listAssets(String projectId, String[] assetTypes, ContentType
ProjectName parent = ProjectName.of(projectId);

// Build initial ListAssetsRequest without setting page token.
ListAssetsRequest request = ListAssetsRequest.newBuilder()
.setParent(parent.toString())
.addAllAssetTypes(Arrays.asList(assetTypes))
.setContentType(contentType)
.build();
ListAssetsRequest request =
ListAssetsRequest.newBuilder()
.setParent(parent.toString())
.addAllAssetTypes(Arrays.asList(assetTypes))
.setContentType(contentType)
.build();

// Repeatedly call ListAssets until page token is empty.
ListAssetsPagedResponse response = client.listAssets(request);
System.out.println(response);
while (!response.getNextPageToken().isEmpty()) {
request = request.toBuilder()
.setPageToken(response.getNextPageToken()).build();
request = request.toBuilder().setPageToken(response.getNextPageToken()).build();
response = client.listAssets(request);
System.out.println(response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public static void searchAllResources(String scope, String query) {
} catch (IOException e) {
System.out.println(String.format("Failed to create client:%n%s", e.toString()));
} catch (InvalidArgumentException e) {
System.out.println(String.format("Invalid request:%n%s", e.toString()));
System.out.println(String.format("Invalid request:%n%s", e.toString()));
} catch (ApiException e) {
System.out.println(String.format("Error during SearchAllResources:%n%s", e.toString()));
System.out.println(String.format("Error during SearchAllResources:%n%s", e.toString()));
}
}
}
Expand Down
26 changes: 16 additions & 10 deletions asset/src/main/java/com/example/asset/UpdateFeedExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,22 @@ public class UpdateFeedExample {
public static void updateFeed(String feedName, String topic) throws Exception {
// String feedName = "MY_FEED_NAME"
// String topic = "projects/[PROJECT_ID]/topics/[TOPIC_NAME]"
Feed feed = Feed.newBuilder()
.setName(feedName)
.setFeedOutputConfig(
FeedOutputConfig.newBuilder().setPubsubDestination(
PubsubDestination.newBuilder().setTopic(topic).build()).build()).build();
UpdateFeedRequest request = UpdateFeedRequest.newBuilder()
.setFeed(feed)
.setUpdateMask(
FieldMask.newBuilder().addPaths("feed_output_config.pubsub_destination.topic").build())
.build();
Feed feed =
Feed.newBuilder()
.setName(feedName)
.setFeedOutputConfig(
FeedOutputConfig.newBuilder()
.setPubsubDestination(PubsubDestination.newBuilder().setTopic(topic).build())
.build())
.build();
UpdateFeedRequest request =
UpdateFeedRequest.newBuilder()
.setFeed(feed)
.setUpdateMask(
FieldMask.newBuilder()
.addPaths("feed_output_config.pubsub_destination.topic")
.build())
.build();
// Initialize client that will be used to send requests. This client only needs to be created
// once, and can be reused for multiple requests. After completing all of your requests, call
// the "close" method on the client to safely clean up any remaining background resources.
Expand Down

0 comments on commit 4c0220e

Please sign in to comment.