Search in sources :

Example 1 with MethodConfig

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

the class JavaDiscoGapicRequestToViewTransformer method getRequestObjectParams.

private RequestObjectParamView getRequestObjectParams(DiscoGapicInterfaceContext context, MethodModel method) {
    MethodConfig methodConfig = context.getMethodConfig(method);
    // Generate the ResourceName methods.
    if (methodConfig.isFlattening()) {
        for (FlatteningConfig flatteningGroup : methodConfig.getFlatteningConfigs()) {
            MethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup);
            Iterable<FieldConfig> fieldConfigs = flattenedMethodContext.getFlatteningConfig().getFlattenedFieldConfigs().values();
            for (FieldConfig fieldConfig : fieldConfigs) {
                if (context.getFeatureConfig().useResourceNameFormatOption(fieldConfig)) {
                    return resourceObjectTransformer.generateRequestObjectParam(flattenedMethodContext, fieldConfig);
                }
            }
        }
    }
    return null;
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) FieldConfig(com.google.api.codegen.config.FieldConfig) MethodContext(com.google.api.codegen.transformer.MethodContext) FlatteningConfig(com.google.api.codegen.config.FlatteningConfig)

Example 2 with MethodConfig

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

the class ApiCallableTransformer method generateApiCallableSettings.

public List<ApiCallSettingsView> generateApiCallableSettings(MethodContext context) {
    List<ApiCallSettingsView> settings = new ArrayList<>();
    MethodConfig methodConfig = context.getMethodConfig();
    if (methodConfig.isGrpcStreaming()) {
        settings.add(generateApiCallableSettings(context, ApiCallableImplType.of(methodConfig.getGrpcStreamingType())));
    } else if (methodConfig.isPageStreaming()) {
        settings.add(generateApiCallableSettings(context, ApiCallableImplType.PagedApiCallable));
    } else if (methodConfig.isBatching()) {
        settings.add(generateApiCallableSettings(context, ApiCallableImplType.BatchingApiCallable));
    } else if (methodConfig.isLongRunningOperation()) {
        if (context.getFeatureConfig().enableRawOperationCallSettings()) {
            settings.add(generateApiCallableSettings(context, ApiCallableImplType.SimpleApiCallable));
        }
        settings.add(generateApiCallableSettings(context, ApiCallableImplType.OperationApiCallable));
    } else {
        settings.add(generateApiCallableSettings(context, ApiCallableImplType.SimpleApiCallable));
    }
    return settings;
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) ArrayList(java.util.ArrayList) ApiCallSettingsView(com.google.api.codegen.viewmodel.ApiCallSettingsView)

Example 3 with MethodConfig

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

the class ApiCallableTransformer method generatePagedApiCallable.

private ApiCallableView generatePagedApiCallable(MethodContext context) {
    MethodConfig methodConfig = context.getMethodConfig();
    SurfaceNamer namer = context.getNamer();
    MethodModel method = context.getMethodModel();
    PageStreamingConfig pageStreaming = methodConfig.getPageStreaming();
    ApiCallableView.Builder pagedApiCallableBuilder = ApiCallableView.newBuilder();
    pagedApiCallableBuilder.type(ApiCallableImplType.PagedApiCallable);
    pagedApiCallableBuilder.interfaceTypeName(namer.getApiCallableTypeName(ServiceMethodType.UnaryMethod));
    String pagedResponseTypeName = namer.getAndSavePagedResponseTypeName(context, pageStreaming.getResourcesFieldConfig());
    pagedApiCallableBuilder.requestTypeName(method.getAndSaveRequestTypeName(context.getTypeTable(), context.getNamer()));
    pagedApiCallableBuilder.responseTypeName(pagedResponseTypeName);
    pagedApiCallableBuilder.name(namer.getPagedCallableName(method));
    pagedApiCallableBuilder.methodName(namer.getApiMethodName(method, context.getMethodConfig().getVisibility()));
    pagedApiCallableBuilder.asyncMethodName(namer.getAsyncApiMethodName(method, VisibilityConfig.PUBLIC));
    pagedApiCallableBuilder.memberName(namer.getSettingsMemberName(method));
    pagedApiCallableBuilder.settingsFunctionName(namer.getSettingsFunctionName(method));
    pagedApiCallableBuilder.grpcClientVarName(namer.getReroutedGrpcClientVarName(methodConfig));
    setCommonApiCallableFields(context, pagedApiCallableBuilder);
    return pagedApiCallableBuilder.build();
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) MethodModel(com.google.api.codegen.config.MethodModel) DiscoveryMethodModel(com.google.api.codegen.config.DiscoveryMethodModel) ApiCallableView(com.google.api.codegen.viewmodel.ApiCallableView) PageStreamingConfig(com.google.api.codegen.config.PageStreamingConfig)

Example 4 with MethodConfig

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

the class DiscoGapicInterfaceContext method createWithInterface.

public static DiscoGapicInterfaceContext createWithInterface(InterfaceModel interfaceModel, GapicProductConfig productConfig, ImportTypeTable typeTable, SurfaceNamer namer, FeatureConfig featureConfig) {
    Preconditions.checkArgument(typeTable instanceof SchemaTypeTable);
    ImmutableList.Builder<MethodModel> interfaceMethods = new ImmutableList.Builder<>();
    for (MethodConfig method : productConfig.getInterfaceConfig(interfaceModel.getFullName()).getMethodConfigs()) {
        interfaceMethods.add(method.getMethodModel());
    }
    return new AutoValue_DiscoGapicInterfaceContext(productConfig, (SchemaTypeTable) typeTable, new DiscoGapicNamer(), (DiscoInterfaceModel) interfaceModel, namer, featureConfig);
}
Also used : DiscoGapicMethodConfig(com.google.api.codegen.config.DiscoGapicMethodConfig) MethodConfig(com.google.api.codegen.config.MethodConfig) DiscoveryMethodModel(com.google.api.codegen.config.DiscoveryMethodModel) MethodModel(com.google.api.codegen.config.MethodModel) ImmutableList(com.google.common.collect.ImmutableList) DiscoGapicNamer(com.google.api.codegen.discogapic.transformer.DiscoGapicNamer)

Example 5 with MethodConfig

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

the class DynamicLangApiMethodTransformer method generateMethodDoc.

private ApiMethodDocView generateMethodDoc(GapicMethodContext context) {
    ApiMethodDocView.Builder docBuilder = ApiMethodDocView.newBuilder();
    SurfaceNamer surfaceNamer = context.getNamer();
    MethodModel method = context.getMethodModel();
    MethodConfig methodConfig = context.getMethodConfig();
    docBuilder.mainDocLines(surfaceNamer.getDocLines(method, methodConfig));
    docBuilder.paramDocs(apiMethodParamTransformer.generateParamDocs(context));
    docBuilder.returnTypeName(surfaceNamer.getDynamicLangReturnTypeName(context));
    docBuilder.returnsDocLines(surfaceNamer.getReturnDocLines(context.getSurfaceInterfaceContext(), context, Synchronicity.Sync));
    if (methodConfig.isPageStreaming()) {
        docBuilder.pageStreamingResourceTypeName(surfaceNamer.getTypeNameDoc(context.getTypeTable(), methodConfig.getPageStreaming().getResourcesField().getType()));
    }
    docBuilder.throwsDocLines(surfaceNamer.getThrowsDocLines(methodConfig));
    return docBuilder.build();
}
Also used : MethodConfig(com.google.api.codegen.config.MethodConfig) MethodModel(com.google.api.codegen.config.MethodModel) ApiMethodDocView(com.google.api.codegen.viewmodel.ApiMethodDocView)

Aggregations

MethodConfig (com.google.api.codegen.config.MethodConfig)51 MethodModel (com.google.api.codegen.config.MethodModel)29 ArrayList (java.util.ArrayList)20 ImmutableList (com.google.common.collect.ImmutableList)14 FieldModel (com.google.api.codegen.config.FieldModel)13 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)9 DiscoveryMethodModel (com.google.api.codegen.config.DiscoveryMethodModel)8 MethodContext (com.google.api.codegen.transformer.MethodContext)8 FieldConfig (com.google.api.codegen.config.FieldConfig)7 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)6 GapicMethodContext (com.google.api.codegen.transformer.GapicMethodContext)6 SimpleParamDocView (com.google.api.codegen.viewmodel.SimpleParamDocView)6 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)6 ParamDocView (com.google.api.codegen.viewmodel.ParamDocView)5 GapicMethodConfig (com.google.api.codegen.config.GapicMethodConfig)4 GapicInterfaceConfig (com.google.api.codegen.config.GapicInterfaceConfig)3 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)3 PageStreamingConfig (com.google.api.codegen.config.PageStreamingConfig)3 ParamWithSimpleDoc (com.google.api.codegen.transformer.ParamWithSimpleDoc)3 SymbolTable (com.google.api.codegen.util.SymbolTable)3