use of com.google.api.codegen.config.PageStreamingConfig in project toolkit by googleapis.
the class CSharpGapicSnippetsTransformer method generatePagedFlattenedMethod.
private StaticLangApiMethodSnippetView generatePagedFlattenedMethod(MethodContext methodContext, String suffix, boolean requiresNamedArguments) {
StaticLangApiMethodView method = apiMethodTransformer.generatePagedFlattenedMethod(methodContext, csharpCommonTransformer.pagedMethodAdditionalParams());
SurfaceNamer namer = methodContext.getNamer();
PageStreamingConfig pageStreaming = methodContext.getMethodConfig().getPageStreaming();
FieldConfig resourceFieldConfig = pageStreaming.getResourcesFieldConfig();
String callerResponseTypeName = namer.getAndSaveCallerPagedResponseTypeName(methodContext, resourceFieldConfig);
return StaticLangApiMethodSnippetView.newBuilder().method(method).snippetMethodName(method.name() + suffix).callerResponseTypeName(callerResponseTypeName).apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())).apiVariableName(method.apiVariableName()).requiresNamedArguments(requiresNamedArguments).build();
}
use of com.google.api.codegen.config.PageStreamingConfig in project toolkit by googleapis.
the class PageStreamingTransformer method generateFactoryClass.
private PagedListResponseFactoryClassView generateFactoryClass(MethodContext context) {
SurfaceNamer namer = context.getNamer();
MethodModel method = context.getMethodModel();
ImportTypeTable typeTable = context.getTypeTable();
PageStreamingConfig pageStreaming = context.getMethodConfig().getPageStreaming();
FieldModel resourceField = pageStreaming.getResourcesField();
FieldConfig resourceFieldConfig = pageStreaming.getResourcesFieldConfig();
PagedListResponseFactoryClassView.Builder factory = PagedListResponseFactoryClassView.newBuilder();
factory.name(namer.getPagedListResponseFactoryConstName(method));
factory.requestTypeName(method.getAndSaveRequestTypeName(typeTable, namer));
factory.responseTypeName(method.getAndSaveResponseTypeName(typeTable, namer));
factory.resourceTypeName(typeTable.getAndSaveNicknameForElementType(resourceField));
factory.pagedListResponseTypeName(namer.getAndSavePagedResponseTypeName(context, resourceFieldConfig));
factory.pageStreamingDescriptorName(namer.getPageStreamingDescriptorConstName(method));
return factory.build();
}
use of com.google.api.codegen.config.PageStreamingConfig 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.config.PageStreamingConfig in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method setListMethodFields.
private void setListMethodFields(MethodContext context, Synchronicity synchronicity, StaticLangApiMethodView.Builder methodViewBuilder) {
MethodModel method = context.getMethodModel();
ImportTypeTable typeTable = context.getTypeTable();
SurfaceNamer namer = context.getNamer();
PageStreamingConfig pageStreaming = context.getMethodConfig().getPageStreaming();
String requestTypeName = method.getAndSaveRequestTypeName(context.getTypeTable(), context.getNamer());
String responseTypeName = method.getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer());
FieldConfig resourceFieldConfig = pageStreaming.getResourcesFieldConfig();
FieldModel resourceField = resourceFieldConfig.getField();
String resourceTypeName;
if (context.getFeatureConfig().useResourceNameFormatOption(resourceFieldConfig)) {
resourceTypeName = namer.getAndSaveElementResourceTypeName(typeTable, resourceFieldConfig);
} else {
resourceTypeName = typeTable.getAndSaveNicknameForElementType(resourceField);
}
String iterateMethodName = context.getNamer().getPagedResponseIterateMethod(context.getFeatureConfig(), resourceFieldConfig);
String resourceFieldName = context.getNamer().getFieldName(resourceField);
List<String> resourceFieldGetFunctionNames = resourceField.getPagedResponseResourceMethods(context.getFeatureConfig(), resourceFieldConfig, context.getNamer());
methodViewBuilder.listMethod(ListMethodDetailView.newBuilder().requestTypeName(requestTypeName).responseTypeName(responseTypeName).resourceTypeName(resourceTypeName).iterateMethodName(iterateMethodName).resourceFieldName(resourceFieldName).resourcesFieldGetFunctions(resourceFieldGetFunctionNames).build());
switch(synchronicity) {
case Sync:
methodViewBuilder.responseTypeName(namer.getAndSavePagedResponseTypeName(context, resourceFieldConfig));
break;
case Async:
methodViewBuilder.responseTypeName(namer.getAndSaveAsyncPagedResponseTypeName(context, resourceFieldConfig));
break;
}
}
use of com.google.api.codegen.config.PageStreamingConfig in project toolkit by googleapis.
the class CSharpGapicSnippetsTransformer method generatePagedRequestMethod.
private StaticLangApiMethodSnippetView generatePagedRequestMethod(MethodContext methodContext) {
StaticLangApiMethodView method = apiMethodTransformer.generatePagedRequestObjectMethod(methodContext, csharpCommonTransformer.pagedMethodAdditionalParams());
SurfaceNamer namer = methodContext.getNamer();
PageStreamingConfig pageStreaming = methodContext.getMethodConfig().getPageStreaming();
FieldConfig resourceFieldConfig = pageStreaming.getResourcesFieldConfig();
String callerResponseTypeName = namer.getAndSaveCallerPagedResponseTypeName(methodContext, resourceFieldConfig);
return StaticLangApiMethodSnippetView.newBuilder().method(method).snippetMethodName(method.name() + "_RequestObject").callerResponseTypeName(callerResponseTypeName).apiClassName(namer.getApiWrapperClassName(methodContext.getInterfaceConfig())).apiVariableName(method.apiVariableName()).build();
}
Aggregations