Search in sources :

Example 26 with FieldConfig

use of com.google.api.codegen.config.FieldConfig 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)

Example 27 with FieldConfig

use of com.google.api.codegen.config.FieldConfig in project toolkit by googleapis.

the class CSharpGapicSnippetsTransformer method generatePagedRequestAsyncMethod.

private StaticLangApiMethodSnippetView generatePagedRequestAsyncMethod(MethodContext methodContext) {
    StaticLangApiMethodView method = apiMethodTransformer.generatePagedRequestObjectAsyncMethod(methodContext, csharpCommonTransformer.pagedMethodAdditionalParams());
    SurfaceNamer namer = methodContext.getNamer();
    PageStreamingConfig pageStreaming = methodContext.getMethodConfig().getPageStreaming();
    FieldConfig resourceFieldConfig = pageStreaming.getResourcesFieldConfig();
    String callerResponseTypeName = namer.getAndSaveCallerAsyncPagedResponseTypeName(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)

Example 28 with FieldConfig

use of com.google.api.codegen.config.FieldConfig in project toolkit by googleapis.

the class JavaSurfaceTransformer method getIterateMethods.

private List<PagedResponseIterateMethodView> getIterateMethods(MethodContext context) {
    SurfaceNamer namer = context.getNamer();
    List<PagedResponseIterateMethodView> iterateMethods = new ArrayList<>();
    FieldConfig resourceFieldConfig = context.getMethodConfig().getPageStreaming().getResourcesFieldConfig();
    if (context.getFeatureConfig().useResourceNameFormatOption(resourceFieldConfig)) {
        String resourceTypeName = namer.getAndSaveElementResourceTypeName(context.getTypeTable(), resourceFieldConfig);
        String resourceTypeIterateMethodName = namer.getPagedResponseIterateMethod(context.getFeatureConfig(), resourceFieldConfig);
        String resourceTypeGetValuesMethodName = namer.getPageGetValuesMethod(context.getFeatureConfig(), resourceFieldConfig);
        String parseMethodName = namer.getResourceTypeParseMethodName(context.getTypeTable(), resourceFieldConfig);
        PagedResponseIterateMethodView.Builder iterateMethod = PagedResponseIterateMethodView.newBuilder().overloadResourceTypeName(resourceTypeName).overloadResourceTypeParseFunctionName(parseMethodName).overloadResourceTypeIterateMethodName(resourceTypeIterateMethodName).overloadResourceTypeGetValuesMethodName(resourceTypeGetValuesMethodName).iterateMethodName(namer.getPagedResponseIterateMethod()).getValuesMethodName(namer.getPageGetValuesMethod());
        iterateMethods.add(iterateMethod.build());
    }
    return iterateMethods;
}
Also used : FieldConfig(com.google.api.codegen.config.FieldConfig) ArrayList(java.util.ArrayList) PagedResponseIterateMethodView(com.google.api.codegen.viewmodel.PagedResponseIterateMethodView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer)

Example 29 with FieldConfig

use of com.google.api.codegen.config.FieldConfig in project toolkit by googleapis.

the class NodeJSGapicSurfaceTestTransformer method createTestCaseViews.

private List<TestCaseView> createTestCaseViews(GapicInterfaceContext context) {
    ArrayList<TestCaseView> testCaseViews = new ArrayList<>();
    SymbolTable testNameTable = new SymbolTable();
    for (MethodModel method : context.getSupportedMethods()) {
        GapicMethodContext methodContext = context.asRequestMethodContext(method);
        if (methodContext.getMethodConfig().getGrpcStreamingType() == GrpcStreamingType.ClientStreaming) {
            // Issue: https://github.com/googleapis/toolkit/issues/946
            continue;
        }
        Iterable<FieldConfig> fieldConfigs = methodContext.getMethodConfig().getRequiredFieldConfigs();
        InitCodeContext initCodeContext = InitCodeContext.newBuilder().initObjectType(methodContext.getMethodModel().getInputType()).suggestedName(Name.from("request")).initFieldConfigStrings(methodContext.getMethodConfig().getSampleCodeInitFields()).initValueConfigMap(InitCodeTransformer.createCollectionMap(methodContext)).initFields(FieldConfig.toFieldTypeIterable(fieldConfigs)).outputType(InitCodeOutputType.SingleObject).fieldConfigMap(FieldConfig.toFieldConfigMap(fieldConfigs)).valueGenerator(valueGenerator).build();
        testCaseViews.add(testCaseTransformer.createTestCaseView(methodContext, testNameTable, initCodeContext, getMethodType(methodContext.getMethodConfig())));
    }
    return testCaseViews;
}
Also used : MethodModel(com.google.api.codegen.config.MethodModel) GapicMethodContext(com.google.api.codegen.transformer.GapicMethodContext) TestCaseView(com.google.api.codegen.viewmodel.testing.TestCaseView) FieldConfig(com.google.api.codegen.config.FieldConfig) ArrayList(java.util.ArrayList) SymbolTable(com.google.api.codegen.util.SymbolTable) InitCodeContext(com.google.api.codegen.metacode.InitCodeContext)

Example 30 with FieldConfig

use of com.google.api.codegen.config.FieldConfig in project toolkit by googleapis.

the class PhpGapicSurfaceTestTransformer method createTestCaseViews.

private List<TestCaseView> createTestCaseViews(GapicInterfaceContext context) {
    ArrayList<TestCaseView> testCaseViews = new ArrayList<>();
    SymbolTable testNameTable = new SymbolTable();
    for (MethodModel method : context.getSupportedMethods()) {
        GapicMethodContext methodContext = context.asRequestMethodContext(method);
        if (methodContext.getMethodConfig().getGrpcStreamingType() == GrpcStreamingType.ClientStreaming) {
            // Issue: https://github.com/googleapis/toolkit/issues/946
            continue;
        }
        InitCodeOutputType initCodeOutputType = InitCodeOutputType.FieldList;
        if (methodContext.getMethodConfig().getGrpcStreamingType() == GrpcStreamingType.BidiStreaming) {
            initCodeOutputType = InitCodeOutputType.SingleObject;
        }
        ClientMethodType clientMethodType = ClientMethodType.OptionalArrayMethod;
        if (methodContext.getMethodConfig().isLongRunningOperation()) {
            clientMethodType = ClientMethodType.OperationOptionalArrayMethod;
        } else if (methodContext.getMethodConfig().isPageStreaming()) {
            clientMethodType = ClientMethodType.PagedOptionalArrayMethod;
        }
        Iterable<FieldConfig> fieldConfigs = methodContext.getMethodConfig().getRequiredFieldConfigs();
        InitCodeContext initCodeContext = InitCodeContext.newBuilder().initObjectType(methodContext.getMethodModel().getInputType()).suggestedName(Name.from("request")).initFieldConfigStrings(methodContext.getMethodConfig().getSampleCodeInitFields()).initValueConfigMap(InitCodeTransformer.createCollectionMap(methodContext)).initFields(FieldConfig.toFieldTypeIterable(fieldConfigs)).outputType(initCodeOutputType).fieldConfigMap(FieldConfig.toFieldConfigMap(fieldConfigs)).valueGenerator(valueGenerator).build();
        testCaseViews.add(testCaseTransformer.createTestCaseView(methodContext, testNameTable, initCodeContext, clientMethodType));
    }
    return testCaseViews;
}
Also used : MethodModel(com.google.api.codegen.config.MethodModel) GapicMethodContext(com.google.api.codegen.transformer.GapicMethodContext) ClientMethodType(com.google.api.codegen.viewmodel.ClientMethodType) TestCaseView(com.google.api.codegen.viewmodel.testing.TestCaseView) FieldConfig(com.google.api.codegen.config.FieldConfig) ArrayList(java.util.ArrayList) SymbolTable(com.google.api.codegen.util.SymbolTable) InitCodeContext(com.google.api.codegen.metacode.InitCodeContext) InitCodeOutputType(com.google.api.codegen.metacode.InitCodeContext.InitCodeOutputType)

Aggregations

FieldConfig (com.google.api.codegen.config.FieldConfig)30 ArrayList (java.util.ArrayList)14 MethodModel (com.google.api.codegen.config.MethodModel)10 FieldModel (com.google.api.codegen.config.FieldModel)9 PageStreamingConfig (com.google.api.codegen.config.PageStreamingConfig)8 MethodConfig (com.google.api.codegen.config.MethodConfig)6 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)6 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)6 InitCodeContext (com.google.api.codegen.metacode.InitCodeContext)4 InitCodeOutputType (com.google.api.codegen.metacode.InitCodeContext.InitCodeOutputType)4 GapicMethodContext (com.google.api.codegen.transformer.GapicMethodContext)4 SymbolTable (com.google.api.codegen.util.SymbolTable)4 ImmutableList (com.google.common.collect.ImmutableList)4 SingleResourceNameConfig (com.google.api.codegen.config.SingleResourceNameConfig)3 InitCodeNode (com.google.api.codegen.metacode.InitCodeNode)3 InitFieldConfig (com.google.api.codegen.metacode.InitFieldConfig)2 MethodContext (com.google.api.codegen.transformer.MethodContext)2 ClientMethodType (com.google.api.codegen.viewmodel.ClientMethodType)2 InitCodeView (com.google.api.codegen.viewmodel.InitCodeView)2 RequestObjectParamView (com.google.api.codegen.viewmodel.RequestObjectParamView)2