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

chore: merge main into autoconfig-gen-draft2 #1082

Merged
merged 21 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b520aa0
fix(deps): update dependency org.yaml:snakeyaml to v1.32 (#1037)
renovate-bot Sep 13, 2022
9d25e47
fix(deps): update dependency com.google.cloud:google-cloud-shared-dep…
renovate-bot Sep 15, 2022
2e33a69
chore(deps): update dependency org.apache.maven.plugins:maven-shade-p…
renovate-bot Sep 20, 2022
67a5dc5
fix(deps): update dependency org.yaml:snakeyaml to v1.33 (#1043)
renovate-bot Sep 26, 2022
3b052e2
fix(deps): update dependency com.google.cloud:google-cloud-shared-dep…
renovate-bot Oct 3, 2022
0fdfa67
fix: Get numeric value for Enum fields if it is configured as query p…
blakeli0 Oct 3, 2022
d222af1
chore(deps): update dependency com.google.auto.value:auto-value to v1…
renovate-bot Oct 10, 2022
01c14d4
fix: update sample region tag to parse host instead of proto package …
alicejli Oct 13, 2022
aad7a88
deps: Upgrade protobuf to 3.21.7 (#1048)
blakeli0 Oct 20, 2022
f36c226
chore(main): release 2.10.1 (#1036)
release-please[bot] Oct 20, 2022
68b33c2
fix: update regionTag to use service name (#1047)
alicejli Oct 24, 2022
80ed62c
fix(deps): update dependency com.google.cloud:google-cloud-shared-dep…
renovate-bot Oct 24, 2022
9faeab4
chore(main): release 2.10.2 (#1067)
release-please[bot] Oct 24, 2022
5591a10
chore(deps): update dependency org.apache.maven.plugins:maven-shade-p…
renovate-bot Oct 28, 2022
da4b130
refactor: expose parsed api short name and version as fields in Servi…
emmileaf Oct 31, 2022
9ac0ca8
fix: fix REST transport client creation generated javadoc sample (#1077)
vam-google Nov 1, 2022
bed9f72
fix: fixes regionTag breakage (#1068)
alicejli Nov 1, 2022
7941431
chore(main): release 2.10.3 (#1079)
release-please[bot] Nov 2, 2022
f5d5524
fix(ast): add import generation for annotations on VariableExpr (#1076)
emmileaf Nov 3, 2022
b291ed3
Merge branch 'main' into autoconfig-gen-draft2
emmileaf Nov 3, 2022
bf4349b
test: update golden files after annotations import fix
emmileaf Nov 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Changelog

## [2.10.3](https://github.com/googleapis/gapic-generator-java/compare/v2.10.2...v2.10.3) (2022-11-01)


### Bug Fixes

* Fix REST transport client creation generated javadoc sample ([#1077](https://github.com/googleapis/gapic-generator-java/issues/1077)) ([9ac0ca8](https://github.com/googleapis/gapic-generator-java/commit/9ac0ca80b09077f7880f0029b5d7b090a10a10b8))
* Fixes regionTag breakage ([#1068](https://github.com/googleapis/gapic-generator-java/issues/1068)) ([bed9f72](https://github.com/googleapis/gapic-generator-java/commit/bed9f721fbafb5f2e974b6f43f8455f2fdb581f7))

## [2.10.2](https://github.com/googleapis/gapic-generator-java/compare/v2.10.1...v2.10.2) (2022-10-24)


### Bug Fixes

* **deps:** Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.5 ([#1063](https://github.com/googleapis/gapic-generator-java/issues/1063)) ([80ed62c](https://github.com/googleapis/gapic-generator-java/commit/80ed62cf6aff395d150e394a44fb60da37e9a6ae))
* Update regionTag to use service name ([#1047](https://github.com/googleapis/gapic-generator-java/issues/1047)) ([68b33c2](https://github.com/googleapis/gapic-generator-java/commit/68b33c23948ffe7a2bf6acd53731d786257f6bd1))

## [2.10.1](https://github.com/googleapis/gapic-generator-java/compare/v2.10.0...v2.10.1) (2022-10-20)


### Bug Fixes

* **deps:** Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.2 ([#1035](https://github.com/googleapis/gapic-generator-java/issues/1035)) ([f76634a](https://github.com/googleapis/gapic-generator-java/commit/f76634af8497ef2977376af570d175eb0fe91e6f))
* **deps:** Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.3 ([#1039](https://github.com/googleapis/gapic-generator-java/issues/1039)) ([9d25e47](https://github.com/googleapis/gapic-generator-java/commit/9d25e477126db35efd111a2b8ee76332b549ce91))
* **deps:** Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.4 ([#1050](https://github.com/googleapis/gapic-generator-java/issues/1050)) ([3b052e2](https://github.com/googleapis/gapic-generator-java/commit/3b052e27bb704124ae3214dd3e8708f8e32afe6c))
* **deps:** Update dependency org.yaml:snakeyaml to v1.32 ([#1037](https://github.com/googleapis/gapic-generator-java/issues/1037)) ([b520aa0](https://github.com/googleapis/gapic-generator-java/commit/b520aa0d35407daf96123d63c3112b9f29715115))
* **deps:** Update dependency org.yaml:snakeyaml to v1.33 ([#1043](https://github.com/googleapis/gapic-generator-java/issues/1043)) ([67a5dc5](https://github.com/googleapis/gapic-generator-java/commit/67a5dc5e4dd3302ececd212dd047f5731c4bf74d))
* Get numeric value for Enum fields if it is configured as query param or path param ([#1042](https://github.com/googleapis/gapic-generator-java/issues/1042)) ([0fdfa67](https://github.com/googleapis/gapic-generator-java/commit/0fdfa67fec84e1983c12b10c7b7ae7a0efa80f4d))
* Update sample region tag to parse host instead of proto package ([#1040](https://github.com/googleapis/gapic-generator-java/issues/1040)) ([01c14d4](https://github.com/googleapis/gapic-generator-java/commit/01c14d41d4195963c0ed46f310360f39eec6d420))

## [2.10.0](https://github.com/googleapis/gapic-generator-java/compare/v2.9.0...v2.10.0) (2022-09-06)


Expand Down
4 changes: 2 additions & 2 deletions PROPERTIES.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PROPERTIES = {
"version.com_google_protobuf": "3.19.1",
"version.com_google_protobuf": "3.21.7",
# Version of google-java-format is downgraded from 1.8 to 1.7, because 1.8 supports java 11 minimum, while our JRE is java 8.
"version.google_java_format": "1.7",
"version.io_grpc_java": "1.42.1",
Expand All @@ -10,7 +10,7 @@ PROPERTIES = {
"maven.com_google_auto_value_auto_value": "com.google.auto.value:auto-value:1.7.2",
"maven.com_google_auto_value_auto_value_annotations": "com.google.auto.value:auto-value-annotations:1.7.2",
"maven.com_google_code_gson": "com.google.code.gson:gson:2.8.6",
"maven.com_google_protobuf_protobuf_java": "com.google.protobuf:protobuf-java:3.19.1",
"maven.com_google_protobuf_protobuf_java": "com.google.protobuf:protobuf-java:3.21.7",
"maven.io_github_java_diff_utils": "io.github.java-diff-utils:java-diff-utils:4.11",
"maven.javax_annotation_javax_annotation_api": "javax.annotation:javax.annotation-api:1.3.2",

Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-shared-dependencies</artifactId>
<version>3.0.2</version>
<version>3.0.5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -42,7 +42,7 @@
<path>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<version>1.9</version>
<version>1.10</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand Down Expand Up @@ -155,7 +155,7 @@
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.19.4:exe:${os.detected.classifier}</protocArtifact>
<protocArtifact>com.google.protobuf:protoc:3.21.7:exe:${os.detected.classifier}</protocArtifact>
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -234,7 +234,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.1</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -311,7 +311,7 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.31</version>
<version>1.33</version>
</dependency>
<dependency>
<groupId>com.google.googlejavaformat</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public void visit(TernaryExpr ternaryExpr) {
@Override
public void visit(VariableExpr variableExpr) {
variableExpr.variable().type().accept(this);
annotations(variableExpr.annotations());
if (variableExpr.exprReferenceExpr() != null) {
variableExpr.exprReferenceExpr().accept(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package com.google.api.generator.gapic.composer;

import com.google.api.generator.engine.ast.ClassDefinition;
import com.google.api.generator.engine.ast.CommentStatement;
import com.google.api.generator.gapic.composer.comment.CommentComposer;
import com.google.api.generator.gapic.composer.grpc.GrpcServiceCallableFactoryClassComposer;
import com.google.api.generator.gapic.composer.grpc.GrpcServiceStubClassComposer;
Expand Down Expand Up @@ -47,8 +48,7 @@ public static List<GapicClass> composeServiceClasses(GapicContext context) {
clazzes.addAll(generateServiceClasses(context));
clazzes.addAll(generateMockClasses(context, context.mixinServices()));
clazzes.addAll(generateResourceNameHelperClasses(context));
return addApacheLicense(
prepareExecutableSamples(clazzes, context.gapicMetadata().getProtoPackage()));
return addApacheLicense(prepareExecutableSamples(clazzes));
}

public static GapicPackageInfo composePackageInfo(GapicContext context) {
Expand Down Expand Up @@ -190,37 +190,30 @@ public static List<GapicClass> generateTestClasses(GapicContext context) {
}

@VisibleForTesting
static List<GapicClass> prepareExecutableSamples(List<GapicClass> clazzes, String protoPackage) {
// parse protoPackage for apiVersion and apiShortName
String[] pakkage = protoPackage.split("\\.");
String apiVersion;
String apiShortName;
// e.g. v1, v2, v1beta1
if (pakkage[pakkage.length - 1].matches("v[0-9].*")) {
apiVersion = pakkage[pakkage.length - 1];
apiShortName = pakkage[pakkage.length - 2];
} else {
apiVersion = "";
apiShortName = pakkage[pakkage.length - 1];
}
// Include license header, apiShortName, and apiVersion
return clazzes.stream()
.map(
gapicClass -> {
List<Sample> samples =
gapicClass.samples().stream()
.map(
sample -> addRegionTagAndHeaderToSample(sample, apiShortName, apiVersion))
.collect(Collectors.toList());
return gapicClass.withSamples(samples);
})
.collect(Collectors.toList());
static List<GapicClass> prepareExecutableSamples(List<GapicClass> clazzes) {
// Include license header, apiShortName, and apiVersion
List<GapicClass> clazzesWithSamples = new ArrayList<>();
clazzes.forEach(
gapicClass -> {
List<Sample> samples = new ArrayList<>();
gapicClass
.samples()
.forEach(
sample ->
samples.add(
addRegionTagAndHeaderToSample(
sample, gapicClass.apiShortName(), gapicClass.apiVersion())));
clazzesWithSamples.add(gapicClass.withSamples(samples));
});
return clazzesWithSamples;
}

private static Sample addRegionTagAndHeaderToSample(
@VisibleForTesting
protected static Sample addRegionTagAndHeaderToSample(
Sample sample, String apiShortName, String apiVersion) {
final List<CommentStatement> header = Arrays.asList(CommentComposer.APACHE_LICENSE_COMMENT);
return sample
.withHeader(Arrays.asList(CommentComposer.APACHE_LICENSE_COMMENT))
.withHeader(header)
.withRegionTag(
sample.regionTag().withApiVersion(apiVersion).withApiShortName(apiShortName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ public GapicClass generate(GapicContext context, Service service) {
.build();

updateGapicMetadata(context, service, className, grpcRpcsToJavaMethodNames);
return GapicClass.create(kind, classDef, SampleComposerUtil.handleDuplicateSamples(samples));
return GapicClass.create(kind, classDef, SampleComposerUtil.handleDuplicateSamples(samples))
.withApiShortName(service.apiShortName())
.withApiVersion(service.apiVersion());
}

private static List<AnnotationNode> createClassAnnotations(Service service, TypeStore typeStore) {
Expand Down Expand Up @@ -198,9 +200,11 @@ protected List<CommentStatement> createClassHeaderComments(
ServiceClientHeaderSampleComposer.composeClassHeaderSample(
service, clientType, resourceNames, messageTypes);
Sample credentialsSampleCode =
ServiceClientHeaderSampleComposer.composeSetCredentialsSample(clientType, settingsType);
ServiceClientHeaderSampleComposer.composeSetCredentialsSample(
clientType, settingsType, service);
Sample endpointSampleCode =
ServiceClientHeaderSampleComposer.composeSetEndpointSample(clientType, settingsType);
ServiceClientHeaderSampleComposer.composeSetEndpointSample(
clientType, settingsType, service);
samples.addAll(Arrays.asList(classMethodSampleCode, credentialsSampleCode, endpointSampleCode));
return ServiceClientCommentComposer.createClassHeaderComments(
service,
Expand Down Expand Up @@ -578,7 +582,8 @@ private static List<MethodDefinition> createServiceMethods(
messageTypes,
typeStore,
resourceNames,
samples);
samples,
service);

// Collect data for gapic_metadata.json.
grpcRpcToJavaMethodMetadata
Expand All @@ -596,7 +601,8 @@ private static List<MethodDefinition> createServiceMethods(
messageTypes,
typeStore,
resourceNames,
samples);
samples,
service);

// Collect data for gapic_metadata.json.
grpcRpcToJavaMethodMetadata.get(method.name()).add(javaMethodNameFn.apply(generatedMethod));
Expand Down Expand Up @@ -636,7 +642,8 @@ private static List<MethodDefinition> createMethodVariants(
Map<String, Message> messageTypes,
TypeStore typeStore,
Map<String, ResourceName> resourceNames,
List<Sample> samples) {
List<Sample> samples,
Service service) {
List<MethodDefinition> javaMethods = new ArrayList<>();
String methodName = JavaStyle.toLowerCamelCase(method.name());
TypeNode methodInputType = method.inputType();
Expand Down Expand Up @@ -700,7 +707,12 @@ private static List<MethodDefinition> createMethodVariants(
Optional<Sample> methodSample =
Optional.of(
ServiceClientHeaderSampleComposer.composeShowcaseMethodSample(
method, typeStore.get(clientName), signature, resourceNames, messageTypes));
method,
typeStore.get(clientName),
signature,
resourceNames,
messageTypes,
service));
Optional<String> methodDocSample = Optional.empty();
if (methodSample.isPresent()) {
samples.add(methodSample.get());
Expand Down Expand Up @@ -744,7 +756,8 @@ private static MethodDefinition createMethodDefaultMethod(
Map<String, Message> messageTypes,
TypeStore typeStore,
Map<String, ResourceName> resourceNames,
List<Sample> samples) {
List<Sample> samples,
Service service) {
String methodName = JavaStyle.toLowerCamelCase(method.name());
TypeNode methodInputType = method.inputType();
TypeNode methodOutputType =
Expand Down Expand Up @@ -788,7 +801,7 @@ private static MethodDefinition createMethodDefaultMethod(
Optional<Sample> defaultMethodSample =
Optional.of(
ServiceClientMethodSampleComposer.composeCanonicalSample(
method, typeStore.get(clientName), resourceNames, messageTypes));
method, typeStore.get(clientName), resourceNames, messageTypes, service));
Optional<String> defaultMethodDocSample = Optional.empty();
if (defaultMethodSample.isPresent()) {
samples.add(defaultMethodSample.get());
Expand Down Expand Up @@ -930,15 +943,17 @@ private static MethodDefinition createCallableMethod(
method,
typeStore.get(ClassNames.getServiceClientClassName(service)),
resourceNames,
messageTypes));
messageTypes,
service));
} else if (callableMethodKind.equals(CallableMethodKind.PAGED)) {
sampleCode =
Optional.of(
ServiceClientCallableMethodSampleComposer.composePagedCallableMethod(
method,
typeStore.get(ClassNames.getServiceClientClassName(service)),
resourceNames,
messageTypes));
messageTypes,
service));
} else if (callableMethodKind.equals(CallableMethodKind.REGULAR)) {
if (method.stream().equals(Stream.NONE)) {
sampleCode =
Expand All @@ -947,15 +962,17 @@ private static MethodDefinition createCallableMethod(
method,
typeStore.get(ClassNames.getServiceClientClassName(service)),
resourceNames,
messageTypes));
messageTypes,
service));
} else {
sampleCode =
Optional.of(
ServiceClientCallableMethodSampleComposer.composeStreamCallableMethod(
method,
typeStore.get(ClassNames.getServiceClientClassName(service)),
resourceNames,
messageTypes));
messageTypes,
service));
}
}
Optional<String> sampleDocCode = Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ public GapicClass generate(GapicContext context, Service service) {
.setMethods(createClassMethods(service, typeStore))
.setNestedClasses(Arrays.asList(createNestedBuilderClass(service, typeStore)))
.build();
return GapicClass.create(kind, classDef, SampleComposerUtil.handleDuplicateSamples(samples));
return GapicClass.create(kind, classDef, SampleComposerUtil.handleDuplicateSamples(samples))
.withApiShortName(service.apiShortName())
.withApiVersion(service.apiVersion());
}

private static List<CommentStatement> createClassHeaderComments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ public GapicClass generate(GapicContext context, Service service) {
Arrays.asList(createNestedBuilderClass(service, serviceConfig, typeStore)))
.build();
return GapicClass.create(
GapicClass.Kind.STUB, classDef, SampleComposerUtil.handleDuplicateSamples(samples));
GapicClass.Kind.STUB, classDef, SampleComposerUtil.handleDuplicateSamples(samples))
.withApiShortName(service.apiShortName())
.withApiVersion(service.apiVersion());
}

protected MethodDefinition createDefaultCredentialsProviderBuilderMethod() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ protected List<CommentStatement> createClassHeaderComments(
ServiceClientHeaderSampleComposer.composeClassHeaderSample(
service, clientType, resourceNames, messageTypes);
Sample credentialsSampleCode =
ServiceClientHeaderSampleComposer.composeSetCredentialsSample(clientType, settingsType);
ServiceClientHeaderSampleComposer.composeSetCredentialsSample(
clientType, settingsType, service);
Sample endpointSampleCode =
ServiceClientHeaderSampleComposer.composeSetEndpointSample(clientType, settingsType);
ServiceClientHeaderSampleComposer.composeSetEndpointSample(
clientType, settingsType, service);
Sample transportSampleCode =
ServiceClientHeaderSampleComposer.composeTransportSample(
clientType, settingsType, "defaultHttpJsonTransportProviderBuilder");
clientType, settingsType, "newHttpJsonBuilder", service);
samples.addAll(
Arrays.asList(
classMethodSampleCode, credentialsSampleCode, endpointSampleCode, transportSampleCode));
Expand Down
Loading