Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def gapic_generator_java_repositories():
_maybe(
http_archive,
name = "com_google_googleapis",
strip_prefix = "googleapis-bda7ce951def5ae6e5c4258d0e569188dd4ae02b",
strip_prefix = "googleapis-2bea43cdc7a4443876380732980d83cd8d560582",
urls = [
"https://github.com/googleapis/googleapis/archive/bda7ce951def5ae6e5c4258d0e569188dd4ae02b.zip",
"https://github.com/googleapis/googleapis/archive/2bea43cdc7a4443876380732980d83cd8d560582.zip",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ import com.google.api.gax.grpc.GaxGrpcProperties;
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.protobuf.AbstractMessage;
import com.google.protobuf.Empty;
Expand All @@ -28,6 +32,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import javax.annotation.Generated;
import org.junit.After;
import org.junit.AfterClass;
Expand Down Expand Up @@ -558,4 +563,62 @@ public class LoggingServiceV2ClientTest {
// Expected exception.
}
}

@Test
public void tailLogEntriesTest() throws Exception {
TailLogEntriesResponse expectedResponse =
TailLogEntriesResponse.newBuilder()
.addAllEntries(new ArrayList<LogEntry>())
.addAllSuppressionInfo(new ArrayList<TailLogEntriesResponse.SuppressionInfo>())
.build();
mockLoggingServiceV2.addResponse(expectedResponse);
TailLogEntriesRequest request =
TailLogEntriesRequest.newBuilder()
.addAllResourceNames(new ArrayList<String>())
.setFilter("filter-1274492040")
.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
public void tailLogEntriesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockLoggingServiceV2.addException(exception);
TailLogEntriesRequest request =
TailLogEntriesRequest.newBuilder()
.addAllResourceNames(new ArrayList<String>())
.setFilter("filter-1274492040")
.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());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.google.api.gax.rpc.PagedCallSettings;
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 @@ -47,6 +48,8 @@ import com.google.logging.v2.ListLogsResponse;
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 @@ -113,6 +116,8 @@ public class LoggingServiceV2StubSettings extends StubSettings<LoggingServiceV2S
listMonitoredResourceDescriptorsSettings;
private final PagedCallSettings<ListLogsRequest, ListLogsResponse, ListLogsPagedResponse>
listLogsSettings;
private final StreamingCallSettings<TailLogEntriesRequest, TailLogEntriesResponse>
tailLogEntriesSettings;

private static final PagedListDescriptor<ListLogEntriesRequest, ListLogEntriesResponse, LogEntry>
LIST_LOG_ENTRIES_PAGE_STR_DESC =
Expand Down Expand Up @@ -395,6 +400,12 @@ public class LoggingServiceV2StubSettings extends StubSettings<LoggingServiceV2S
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 @@ -470,6 +481,7 @@ public class LoggingServiceV2StubSettings extends StubSettings<LoggingServiceV2S
listMonitoredResourceDescriptorsSettings =
settingsBuilder.listMonitoredResourceDescriptorsSettings().build();
listLogsSettings = settingsBuilder.listLogsSettings().build();
tailLogEntriesSettings = settingsBuilder.tailLogEntriesSettings().build();
}

/** Builder for LoggingServiceV2StubSettings. */
Expand All @@ -489,6 +501,8 @@ public class LoggingServiceV2StubSettings extends StubSettings<LoggingServiceV2S
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 All @@ -502,6 +516,13 @@ public class LoggingServiceV2StubSettings extends StubSettings<LoggingServiceV2S
StatusCode.Code.DEADLINE_EXCEEDED,
StatusCode.Code.INTERNAL,
StatusCode.Code.UNAVAILABLE)));
definitions.put(
"retry_policy_2_codes",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.DEADLINE_EXCEEDED,
StatusCode.Code.INTERNAL,
StatusCode.Code.UNAVAILABLE)));
RETRYABLE_CODE_DEFINITIONS = definitions.build();
}

Expand All @@ -521,6 +542,17 @@ public class LoggingServiceV2StubSettings extends StubSettings<LoggingServiceV2S
.setTotalTimeout(Duration.ofMillis(60000L))
.build();
definitions.put("retry_policy_1_params", settings);
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(3600000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(3600000L))
.setTotalTimeout(Duration.ofMillis(3600000L))
.build();
definitions.put("retry_policy_2_params", settings);
RETRY_PARAM_DEFINITIONS = definitions.build();
}

Expand All @@ -539,6 +571,7 @@ public class LoggingServiceV2StubSettings extends StubSettings<LoggingServiceV2S
listMonitoredResourceDescriptorsSettings =
PagedCallSettings.newBuilder(LIST_MONITORED_RESOURCE_DESCRIPTORS_PAGE_STR_FACT);
listLogsSettings = PagedCallSettings.newBuilder(LIST_LOGS_PAGE_STR_FACT);
tailLogEntriesSettings = StreamingCallSettings.newBuilder();

unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
Expand All @@ -559,6 +592,7 @@ public class LoggingServiceV2StubSettings extends StubSettings<LoggingServiceV2S
listMonitoredResourceDescriptorsSettings =
settings.listMonitoredResourceDescriptorsSettings.toBuilder();
listLogsSettings = settings.listLogsSettings.toBuilder();
tailLogEntriesSettings = settings.tailLogEntriesSettings.toBuilder();

unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
Expand Down Expand Up @@ -674,6 +708,12 @@ public class LoggingServiceV2StubSettings extends StubSettings<LoggingServiceV2S
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
6 changes: 3 additions & 3 deletions test/integration/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
load(
"@com_google_googleapis_imports//:imports.bzl",
java_gapic_assembly_gradle_pkg = "java_gapic_assembly_gradle_pkg2",
java_gapic_library = "java_gapic_library2",
java_gapic_test = "java_gapic_test2",
"java_gapic_assembly_gradle_pkg",
"java_gapic_library",
"java_gapic_test",
)
load(
"//:rules_bazel/java/integration_test.bzl",
Expand Down
151 changes: 151 additions & 0 deletions test/integration/goldens/asset/AssetServiceClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,157 @@ public final SearchAllIamPoliciesPagedResponse searchAllIamPolicies(
return stub.searchAllIamPoliciesCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Analyzes IAM policies to answer which identities have what accesses on which resources.
*
* <p>Sample code:
*
* <pre>{@code
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
* AnalyzeIamPolicyRequest request =
* AnalyzeIamPolicyRequest.newBuilder()
* .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
* .setExecutionTimeout(Duration.newBuilder().build())
* .build();
* AnalyzeIamPolicyResponse response = assetServiceClient.analyzeIamPolicy(request);
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final AnalyzeIamPolicyResponse analyzeIamPolicy(AnalyzeIamPolicyRequest request) {
return analyzeIamPolicyCallable().call(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Analyzes IAM policies to answer which identities have what accesses on which resources.
*
* <p>Sample code:
*
* <pre>{@code
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
* AnalyzeIamPolicyRequest request =
* AnalyzeIamPolicyRequest.newBuilder()
* .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
* .setExecutionTimeout(Duration.newBuilder().build())
* .build();
* ApiFuture<AnalyzeIamPolicyResponse> future =
* assetServiceClient.analyzeIamPolicyCallable().futureCall(request);
* // Do something.
* AnalyzeIamPolicyResponse response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<AnalyzeIamPolicyRequest, AnalyzeIamPolicyResponse>
analyzeIamPolicyCallable() {
return stub.analyzeIamPolicyCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Analyzes IAM policies asynchronously to answer which identities have what accesses on which
* resources, and writes the analysis results to a Google Cloud Storage or a BigQuery destination.
* For Cloud Storage destination, the output format is the JSON format that represents a
* [AnalyzeIamPolicyResponse][google.cloud.asset.v1.AnalyzeIamPolicyResponse]. This method
* implements the [google.longrunning.Operation][google.longrunning.Operation], which allows you
* to track the operation status. We recommend intervals of at least 2 seconds with exponential
* backoff retry to poll the operation result. The metadata contains the request to help callers
* to map responses to requests.
*
* <p>Sample code:
*
* <pre>{@code
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
* AnalyzeIamPolicyLongrunningRequest request =
* AnalyzeIamPolicyLongrunningRequest.newBuilder()
* .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
* .setOutputConfig(IamPolicyAnalysisOutputConfig.newBuilder().build())
* .build();
* AnalyzeIamPolicyLongrunningResponse response =
* assetServiceClient.analyzeIamPolicyLongrunningAsync(request).get();
* }
* }</pre>
*
* @param request The request object containing all of the parameters for the API call.
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
*/
public final OperationFuture<
AnalyzeIamPolicyLongrunningResponse, AnalyzeIamPolicyLongrunningRequest>
analyzeIamPolicyLongrunningAsync(AnalyzeIamPolicyLongrunningRequest request) {
return analyzeIamPolicyLongrunningOperationCallable().futureCall(request);
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Analyzes IAM policies asynchronously to answer which identities have what accesses on which
* resources, and writes the analysis results to a Google Cloud Storage or a BigQuery destination.
* For Cloud Storage destination, the output format is the JSON format that represents a
* [AnalyzeIamPolicyResponse][google.cloud.asset.v1.AnalyzeIamPolicyResponse]. This method
* implements the [google.longrunning.Operation][google.longrunning.Operation], which allows you
* to track the operation status. We recommend intervals of at least 2 seconds with exponential
* backoff retry to poll the operation result. The metadata contains the request to help callers
* to map responses to requests.
*
* <p>Sample code:
*
* <pre>{@code
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
* AnalyzeIamPolicyLongrunningRequest request =
* AnalyzeIamPolicyLongrunningRequest.newBuilder()
* .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
* .setOutputConfig(IamPolicyAnalysisOutputConfig.newBuilder().build())
* .build();
* OperationFuture<AnalyzeIamPolicyLongrunningResponse, AnalyzeIamPolicyLongrunningRequest>
* future =
* assetServiceClient.analyzeIamPolicyLongrunningOperationCallable().futureCall(request);
* // Do something.
* AnalyzeIamPolicyLongrunningResponse response = future.get();
* }
* }</pre>
*/
public final OperationCallable<
AnalyzeIamPolicyLongrunningRequest,
AnalyzeIamPolicyLongrunningResponse,
AnalyzeIamPolicyLongrunningRequest>
analyzeIamPolicyLongrunningOperationCallable() {
return stub.analyzeIamPolicyLongrunningOperationCallable();
}

// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Analyzes IAM policies asynchronously to answer which identities have what accesses on which
* resources, and writes the analysis results to a Google Cloud Storage or a BigQuery destination.
* For Cloud Storage destination, the output format is the JSON format that represents a
* [AnalyzeIamPolicyResponse][google.cloud.asset.v1.AnalyzeIamPolicyResponse]. This method
* implements the [google.longrunning.Operation][google.longrunning.Operation], which allows you
* to track the operation status. We recommend intervals of at least 2 seconds with exponential
* backoff retry to poll the operation result. The metadata contains the request to help callers
* to map responses to requests.
*
* <p>Sample code:
*
* <pre>{@code
* try (AssetServiceClient assetServiceClient = AssetServiceClient.create()) {
* AnalyzeIamPolicyLongrunningRequest request =
* AnalyzeIamPolicyLongrunningRequest.newBuilder()
* .setAnalysisQuery(IamPolicyAnalysisQuery.newBuilder().build())
* .setOutputConfig(IamPolicyAnalysisOutputConfig.newBuilder().build())
* .build();
* ApiFuture<Operation> future =
* assetServiceClient.analyzeIamPolicyLongrunningCallable().futureCall(request);
* // Do something.
* Operation response = future.get();
* }
* }</pre>
*/
public final UnaryCallable<AnalyzeIamPolicyLongrunningRequest, Operation>
analyzeIamPolicyLongrunningCallable() {
return stub.analyzeIamPolicyLongrunningCallable();
}

@Override
public final void close() {
stub.close();
Expand Down
Loading