Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

Commit

Permalink
feat!: release gapic-generator-java v2.0.0 (#300)
Browse files Browse the repository at this point in the history
Committer: @miraleung
PiperOrigin-RevId: 388535346

Source-Link: googleapis/googleapis@d9eaf41

Source-Link: googleapis/googleapis-gen@976c5ab
  • Loading branch information
gcf-owl-bot[bot] committed Aug 5, 2021
1 parent 9b516b6 commit 3f26958
Show file tree
Hide file tree
Showing 20 changed files with 2,135 additions and 293 deletions.
Expand Up @@ -186,14 +186,13 @@ public AlphaAnalyticsDataStubSettings.Builder getStubSettingsBuilder() {
return ((AlphaAnalyticsDataStubSettings.Builder) getStubSettings());
}

// NEXT_MAJOR_VER: remove 'throws Exception'.
/**
* Applies the given settings updater function to all of the unary API methods in this service.
*
* <p>Note: This method does not support applying settings to streaming methods.
*/
public Builder applyToAllUnaryMethods(
ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) throws Exception {
ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) {
super.applyToAllUnaryMethods(
getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater);
return this;
Expand Down
Expand Up @@ -161,6 +161,11 @@ public static String getDefaultEndpoint() {
return "analyticsdata.googleapis.com:443";
}

/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "analyticsdata.mtls.googleapis.com:443";
}

/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down Expand Up @@ -324,6 +329,8 @@ private static Builder createDefault() {
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);

return initDefaults(builder);
}
Expand Down Expand Up @@ -362,14 +369,13 @@ private static Builder initDefaults(Builder builder) {
return builder;
}

// NEXT_MAJOR_VER: remove 'throws Exception'.
/**
* Applies the given settings updater function to all of the unary API methods in this service.
*
* <p>Note: This method does not support applying settings to streaming methods.
*/
public Builder applyToAllUnaryMethods(
ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) throws Exception {
ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) {
super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater);
return this;
}
Expand Down
Expand Up @@ -34,14 +34,12 @@
import com.google.api.gax.grpc.GrpcCallSettings;
import com.google.api.gax.grpc.GrpcStubCallableFactory;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.RequestParamsExtractor;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.common.collect.ImmutableMap;
import com.google.longrunning.stub.GrpcOperationsStub;
import io.grpc.MethodDescriptor;
import io.grpc.protobuf.ProtoUtils;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;

Expand Down Expand Up @@ -194,27 +192,21 @@ protected GrpcAlphaAnalyticsDataStub(
GrpcCallSettings.<GetMetadataRequest, Metadata>newBuilder()
.setMethodDescriptor(getMetadataMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<GetMetadataRequest>() {
@Override
public Map<String, String> extract(GetMetadataRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("name", String.valueOf(request.getName()));
return params.build();
}
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("name", String.valueOf(request.getName()));
return params.build();
})
.build();
GrpcCallSettings<RunRealtimeReportRequest, RunRealtimeReportResponse>
runRealtimeReportTransportSettings =
GrpcCallSettings.<RunRealtimeReportRequest, RunRealtimeReportResponse>newBuilder()
.setMethodDescriptor(runRealtimeReportMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<RunRealtimeReportRequest>() {
@Override
public Map<String, String> extract(RunRealtimeReportRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("property", String.valueOf(request.getProperty()));
return params.build();
}
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("property", String.valueOf(request.getProperty()));
return params.build();
})
.build();

Expand Down Expand Up @@ -283,7 +275,13 @@ public UnaryCallable<GetMetadataRequest, Metadata> getMetadataCallable() {

@Override
public final void close() {
shutdown();
try {
backgroundResources.close();
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new IllegalStateException("Failed to close resource", e);
}
}

@Override
Expand Down
Expand Up @@ -555,6 +555,7 @@ public final UnaryCallable<GetMetadataRequest, Metadata> getMetadataCallable() {
* .addAllMetricAggregations(new ArrayList<MetricAggregation>())
* .addAllOrderBys(new ArrayList<OrderBy>())
* .setReturnPropertyQuota(true)
* .addAllMinuteRanges(new ArrayList<MinuteRange>())
* .build();
* RunRealtimeReportResponse response = betaAnalyticsDataClient.runRealtimeReport(request);
* }
Expand Down Expand Up @@ -587,6 +588,7 @@ public final RunRealtimeReportResponse runRealtimeReport(RunRealtimeReportReques
* .addAllMetricAggregations(new ArrayList<MetricAggregation>())
* .addAllOrderBys(new ArrayList<OrderBy>())
* .setReturnPropertyQuota(true)
* .addAllMinuteRanges(new ArrayList<MinuteRange>())
* .build();
* ApiFuture<RunRealtimeReportResponse> future =
* betaAnalyticsDataClient.runRealtimeReportCallable().futureCall(request);
Expand Down
Expand Up @@ -185,14 +185,13 @@ public BetaAnalyticsDataStubSettings.Builder getStubSettingsBuilder() {
return ((BetaAnalyticsDataStubSettings.Builder) getStubSettings());
}

// NEXT_MAJOR_VER: remove 'throws Exception'.
/**
* Applies the given settings updater function to all of the unary API methods in this service.
*
* <p>Note: This method does not support applying settings to streaming methods.
*/
public Builder applyToAllUnaryMethods(
ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) throws Exception {
ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) {
super.applyToAllUnaryMethods(
getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater);
return this;
Expand Down
Expand Up @@ -161,6 +161,11 @@ public static String getDefaultEndpoint() {
return "analyticsdata.googleapis.com:443";
}

/** Returns the default mTLS service endpoint. */
public static String getDefaultMtlsEndpoint() {
return "analyticsdata.mtls.googleapis.com:443";
}

/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
Expand Down Expand Up @@ -323,6 +328,8 @@ private static Builder createDefault() {
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
builder.setMtlsEndpoint(getDefaultMtlsEndpoint());
builder.setSwitchToMtlsEndpointAllowed(true);

return initDefaults(builder);
}
Expand Down Expand Up @@ -361,14 +368,13 @@ private static Builder initDefaults(Builder builder) {
return builder;
}

// NEXT_MAJOR_VER: remove 'throws Exception'.
/**
* Applies the given settings updater function to all of the unary API methods in this service.
*
* <p>Note: This method does not support applying settings to streaming methods.
*/
public Builder applyToAllUnaryMethods(
ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) throws Exception {
ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) {
super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater);
return this;
}
Expand Down
Expand Up @@ -34,14 +34,12 @@
import com.google.api.gax.grpc.GrpcCallSettings;
import com.google.api.gax.grpc.GrpcStubCallableFactory;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.RequestParamsExtractor;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.common.collect.ImmutableMap;
import com.google.longrunning.stub.GrpcOperationsStub;
import io.grpc.MethodDescriptor;
import io.grpc.protobuf.ProtoUtils;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;

Expand Down Expand Up @@ -174,82 +172,64 @@ protected GrpcBetaAnalyticsDataStub(
GrpcCallSettings.<RunReportRequest, RunReportResponse>newBuilder()
.setMethodDescriptor(runReportMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<RunReportRequest>() {
@Override
public Map<String, String> extract(RunReportRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("property", String.valueOf(request.getProperty()));
return params.build();
}
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("property", String.valueOf(request.getProperty()));
return params.build();
})
.build();
GrpcCallSettings<RunPivotReportRequest, RunPivotReportResponse>
runPivotReportTransportSettings =
GrpcCallSettings.<RunPivotReportRequest, RunPivotReportResponse>newBuilder()
.setMethodDescriptor(runPivotReportMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<RunPivotReportRequest>() {
@Override
public Map<String, String> extract(RunPivotReportRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("property", String.valueOf(request.getProperty()));
return params.build();
}
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("property", String.valueOf(request.getProperty()));
return params.build();
})
.build();
GrpcCallSettings<BatchRunReportsRequest, BatchRunReportsResponse>
batchRunReportsTransportSettings =
GrpcCallSettings.<BatchRunReportsRequest, BatchRunReportsResponse>newBuilder()
.setMethodDescriptor(batchRunReportsMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<BatchRunReportsRequest>() {
@Override
public Map<String, String> extract(BatchRunReportsRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("property", String.valueOf(request.getProperty()));
return params.build();
}
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("property", String.valueOf(request.getProperty()));
return params.build();
})
.build();
GrpcCallSettings<BatchRunPivotReportsRequest, BatchRunPivotReportsResponse>
batchRunPivotReportsTransportSettings =
GrpcCallSettings.<BatchRunPivotReportsRequest, BatchRunPivotReportsResponse>newBuilder()
.setMethodDescriptor(batchRunPivotReportsMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<BatchRunPivotReportsRequest>() {
@Override
public Map<String, String> extract(BatchRunPivotReportsRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("property", String.valueOf(request.getProperty()));
return params.build();
}
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("property", String.valueOf(request.getProperty()));
return params.build();
})
.build();
GrpcCallSettings<GetMetadataRequest, Metadata> getMetadataTransportSettings =
GrpcCallSettings.<GetMetadataRequest, Metadata>newBuilder()
.setMethodDescriptor(getMetadataMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<GetMetadataRequest>() {
@Override
public Map<String, String> extract(GetMetadataRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("name", String.valueOf(request.getName()));
return params.build();
}
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("name", String.valueOf(request.getName()));
return params.build();
})
.build();
GrpcCallSettings<RunRealtimeReportRequest, RunRealtimeReportResponse>
runRealtimeReportTransportSettings =
GrpcCallSettings.<RunRealtimeReportRequest, RunRealtimeReportResponse>newBuilder()
.setMethodDescriptor(runRealtimeReportMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<RunRealtimeReportRequest>() {
@Override
public Map<String, String> extract(RunRealtimeReportRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("property", String.valueOf(request.getProperty()));
return params.build();
}
request -> {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("property", String.valueOf(request.getProperty()));
return params.build();
})
.build();

Expand Down Expand Up @@ -318,7 +298,13 @@ public UnaryCallable<GetMetadataRequest, Metadata> getMetadataCallable() {

@Override
public final void close() {
shutdown();
try {
backgroundResources.close();
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new IllegalStateException("Failed to close resource", e);
}
}

@Override
Expand Down
Expand Up @@ -42,8 +42,8 @@
public class AlphaAnalyticsDataClientTest {
private static MockAlphaAnalyticsData mockAlphaAnalyticsData;
private static MockServiceHelper mockServiceHelper;
private AlphaAnalyticsDataClient client;
private LocalChannelProvider channelProvider;
private AlphaAnalyticsDataClient client;

@BeforeClass
public static void startStaticServer() {
Expand Down
Expand Up @@ -42,8 +42,8 @@
public class BetaAnalyticsDataClientTest {
private static MockBetaAnalyticsData mockBetaAnalyticsData;
private static MockServiceHelper mockServiceHelper;
private BetaAnalyticsDataClient client;
private LocalChannelProvider channelProvider;
private BetaAnalyticsDataClient client;

@BeforeClass
public static void startStaticServer() {
Expand Down Expand Up @@ -454,6 +454,7 @@ public void runRealtimeReportTest() throws Exception {
.addAllMetricAggregations(new ArrayList<MetricAggregation>())
.addAllOrderBys(new ArrayList<OrderBy>())
.setReturnPropertyQuota(true)
.addAllMinuteRanges(new ArrayList<MinuteRange>())
.build();

RunRealtimeReportResponse actualResponse = client.runRealtimeReport(request);
Expand All @@ -473,6 +474,7 @@ public void runRealtimeReportTest() throws Exception {
request.getMetricAggregationsList(), actualRequest.getMetricAggregationsList());
Assert.assertEquals(request.getOrderBysList(), actualRequest.getOrderBysList());
Assert.assertEquals(request.getReturnPropertyQuota(), actualRequest.getReturnPropertyQuota());
Assert.assertEquals(request.getMinuteRangesList(), actualRequest.getMinuteRangesList());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -496,6 +498,7 @@ public void runRealtimeReportExceptionTest() throws Exception {
.addAllMetricAggregations(new ArrayList<MetricAggregation>())
.addAllOrderBys(new ArrayList<OrderBy>())
.setReturnPropertyQuota(true)
.addAllMinuteRanges(new ArrayList<MinuteRange>())
.build();
client.runRealtimeReport(request);
Assert.fail("No exception raised");
Expand Down
Expand Up @@ -158,7 +158,7 @@ public Builder setProperty(String property) {
}

private Builder(MetadataName metadataName) {
property = metadataName.property;
this.property = metadataName.property;
}

public MetadataName build() {
Expand Down

0 comments on commit 3f26958

Please sign in to comment.