use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class JavaSurfaceTransformer method generateRpcStubClass.
private StaticLangRpcStubView generateRpcStubClass(InterfaceContext context, GapicProductConfig productConfig) {
SurfaceNamer namer = context.getNamer();
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
addRpcStubImports(context);
// Stub class has different default package name from method, request, and resource classes.
InterfaceContext apiMethodsContext = context.withNewTypeTable(context.getNamer().getRootPackageName());
List<StaticLangApiMethodView> methods = generateApiMethods(apiMethodsContext);
StaticLangRpcStubView.Builder stubClass = StaticLangRpcStubView.newBuilder();
stubClass.doc(serviceTransformer.generateServiceDoc(context, null, productConfig));
String name = namer.getApiRpcStubClassName(interfaceConfig.getInterfaceModel(), productConfig.getTransportProtocol());
stubClass.releaseLevelAnnotation(namer.getReleaseAnnotation(ReleaseLevel.BETA));
stubClass.name(name);
stubClass.parentName(namer.getApiStubInterfaceName(interfaceConfig));
stubClass.settingsClassName(getAndSaveNicknameForRootType(apiMethodsContext, namer.getApiSettingsClassName(interfaceConfig)));
stubClass.stubSettingsClassName(getAndSaveNicknameForStubType(apiMethodsContext, namer.getApiStubSettingsClassName(interfaceConfig)));
stubClass.callableFactoryClassName(getAndSaveNicknameForStubType(apiMethodsContext, namer.getCallableFactoryClassName(interfaceConfig, productConfig.getTransportProtocol())));
stubClass.methodDescriptors(apiCallableTransformer.generateMethodDescriptors(apiMethodsContext));
stubClass.apiCallables(apiCallableTransformer.generateStaticLangApiCallables(apiMethodsContext));
stubClass.callableMethods(filterIncludeCallableMethods(methods));
stubClass.hasDefaultInstance(interfaceConfig.hasDefaultInstance());
stubClass.hasLongRunningOperations(interfaceConfig.hasLongRunningOperations());
for (TypeAlias alias : apiMethodsContext.getImportTypeTable().getTypeTable().getAllImports().values()) {
context.getImportTypeTable().getAndSaveNicknameFor(alias);
}
return stubClass.build();
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generateOperationCallableMethod.
public StaticLangApiMethodView generateOperationCallableMethod(MethodContext context) {
MethodModel method = context.getMethodModel();
SurfaceNamer namer = context.getNamer();
StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
setCommonFields(context, methodViewBuilder);
methodViewBuilder.name(namer.getOperationCallableMethodName(method));
methodViewBuilder.exampleName(context.getNamer().getOperationCallableMethodExampleName(method));
setCallableMethodFields(context, namer.getOperationCallableName(method), methodViewBuilder);
TypeModel returnType = context.getMethodConfig().getLongRunningConfig().getReturnType();
methodViewBuilder.responseTypeName(context.getTypeTable().getAndSaveNicknameFor(returnType));
methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context));
return methodViewBuilder.type(ClientMethodType.OperationCallableMethod).build();
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generateUnpagedListCallableMethod.
public StaticLangApiMethodView generateUnpagedListCallableMethod(MethodContext context) {
MethodModel method = context.getMethodModel();
SurfaceNamer namer = context.getNamer();
StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
setCommonFields(context, methodViewBuilder);
methodViewBuilder.name(namer.getCallableMethodName(method));
methodViewBuilder.exampleName(namer.getCallableMethodExampleName(method));
setListMethodFields(context, Synchronicity.Sync, methodViewBuilder);
setCallableMethodFields(context, namer.getCallableName(method), methodViewBuilder);
String getResourceListCallName = namer.getFieldGetFunctionName(context.getFeatureConfig(), context.getMethodConfig().getPageStreaming().getResourcesFieldConfig());
String resourceListParseFunction = "";
PageStreamingConfig pageStreaming = context.getMethodConfig().getPageStreaming();
FieldConfig resourceFieldConfig = pageStreaming.getResourcesFieldConfig();
if (context.getFeatureConfig().useResourceNameConverters(resourceFieldConfig)) {
resourceListParseFunction = namer.getResourceTypeParseListMethodName(context.getTypeTable(), resourceFieldConfig);
}
UnpagedListCallableMethodDetailView unpagedListCallableDetails = UnpagedListCallableMethodDetailView.newBuilder().resourceListGetFunction(getResourceListCallName).resourceListParseFunction(resourceListParseFunction).build();
methodViewBuilder.unpagedListCallableMethod(unpagedListCallableDetails);
methodViewBuilder.responseTypeName(context.getMethodModel().getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer()));
return methodViewBuilder.type(ClientMethodType.UnpagedListCallableMethod).build();
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generateRequestObjectAsyncMethod.
public StaticLangApiMethodView generateRequestObjectAsyncMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams, ClientMethodType type) {
MethodModel method = context.getMethodModel();
SurfaceNamer namer = context.getNamer();
StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
setCommonFields(context, methodViewBuilder);
methodViewBuilder.name(namer.getAsyncApiMethodName(method, context.getMethodConfig().getVisibility()));
methodViewBuilder.exampleName(namer.getAsyncApiMethodExampleName(method));
setRequestObjectMethodFields(context, namer.getCallableAsyncMethodName(method), Synchronicity.Async, additionalParams, methodViewBuilder);
setStaticLangAsyncReturnTypeName(context, methodViewBuilder);
return methodViewBuilder.type(type).build();
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generatePagedRequestObjectMethod.
public StaticLangApiMethodView generatePagedRequestObjectMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams) {
MethodModel method = context.getMethodModel();
SurfaceNamer namer = context.getNamer();
StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
setCommonFields(context, methodViewBuilder);
methodViewBuilder.name(namer.getApiMethodName(method, context.getMethodConfig().getVisibility()));
methodViewBuilder.exampleName(namer.getApiMethodExampleName(context.getInterfaceConfig(), method));
setListMethodFields(context, Synchronicity.Sync, methodViewBuilder);
setRequestObjectMethodFields(context, namer.getPagedCallableMethodName(method), Synchronicity.Sync, additionalParams, methodViewBuilder);
return methodViewBuilder.type(ClientMethodType.PagedRequestObjectMethod).build();
}
Aggregations