Skip to content

Commit 0611949

Browse files
Regenerating SPI layer (#1501)
* Converting Error Reporting and Monitoring to use resource name types * Removing formatX/parseX methods from pubsub, converting usage of the same to resource name types * New methods in Logging and PubSub
1 parent 15c9e23 commit 0611949

File tree

40 files changed

+1022
-762
lines changed

40 files changed

+1022
-762
lines changed

google-cloud-core/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
<dependency>
123123
<groupId>com.google.api.grpc</groupId>
124124
<artifactId>grpc-google-common-protos</artifactId>
125-
<version>0.1.3</version>
125+
<version>0.1.5</version>
126126
<exclusions>
127127
<exclusion>
128128
<groupId>io.grpc</groupId>
@@ -133,7 +133,7 @@
133133
<dependency>
134134
<groupId>com.google.api.grpc</groupId>
135135
<artifactId>grpc-google-iam-v1</artifactId>
136-
<version>0.1.3</version>
136+
<version>0.1.5</version>
137137
<exclusions>
138138
<exclusion>
139139
<groupId>io.grpc</groupId>

google-cloud-errorreporting/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<dependency>
3131
<groupId>com.google.api.grpc</groupId>
3232
<artifactId>grpc-google-cloud-error-reporting-v1beta1</artifactId>
33-
<version>0.1.3</version>
33+
<version>0.1.5</version>
3434
<exclusions>
3535
<exclusion>
3636
<groupId>io.grpc</groupId>

google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorGroupServiceClient.java

+13-32
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
import com.google.api.gax.grpc.ChannelAndExecutor;
1919
import com.google.api.gax.grpc.UnaryCallable;
20-
import com.google.api.gax.protobuf.PathTemplate;
2120
import com.google.devtools.clouderrorreporting.v1beta1.ErrorGroup;
2221
import com.google.devtools.clouderrorreporting.v1beta1.GetGroupRequest;
22+
import com.google.devtools.clouderrorreporting.v1beta1.GroupName;
2323
import com.google.devtools.clouderrorreporting.v1beta1.UpdateGroupRequest;
2424
import com.google.protobuf.ExperimentalApi;
2525
import io.grpc.ManagedChannel;
@@ -40,8 +40,8 @@
4040
* <pre>
4141
* <code>
4242
* try (ErrorGroupServiceClient errorGroupServiceClient = ErrorGroupServiceClient.create()) {
43-
* String formattedGroupName = ErrorGroupServiceClient.formatGroupName("[PROJECT]", "[GROUP]");
44-
* ErrorGroup response = errorGroupServiceClient.getGroup(formattedGroupName);
43+
* GroupName groupName = GroupName.create("[PROJECT]", "[GROUP]");
44+
* ErrorGroup response = errorGroupServiceClient.getGroup(groupName);
4545
* }
4646
* </code>
4747
* </pre>
@@ -97,26 +97,6 @@ public class ErrorGroupServiceClient implements AutoCloseable {
9797
private final UnaryCallable<GetGroupRequest, ErrorGroup> getGroupCallable;
9898
private final UnaryCallable<UpdateGroupRequest, ErrorGroup> updateGroupCallable;
9999

100-
private static final PathTemplate GROUP_PATH_TEMPLATE =
101-
PathTemplate.createWithoutUrlEncoding("projects/{project}/groups/{group}");
102-
103-
/** Formats a string containing the fully-qualified path to represent a group resource. */
104-
public static final String formatGroupName(String project, String group) {
105-
return GROUP_PATH_TEMPLATE.instantiate(
106-
"project", project,
107-
"group", group);
108-
}
109-
110-
/** Parses the project from the given fully-qualified path which represents a group resource. */
111-
public static final String parseProjectFromGroupName(String groupName) {
112-
return GROUP_PATH_TEMPLATE.parse(groupName).get("project");
113-
}
114-
115-
/** Parses the group from the given fully-qualified path which represents a group resource. */
116-
public static final String parseGroupFromGroupName(String groupName) {
117-
return GROUP_PATH_TEMPLATE.parse(groupName).get("group");
118-
}
119-
120100
/** Constructs an instance of ErrorGroupServiceClient with default settings. */
121101
public static final ErrorGroupServiceClient create() throws IOException {
122102
return create(ErrorGroupServiceSettings.defaultBuilder().build());
@@ -179,8 +159,8 @@ public final ErrorGroupServiceSettings getSettings() {
179159
*
180160
* <pre><code>
181161
* try (ErrorGroupServiceClient errorGroupServiceClient = ErrorGroupServiceClient.create()) {
182-
* String formattedGroupName = ErrorGroupServiceClient.formatGroupName("[PROJECT]", "[GROUP]");
183-
* ErrorGroup response = errorGroupServiceClient.getGroup(formattedGroupName);
162+
* GroupName groupName = GroupName.create("[PROJECT]", "[GROUP]");
163+
* ErrorGroup response = errorGroupServiceClient.getGroup(groupName);
184164
* }
185165
* </code></pre>
186166
*
@@ -192,9 +172,10 @@ public final ErrorGroupServiceSettings getSettings() {
192172
* <p>Example: &lt;code&gt;projects/my-project-123/groups/my-group&lt;/code&gt;
193173
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
194174
*/
195-
public final ErrorGroup getGroup(String groupName) {
196-
GROUP_PATH_TEMPLATE.validate(groupName, "getGroup");
197-
GetGroupRequest request = GetGroupRequest.newBuilder().setGroupName(groupName).build();
175+
public final ErrorGroup getGroup(GroupName groupName) {
176+
177+
GetGroupRequest request =
178+
GetGroupRequest.newBuilder().setGroupNameWithGroupName(groupName).build();
198179
return getGroup(request);
199180
}
200181

@@ -206,9 +187,9 @@ public final ErrorGroup getGroup(String groupName) {
206187
*
207188
* <pre><code>
208189
* try (ErrorGroupServiceClient errorGroupServiceClient = ErrorGroupServiceClient.create()) {
209-
* String formattedGroupName = ErrorGroupServiceClient.formatGroupName("[PROJECT]", "[GROUP]");
190+
* GroupName groupName = GroupName.create("[PROJECT]", "[GROUP]");
210191
* GetGroupRequest request = GetGroupRequest.newBuilder()
211-
* .setGroupName(formattedGroupName)
192+
* .setGroupNameWithGroupName(groupName)
212193
* .build();
213194
* ErrorGroup response = errorGroupServiceClient.getGroup(request);
214195
* }
@@ -229,9 +210,9 @@ private final ErrorGroup getGroup(GetGroupRequest request) {
229210
*
230211
* <pre><code>
231212
* try (ErrorGroupServiceClient errorGroupServiceClient = ErrorGroupServiceClient.create()) {
232-
* String formattedGroupName = ErrorGroupServiceClient.formatGroupName("[PROJECT]", "[GROUP]");
213+
* GroupName groupName = GroupName.create("[PROJECT]", "[GROUP]");
233214
* GetGroupRequest request = GetGroupRequest.newBuilder()
234-
* .setGroupName(formattedGroupName)
215+
* .setGroupNameWithGroupName(groupName)
235216
* .build();
236217
* ListenableFuture&lt;ErrorGroup&gt; future = errorGroupServiceClient.getGroupCallable().futureCall(request);
237218
* // Do something

google-cloud-errorreporting/src/main/java/com/google/cloud/errorreporting/spi/v1beta1/ErrorStatsServiceClient.java

+41-51
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020

2121
import com.google.api.gax.grpc.ChannelAndExecutor;
2222
import com.google.api.gax.grpc.UnaryCallable;
23-
import com.google.api.gax.protobuf.PathTemplate;
2423
import com.google.devtools.clouderrorreporting.v1beta1.DeleteEventsRequest;
2524
import com.google.devtools.clouderrorreporting.v1beta1.DeleteEventsResponse;
2625
import com.google.devtools.clouderrorreporting.v1beta1.ListEventsRequest;
2726
import com.google.devtools.clouderrorreporting.v1beta1.ListEventsResponse;
2827
import com.google.devtools.clouderrorreporting.v1beta1.ListGroupStatsRequest;
2928
import com.google.devtools.clouderrorreporting.v1beta1.ListGroupStatsResponse;
29+
import com.google.devtools.clouderrorreporting.v1beta1.ProjectName;
3030
import com.google.devtools.clouderrorreporting.v1beta1.QueryTimeRange;
3131
import com.google.protobuf.ExperimentalApi;
3232
import io.grpc.ManagedChannel;
@@ -48,8 +48,8 @@
4848
* <pre>
4949
* <code>
5050
* try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
51-
* String formattedProjectName = ErrorStatsServiceClient.formatProjectName("[PROJECT]");
52-
* DeleteEventsResponse response = errorStatsServiceClient.deleteEvents(formattedProjectName);
51+
* ProjectName projectName = ProjectName.create("[PROJECT]");
52+
* DeleteEventsResponse response = errorStatsServiceClient.deleteEvents(projectName);
5353
* }
5454
* </code>
5555
* </pre>
@@ -109,19 +109,6 @@ public class ErrorStatsServiceClient implements AutoCloseable {
109109
private final UnaryCallable<ListEventsRequest, ListEventsPagedResponse> listEventsPagedCallable;
110110
private final UnaryCallable<DeleteEventsRequest, DeleteEventsResponse> deleteEventsCallable;
111111

112-
private static final PathTemplate PROJECT_PATH_TEMPLATE =
113-
PathTemplate.createWithoutUrlEncoding("projects/{project}");
114-
115-
/** Formats a string containing the fully-qualified path to represent a project resource. */
116-
public static final String formatProjectName(String project) {
117-
return PROJECT_PATH_TEMPLATE.instantiate("project", project);
118-
}
119-
120-
/** Parses the project from the given fully-qualified path which represents a project resource. */
121-
public static final String parseProjectFromProjectName(String projectName) {
122-
return PROJECT_PATH_TEMPLATE.parse(projectName).get("project");
123-
}
124-
125112
/** Constructs an instance of ErrorStatsServiceClient with default settings. */
126113
public static final ErrorStatsServiceClient create() throws IOException {
127114
return create(ErrorStatsServiceSettings.defaultBuilder().build());
@@ -192,9 +179,9 @@ public final ErrorStatsServiceSettings getSettings() {
192179
*
193180
* <pre><code>
194181
* try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
195-
* String formattedProjectName = ErrorStatsServiceClient.formatProjectName("[PROJECT]");
182+
* ProjectName projectName = ProjectName.create("[PROJECT]");
196183
* QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
197-
* for (ErrorGroupStats element : errorStatsServiceClient.listGroupStats(formattedProjectName, timeRange).iterateAllElements()) {
184+
* for (ErrorGroupStats element : errorStatsServiceClient.listGroupStats(projectName, timeRange).iterateAllElements()) {
198185
* // doThingsWith(element);
199186
* }
200187
* }
@@ -205,18 +192,19 @@ public final ErrorStatsServiceSettings getSettings() {
205192
* href="https://support.google.com/cloud/answer/6158840"&gt;Google Cloud Platform project
206193
* ID&lt;/a&gt;.
207194
* <p>Example: &lt;code&gt;projects/my-project-123&lt;/code&gt;.
208-
* @param timeRange [Required] List data for the given time range. Only
209-
* &lt;code&gt;ErrorGroupStats&lt;/code&gt; with a non-zero count in the given time range are
210-
* returned, unless the request contains an explicit group_id list. If a group_id list is
211-
* given, also &lt;code&gt;ErrorGroupStats&lt;/code&gt; with zero occurrences are returned.
195+
* @param timeRange [Optional] List data for the given time range. If not set a default time range
196+
* is used. The field time_range_begin in the response will specify the beginning of this time
197+
* range. Only &lt;code&gt;ErrorGroupStats&lt;/code&gt; with a non-zero count in the given
198+
* time range are returned, unless the request contains an explicit group_id list. If a
199+
* group_id list is given, also &lt;code&gt;ErrorGroupStats&lt;/code&gt; with zero occurrences
200+
* are returned.
212201
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
213202
*/
214203
public final ListGroupStatsPagedResponse listGroupStats(
215-
String projectName, QueryTimeRange timeRange) {
216-
PROJECT_PATH_TEMPLATE.validate(projectName, "listGroupStats");
204+
ProjectName projectName, QueryTimeRange timeRange) {
217205
ListGroupStatsRequest request =
218206
ListGroupStatsRequest.newBuilder()
219-
.setProjectName(projectName)
207+
.setProjectNameWithProjectName(projectName)
220208
.setTimeRange(timeRange)
221209
.build();
222210
return listGroupStats(request);
@@ -230,10 +218,10 @@ public final ListGroupStatsPagedResponse listGroupStats(
230218
*
231219
* <pre><code>
232220
* try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
233-
* String formattedProjectName = ErrorStatsServiceClient.formatProjectName("[PROJECT]");
221+
* ProjectName projectName = ProjectName.create("[PROJECT]");
234222
* QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
235223
* ListGroupStatsRequest request = ListGroupStatsRequest.newBuilder()
236-
* .setProjectName(formattedProjectName)
224+
* .setProjectNameWithProjectName(projectName)
237225
* .setTimeRange(timeRange)
238226
* .build();
239227
* for (ErrorGroupStats element : errorStatsServiceClient.listGroupStats(request).iterateAllElements()) {
@@ -257,10 +245,10 @@ public final ListGroupStatsPagedResponse listGroupStats(ListGroupStatsRequest re
257245
*
258246
* <pre><code>
259247
* try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
260-
* String formattedProjectName = ErrorStatsServiceClient.formatProjectName("[PROJECT]");
248+
* ProjectName projectName = ProjectName.create("[PROJECT]");
261249
* QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
262250
* ListGroupStatsRequest request = ListGroupStatsRequest.newBuilder()
263-
* .setProjectName(formattedProjectName)
251+
* .setProjectNameWithProjectName(projectName)
264252
* .setTimeRange(timeRange)
265253
* .build();
266254
* ListenableFuture&lt;ListGroupStatsPagedResponse&gt; future = errorStatsServiceClient.listGroupStatsPagedCallable().futureCall(request);
@@ -284,10 +272,10 @@ public final ListGroupStatsPagedResponse listGroupStats(ListGroupStatsRequest re
284272
*
285273
* <pre><code>
286274
* try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
287-
* String formattedProjectName = ErrorStatsServiceClient.formatProjectName("[PROJECT]");
275+
* ProjectName projectName = ProjectName.create("[PROJECT]");
288276
* QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
289277
* ListGroupStatsRequest request = ListGroupStatsRequest.newBuilder()
290-
* .setProjectName(formattedProjectName)
278+
* .setProjectNameWithProjectName(projectName)
291279
* .setTimeRange(timeRange)
292280
* .build();
293281
* while (true) {
@@ -318,9 +306,9 @@ public final ListGroupStatsPagedResponse listGroupStats(ListGroupStatsRequest re
318306
*
319307
* <pre><code>
320308
* try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
321-
* String formattedProjectName = ErrorStatsServiceClient.formatProjectName("[PROJECT]");
309+
* ProjectName projectName = ProjectName.create("[PROJECT]");
322310
* String groupId = "";
323-
* for (ErrorEvent element : errorStatsServiceClient.listEvents(formattedProjectName, groupId).iterateAllElements()) {
311+
* for (ErrorEvent element : errorStatsServiceClient.listEvents(projectName, groupId).iterateAllElements()) {
324312
* // doThingsWith(element);
325313
* }
326314
* }
@@ -332,10 +320,12 @@ public final ListGroupStatsPagedResponse listGroupStats(ListGroupStatsRequest re
332320
* @param groupId [Required] The group for which events shall be returned.
333321
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
334322
*/
335-
public final ListEventsPagedResponse listEvents(String projectName, String groupId) {
336-
PROJECT_PATH_TEMPLATE.validate(projectName, "listEvents");
323+
public final ListEventsPagedResponse listEvents(ProjectName projectName, String groupId) {
337324
ListEventsRequest request =
338-
ListEventsRequest.newBuilder().setProjectName(projectName).setGroupId(groupId).build();
325+
ListEventsRequest.newBuilder()
326+
.setProjectNameWithProjectName(projectName)
327+
.setGroupId(groupId)
328+
.build();
339329
return listEvents(request);
340330
}
341331

@@ -347,10 +337,10 @@ public final ListEventsPagedResponse listEvents(String projectName, String group
347337
*
348338
* <pre><code>
349339
* try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
350-
* String formattedProjectName = ErrorStatsServiceClient.formatProjectName("[PROJECT]");
340+
* ProjectName projectName = ProjectName.create("[PROJECT]");
351341
* String groupId = "";
352342
* ListEventsRequest request = ListEventsRequest.newBuilder()
353-
* .setProjectName(formattedProjectName)
343+
* .setProjectNameWithProjectName(projectName)
354344
* .setGroupId(groupId)
355345
* .build();
356346
* for (ErrorEvent element : errorStatsServiceClient.listEvents(request).iterateAllElements()) {
@@ -374,10 +364,10 @@ public final ListEventsPagedResponse listEvents(ListEventsRequest request) {
374364
*
375365
* <pre><code>
376366
* try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
377-
* String formattedProjectName = ErrorStatsServiceClient.formatProjectName("[PROJECT]");
367+
* ProjectName projectName = ProjectName.create("[PROJECT]");
378368
* String groupId = "";
379369
* ListEventsRequest request = ListEventsRequest.newBuilder()
380-
* .setProjectName(formattedProjectName)
370+
* .setProjectNameWithProjectName(projectName)
381371
* .setGroupId(groupId)
382372
* .build();
383373
* ListenableFuture&lt;ListEventsPagedResponse&gt; future = errorStatsServiceClient.listEventsPagedCallable().futureCall(request);
@@ -400,10 +390,10 @@ public final UnaryCallable<ListEventsRequest, ListEventsPagedResponse> listEvent
400390
*
401391
* <pre><code>
402392
* try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
403-
* String formattedProjectName = ErrorStatsServiceClient.formatProjectName("[PROJECT]");
393+
* ProjectName projectName = ProjectName.create("[PROJECT]");
404394
* String groupId = "";
405395
* ListEventsRequest request = ListEventsRequest.newBuilder()
406-
* .setProjectName(formattedProjectName)
396+
* .setProjectNameWithProjectName(projectName)
407397
* .setGroupId(groupId)
408398
* .build();
409399
* while (true) {
@@ -433,8 +423,8 @@ public final UnaryCallable<ListEventsRequest, ListEventsResponse> listEventsCall
433423
*
434424
* <pre><code>
435425
* try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
436-
* String formattedProjectName = ErrorStatsServiceClient.formatProjectName("[PROJECT]");
437-
* DeleteEventsResponse response = errorStatsServiceClient.deleteEvents(formattedProjectName);
426+
* ProjectName projectName = ProjectName.create("[PROJECT]");
427+
* DeleteEventsResponse response = errorStatsServiceClient.deleteEvents(projectName);
438428
* }
439429
* </code></pre>
440430
*
@@ -443,10 +433,10 @@ public final UnaryCallable<ListEventsRequest, ListEventsResponse> listEventsCall
443433
* ID](https://support.google.com/cloud/answer/6158840). Example: `projects/my-project-123`.
444434
* @throws com.google.api.gax.grpc.ApiException if the remote call fails
445435
*/
446-
public final DeleteEventsResponse deleteEvents(String projectName) {
447-
PROJECT_PATH_TEMPLATE.validate(projectName, "deleteEvents");
436+
public final DeleteEventsResponse deleteEvents(ProjectName projectName) {
437+
448438
DeleteEventsRequest request =
449-
DeleteEventsRequest.newBuilder().setProjectName(projectName).build();
439+
DeleteEventsRequest.newBuilder().setProjectNameWithProjectName(projectName).build();
450440
return deleteEvents(request);
451441
}
452442

@@ -458,9 +448,9 @@ public final DeleteEventsResponse deleteEvents(String projectName) {
458448
*
459449
* <pre><code>
460450
* try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
461-
* String formattedProjectName = ErrorStatsServiceClient.formatProjectName("[PROJECT]");
451+
* ProjectName projectName = ProjectName.create("[PROJECT]");
462452
* DeleteEventsRequest request = DeleteEventsRequest.newBuilder()
463-
* .setProjectName(formattedProjectName)
453+
* .setProjectNameWithProjectName(projectName)
464454
* .build();
465455
* DeleteEventsResponse response = errorStatsServiceClient.deleteEvents(request);
466456
* }
@@ -481,9 +471,9 @@ private final DeleteEventsResponse deleteEvents(DeleteEventsRequest request) {
481471
*
482472
* <pre><code>
483473
* try (ErrorStatsServiceClient errorStatsServiceClient = ErrorStatsServiceClient.create()) {
484-
* String formattedProjectName = ErrorStatsServiceClient.formatProjectName("[PROJECT]");
474+
* ProjectName projectName = ProjectName.create("[PROJECT]");
485475
* DeleteEventsRequest request = DeleteEventsRequest.newBuilder()
486-
* .setProjectName(formattedProjectName)
476+
* .setProjectNameWithProjectName(projectName)
487477
* .build();
488478
* ListenableFuture&lt;DeleteEventsResponse&gt; future = errorStatsServiceClient.deleteEventsCallable().futureCall(request);
489479
* // Do something

0 commit comments

Comments
 (0)