Search in sources :

Example 1 with MethodModel

use of com.google.api.codegen.config.MethodModel 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 2 with MethodModel

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

the class ApiCallableTransformer method generateMethodDescriptors.

public List<MethodDescriptorView> generateMethodDescriptors(InterfaceContext context) {
    List<MethodDescriptorView> callables = new ArrayList<>();
    boolean excludeMixins = !context.getFeatureConfig().enableMixins();
    for (MethodModel method : context.getSupportedMethods()) {
        if (excludeMixins && context.getMethodConfig(method).getRerouteToGrpcInterface() != null) {
            continue;
        }
        callables.add(generateMethodDescriptor(context.asRequestMethodContext(method)));
    }
    return callables;
}
Also used : MethodModel(com.google.api.codegen.config.MethodModel) DiscoveryMethodModel(com.google.api.codegen.config.DiscoveryMethodModel) MethodDescriptorView(com.google.api.codegen.viewmodel.MethodDescriptorView) ArrayList(java.util.ArrayList)

Example 3 with MethodModel

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

the class ApiCallableTransformer method generateStaticLangApiCallables.

public List<ApiCallableView> generateStaticLangApiCallables(InterfaceContext context) {
    List<ApiCallableView> callableMembers = new ArrayList<>();
    boolean excludeMixins = !context.getFeatureConfig().enableMixins();
    for (MethodModel method : context.getSupportedMethods()) {
        if (excludeMixins && context.getMethodConfig(method).getRerouteToGrpcInterface() != null) {
            continue;
        }
        callableMembers.addAll(generateStaticLangApiCallables(context.asRequestMethodContext(method)));
    }
    return callableMembers;
}
Also used : MethodModel(com.google.api.codegen.config.MethodModel) DiscoveryMethodModel(com.google.api.codegen.config.DiscoveryMethodModel) ApiCallableView(com.google.api.codegen.viewmodel.ApiCallableView) ArrayList(java.util.ArrayList)

Example 4 with MethodModel

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

the class BatchingTransformer method generateDescriptorClass.

private BatchingDescriptorClassView generateDescriptorClass(MethodContext context) {
    SurfaceNamer namer = context.getNamer();
    MethodModel method = context.getMethodModel();
    BatchingConfig batching = context.getMethodConfig().getBatching();
    FieldModel batchedField = batching.getBatchedField();
    FieldModel subresponseField = batching.getSubresponseField();
    BatchingDescriptorClassView.Builder desc = BatchingDescriptorClassView.newBuilder();
    desc.name(context.getNamer().getBatchingDescriptorConstName(context.getMethodModel()));
    desc.requestTypeName(method.getAndSaveRequestTypeName(context.getTypeTable(), context.getNamer()));
    desc.responseTypeName(method.getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer()));
    desc.batchedFieldTypeName(context.getTypeTable().getAndSaveNicknameFor(batchedField));
    desc.partitionKeys(generatePartitionKeys(context));
    desc.discriminatorFieldCopies(generateDiscriminatorFieldCopies(context));
    desc.batchedFieldGetFunction(namer.getFieldGetFunctionName(batchedField));
    desc.batchedFieldSetFunction(namer.getFieldSetFunctionName(batchedField));
    desc.batchedFieldCountGetFunction(namer.getFieldCountGetFunctionName(batchedField));
    if (subresponseField != null) {
        desc.subresponseTypeName(context.getTypeTable().getAndSaveNicknameFor(subresponseField));
        desc.subresponseByIndexGetFunction(namer.getByIndexGetFunctionName(subresponseField));
        desc.subresponseSetFunction(namer.getFieldSetFunctionName(subresponseField));
    }
    return desc.build();
}
Also used : MethodModel(com.google.api.codegen.config.MethodModel) BatchingDescriptorClassView(com.google.api.codegen.viewmodel.BatchingDescriptorClassView) BatchingConfig(com.google.api.codegen.config.BatchingConfig) FieldModel(com.google.api.codegen.config.FieldModel)

Example 5 with MethodModel

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

Aggregations

MethodModel (com.google.api.codegen.config.MethodModel)95 ArrayList (java.util.ArrayList)30 MethodConfig (com.google.api.codegen.config.MethodConfig)29 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)23 GapicMethodContext (com.google.api.codegen.transformer.GapicMethodContext)20 ImmutableList (com.google.common.collect.ImmutableList)16 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)14 Builder (com.google.api.codegen.viewmodel.StaticLangApiMethodView.Builder)14 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)12 DiscoveryMethodModel (com.google.api.codegen.config.DiscoveryMethodModel)11 FieldConfig (com.google.api.codegen.config.FieldConfig)11 ProtoMethodModel (com.google.api.codegen.config.ProtoMethodModel)9 Test (org.junit.Test)9 FieldModel (com.google.api.codegen.config.FieldModel)8 MethodContext (com.google.api.codegen.transformer.MethodContext)8 SymbolTable (com.google.api.codegen.util.SymbolTable)8 TypeModel (com.google.api.codegen.config.TypeModel)7 TestCaseView (com.google.api.codegen.viewmodel.testing.TestCaseView)7 InterfaceModel (com.google.api.codegen.config.InterfaceModel)6 PageStreamingConfig (com.google.api.codegen.config.PageStreamingConfig)6