Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHANGE ME] Re-generated to pick up changes from googleapis. #349

Merged
merged 3 commits into from Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -25,6 +25,7 @@
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
import com.google.api.gax.paging.AbstractPagedListResponse;
import com.google.api.gax.rpc.BidiStreamingCallable;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.logging.v2.stub.LoggingServiceV2Stub;
Expand All @@ -43,6 +44,8 @@
import com.google.logging.v2.LogName;
import com.google.logging.v2.OrganizationName;
import com.google.logging.v2.ProjectName;
import com.google.logging.v2.TailLogEntriesRequest;
import com.google.logging.v2.TailLogEntriesResponse;
import com.google.logging.v2.WriteLogEntriesRequest;
import com.google.logging.v2.WriteLogEntriesResponse;
import com.google.protobuf.Empty;
Expand Down Expand Up @@ -301,6 +304,11 @@ public final UnaryCallable<DeleteLogRequest, Empty> deleteLogCallable() {
* entries:
* <p>"projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]"
* "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]"
* <p>May alternatively be one or more views
* projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
* organization/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
* billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
* folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
* <p>Projects listed in the `project_ids` field are added to this list.
* @param filter Optional. A filter that chooses which log entries to return. See [Advanced Logs
* Queries](https://cloud.google.com/logging/docs/view/advanced-queries). Only log entries
Expand Down Expand Up @@ -907,6 +915,34 @@ public final UnaryCallable<ListLogsRequest, ListLogsResponse> listLogsCallable()
return stub.listLogsCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD
/**
* Streaming read of log entries as they are ingested. Until the stream is terminated, it will
* continue reading logs.
*
* <p>Sample code:
*
* <pre><code>
* try (LoggingClient loggingClient = LoggingClient.create()) {
* BidiStream&lt;TailLogEntriesRequest, TailLogEntriesResponse&gt; bidiStream =
* loggingClient.tailLogEntriesCallable().call();
*
* List&lt;String&gt; resourceNames = new ArrayList&lt;&gt;();
* TailLogEntriesRequest request = TailLogEntriesRequest.newBuilder()
* .addAllResourceNames(resourceNames)
* .build();
* bidiStream.send(request);
* for (TailLogEntriesResponse response : bidiStream) {
* // Do something when receive a response
* }
* }
* </code></pre>
*/
public final BidiStreamingCallable<TailLogEntriesRequest, TailLogEntriesResponse>
tailLogEntriesCallable() {
return stub.tailLogEntriesCallable();
}

@Override
public final void close() {
stub.close();
Expand Down
Expand Up @@ -29,6 +29,7 @@
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.ClientSettings;
import com.google.api.gax.rpc.PagedCallSettings;
import com.google.api.gax.rpc.StreamingCallSettings;
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.api.gax.rpc.UnaryCallSettings;
import com.google.cloud.logging.v2.stub.LoggingServiceV2StubSettings;
Expand All @@ -39,6 +40,8 @@
import com.google.logging.v2.ListLogsResponse;
import com.google.logging.v2.ListMonitoredResourceDescriptorsRequest;
import com.google.logging.v2.ListMonitoredResourceDescriptorsResponse;
import com.google.logging.v2.TailLogEntriesRequest;
import com.google.logging.v2.TailLogEntriesResponse;
import com.google.logging.v2.WriteLogEntriesRequest;
import com.google.logging.v2.WriteLogEntriesResponse;
import com.google.protobuf.Empty;
Expand Down Expand Up @@ -114,6 +117,12 @@ public UnaryCallSettings<DeleteLogRequest, Empty> deleteLogSettings() {
return ((LoggingServiceV2StubSettings) getStubSettings()).listLogsSettings();
}

/** Returns the object with the settings used for calls to tailLogEntries. */
public StreamingCallSettings<TailLogEntriesRequest, TailLogEntriesResponse>
tailLogEntriesSettings() {
return ((LoggingServiceV2StubSettings) getStubSettings()).tailLogEntriesSettings();
}

public static final LoggingSettings create(LoggingServiceV2StubSettings stub) throws IOException {
return new LoggingSettings.Builder(stub.toBuilder()).build();
}
Expand Down Expand Up @@ -243,6 +252,12 @@ public UnaryCallSettings.Builder<DeleteLogRequest, Empty> deleteLogSettings() {
return getStubSettingsBuilder().listLogsSettings();
}

/** Returns the builder for the settings used for calls to tailLogEntries. */
public StreamingCallSettings.Builder<TailLogEntriesRequest, TailLogEntriesResponse>
tailLogEntriesSettings() {
return getStubSettingsBuilder().tailLogEntriesSettings();
}

@Override
public LoggingSettings build() throws IOException {
return new LoggingSettings(this);
Expand Down
Expand Up @@ -24,6 +24,7 @@
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.grpc.GrpcCallSettings;
import com.google.api.gax.grpc.GrpcStubCallableFactory;
import com.google.api.gax.rpc.BidiStreamingCallable;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.RequestParamsExtractor;
import com.google.api.gax.rpc.UnaryCallable;
Expand All @@ -35,6 +36,8 @@
import com.google.logging.v2.ListLogsResponse;
import com.google.logging.v2.ListMonitoredResourceDescriptorsRequest;
import com.google.logging.v2.ListMonitoredResourceDescriptorsResponse;
import com.google.logging.v2.TailLogEntriesRequest;
import com.google.logging.v2.TailLogEntriesResponse;
import com.google.logging.v2.WriteLogEntriesRequest;
import com.google.logging.v2.WriteLogEntriesResponse;
import com.google.protobuf.Empty;
Expand Down Expand Up @@ -106,6 +109,16 @@ public class GrpcLoggingServiceV2Stub extends LoggingServiceV2Stub {
.setRequestMarshaller(ProtoUtils.marshaller(ListLogsRequest.getDefaultInstance()))
.setResponseMarshaller(ProtoUtils.marshaller(ListLogsResponse.getDefaultInstance()))
.build();
private static final MethodDescriptor<TailLogEntriesRequest, TailLogEntriesResponse>
tailLogEntriesMethodDescriptor =
MethodDescriptor.<TailLogEntriesRequest, TailLogEntriesResponse>newBuilder()
.setType(MethodDescriptor.MethodType.BIDI_STREAMING)
.setFullMethodName("google.logging.v2.LoggingServiceV2/TailLogEntries")
.setRequestMarshaller(
ProtoUtils.marshaller(TailLogEntriesRequest.getDefaultInstance()))
.setResponseMarshaller(
ProtoUtils.marshaller(TailLogEntriesResponse.getDefaultInstance()))
.build();

private final BackgroundResource backgroundResources;

Expand All @@ -123,6 +136,8 @@ public class GrpcLoggingServiceV2Stub extends LoggingServiceV2Stub {
listMonitoredResourceDescriptorsPagedCallable;
private final UnaryCallable<ListLogsRequest, ListLogsResponse> listLogsCallable;
private final UnaryCallable<ListLogsRequest, ListLogsPagedResponse> listLogsPagedCallable;
private final BidiStreamingCallable<TailLogEntriesRequest, TailLogEntriesResponse>
tailLogEntriesCallable;

private final GrpcStubCallableFactory callableFactory;

Expand Down Expand Up @@ -209,6 +224,11 @@ public Map<String, String> extract(ListLogsRequest request) {
}
})
.build();
GrpcCallSettings<TailLogEntriesRequest, TailLogEntriesResponse>
tailLogEntriesTransportSettings =
GrpcCallSettings.<TailLogEntriesRequest, TailLogEntriesResponse>newBuilder()
.setMethodDescriptor(tailLogEntriesMethodDescriptor)
.build();

this.deleteLogCallable =
callableFactory.createUnaryCallable(
Expand Down Expand Up @@ -238,6 +258,9 @@ public Map<String, String> extract(ListLogsRequest request) {
this.listLogsPagedCallable =
callableFactory.createPagedCallable(
listLogsTransportSettings, settings.listLogsSettings(), clientContext);
this.tailLogEntriesCallable =
callableFactory.createBidiStreamingCallable(
tailLogEntriesTransportSettings, settings.tailLogEntriesSettings(), clientContext);

backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources());
}
Expand Down Expand Up @@ -279,6 +302,11 @@ public UnaryCallable<ListLogsRequest, ListLogsResponse> listLogsCallable() {
return listLogsCallable;
}

public BidiStreamingCallable<TailLogEntriesRequest, TailLogEntriesResponse>
tailLogEntriesCallable() {
return tailLogEntriesCallable;
}

@Override
public final void close() {
shutdown();
Expand Down
Expand Up @@ -21,6 +21,7 @@

import com.google.api.core.BetaApi;
import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.rpc.BidiStreamingCallable;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.logging.v2.DeleteLogRequest;
import com.google.logging.v2.ListLogEntriesRequest;
Expand All @@ -29,6 +30,8 @@
import com.google.logging.v2.ListLogsResponse;
import com.google.logging.v2.ListMonitoredResourceDescriptorsRequest;
import com.google.logging.v2.ListMonitoredResourceDescriptorsResponse;
import com.google.logging.v2.TailLogEntriesRequest;
import com.google.logging.v2.TailLogEntriesResponse;
import com.google.logging.v2.WriteLogEntriesRequest;
import com.google.logging.v2.WriteLogEntriesResponse;
import com.google.protobuf.Empty;
Expand Down Expand Up @@ -83,6 +86,11 @@ public UnaryCallable<ListLogsRequest, ListLogsResponse> listLogsCallable() {
throw new UnsupportedOperationException("Not implemented: listLogsCallable()");
}

public BidiStreamingCallable<TailLogEntriesRequest, TailLogEntriesResponse>
tailLogEntriesCallable() {
throw new UnsupportedOperationException("Not implemented: tailLogEntriesCallable()");
}

@Override
public abstract void close();
}
Expand Up @@ -46,6 +46,7 @@
import com.google.api.gax.rpc.PagedListDescriptor;
import com.google.api.gax.rpc.PagedListResponseFactory;
import com.google.api.gax.rpc.StatusCode;
import com.google.api.gax.rpc.StreamingCallSettings;
import com.google.api.gax.rpc.StubSettings;
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.api.gax.rpc.UnaryCallSettings;
Expand All @@ -62,6 +63,8 @@
import com.google.logging.v2.ListMonitoredResourceDescriptorsRequest;
import com.google.logging.v2.ListMonitoredResourceDescriptorsResponse;
import com.google.logging.v2.LogEntry;
import com.google.logging.v2.TailLogEntriesRequest;
import com.google.logging.v2.TailLogEntriesResponse;
import com.google.logging.v2.WriteLogEntriesRequest;
import com.google.logging.v2.WriteLogEntriesResponse;
import com.google.protobuf.Empty;
Expand Down Expand Up @@ -128,6 +131,8 @@ public class LoggingServiceV2StubSettings extends StubSettings<LoggingServiceV2S
listMonitoredResourceDescriptorsSettings;
private final PagedCallSettings<ListLogsRequest, ListLogsResponse, ListLogsPagedResponse>
listLogsSettings;
private final StreamingCallSettings<TailLogEntriesRequest, TailLogEntriesResponse>
tailLogEntriesSettings;

/** Returns the object with the settings used for calls to deleteLog. */
public UnaryCallSettings<DeleteLogRequest, Empty> deleteLogSettings() {
Expand Down Expand Up @@ -162,6 +167,12 @@ public UnaryCallSettings<DeleteLogRequest, Empty> deleteLogSettings() {
return listLogsSettings;
}

/** Returns the object with the settings used for calls to tailLogEntries. */
public StreamingCallSettings<TailLogEntriesRequest, TailLogEntriesResponse>
tailLogEntriesSettings() {
return tailLogEntriesSettings;
}

@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public LoggingServiceV2Stub createStub() throws IOException {
if (getTransportChannelProvider()
Expand Down Expand Up @@ -237,6 +248,7 @@ protected LoggingServiceV2StubSettings(Builder settingsBuilder) throws IOExcepti
listMonitoredResourceDescriptorsSettings =
settingsBuilder.listMonitoredResourceDescriptorsSettings().build();
listLogsSettings = settingsBuilder.listLogsSettings().build();
tailLogEntriesSettings = settingsBuilder.tailLogEntriesSettings().build();
}

private static final PagedListDescriptor<ListLogEntriesRequest, ListLogEntriesResponse, LogEntry>
Expand Down Expand Up @@ -506,6 +518,8 @@ public static class Builder extends StubSettings.Builder<LoggingServiceV2StubSet
private final PagedCallSettings.Builder<
ListLogsRequest, ListLogsResponse, ListLogsPagedResponse>
listLogsSettings;
private final StreamingCallSettings.Builder<TailLogEntriesRequest, TailLogEntriesResponse>
tailLogEntriesSettings;

private static final ImmutableMap<String, ImmutableSet<StatusCode.Code>>
RETRYABLE_CODE_DEFINITIONS;
Expand Down Expand Up @@ -583,6 +597,8 @@ protected Builder(ClientContext clientContext) {

listLogsSettings = PagedCallSettings.newBuilder(LIST_LOGS_PAGE_STR_FACT);

tailLogEntriesSettings = StreamingCallSettings.newBuilder();

unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
deleteLogSettings,
Expand Down Expand Up @@ -656,6 +672,7 @@ protected Builder(LoggingServiceV2StubSettings settings) {
listMonitoredResourceDescriptorsSettings =
settings.listMonitoredResourceDescriptorsSettings.toBuilder();
listLogsSettings = settings.listLogsSettings.toBuilder();
tailLogEntriesSettings = settings.tailLogEntriesSettings.toBuilder();

unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
Expand Down Expand Up @@ -715,6 +732,12 @@ public UnaryCallSettings.Builder<DeleteLogRequest, Empty> deleteLogSettings() {
return listLogsSettings;
}

/** Returns the builder for the settings used for calls to tailLogEntries. */
public StreamingCallSettings.Builder<TailLogEntriesRequest, TailLogEntriesResponse>
tailLogEntriesSettings() {
return tailLogEntriesSettings;
}

@Override
public LoggingServiceV2StubSettings build() throws IOException {
return new LoggingServiceV2StubSettings(this);
Expand Down
Expand Up @@ -26,8 +26,12 @@
import com.google.api.gax.grpc.testing.LocalChannelProvider;
import com.google.api.gax.grpc.testing.MockGrpcService;
import com.google.api.gax.grpc.testing.MockServiceHelper;
import com.google.api.gax.grpc.testing.MockStreamObserver;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.ApiStreamObserver;
import com.google.api.gax.rpc.BidiStreamingCallable;
import com.google.api.gax.rpc.InvalidArgumentException;
import com.google.api.gax.rpc.StatusCode;
import com.google.common.collect.Lists;
import com.google.logging.v2.DeleteLogRequest;
import com.google.logging.v2.ListLogEntriesRequest;
Expand All @@ -39,6 +43,8 @@
import com.google.logging.v2.LogEntry;
import com.google.logging.v2.LogName;
import com.google.logging.v2.ProjectName;
import com.google.logging.v2.TailLogEntriesRequest;
import com.google.logging.v2.TailLogEntriesResponse;
import com.google.logging.v2.WriteLogEntriesRequest;
import com.google.logging.v2.WriteLogEntriesResponse;
import com.google.protobuf.AbstractMessage;
Expand All @@ -52,6 +58,7 @@
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
Expand Down Expand Up @@ -344,4 +351,56 @@ public void listLogsExceptionTest() throws Exception {
// Expected exception
}
}

@Test
@SuppressWarnings("all")
public void tailLogEntriesTest() throws Exception {
TailLogEntriesResponse expectedResponse = TailLogEntriesResponse.newBuilder().build();
mockLoggingServiceV2.addResponse(expectedResponse);
List<String> resourceNames = new ArrayList<>();
TailLogEntriesRequest request =
TailLogEntriesRequest.newBuilder().addAllResourceNames(resourceNames).build();

MockStreamObserver<TailLogEntriesResponse> responseObserver = new MockStreamObserver<>();

BidiStreamingCallable<TailLogEntriesRequest, TailLogEntriesResponse> callable =
client.tailLogEntriesCallable();
ApiStreamObserver<TailLogEntriesRequest> requestObserver =
callable.bidiStreamingCall(responseObserver);

requestObserver.onNext(request);
requestObserver.onCompleted();

List<TailLogEntriesResponse> actualResponses = responseObserver.future().get();
Assert.assertEquals(1, actualResponses.size());
Assert.assertEquals(expectedResponse, actualResponses.get(0));
}

@Test
@SuppressWarnings("all")
public void tailLogEntriesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockLoggingServiceV2.addException(exception);
List<String> resourceNames = new ArrayList<>();
TailLogEntriesRequest request =
TailLogEntriesRequest.newBuilder().addAllResourceNames(resourceNames).build();

MockStreamObserver<TailLogEntriesResponse> responseObserver = new MockStreamObserver<>();

BidiStreamingCallable<TailLogEntriesRequest, TailLogEntriesResponse> callable =
client.tailLogEntriesCallable();
ApiStreamObserver<TailLogEntriesRequest> requestObserver =
callable.bidiStreamingCall(responseObserver);

requestObserver.onNext(request);

try {
List<TailLogEntriesResponse> actualResponses = responseObserver.future().get();
Assert.fail("No exception thrown");
} catch (ExecutionException e) {
Assert.assertTrue(e.getCause() instanceof InvalidArgumentException);
InvalidArgumentException apiException = (InvalidArgumentException) e.getCause();
Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
}
}
}