Skip to content

Commit f4bcc10

Browse files
committed
Regenerate spi layer and update
- Regenerate spi layer with resource names - Update to use resource names instead of formatting methods
1 parent b24ec1a commit f4bcc10

10 files changed

Lines changed: 224 additions & 299 deletions

File tree

google-cloud-logging/pom.xml

Lines changed: 1 addition & 1 deletion
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-logging-v2</artifactId>
33-
<version>0.1.3</version>
33+
<version>0.1.4</version>
3434
<exclusions>
3535
<exclusion>
3636
<groupId>io.grpc</groupId>

google-cloud-logging/src/main/java/com/google/cloud/logging/LogEntry.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
import static com.google.common.base.Preconditions.checkNotNull;
2020

2121
import com.google.cloud.MonitoredResource;
22-
import com.google.cloud.logging.spi.v2.LoggingServiceV2Client;
2322
import com.google.common.base.Function;
2423
import com.google.common.base.MoreObjects;
2524
import com.google.common.collect.ImmutableMap;
2625
import com.google.logging.v2.LogEntryOperation;
26+
import com.google.logging.v2.LogName;
2727
import com.google.protobuf.Timestamp;
2828

2929
import java.io.Serializable;
@@ -520,7 +520,7 @@ com.google.logging.v2.LogEntry toPb(String projectId) {
520520
com.google.logging.v2.LogEntry.Builder builder = payload.toPb();
521521
builder.putAllLabels(labels);
522522
if (logName != null) {
523-
builder.setLogName(LoggingServiceV2Client.formatLogName(projectId, logName));
523+
builder.setLogName(LogName.create(projectId, logName).toString());
524524
}
525525
if (resource != null) {
526526
builder.setResource(resource.toPb());
@@ -581,7 +581,7 @@ static LogEntry fromPb(com.google.logging.v2.LogEntry entryPb) {
581581
builder.setLabels(entryPb.getLabelsMap());
582582
builder.setSeverity(Severity.fromPb(entryPb.getSeverity()));
583583
if (!entryPb.getLogName().equals("")) {
584-
builder.setLogName(LoggingServiceV2Client.parseLogFromLogName(entryPb.getLogName()));
584+
builder.setLogName(LogName.parse(entryPb.getLogName()).getLog());
585585
}
586586
if (!entryPb.getResource().equals(com.google.api.MonitoredResource.getDefaultInstance())) {
587587
builder.setResource(MonitoredResource.fromPb(entryPb.getResource()));

google-cloud-logging/src/main/java/com/google/cloud/logging/LoggingImpl.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
import com.google.cloud.Page;
3434
import com.google.cloud.PageImpl;
3535
import com.google.cloud.logging.spi.LoggingRpc;
36-
import com.google.cloud.logging.spi.v2.ConfigServiceV2Client;
37-
import com.google.cloud.logging.spi.v2.LoggingServiceV2Client;
38-
import com.google.cloud.logging.spi.v2.MetricsServiceV2Client;
3936
import com.google.common.base.Function;
4037
import com.google.common.base.Throwables;
4138
import com.google.common.collect.ImmutableList;
@@ -60,6 +57,10 @@
6057
import com.google.logging.v2.ListMonitoredResourceDescriptorsResponse;
6158
import com.google.logging.v2.ListSinksRequest;
6259
import com.google.logging.v2.ListSinksResponse;
60+
import com.google.logging.v2.LogName;
61+
import com.google.logging.v2.MetricName;
62+
import com.google.logging.v2.ProjectName;
63+
import com.google.logging.v2.SinkName;
6364
import com.google.logging.v2.UpdateLogMetricRequest;
6465
import com.google.logging.v2.UpdateSinkRequest;
6566
import com.google.logging.v2.WriteLogEntriesRequest;
@@ -228,7 +229,7 @@ public Sink create(SinkInfo sink) {
228229
@Override
229230
public Future<Sink> createAsync(SinkInfo sink) {
230231
CreateSinkRequest request = CreateSinkRequest.newBuilder()
231-
.setParent(ConfigServiceV2Client.formatParentName(getOptions().getProjectId()))
232+
.setParent(ProjectName.create(getOptions().getProjectId()).toString())
232233
.setSink(sink.toPb(getOptions().getProjectId()))
233234
.build();
234235
return transform(rpc.create(request), Sink.fromPbFunction(this));
@@ -242,7 +243,7 @@ public Sink update(SinkInfo sink) {
242243
@Override
243244
public Future<Sink> updateAsync(SinkInfo sink) {
244245
UpdateSinkRequest request = UpdateSinkRequest.newBuilder()
245-
.setSinkName(ConfigServiceV2Client.formatSinkName(getOptions().getProjectId(), sink.getName()))
246+
.setSinkName(SinkName.create(getOptions().getProjectId(), sink.getName()).toString())
246247
.setSink(sink.toPb(getOptions().getProjectId()))
247248
.build();
248249
return transform(rpc.update(request), Sink.fromPbFunction(this));
@@ -256,15 +257,15 @@ public Sink getSink(String sink) {
256257
@Override
257258
public Future<Sink> getSinkAsync(String sink) {
258259
GetSinkRequest request = GetSinkRequest.newBuilder()
259-
.setSinkName(ConfigServiceV2Client.formatSinkName(getOptions().getProjectId(), sink))
260+
.setSinkName(SinkName.create(getOptions().getProjectId(), sink).toString())
260261
.build();
261262
return transform(rpc.get(request), Sink.fromPbFunction(this));
262263
}
263264

264265
private static ListSinksRequest listSinksRequest(LoggingOptions serviceOptions,
265266
Map<Option.OptionType, ?> options) {
266267
ListSinksRequest.Builder builder = ListSinksRequest.newBuilder();
267-
builder.setParent(ConfigServiceV2Client.formatParentName(serviceOptions.getProjectId()));
268+
builder.setParent(ProjectName.create(serviceOptions.getProjectId()).toString());
268269
Integer pageSize = PAGE_SIZE.get(options);
269270
String pageToken = PAGE_TOKEN.get(options);
270271
if (pageSize != null) {
@@ -312,7 +313,7 @@ public boolean deleteSink(String sink) {
312313
@Override
313314
public Future<Boolean> deleteSinkAsync(String sink) {
314315
DeleteSinkRequest request = DeleteSinkRequest.newBuilder()
315-
.setSinkName(ConfigServiceV2Client.formatSinkName(getOptions().getProjectId(), sink))
316+
.setSinkName(SinkName.create(getOptions().getProjectId(), sink).toString())
316317
.build();
317318
return transform(rpc.delete(request), EMPTY_TO_BOOLEAN_FUNCTION);
318319
}
@@ -323,7 +324,7 @@ public boolean deleteLog(String log) {
323324

324325
public Future<Boolean> deleteLogAsync(String log) {
325326
DeleteLogRequest request = DeleteLogRequest.newBuilder()
326-
.setLogName(LoggingServiceV2Client.formatLogName(getOptions().getProjectId(), log))
327+
.setLogName(LogName.create(getOptions().getProjectId(), log).toString())
327328
.build();
328329
return transform(rpc.delete(request), EMPTY_TO_BOOLEAN_FUNCTION);
329330
}
@@ -385,7 +386,7 @@ public Metric create(MetricInfo metric) {
385386
@Override
386387
public Future<Metric> createAsync(MetricInfo metric) {
387388
CreateLogMetricRequest request = CreateLogMetricRequest.newBuilder()
388-
.setParent(MetricsServiceV2Client.formatParentName(getOptions().getProjectId()))
389+
.setParent(ProjectName.create(getOptions().getProjectId()).toString())
389390
.setMetric(metric.toPb())
390391
.build();
391392
return transform(rpc.create(request), Metric.fromPbFunction(this));
@@ -399,8 +400,7 @@ public Metric update(MetricInfo metric) {
399400
@Override
400401
public Future<Metric> updateAsync(MetricInfo metric) {
401402
UpdateLogMetricRequest request = UpdateLogMetricRequest.newBuilder()
402-
.setMetricName(MetricsServiceV2Client.formatMetricName(getOptions().getProjectId(),
403-
metric.getName()))
403+
.setMetricName(MetricName.create(getOptions().getProjectId(), metric.getName()).toString())
404404
.setMetric(metric.toPb())
405405
.build();
406406
return transform(rpc.update(request), Metric.fromPbFunction(this));
@@ -414,15 +414,15 @@ public Metric getMetric(String metric) {
414414
@Override
415415
public Future<Metric> getMetricAsync(String metric) {
416416
GetLogMetricRequest request = GetLogMetricRequest.newBuilder()
417-
.setMetricName(MetricsServiceV2Client.formatMetricName(getOptions().getProjectId(), metric))
417+
.setMetricName(MetricName.create(getOptions().getProjectId(), metric).toString())
418418
.build();
419419
return transform(rpc.get(request), Metric.fromPbFunction(this));
420420
}
421421

422422
private static ListLogMetricsRequest listMetricsRequest(LoggingOptions serviceOptions,
423423
Map<Option.OptionType, ?> options) {
424424
ListLogMetricsRequest.Builder builder = ListLogMetricsRequest.newBuilder();
425-
builder.setParent(MetricsServiceV2Client.formatParentName(serviceOptions.getProjectId()));
425+
builder.setParent(ProjectName.create(serviceOptions.getProjectId()).toString());
426426
Integer pageSize = PAGE_SIZE.get(options);
427427
String pageToken = PAGE_TOKEN.get(options);
428428
if (pageSize != null) {
@@ -470,7 +470,7 @@ public boolean deleteMetric(String metric) {
470470
@Override
471471
public Future<Boolean> deleteMetricAsync(String metric) {
472472
DeleteLogMetricRequest request = DeleteLogMetricRequest.newBuilder()
473-
.setMetricName(MetricsServiceV2Client.formatMetricName(getOptions().getProjectId(), metric))
473+
.setMetricName(MetricName.create(getOptions().getProjectId(), metric).toString())
474474
.build();
475475
return transform(rpc.delete(request), EMPTY_TO_BOOLEAN_FUNCTION);
476476
}
@@ -481,7 +481,7 @@ private static WriteLogEntriesRequest writeLogEntriesRequest(LoggingOptions serv
481481
WriteLogEntriesRequest.Builder builder = WriteLogEntriesRequest.newBuilder();
482482
String logName = LOG_NAME.get(options);
483483
if (logName != null) {
484-
builder.setLogName(LoggingServiceV2Client.formatLogName(projectId, logName));
484+
builder.setLogName(LogName.create(projectId, logName).toString());
485485
}
486486
MonitoredResource resource = RESOURCE.get(options);
487487
if (resource != null) {

0 commit comments

Comments
 (0)