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

feat: Diregapic lro #858

Merged
merged 21 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1b7ee1e
feat: enable self signed jwt for gapic clients (#794)
arithmetic1728 Aug 17, 2021
7691f4e
chore: release 2.1.0 (#827)
release-please[bot] Aug 17, 2021
fdcfe70
feat: REGAPIC initial implementation (#824)
vam-google Aug 26, 2021
445daf4
feat: REGAPIC Multitransport implementation (grpc+rest) (#833)
vam-google Sep 6, 2021
92f7c1c
fix: [bazel] fix rest transport handling in assembly rule (#835)
vam-google Sep 7, 2021
556e7dd
Portable String <--> bytes conversion (#841)
chanseokoh Sep 14, 2021
d335340
Fix development doc (#837)
chanseokoh Sep 14, 2021
8ca140c
Remove warnings (unused vars, dead code, missing annotations, missing…
chanseokoh Sep 14, 2021
a7d905e
Remove warnings for test code (#842)
chanseokoh Sep 17, 2021
6a9f329
Remove extraneous call (#844)
chanseokoh Sep 17, 2021
98b891f
Fix preserving sorted order of a collection (#845)
chanseokoh Sep 20, 2021
cb1b534
feat: Add REST AIP-151 LRO suport
vam-google Sep 21, 2021
f569c11
chore(deps): update dependency gradle to v7 (#713)
renovate-bot Sep 29, 2021
73e5a3e
chore(deps): update dependency bazel_skylib to v1.0.3 (#722)
renovate-bot Sep 29, 2021
108e93d
chore(deps): update dependency bazel_skylib to v1.1.1 (#849)
renovate-bot Oct 1, 2021
cd84efe
chore(deps): update dependency gradle to v7.2 (#848)
renovate-bot Oct 1, 2021
3f0bf5a
chore: rename default branch to main (#851)
Neenu1995 Oct 4, 2021
aba0ec0
feat: enable self signed JWT for http (#850)
arithmetic1728 Oct 6, 2021
39c7b9c
Merge remote-tracking branch 'upstream/master' into diregapic-lro
vam-google Oct 6, 2021
d029941
chore: merge changes from master
vam-google Oct 6, 2021
0cf77b5
Merge remote-tracking branch 'upstream/main' into diregapic-lro
vam-google Oct 6, 2021
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
Next Next commit
feat: enable self signed jwt for gapic clients (#794)
* feat: enable self signed jwt for gapic clients

* resolve comments

* update gax version

* update goldens

* update golden files
  • Loading branch information
arithmetic1728 authored Aug 17, 2021
commit 1b7ee1e3911e1c8ecab9a94d68d7a59b437d2449
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jvm_maven_import_external(
# gapic-generator-java dependencies to match the order in googleapis repository,
# which in its turn, prioritizes actual generated clients runtime dependencies
# over the generator dependencies.
_gax_java_version = "1.65.1"
_gax_java_version = "2.3.0"

http_archive(
name = "com_google_api_gax_java",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ public abstract class AbstractServiceStubSettingsClassComposer implements ClassC

protected static final TypeStore FIXED_TYPESTORE = createStaticTypes();

private static final VariableExpr DEFAULT_SERVICE_SCOPES_VAR_EXPR =
createDefaultServiceScopesVarExpr();
private static final VariableExpr NESTED_UNARY_METHOD_SETTINGS_BUILDERS_VAR_EXPR =
createNestedUnaryMethodSettingsBuildersVarExpr();
private static final VariableExpr NESTED_RETRYABLE_CODE_DEFINITIONS_VAR_EXPR =
Expand All @@ -150,6 +148,9 @@ public abstract class AbstractServiceStubSettingsClassComposer implements ClassC

private final TransportContext transportContext;

protected static final VariableExpr DEFAULT_SERVICE_SCOPES_VAR_EXPR =
createDefaultServiceScopesVarExpr();

protected AbstractServiceStubSettingsClassComposer(TransportContext transportContext) {
this.transportContext = transportContext;
}
Expand Down Expand Up @@ -197,6 +198,33 @@ public GapicClass generate(GapicContext context, Service service) {
return GapicClass.create(GapicClass.Kind.STUB, classDef);
}

protected MethodDefinition createDefaultCredentialsProviderBuilderMethod() {
TypeNode returnType =
TypeNode.withReference(
ConcreteReference.withClazz(GoogleCredentialsProvider.Builder.class));
MethodInvocationExpr credsProviderBuilderExpr =
MethodInvocationExpr.builder()
.setStaticReferenceType(FIXED_TYPESTORE.get("GoogleCredentialsProvider"))
.setMethodName("newBuilder")
.build();
credsProviderBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(credsProviderBuilderExpr)
.setMethodName("setScopesToApply")
.setArguments(DEFAULT_SERVICE_SCOPES_VAR_EXPR)
.setReturnType(returnType)
.build();
return MethodDefinition.builder()
.setHeaderCommentStatements(
SettingsCommentComposer.DEFAULT_CREDENTIALS_PROVIDER_BUILDER_METHOD_COMMENT)
.setScope(ScopeNode.PUBLIC)
.setIsStatic(true)
.setReturnType(returnType)
.setName("defaultCredentialsProviderBuilder")
.setReturnExpr(credsProviderBuilderExpr)
.build();
}

protected abstract MethodDefinition createDefaultTransportTransportProviderBuilderMethod();

protected abstract MethodDefinition createDefaultApiClientHeaderProviderBuilderMethod(
Expand Down Expand Up @@ -992,33 +1020,7 @@ private List<MethodDefinition> createDefaultHelperAndGetterMethods(
.setReturnExpr(DEFAULT_SERVICE_SCOPES_VAR_EXPR)
.build());

// Create the defaultCredentialsProviderBuilder method.
returnType =
TypeNode.withReference(
ConcreteReference.withClazz(GoogleCredentialsProvider.Builder.class));
MethodInvocationExpr credsProviderBuilderExpr =
MethodInvocationExpr.builder()
.setStaticReferenceType(FIXED_TYPESTORE.get("GoogleCredentialsProvider"))
.setMethodName("newBuilder")
.build();
credsProviderBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(credsProviderBuilderExpr)
.setMethodName("setScopesToApply")
.setArguments(DEFAULT_SERVICE_SCOPES_VAR_EXPR)
.setReturnType(returnType)
.build();
javaMethods.add(
MethodDefinition.builder()
.setHeaderCommentStatements(
SettingsCommentComposer.DEFAULT_CREDENTIALS_PROVIDER_BUILDER_METHOD_COMMENT)
.setScope(ScopeNode.PUBLIC)
.setIsStatic(true)
.setReturnType(returnType)
.setName("defaultCredentialsProviderBuilder")
.setReturnExpr(credsProviderBuilderExpr)
.build());

javaMethods.add(createDefaultCredentialsProviderBuilderMethod());
javaMethods.add(createDefaultTransportTransportProviderBuilderMethod());
javaMethods.add(createDefaultTransportChannelProviderMethod());
javaMethods.add(createDefaultApiClientHeaderProviderBuilderMethod(service, typeStore));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.google.api.generator.gapic.composer.grpc;

import com.google.api.gax.core.GoogleCredentialsProvider;
import com.google.api.gax.grpc.GaxGrpcProperties;
import com.google.api.gax.grpc.GrpcTransportChannel;
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
Expand All @@ -22,6 +23,7 @@
import com.google.api.generator.engine.ast.ConcreteReference;
import com.google.api.generator.engine.ast.MethodDefinition;
import com.google.api.generator.engine.ast.MethodInvocationExpr;
import com.google.api.generator.engine.ast.PrimitiveValue;
import com.google.api.generator.engine.ast.ScopeNode;
import com.google.api.generator.engine.ast.StringObjectValue;
import com.google.api.generator.engine.ast.TypeNode;
Expand Down Expand Up @@ -94,6 +96,47 @@ protected MethodDefinition createDefaultTransportTransportProviderBuilderMethod(
.build();
}

@Override
protected MethodDefinition createDefaultCredentialsProviderBuilderMethod() {
TypeNode returnType =
TypeNode.withReference(
ConcreteReference.withClazz(GoogleCredentialsProvider.Builder.class));
MethodInvocationExpr credsProviderBuilderExpr =
MethodInvocationExpr.builder()
.setStaticReferenceType(FIXED_TYPESTORE.get("GoogleCredentialsProvider"))
.setMethodName("newBuilder")
.build();
credsProviderBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(credsProviderBuilderExpr)
.setMethodName("setScopesToApply")
.setArguments(DEFAULT_SERVICE_SCOPES_VAR_EXPR)
.setReturnType(returnType)
.build();

// This section is specific to GAPIC clients. It sets UseJwtAccessWithScope value to true to
// enable self signed JWT feature.
credsProviderBuilderExpr =
MethodInvocationExpr.builder()
.setExprReferenceExpr(credsProviderBuilderExpr)
.setMethodName("setUseJwtAccessWithScope")
.setArguments(
ValueExpr.withValue(
PrimitiveValue.builder().setType(TypeNode.BOOLEAN).setValue("true").build()))
.setReturnType(returnType)
.build();

return MethodDefinition.builder()
.setHeaderCommentStatements(
SettingsCommentComposer.DEFAULT_CREDENTIALS_PROVIDER_BUILDER_METHOD_COMMENT)
.setScope(ScopeNode.PUBLIC)
.setIsStatic(true)
.setReturnType(returnType)
.setName("defaultCredentialsProviderBuilder")
.setReturnExpr(credsProviderBuilderExpr)
.build();
}

@Override
protected MethodDefinition createDefaultApiClientHeaderProviderBuilderMethod(
Service service, TypeStore typeStore) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ public class DeprecatedServiceStubSettings extends StubSettings<DeprecatedServic

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ public class EchoStubSettings extends StubSettings<EchoStubSettings> {

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,9 @@ public class LoggingServiceV2StubSettings extends StubSettings<LoggingServiceV2S

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,9 @@ public class PublisherStubSettings extends StubSettings<PublisherStubSettings> {

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,9 @@ public static List<String> getDefaultServiceScopes() {

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ public static List<String> getDefaultServiceScopes() {

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ public static List<String> getDefaultServiceScopes() {

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,9 @@ public static List<String> getDefaultServiceScopes() {

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,9 @@ public static List<String> getDefaultServiceScopes() {

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,9 @@ public static List<String> getDefaultServiceScopes() {

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,9 @@ public static List<String> getDefaultServiceScopes() {

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,9 @@ public static List<String> getDefaultServiceScopes() {

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,9 @@ public static List<String> getDefaultServiceScopes() {

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ public static List<String> getDefaultServiceScopes() {

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ public static List<String> getDefaultServiceScopes() {

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ public static List<String> getDefaultServiceScopes() {

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ public static List<String> getDefaultServiceScopes() {

/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
return GoogleCredentialsProvider.newBuilder()
.setScopesToApply(DEFAULT_SERVICE_SCOPES)
.setUseJwtAccessWithScope(true);
}

/** Returns a builder for the default ChannelProvider for this service. */
Expand Down