Skip to content

Commit 6a1f788

Browse files
Surface updates from internal review
1 parent e85e69f commit 6a1f788

10 files changed

Lines changed: 388 additions & 378 deletions

File tree

gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java

Lines changed: 93 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
// AUTO-GENERATED DOCUMENTATION AND SERVICE - see instructions at the top of the file for editing.
5959
/**
60-
* The service that an application uses to manipulate topics, and to send
60+
* Service Description: The service that an application uses to manipulate topics, and to send
6161
* messages to a topic.
6262
*
6363
* <!-- manual edit -->
@@ -66,28 +66,92 @@
6666
@javax.annotation.Generated("by GAPIC")
6767
public class PublisherApi implements AutoCloseable {
6868

69-
// =========
70-
// Constants
71-
// =========
69+
public static class ResourceNames {
70+
private ResourceNames() {}
71+
72+
// =======================
73+
// ResourceNames Constants
74+
// =======================
75+
76+
/**
77+
* A PathTemplate representing the fully-qualified path to represent
78+
* a project resource.
79+
*
80+
* <!-- manual edit -->
81+
* <!-- end manual edit -->
82+
*/
83+
private static final PathTemplate PROJECT_PATH_TEMPLATE =
84+
PathTemplate.create("projects/{project}");
85+
86+
/**
87+
* A PathTemplate representing the fully-qualified path to represent
88+
* a topic resource.
89+
*
90+
* <!-- manual edit -->
91+
* <!-- end manual edit -->
92+
*/
93+
private static final PathTemplate TOPIC_PATH_TEMPLATE =
94+
PathTemplate.create("projects/{project}/topics/{topic}");
95+
96+
// ==============================
97+
// Resource Name Helper Functions
98+
// ==============================
99+
100+
/**
101+
* Formats a string containing the fully-qualified path to represent
102+
* a project resource.
103+
*
104+
* <!-- manual edit -->
105+
* <!-- end manual edit -->
106+
*/
107+
public static final String formatProjectPath(String project) {
108+
return PROJECT_PATH_TEMPLATE.instantiate("project", project);
109+
}
72110

73-
/**
74-
* A PathTemplate representing the fully-qualified path to represent
75-
* a project resource.
76-
*
77-
* <!-- manual edit -->
78-
* <!-- end manual edit -->
79-
*/
80-
private static final PathTemplate PROJECT_PATH_TEMPLATE =
81-
PathTemplate.create("projects/{project}");
82-
/**
83-
* A PathTemplate representing the fully-qualified path to represent
84-
* a topic resource.
85-
*
86-
* <!-- manual edit -->
87-
* <!-- end manual edit -->
88-
*/
89-
private static final PathTemplate TOPIC_PATH_TEMPLATE =
90-
PathTemplate.create("projects/{project}/topics/{topic}");
111+
/**
112+
* Formats a string containing the fully-qualified path to represent
113+
* a topic resource.
114+
*
115+
* <!-- manual edit -->
116+
* <!-- end manual edit -->
117+
*/
118+
public static final String formatTopicPath(String project, String topic) {
119+
return TOPIC_PATH_TEMPLATE.instantiate("project", project, "topic", topic);
120+
}
121+
122+
/**
123+
* Parses the project from the given fully-qualified path which
124+
* represents a project resource.
125+
*
126+
* <!-- manual edit -->
127+
* <!-- end manual edit -->
128+
*/
129+
public static final String parseProjectFromProjectPath(String projectPath) {
130+
return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project");
131+
}
132+
133+
/**
134+
* Parses the project from the given fully-qualified path which
135+
* represents a topic resource.
136+
*
137+
* <!-- manual edit -->
138+
* <!-- end manual edit -->
139+
*/
140+
public static final String parseProjectFromTopicPath(String topicPath) {
141+
return TOPIC_PATH_TEMPLATE.parse(topicPath).get("project");
142+
}
143+
144+
/**
145+
* Parses the topic from the given fully-qualified path which
146+
* represents a topic resource.
147+
*
148+
* <!-- manual edit -->
149+
* <!-- end manual edit -->
150+
*/
151+
public static final String parseTopicFromTopicPath(String topicPath) {
152+
return TOPIC_PATH_TEMPLATE.parse(topicPath).get("topic");
153+
}
154+
}
91155

92156
// ========
93157
// Members
@@ -174,65 +238,6 @@ public void close() throws IOException {
174238
});
175239
}
176240

177-
// ==============================
178-
// Resource Name Helper Functions
179-
// ==============================
180-
181-
/**
182-
* Creates a string containing the fully-qualified path to represent
183-
* a project resource.
184-
*
185-
* <!-- manual edit -->
186-
* <!-- end manual edit -->
187-
*/
188-
public static final String createProjectPath(String project) {
189-
return PROJECT_PATH_TEMPLATE.instantiate("project", project);
190-
}
191-
192-
/**
193-
* Creates a string containing the fully-qualified path to represent
194-
* a topic resource.
195-
*
196-
* <!-- manual edit -->
197-
* <!-- end manual edit -->
198-
*/
199-
public static final String createTopicPath(String project, String topic) {
200-
return TOPIC_PATH_TEMPLATE.instantiate("project", project, "topic", topic);
201-
}
202-
203-
/**
204-
* Extracts the project from the given fully-qualified path which
205-
* represents a project resource.
206-
*
207-
* <!-- manual edit -->
208-
* <!-- end manual edit -->
209-
*/
210-
public static final String extractProjectFromProjectPath(String projectPath) {
211-
return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project");
212-
}
213-
214-
/**
215-
* Extracts the project from the given fully-qualified path which
216-
* represents a topic resource.
217-
*
218-
* <!-- manual edit -->
219-
* <!-- end manual edit -->
220-
*/
221-
public static final String extractProjectFromTopicPath(String topicPath) {
222-
return TOPIC_PATH_TEMPLATE.parse(topicPath).get("project");
223-
}
224-
225-
/**
226-
* Extracts the topic from the given fully-qualified path which
227-
* represents a topic resource.
228-
*
229-
* <!-- manual edit -->
230-
* <!-- end manual edit -->
231-
*/
232-
public static final String extractTopicFromTopicPath(String topicPath) {
233-
return TOPIC_PATH_TEMPLATE.parse(topicPath).get("topic");
234-
}
235-
236241
// =============
237242
// Service Calls
238243
// =============
@@ -268,7 +273,7 @@ public Topic createTopic(String name) {
268273
*
269274
* @param request The request object containing all of the parameters for the API call.
270275
*/
271-
public Topic createTopic(Topic request) {
276+
private Topic createTopic(Topic request) {
272277
return createTopicCallable().call(request);
273278
}
274279

@@ -358,7 +363,7 @@ public Topic getTopic(String topic) {
358363
*
359364
* @param request The request object containing all of the parameters for the API call.
360365
*/
361-
public Topic getTopic(GetTopicRequest request) {
366+
private Topic getTopic(GetTopicRequest request) {
362367
return getTopicCallable().call(request);
363368
}
364369

@@ -508,7 +513,7 @@ public void deleteTopic(String topic) {
508513
*
509514
* @param request The request object containing all of the parameters for the API call.
510515
*/
511-
public void deleteTopic(DeleteTopicRequest request) {
516+
private void deleteTopic(DeleteTopicRequest request) {
512517
deleteTopicCallable().call(request);
513518
}
514519

@@ -539,13 +544,10 @@ public ApiCallable<DeleteTopicRequest, Empty> deleteTopicCallable() {
539544
* <!-- end manual edit -->
540545
*/
541546
@Override
542-
public void close() {
543-
// Manually-added shutdown code
544-
545-
// Auto-generated shutdown code
546-
channel.shutdown();
547-
548-
// Manually-added shutdown code
547+
public void close() throws Exception {
548+
for (AutoCloseable closeable : closeables) {
549+
closeable.close();
550+
}
549551
}
550552

551553
// ========

gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public class PublisherSettings extends ApiCallSettings {
8787
/**
8888
* The default scopes of the service.
8989
*/
90-
public static ImmutableList<String> DEFAULT_SERVICE_SCOPES =
90+
public static final ImmutableList<String> DEFAULT_SERVICE_SCOPES =
9191
ImmutableList.<String>builder()
9292
.add("https://www.googleapis.com/auth/pubsub")
9393
.add("https://www.googleapis.com/auth/cloud-platform")

0 commit comments

Comments
 (0)