Search in sources :

Example 6 with PageStreamingConfig

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();
}
Also used : StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) FieldConfig(com.google.api.codegen.config.FieldConfig) PageStreamingConfig(com.google.api.codegen.config.PageStreamingConfig) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 7 with PageStreamingConfig

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();
}
Also used : MethodModel(com.google.api.codegen.config.MethodModel) FieldConfig(com.google.api.codegen.config.FieldConfig) PageStreamingConfig(com.google.api.codegen.config.PageStreamingConfig) PagedListResponseFactoryClassView(com.google.api.codegen.viewmodel.PagedListResponseFactoryClassView) FieldModel(com.google.api.codegen.config.FieldModel)

Example 8 with PageStreamingConfig

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();
}
Also used : Builder(com.google.api.codegen.viewmodel.StaticLangApiMethodView.Builder) MethodModel(com.google.api.codegen.config.MethodModel) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) UnpagedListCallableMethodDetailView(com.google.api.codegen.viewmodel.UnpagedListCallableMethodDetailView) FieldConfig(com.google.api.codegen.config.FieldConfig) PageStreamingConfig(com.google.api.codegen.config.PageStreamingConfig)

Example 9 with PageStreamingConfig

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;
    }
}
Also used : MethodModel(com.google.api.codegen.config.MethodModel) FieldConfig(com.google.api.codegen.config.FieldConfig) PageStreamingConfig(com.google.api.codegen.config.PageStreamingConfig) FieldModel(com.google.api.codegen.config.FieldModel)

Example 10 with PageStreamingConfig

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();
}
Also used : StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) FieldConfig(com.google.api.codegen.config.FieldConfig) PageStreamingConfig(com.google.api.codegen.config.PageStreamingConfig) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Aggregations

PageStreamingConfig (com.google.api.codegen.config.PageStreamingConfig)11 FieldConfig (com.google.api.codegen.config.FieldConfig)8 MethodModel (com.google.api.codegen.config.MethodModel)5 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)5 FieldModel (com.google.api.codegen.config.FieldModel)4 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)4 MethodConfig (com.google.api.codegen.config.MethodConfig)2 BatchingConfig (com.google.api.codegen.config.BatchingConfig)1 DiscoveryMethodModel (com.google.api.codegen.config.DiscoveryMethodModel)1 GrpcStreamingConfig (com.google.api.codegen.config.GrpcStreamingConfig)1 InitCodeLineType (com.google.api.codegen.metacode.InitCodeLineType)1 InitCodeNode (com.google.api.codegen.metacode.InitCodeNode)1 ApiCallableView (com.google.api.codegen.viewmodel.ApiCallableView)1 PageStreamingDescriptorClassView (com.google.api.codegen.viewmodel.PageStreamingDescriptorClassView)1 PageStreamingDescriptorView (com.google.api.codegen.viewmodel.PageStreamingDescriptorView)1 PagedListResponseFactoryClassView (com.google.api.codegen.viewmodel.PagedListResponseFactoryClassView)1 Builder (com.google.api.codegen.viewmodel.StaticLangApiMethodView.Builder)1 UnpagedListCallableMethodDetailView (com.google.api.codegen.viewmodel.UnpagedListCallableMethodDetailView)1 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1