|
57 | 57 |
|
58 | 58 | // AUTO-GENERATED DOCUMENTATION AND SERVICE - see instructions at the top of the file for editing. |
59 | 59 | /** |
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 |
61 | 61 | * messages to a topic. |
62 | 62 | * |
63 | 63 | * <!-- manual edit --> |
|
66 | 66 | @javax.annotation.Generated("by GAPIC") |
67 | 67 | public class PublisherApi implements AutoCloseable { |
68 | 68 |
|
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 | + } |
72 | 110 |
|
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 | + } |
91 | 155 |
|
92 | 156 | // ======== |
93 | 157 | // Members |
@@ -174,65 +238,6 @@ public void close() throws IOException { |
174 | 238 | }); |
175 | 239 | } |
176 | 240 |
|
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 | | - |
236 | 241 | // ============= |
237 | 242 | // Service Calls |
238 | 243 | // ============= |
@@ -268,7 +273,7 @@ public Topic createTopic(String name) { |
268 | 273 | * |
269 | 274 | * @param request The request object containing all of the parameters for the API call. |
270 | 275 | */ |
271 | | - public Topic createTopic(Topic request) { |
| 276 | + private Topic createTopic(Topic request) { |
272 | 277 | return createTopicCallable().call(request); |
273 | 278 | } |
274 | 279 |
|
@@ -358,7 +363,7 @@ public Topic getTopic(String topic) { |
358 | 363 | * |
359 | 364 | * @param request The request object containing all of the parameters for the API call. |
360 | 365 | */ |
361 | | - public Topic getTopic(GetTopicRequest request) { |
| 366 | + private Topic getTopic(GetTopicRequest request) { |
362 | 367 | return getTopicCallable().call(request); |
363 | 368 | } |
364 | 369 |
|
@@ -508,7 +513,7 @@ public void deleteTopic(String topic) { |
508 | 513 | * |
509 | 514 | * @param request The request object containing all of the parameters for the API call. |
510 | 515 | */ |
511 | | - public void deleteTopic(DeleteTopicRequest request) { |
| 516 | + private void deleteTopic(DeleteTopicRequest request) { |
512 | 517 | deleteTopicCallable().call(request); |
513 | 518 | } |
514 | 519 |
|
@@ -539,13 +544,10 @@ public ApiCallable<DeleteTopicRequest, Empty> deleteTopicCallable() { |
539 | 544 | * <!-- end manual edit --> |
540 | 545 | */ |
541 | 546 | @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 | + } |
549 | 551 | } |
550 | 552 |
|
551 | 553 | // ======== |
|
0 commit comments