Skip to content

Commit

Permalink
Revert "fix: update regionTag to use service name (#1047)"
Browse files Browse the repository at this point in the history
This reverts commit 38010fd.
  • Loading branch information
emmileaf authored Nov 3, 2022
1 parent 172fd01 commit 1e3a935
Show file tree
Hide file tree
Showing 874 changed files with 1,761 additions and 1,815 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import com.google.api.generator.engine.ast.VariableExpr;
import com.google.api.generator.engine.ast.WhileStatement;
import com.google.api.generator.gapic.composer.defaultvalue.DefaultValueComposer;
import com.google.api.generator.gapic.composer.utils.ClassNames;
import com.google.api.generator.gapic.model.Field;
import com.google.api.generator.gapic.model.Message;
import com.google.api.generator.gapic.model.Method;
Expand Down Expand Up @@ -125,8 +124,7 @@ private static Sample composeUnaryOrLroCallableSample(

RegionTag regionTag =
RegionTag.builder()
.setServiceName(
ClassNames.getPureServiceName(clientVarExpr.variable().identifier().name()))
.setServiceName(clientVarExpr.variable().identifier().name())
.setRpcName(method.name())
.setIsAsynchronous(true)
.build();
Expand Down Expand Up @@ -280,8 +278,7 @@ private static Sample composePagedCallableSample(

RegionTag regionTag =
RegionTag.builder()
.setServiceName(
ClassNames.getPureServiceName(clientVarExpr.variable().identifier().name()))
.setServiceName(clientVarExpr.variable().identifier().name())
.setRpcName(method.name())
.setOverloadDisambiguation("Paged")
.setIsAsynchronous(true)
Expand Down Expand Up @@ -397,7 +394,7 @@ public static Sample composeLroCallableMethod(

RegionTag regionTag =
RegionTag.builder()
.setServiceName(ClassNames.getPureServiceName(clientType.reference().name()))
.setServiceName(clientType.reference().name())
.setRpcName(method.name())
.setIsAsynchronous(true)
.setOverloadDisambiguation("LRO")
Expand Down Expand Up @@ -534,7 +531,7 @@ public static Sample composePagedCallableMethod(

RegionTag regionTag =
RegionTag.builder()
.setServiceName(ClassNames.getPureServiceName(clientType.reference().name()))
.setServiceName(clientType.reference().name())
.setRpcName(method.name())
.setIsAsynchronous(true)
.build();
Expand Down Expand Up @@ -720,8 +717,7 @@ private static Sample composeStreamServerSample(

RegionTag regionTag =
RegionTag.builder()
.setServiceName(
ClassNames.getPureServiceName(clientVarExpr.variable().identifier().name()))
.setServiceName(clientVarExpr.variable().identifier().name())
.setRpcName(method.name())
.setIsAsynchronous(true)
.build();
Expand Down Expand Up @@ -800,8 +796,7 @@ private static Sample composeStreamBidiSample(

RegionTag regionTag =
RegionTag.builder()
.setServiceName(
ClassNames.getPureServiceName(clientVarExpr.variable().identifier().name()))
.setServiceName(clientVarExpr.variable().identifier().name())
.setRpcName(method.name())
.setIsAsynchronous(true)
.build();
Expand Down Expand Up @@ -933,8 +928,7 @@ private static Sample composeStreamClientSample(

RegionTag regionTag =
RegionTag.builder()
.setServiceName(
ClassNames.getPureServiceName(clientVarExpr.variable().identifier().name()))
.setServiceName(clientVarExpr.variable().identifier().name())
.setRpcName(method.name())
.setIsAsynchronous(true)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.google.api.generator.engine.ast.Variable;
import com.google.api.generator.engine.ast.VariableExpr;
import com.google.api.generator.gapic.composer.defaultvalue.DefaultValueComposer;
import com.google.api.generator.gapic.composer.utils.ClassNames;
import com.google.api.generator.gapic.model.HttpBindings;
import com.google.api.generator.gapic.model.Message;
import com.google.api.generator.gapic.model.Method;
Expand Down Expand Up @@ -207,7 +206,7 @@ public static Sample composeSetCredentialsSample(TypeNode clientType, TypeNode s
ExprStatement.withExpr(initSettingsVarExpr), ExprStatement.withExpr(initClientVarExpr));
RegionTag regionTag =
RegionTag.builder()
.setServiceName(ClassNames.getPureServiceName(clientName))
.setServiceName(clientName)
.setRpcName(rpcName)
.setOverloadDisambiguation("setCredentialsProvider")
.build();
Expand Down Expand Up @@ -274,7 +273,7 @@ public static Sample composeSetEndpointSample(TypeNode clientType, TypeNode sett
.build();
RegionTag regionTag =
RegionTag.builder()
.setServiceName(ClassNames.getPureServiceName(clientName))
.setServiceName(clientName)
.setRpcName(rpcName)
.setOverloadDisambiguation("setEndpoint")
.build();
Expand Down Expand Up @@ -347,7 +346,7 @@ public static Sample composeTransportSample(
ExprStatement.withExpr(initSettingsVarExpr), ExprStatement.withExpr(initClientVarExpr));
RegionTag regionTag =
RegionTag.builder()
.setServiceName(ClassNames.getPureServiceName(clientName))
.setServiceName(clientName)
.setRpcName(rpcName)
.setOverloadDisambiguation("setCredentialsProvider")
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.google.api.generator.engine.ast.Variable;
import com.google.api.generator.engine.ast.VariableExpr;
import com.google.api.generator.gapic.composer.defaultvalue.DefaultValueComposer;
import com.google.api.generator.gapic.composer.utils.ClassNames;
import com.google.api.generator.gapic.model.Field;
import com.google.api.generator.gapic.model.Message;
import com.google.api.generator.gapic.model.Method;
Expand Down Expand Up @@ -58,8 +57,7 @@ public static Sample composeEmptyServiceSample(TypeNode clientType) {

RegionTag regionTag =
RegionTag.builder()
.setServiceName(
ClassNames.getPureServiceName(clientVarExpr.variable().identifier().name()))
.setServiceName(clientVarExpr.variable().identifier().name())
.setRpcName("emtpy")
.build();

Expand Down Expand Up @@ -171,8 +169,7 @@ static Sample composeSample(

RegionTag regionTag =
RegionTag.builder()
.setServiceName(
ClassNames.getPureServiceName(clientVarExpr.variable().identifier().name()))
.setServiceName(clientVarExpr.variable().identifier().name())
.setRpcName(method.name())
.setOverloadDisambiguation(
SampleComposerUtil.createOverloadDisambiguation(rpcMethodArgVarExprs))
Expand Down Expand Up @@ -246,8 +243,7 @@ static Sample composePagedSample(

RegionTag regionTag =
RegionTag.builder()
.setServiceName(
ClassNames.getPureServiceName(clientVarExpr.variable().identifier().name()))
.setServiceName(clientVarExpr.variable().identifier().name())
.setRpcName(method.name())
.setOverloadDisambiguation(
SampleComposerUtil.createOverloadDisambiguation(rpcMethodArgVarExprs))
Expand Down Expand Up @@ -297,8 +293,7 @@ static Sample composeLroSample(
}
RegionTag regionTag =
RegionTag.builder()
.setServiceName(
ClassNames.getPureServiceName(clientVarExpr.variable().identifier().name()))
.setServiceName(clientVarExpr.variable().identifier().name())
.setRpcName(method.name())
.setOverloadDisambiguation(
SampleComposerUtil.createOverloadDisambiguation(rpcMethodArgVarExprs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
package com.google.api.generator.gapic.composer.utils;

import com.google.api.generator.gapic.model.Service;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -26,8 +24,7 @@ public class ClassNames {
// Using constants since many of these class names are used often.
private static final String MOCK_SERVICE_CLASS_NAME_PATTERN = "Mock%s";
private static final String MOCK_SERVICE_IMPL_CLASS_NAME_PATTERN = "Mock%sImpl";
private static final String CLIENT_SUFFIX = "Client";
private static final String SERVICE_CLIENT_CLASS_NAME_PATTERN = "%s" + CLIENT_SUFFIX;
private static final String SERVICE_CLIENT_CLASS_NAME_PATTERN = "%sClient";
private static final String SERVICE_CLIENT_TEST_CLASS_NAME_PATTERN = "%sClientTest";
private static final String SERVICE_CLIENT_TRANSPORT_TEST_CLASS_NAME_PATTERN = "%sClient%sTest";
private static final String SERVICE_SETTINGS_CLASS_NAME_PATTERN = "%sSettings";
Expand Down Expand Up @@ -123,11 +120,4 @@ private static String monolithBackwardsCompatibleName(String rawServiceName) {
? rawServiceName.replace("IAM", "Iam")
: rawServiceName;
}

// For region tags, the service name should not include `Client` in the name
public static String getPureServiceName(String serviceClassName) {
return String.format(
"%s",
Iterables.getFirst(Splitter.on(CLIENT_SUFFIX).split(serviceClassName), serviceClassName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ public String generate() {
if (!apiVersion().isEmpty()) {
rt = rt + apiVersion() + "_";
}
rt = rt.toLowerCase() + "generated_" + serviceName() + "_" + rpcName();
// TODO: @alicejli overloadDisambiguation will need to be updated to match other languages
rt = rt + "generated_" + serviceName() + "_" + rpcName();
if (!overloadDisambiguation().isEmpty()) {
rt = rt + "_" + overloadDisambiguation();
}
Expand All @@ -149,7 +148,7 @@ public String generate() {
rt = rt + "_sync";
}

return rt;
return rt.toLowerCase();
}

public static CommentStatement generateTag(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.bookshop.v1beta1.samples;

// [START goldensample_generated_Bookshop_GetBook_async]
// [START goldensample_generated_bookshopclient_getbook_async]
import com.google.api.core.ApiFuture;
import com.google.bookshop.v1beta1.Book;
import com.google.bookshop.v1beta1.BookshopClient;
Expand Down Expand Up @@ -48,4 +48,4 @@ public class AsyncGetBook {
}
}
}
// [END goldensample_generated_Bookshop_GetBook_async]
// [END goldensample_generated_bookshopclient_getbook_async]
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.bookshop.v1beta1.samples;

// [START goldensample_generated_Bookshop_Create_SetCredentialsProvider_sync]
// [START goldensample_generated_bookshopclient_create_setcredentialsprovider_sync]
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.bookshop.v1beta1.BookshopClient;
import com.google.bookshop.v1beta1.BookshopSettings;
Expand All @@ -41,4 +41,4 @@ public class SyncCreateSetCredentialsProvider {
BookshopClient bookshopClient = BookshopClient.create(bookshopSettings);
}
}
// [END goldensample_generated_Bookshop_Create_SetCredentialsProvider_sync]
// [END goldensample_generated_bookshopclient_create_setcredentialsprovider_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.bookshop.v1beta1.samples;

// [START goldensample_generated_Bookshop_Create_SetEndpoint_sync]
// [START goldensample_generated_bookshopclient_create_setendpoint_sync]
import com.google.bookshop.v1beta1.BookshopClient;
import com.google.bookshop.v1beta1.BookshopSettings;
import com.google.bookshop.v1beta1.myEndpoint;
Expand All @@ -38,4 +38,4 @@ public class SyncCreateSetEndpoint {
BookshopClient bookshopClient = BookshopClient.create(bookshopSettings);
}
}
// [END goldensample_generated_Bookshop_Create_SetEndpoint_sync]
// [END goldensample_generated_bookshopclient_create_setendpoint_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.bookshop.v1beta1.samples;

// [START goldensample_generated_Bookshop_GetBook_sync]
// [START goldensample_generated_bookshopclient_getbook_sync]
import com.google.bookshop.v1beta1.Book;
import com.google.bookshop.v1beta1.BookshopClient;
import com.google.bookshop.v1beta1.GetBookRequest;
Expand Down Expand Up @@ -45,4 +45,4 @@ public class SyncGetBook {
}
}
}
// [END goldensample_generated_Bookshop_GetBook_sync]
// [END goldensample_generated_bookshopclient_getbook_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.bookshop.v1beta1.samples;

// [START goldensample_generated_Bookshop_GetBook_IntListbook_sync]
// [START goldensample_generated_bookshopclient_getbook_intlistbook_sync]
import com.google.bookshop.v1beta1.Book;
import com.google.bookshop.v1beta1.BookshopClient;
import java.util.ArrayList;
Expand All @@ -41,4 +41,4 @@ public class SyncGetBookIntListbook {
}
}
}
// [END goldensample_generated_Bookshop_GetBook_IntListbook_sync]
// [END goldensample_generated_bookshopclient_getbook_intlistbook_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.bookshop.v1beta1.samples;

// [START goldensample_generated_Bookshop_GetBook_StringListbook_sync]
// [START goldensample_generated_bookshopclient_getbook_stringlistbook_sync]
import com.google.bookshop.v1beta1.Book;
import com.google.bookshop.v1beta1.BookshopClient;
import java.util.ArrayList;
Expand All @@ -41,4 +41,4 @@ public class SyncGetBookStringListbook {
}
}
}
// [END goldensample_generated_Bookshop_GetBook_StringListbook_sync]
// [END goldensample_generated_bookshopclient_getbook_stringlistbook_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.testdata.v1.samples;

// [START goldensample_generated_DeprecatedService_FastFibonacci_async]
// [START goldensample_generated_deprecatedserviceclient_fastfibonacci_async]
import com.google.api.core.ApiFuture;
import com.google.protobuf.Empty;
import com.google.testdata.v1.DeprecatedServiceClient;
Expand All @@ -42,4 +42,4 @@ public class AsyncFastFibonacci {
}
}
}
// [END goldensample_generated_DeprecatedService_FastFibonacci_async]
// [END goldensample_generated_deprecatedserviceclient_fastfibonacci_async]
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.testdata.v1.samples;

// [START goldensample_generated_DeprecatedService_SlowFibonacci_async]
// [START goldensample_generated_deprecatedserviceclient_slowfibonacci_async]
import com.google.api.core.ApiFuture;
import com.google.protobuf.Empty;
import com.google.testdata.v1.DeprecatedServiceClient;
Expand All @@ -42,4 +42,4 @@ public class AsyncSlowFibonacci {
}
}
}
// [END goldensample_generated_DeprecatedService_SlowFibonacci_async]
// [END goldensample_generated_deprecatedserviceclient_slowfibonacci_async]
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.testdata.v1.samples;

// [START goldensample_generated_DeprecatedService_Create_SetCredentialsProvider_sync]
// [START goldensample_generated_deprecatedserviceclient_create_setcredentialsprovider_sync]
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.testdata.v1.DeprecatedServiceClient;
import com.google.testdata.v1.DeprecatedServiceSettings;
Expand All @@ -42,4 +42,4 @@ public class SyncCreateSetCredentialsProvider {
DeprecatedServiceClient.create(deprecatedServiceSettings);
}
}
// [END goldensample_generated_DeprecatedService_Create_SetCredentialsProvider_sync]
// [END goldensample_generated_deprecatedserviceclient_create_setcredentialsprovider_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.testdata.v1.samples;

// [START goldensample_generated_DeprecatedService_Create_SetEndpoint_sync]
// [START goldensample_generated_deprecatedserviceclient_create_setendpoint_sync]
import com.google.testdata.v1.DeprecatedServiceClient;
import com.google.testdata.v1.DeprecatedServiceSettings;
import com.google.testdata.v1.myEndpoint;
Expand All @@ -39,4 +39,4 @@ public class SyncCreateSetEndpoint {
DeprecatedServiceClient.create(deprecatedServiceSettings);
}
}
// [END goldensample_generated_DeprecatedService_Create_SetEndpoint_sync]
// [END goldensample_generated_deprecatedserviceclient_create_setendpoint_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.testdata.v1.samples;

// [START goldensample_generated_DeprecatedService_FastFibonacci_sync]
// [START goldensample_generated_deprecatedserviceclient_fastfibonacci_sync]
import com.google.protobuf.Empty;
import com.google.testdata.v1.DeprecatedServiceClient;
import com.google.testdata.v1.FibonacciRequest;
Expand All @@ -39,4 +39,4 @@ public class SyncFastFibonacci {
}
}
}
// [END goldensample_generated_DeprecatedService_FastFibonacci_sync]
// [END goldensample_generated_deprecatedserviceclient_fastfibonacci_sync]
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.testdata.v1.samples;

// [START goldensample_generated_DeprecatedService_SlowFibonacci_sync]
// [START goldensample_generated_deprecatedserviceclient_slowfibonacci_sync]
import com.google.protobuf.Empty;
import com.google.testdata.v1.DeprecatedServiceClient;
import com.google.testdata.v1.FibonacciRequest;
Expand All @@ -39,4 +39,4 @@ public class SyncSlowFibonacci {
}
}
}
// [END goldensample_generated_DeprecatedService_SlowFibonacci_sync]
// [END goldensample_generated_deprecatedserviceclient_slowfibonacci_sync]
Loading

0 comments on commit 1e3a935

Please sign in to comment.