Skip to content

Commit 4e14e03

Browse files
---
yaml --- r: 8863 b: refs/heads/lesv-patch-1 c: ab10263 h: refs/heads/master i: 8861: e956a20 8859: a3b9659 8855: 6096d1b 8847: d351754 8831: 50dfaab
1 parent 5a355a5 commit 4e14e03

25 files changed

Lines changed: 73 additions & 67 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ refs/tags/v0.22.0: 18b298fe4bfe8ec2f20b0e0bf7ffdcce5cc3c5fe
6666
refs/heads/vam-google-patch-1: d0c8fee3a4074d0bf7360ce8c4f7f7223d0ee7b9
6767
refs/heads/vam-google-patch-CODEOWNERS: 2ac1616e25229e51d08a984708ef1918f91a35ee
6868
refs/heads/danoscarmike-patch-1: 7342a9916bce4ed00002c7202e2a16c5d46afaea
69-
refs/heads/lesv-patch-1: ae1b0e7a9c7e4f67b12ff4f779330ea9d8c73570
69+
refs/heads/lesv-patch-1: ab102630bb3db277a0810c44b05100114e128e44
7070
refs/heads/ml-update-branch: 079dd6610017f5c51b9d1938c12d6d55b61513cf
7171
refs/heads/vkedia-patch-2: 7d8241388a9769a5c069334761b06c7012c878e7
7272
refs/heads/vkedia-patch-3: 4d128043acaa7db9160faf439d2ca6104e8a88cb

branches/lesv-patch-1/google-cloud-core/src/main/java/com/google/cloud/AsyncPageImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public Page<T> getNextPage() {
6464
return asyncPageFetcher != null
6565
? Uninterruptibles.getUninterruptibly(asyncPageFetcher.getNextPage()) : null;
6666
} catch (ExecutionException ex) {
67-
throw Throwables.propagate(ex.getCause());
67+
Throwables.throwIfUnchecked(ex.getCause());
68+
throw new RuntimeException(ex);
6869
}
6970
}
7071
}

branches/lesv-patch-1/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/CreateSubscriptionAndConsumeMessages.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
public class CreateSubscriptionAndConsumeMessages {
3434

3535
public static void main(String... args) throws Exception {
36-
TopicName topic = TopicName.create("my-project-id", "my-topic-id");
37-
SubscriptionName subscription = SubscriptionName.create("my-project-id", "my-topic-id");
36+
TopicName topic = TopicName.of("my-project-id", "my-topic-id");
37+
SubscriptionName subscription = SubscriptionName.of("my-project-id", "my-topic-id");
3838

3939
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
4040
subscriptionAdminClient.createSubscription(subscription, topic, PushConfig.getDefaultInstance(), 0);

branches/lesv-patch-1/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/CreateTopicAndPublishMessages.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
3434
public class CreateTopicAndPublishMessages {
3535

3636
public static void createTopic() throws Exception {
37-
TopicName topic = TopicName.create("my-project-id", "my-topic-id");
37+
TopicName topic = TopicName.of("my-project-id", "my-topic-id");
3838
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
3939
topicAdminClient.createTopic(topic);
4040
}
4141
}
4242

4343
public static void publishMessages() throws Exception {
4444
// [START pubsub_publish]
45-
TopicName topicName = TopicName.create("my-project-id", "my-topic-id");
45+
TopicName topicName = TopicName.of("my-project-id", "my-topic-id");
4646
Publisher publisher = null;
4747
List<ApiFuture<String>> messageIdFutures = new ArrayList<>();
4848

branches/lesv-patch-1/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/PublisherSnippets.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void onFailure(Throwable t) {
7171
// [VARIABLE "my_project"]
7272
// [VARIABLE "my_topic"]
7373
public static void newBuilder(String projectId, String topicId) throws Exception {
74-
TopicName topic = TopicName.create(projectId, topicId);
74+
TopicName topic = TopicName.of(projectId, topicId);
7575
Publisher publisher = Publisher.newBuilder(topic).build();
7676
try {
7777
// ...

branches/lesv-patch-1/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/SubscriberSnippets.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private void createSubscriber() throws Exception {
9494
String projectId = "my-project-id";
9595
String subscriptionId = "my-subscription-id";
9696

97-
SubscriptionName subscriptionName = SubscriptionName.create(projectId, subscriptionId);
97+
SubscriptionName subscriptionName = SubscriptionName.of(projectId, subscriptionId);
9898
// Instantiate an asynchronous message receiver
9999
MessageReceiver receiver =
100100
new MessageReceiver() {
@@ -186,7 +186,7 @@ static List<ReceivedMessage> createSubscriberWithSyncPull(
186186
// String projectId = "my-project-id";
187187
// String subscriptionId = "my-subscription-id";
188188
// int numOfMessages = 10; // max number of messages to be pulled
189-
String subscriptionName = SubscriptionName.create(projectId, subscriptionId).toString();
189+
String subscriptionName = SubscriptionName.of(projectId, subscriptionId).toString();
190190
PullRequest pullRequest =
191191
PullRequest.newBuilder()
192192
.setMaxMessages(numOfMessages)

branches/lesv-patch-1/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/SubscriptionAdminClientSnippets.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ public Subscription createSubscription(String topicId, String subscriptionId) th
5454
// [START pubsub_create_pull_subscription]
5555
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
5656
// eg. projectId = "my-test-project", topicId = "my-test-topic"
57-
TopicName topicName = TopicName.create(projectId, topicId);
57+
TopicName topicName = TopicName.of(projectId, topicId);
5858
// eg. subscriptionId = "my-test-subscription"
5959
SubscriptionName subscriptionName =
60-
SubscriptionName.create(projectId, subscriptionId);
60+
SubscriptionName.of(projectId, subscriptionId);
6161
// create a pull subscription with default acknowledgement deadline
6262
Subscription subscription =
6363
subscriptionAdminClient.createSubscription(
@@ -73,9 +73,9 @@ public Subscription createSubscriptionWithPushEndpoint(String topicId, String su
7373
throws Exception {
7474
// [START pubsub_create_push_subscription]
7575
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
76-
TopicName topicName = TopicName.create(projectId, topicId);
76+
TopicName topicName = TopicName.of(projectId, topicId);
7777
SubscriptionName subscriptionName =
78-
SubscriptionName.create(projectId, subscriptionId);
78+
SubscriptionName.of(projectId, subscriptionId);
7979

8080
// eg. endpoint = "https://my-test-project.appspot.com/push"
8181
PushConfig pushConfig = PushConfig.newBuilder().setPushEndpoint(endpoint).build();
@@ -95,7 +95,7 @@ public Subscription createSubscriptionWithPushEndpoint(String topicId, String su
9595
public void replacePushConfig(String subscriptionId, String endpoint) throws Exception {
9696
// [START pubsub_update_push_configuration]
9797
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
98-
SubscriptionName subscriptionName = SubscriptionName.create(projectId, subscriptionId);
98+
SubscriptionName subscriptionName = SubscriptionName.of(projectId, subscriptionId);
9999
PushConfig pushConfig = PushConfig.newBuilder().setPushEndpoint(endpoint).build();
100100
subscriptionAdminClient.modifyPushConfig(subscriptionName, pushConfig);
101101
}
@@ -108,7 +108,7 @@ public ListSubscriptionsPagedResponse listSubscriptions() throws Exception {
108108
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
109109
ListSubscriptionsRequest listSubscriptionsRequest =
110110
ListSubscriptionsRequest.newBuilder()
111-
.setProjectWithProjectName(ProjectName.create(projectId))
111+
.setProjectWithProjectName(ProjectName.of(projectId))
112112
.build();
113113
ListSubscriptionsPagedResponse response =
114114
subscriptionAdminClient.listSubscriptions(listSubscriptionsRequest);
@@ -125,7 +125,7 @@ public ListSubscriptionsPagedResponse listSubscriptions() throws Exception {
125125
public SubscriptionName deleteSubscription(String subscriptionId) throws Exception {
126126
// [START pubsub_delete_subscription]
127127
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
128-
SubscriptionName subscriptionName = SubscriptionName.create(projectId, subscriptionId);
128+
SubscriptionName subscriptionName = SubscriptionName.of(projectId, subscriptionId);
129129
subscriptionAdminClient.deleteSubscription(subscriptionName);
130130
return subscriptionName;
131131
}
@@ -136,7 +136,7 @@ public SubscriptionName deleteSubscription(String subscriptionId) throws Excepti
136136
public Policy getSubscriptionPolicy(String subscriptionId) throws Exception {
137137
// [START pubsub_get_subscription_policy]
138138
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
139-
SubscriptionName subscriptionName = SubscriptionName.create(projectId, subscriptionId);
139+
SubscriptionName subscriptionName = SubscriptionName.of(projectId, subscriptionId);
140140
Policy policy = subscriptionAdminClient.getIamPolicy(subscriptionName.toString());
141141
if (policy == null) {
142142
// subscription was not found
@@ -150,7 +150,7 @@ public Policy getSubscriptionPolicy(String subscriptionId) throws Exception {
150150
public Policy replaceSubscriptionPolicy(String subscriptionId) throws Exception {
151151
// [START pubsub_set_subscription_policy]
152152
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
153-
SubscriptionName subscriptionName = SubscriptionName.create(projectId, subscriptionId);
153+
SubscriptionName subscriptionName = SubscriptionName.of(projectId, subscriptionId);
154154
Policy policy = subscriptionAdminClient.getIamPolicy(subscriptionName.toString());
155155
// Create a role => members binding
156156
Binding binding =
@@ -174,7 +174,7 @@ public TestIamPermissionsResponse testSubscriptionPermissions(String subscriptio
174174
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
175175
List<String> permissions = new LinkedList<>();
176176
permissions.add("pubsub.subscriptions.get");
177-
SubscriptionName subscriptionName = SubscriptionName.create(projectId, subscriptionId);
177+
SubscriptionName subscriptionName = SubscriptionName.of(projectId, subscriptionId);
178178
TestIamPermissionsResponse testedPermissions =
179179
topicAdminClient.testIamPermissions(subscriptionName.toString(), permissions);
180180
return testedPermissions;
@@ -186,7 +186,7 @@ public TestIamPermissionsResponse testSubscriptionPermissions(String subscriptio
186186
public Subscription getSubscription(String subscriptionId) throws Exception {
187187
// [START pubsub_get_subscription]
188188
try (SubscriptionAdminClient subscriptionAdminClient = SubscriptionAdminClient.create()) {
189-
SubscriptionName subscriptionName = SubscriptionName.create(projectId, subscriptionId);
189+
SubscriptionName subscriptionName = SubscriptionName.of(projectId, subscriptionId);
190190
Subscription subscription = subscriptionAdminClient.getSubscription(subscriptionName);
191191
return subscription;
192192
}

branches/lesv-patch-1/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/TopicAdminClientSnippets.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public Topic createTopic(String topicId) throws Exception {
5252
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
5353
// projectId <= unique project identifier, eg. "my-project-id"
5454
// topicId <= "my-topic-id"
55-
TopicName topicName = TopicName.create(projectId, topicId);
55+
TopicName topicName = TopicName.of(projectId, topicId);
5656
Topic topic = topicAdminClient.createTopic(topicName);
5757
return topic;
5858
}
@@ -65,7 +65,7 @@ public ListTopicsPagedResponse listTopics() throws Exception {
6565
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
6666
ListTopicsRequest listTopicsRequest =
6767
ListTopicsRequest.newBuilder()
68-
.setProjectWithProjectName(ProjectName.create(projectId))
68+
.setProjectWithProjectName(ProjectName.of(projectId))
6969
.build();
7070
ListTopicsPagedResponse response = topicAdminClient.listTopics(listTopicsRequest);
7171
Iterable<Topic> topics = response.iterateAll();
@@ -82,7 +82,7 @@ public ListTopicSubscriptionsPagedResponse listTopicSubscriptions(String topicId
8282
throws Exception {
8383
// [START pubsub_list_topic_subscriptions]
8484
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
85-
TopicName topicName = TopicName.create(projectId, topicId);
85+
TopicName topicName = TopicName.of(projectId, topicId);
8686
ListTopicSubscriptionsRequest request =
8787
ListTopicSubscriptionsRequest.newBuilder()
8888
.setTopicWithTopicName(topicName)
@@ -102,7 +102,7 @@ public ListTopicSubscriptionsPagedResponse listTopicSubscriptions(String topicId
102102
public TopicName deleteTopic(String topicId) throws Exception {
103103
// [START pubsub_delete_topic]
104104
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
105-
TopicName topicName = TopicName.create(projectId, topicId);
105+
TopicName topicName = TopicName.of(projectId, topicId);
106106
topicAdminClient.deleteTopic(topicName);
107107
return topicName;
108108
}
@@ -113,7 +113,7 @@ public TopicName deleteTopic(String topicId) throws Exception {
113113
public Policy getTopicPolicy(String topicId) throws Exception {
114114
// [START pubsub_get_topic_policy]
115115
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
116-
TopicName topicName = TopicName.create(projectId, topicId);
116+
TopicName topicName = TopicName.of(projectId, topicId);
117117
Policy policy = topicAdminClient.getIamPolicy(topicName.toString());
118118
if (policy == null) {
119119
// topic iam policy was not found
@@ -127,7 +127,7 @@ public Policy getTopicPolicy(String topicId) throws Exception {
127127
public Policy replaceTopicPolicy(String topicId) throws Exception {
128128
// [START pubsub_set_topic_policy]
129129
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
130-
String topicName = TopicName.create(projectId, topicId).toString();
130+
String topicName = TopicName.of(projectId, topicId).toString();
131131
Policy policy = topicAdminClient.getIamPolicy(topicName);
132132
// add role -> members binding
133133
Binding binding =
@@ -150,7 +150,7 @@ public TestIamPermissionsResponse testTopicPermissions(String topicId) throws Ex
150150
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
151151
List<String> permissions = new LinkedList<>();
152152
permissions.add("pubsub.topics.get");
153-
TopicName topicName = TopicName.create(projectId, topicId);
153+
TopicName topicName = TopicName.of(projectId, topicId);
154154
TestIamPermissionsResponse testedPermissions =
155155
topicAdminClient.testIamPermissions(topicName.toString(), permissions);
156156
return testedPermissions;
@@ -162,7 +162,7 @@ public TestIamPermissionsResponse testTopicPermissions(String topicId) throws Ex
162162
public Topic getTopic(String topicId) throws Exception {
163163
// [START pubsub_get_topic]
164164
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
165-
TopicName topicName = TopicName.create(projectId, topicId);
165+
TopicName topicName = TopicName.of(projectId, topicId);
166166
Topic topic = topicAdminClient.getTopic(topicName);
167167
return topic;
168168
}

branches/lesv-patch-1/google-cloud-examples/src/main/java/com/google/cloud/examples/pubsub/snippets/UsePubSubEmulatorSnippet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static void main(String... args) throws IOException {
5555
.setCredentialsProvider(credentialsProvider)
5656
.build());
5757

58-
TopicName topicName = TopicName.create("my-project-id", "my-topic-id");
58+
TopicName topicName = TopicName.of("my-project-id", "my-topic-id");
5959
// Set the channel and credentials provider when creating a `Publisher`.
6060
// Similarly for Subscriber
6161
Publisher publisher =

branches/lesv-patch-1/google-cloud-examples/src/main/java/com/google/cloud/examples/storage/StorageExample.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,10 @@ Tuple<ServiceAccountCredentials, BlobInfo> parse(String... args) throws IOExcept
551551
KeyStore keystore = KeyStore.getInstance("PKCS12");
552552
keystore.load(Files.newInputStream(Paths.get(args[0])), PASSWORD);
553553
PrivateKey privateKey = (PrivateKey) keystore.getKey("privatekey", PASSWORD);
554-
ServiceAccountCredentials credentials =
555-
new ServiceAccountCredentials(null, args[1], privateKey, null, null);
554+
ServiceAccountCredentials credentials = ServiceAccountCredentials.newBuilder()
555+
.setClientEmail(args[1])
556+
.setPrivateKey(privateKey)
557+
.build();
556558
return Tuple.of(credentials, BlobInfo.newBuilder(BlobId.of(args[2], args[3])).build());
557559
}
558560

0 commit comments

Comments
 (0)