Skip to content

Commit

Permalink
Regenerate spi layer and update (googleapis#1454)
Browse files Browse the repository at this point in the history
- Regenerate spi layer with resource names
- Update to use resource names instead of formatting methods
  • Loading branch information
michaelbausor committed Dec 7, 2016
1 parent b24ec1a commit 84480fb
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 299 deletions.
2 changes: 1 addition & 1 deletion google-cloud-logging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-cloud-logging-v2</artifactId>
<version>0.1.3</version>
<version>0.1.4</version>
<exclusions>
<exclusion>
<groupId>io.grpc</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.cloud.MonitoredResource;
import com.google.cloud.logging.spi.v2.LoggingServiceV2Client;
import com.google.common.base.Function;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableMap;
import com.google.logging.v2.LogEntryOperation;
import com.google.logging.v2.LogName;
import com.google.protobuf.Timestamp;

import java.io.Serializable;
Expand Down Expand Up @@ -520,7 +520,7 @@ com.google.logging.v2.LogEntry toPb(String projectId) {
com.google.logging.v2.LogEntry.Builder builder = payload.toPb();
builder.putAllLabels(labels);
if (logName != null) {
builder.setLogName(LoggingServiceV2Client.formatLogName(projectId, logName));
builder.setLogName(LogName.create(projectId, logName).toString());
}
if (resource != null) {
builder.setResource(resource.toPb());
Expand Down Expand Up @@ -581,7 +581,7 @@ static LogEntry fromPb(com.google.logging.v2.LogEntry entryPb) {
builder.setLabels(entryPb.getLabelsMap());
builder.setSeverity(Severity.fromPb(entryPb.getSeverity()));
if (!entryPb.getLogName().equals("")) {
builder.setLogName(LoggingServiceV2Client.parseLogFromLogName(entryPb.getLogName()));
builder.setLogName(LogName.parse(entryPb.getLogName()).getLog());
}
if (!entryPb.getResource().equals(com.google.api.MonitoredResource.getDefaultInstance())) {
builder.setResource(MonitoredResource.fromPb(entryPb.getResource()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
import com.google.cloud.Page;
import com.google.cloud.PageImpl;
import com.google.cloud.logging.spi.LoggingRpc;
import com.google.cloud.logging.spi.v2.ConfigServiceV2Client;
import com.google.cloud.logging.spi.v2.LoggingServiceV2Client;
import com.google.cloud.logging.spi.v2.MetricsServiceV2Client;
import com.google.common.base.Function;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
Expand All @@ -60,6 +57,10 @@
import com.google.logging.v2.ListMonitoredResourceDescriptorsResponse;
import com.google.logging.v2.ListSinksRequest;
import com.google.logging.v2.ListSinksResponse;
import com.google.logging.v2.LogName;
import com.google.logging.v2.MetricName;
import com.google.logging.v2.ProjectName;
import com.google.logging.v2.SinkName;
import com.google.logging.v2.UpdateLogMetricRequest;
import com.google.logging.v2.UpdateSinkRequest;
import com.google.logging.v2.WriteLogEntriesRequest;
Expand Down Expand Up @@ -228,7 +229,7 @@ public Sink create(SinkInfo sink) {
@Override
public Future<Sink> createAsync(SinkInfo sink) {
CreateSinkRequest request = CreateSinkRequest.newBuilder()
.setParent(ConfigServiceV2Client.formatParentName(getOptions().getProjectId()))
.setParent(ProjectName.create(getOptions().getProjectId()).toString())
.setSink(sink.toPb(getOptions().getProjectId()))
.build();
return transform(rpc.create(request), Sink.fromPbFunction(this));
Expand All @@ -242,7 +243,7 @@ public Sink update(SinkInfo sink) {
@Override
public Future<Sink> updateAsync(SinkInfo sink) {
UpdateSinkRequest request = UpdateSinkRequest.newBuilder()
.setSinkName(ConfigServiceV2Client.formatSinkName(getOptions().getProjectId(), sink.getName()))
.setSinkName(SinkName.create(getOptions().getProjectId(), sink.getName()).toString())
.setSink(sink.toPb(getOptions().getProjectId()))
.build();
return transform(rpc.update(request), Sink.fromPbFunction(this));
Expand All @@ -256,15 +257,15 @@ public Sink getSink(String sink) {
@Override
public Future<Sink> getSinkAsync(String sink) {
GetSinkRequest request = GetSinkRequest.newBuilder()
.setSinkName(ConfigServiceV2Client.formatSinkName(getOptions().getProjectId(), sink))
.setSinkName(SinkName.create(getOptions().getProjectId(), sink).toString())
.build();
return transform(rpc.get(request), Sink.fromPbFunction(this));
}

private static ListSinksRequest listSinksRequest(LoggingOptions serviceOptions,
Map<Option.OptionType, ?> options) {
ListSinksRequest.Builder builder = ListSinksRequest.newBuilder();
builder.setParent(ConfigServiceV2Client.formatParentName(serviceOptions.getProjectId()));
builder.setParent(ProjectName.create(serviceOptions.getProjectId()).toString());
Integer pageSize = PAGE_SIZE.get(options);
String pageToken = PAGE_TOKEN.get(options);
if (pageSize != null) {
Expand Down Expand Up @@ -312,7 +313,7 @@ public boolean deleteSink(String sink) {
@Override
public Future<Boolean> deleteSinkAsync(String sink) {
DeleteSinkRequest request = DeleteSinkRequest.newBuilder()
.setSinkName(ConfigServiceV2Client.formatSinkName(getOptions().getProjectId(), sink))
.setSinkName(SinkName.create(getOptions().getProjectId(), sink).toString())
.build();
return transform(rpc.delete(request), EMPTY_TO_BOOLEAN_FUNCTION);
}
Expand All @@ -323,7 +324,7 @@ public boolean deleteLog(String log) {

public Future<Boolean> deleteLogAsync(String log) {
DeleteLogRequest request = DeleteLogRequest.newBuilder()
.setLogName(LoggingServiceV2Client.formatLogName(getOptions().getProjectId(), log))
.setLogName(LogName.create(getOptions().getProjectId(), log).toString())
.build();
return transform(rpc.delete(request), EMPTY_TO_BOOLEAN_FUNCTION);
}
Expand Down Expand Up @@ -385,7 +386,7 @@ public Metric create(MetricInfo metric) {
@Override
public Future<Metric> createAsync(MetricInfo metric) {
CreateLogMetricRequest request = CreateLogMetricRequest.newBuilder()
.setParent(MetricsServiceV2Client.formatParentName(getOptions().getProjectId()))
.setParent(ProjectName.create(getOptions().getProjectId()).toString())
.setMetric(metric.toPb())
.build();
return transform(rpc.create(request), Metric.fromPbFunction(this));
Expand All @@ -399,8 +400,7 @@ public Metric update(MetricInfo metric) {
@Override
public Future<Metric> updateAsync(MetricInfo metric) {
UpdateLogMetricRequest request = UpdateLogMetricRequest.newBuilder()
.setMetricName(MetricsServiceV2Client.formatMetricName(getOptions().getProjectId(),
metric.getName()))
.setMetricName(MetricName.create(getOptions().getProjectId(), metric.getName()).toString())
.setMetric(metric.toPb())
.build();
return transform(rpc.update(request), Metric.fromPbFunction(this));
Expand All @@ -414,15 +414,15 @@ public Metric getMetric(String metric) {
@Override
public Future<Metric> getMetricAsync(String metric) {
GetLogMetricRequest request = GetLogMetricRequest.newBuilder()
.setMetricName(MetricsServiceV2Client.formatMetricName(getOptions().getProjectId(), metric))
.setMetricName(MetricName.create(getOptions().getProjectId(), metric).toString())
.build();
return transform(rpc.get(request), Metric.fromPbFunction(this));
}

private static ListLogMetricsRequest listMetricsRequest(LoggingOptions serviceOptions,
Map<Option.OptionType, ?> options) {
ListLogMetricsRequest.Builder builder = ListLogMetricsRequest.newBuilder();
builder.setParent(MetricsServiceV2Client.formatParentName(serviceOptions.getProjectId()));
builder.setParent(ProjectName.create(serviceOptions.getProjectId()).toString());
Integer pageSize = PAGE_SIZE.get(options);
String pageToken = PAGE_TOKEN.get(options);
if (pageSize != null) {
Expand Down Expand Up @@ -470,7 +470,7 @@ public boolean deleteMetric(String metric) {
@Override
public Future<Boolean> deleteMetricAsync(String metric) {
DeleteLogMetricRequest request = DeleteLogMetricRequest.newBuilder()
.setMetricName(MetricsServiceV2Client.formatMetricName(getOptions().getProjectId(), metric))
.setMetricName(MetricName.create(getOptions().getProjectId(), metric).toString())
.build();
return transform(rpc.delete(request), EMPTY_TO_BOOLEAN_FUNCTION);
}
Expand All @@ -481,7 +481,7 @@ private static WriteLogEntriesRequest writeLogEntriesRequest(LoggingOptions serv
WriteLogEntriesRequest.Builder builder = WriteLogEntriesRequest.newBuilder();
String logName = LOG_NAME.get(options);
if (logName != null) {
builder.setLogName(LoggingServiceV2Client.formatLogName(projectId, logName));
builder.setLogName(LogName.create(projectId, logName).toString());
}
MonitoredResource resource = RESOURCE.get(options);
if (resource != null) {
Expand Down
Loading

0 comments on commit 84480fb

Please sign in to comment.