Search in sources :

Example 56 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.

the class StaticLangGapicSamplesTransformer method generateSamplesFromSampleConfigs.

private List<ViewModel> generateSamplesFromSampleConfigs(List<InterfaceContext> interfaceContexts, GapicProductConfig productConfig) {
    SurfaceNamer namer = newSurfaceNamer.apply(productConfig);
    List<SampleContext> sampleContexts = getSampleContexts(interfaceContexts, productConfig);
    List<ViewModel> sampleFileViews = new ArrayList<>();
    for (SampleContext sampleContext : sampleContexts) {
        StaticLangApiMethodView methodView = apiMethodTransformer.generateApiMethod(sampleContext.methodContext(), sampleContext);
        MethodSampleView methodSampleView = methodView.samples().get(0);
        String fileName = namer.getApiSampleFileName(sampleContext.uniqueSampleId());
        String className = namer.getApiSampleClassName(sampleContext.uniqueSampleId());
        InterfaceContext interfaceContext = sampleContext.methodContext().getSurfaceInterfaceContext();
        sampleFileViews.add(newSampleFileView(productConfig, interfaceContext, className, fileName, methodView, methodSampleView));
    }
    return sampleFileViews;
}
Also used : MethodSampleView(com.google.api.codegen.viewmodel.MethodSampleView) SampleContext(com.google.api.codegen.config.SampleContext) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) ArrayList(java.util.ArrayList) ViewModel(com.google.api.codegen.viewmodel.ViewModel) InterfaceContext(com.google.api.codegen.config.InterfaceContext) GapicInterfaceContext(com.google.api.codegen.config.GapicInterfaceContext)

Example 57 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.

the class StaticLangApiMethodTransformer method generateOperationCallableMethod.

public StaticLangApiMethodView generateOperationCallableMethod(MethodContext context, SampleContext sampleContext) {
    MethodModel method = context.getMethodModel();
    SurfaceNamer namer = context.getNamer();
    StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
    setCommonFields(context, methodViewBuilder);
    methodViewBuilder.name(namer.getOperationCallableMethodName(method));
    methodViewBuilder.exampleName(context.getNamer().getOperationCallableMethodExampleName(method));
    setCallableMethodFields(context, namer.getOperationCallableName(method), methodViewBuilder, context.getCallingForms(), sampleContext);
    TypeModel returnType = context.getLongRunningConfig().getReturnType();
    methodViewBuilder.responseTypeName(context.getTypeTable().getAndSaveNicknameFor(returnType));
    methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context));
    return methodViewBuilder.type(ClientMethodType.OperationCallableMethod).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) TypeModel(com.google.api.codegen.config.TypeModel)

Example 58 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.

the class StaticLangApiMethodTransformer method generateAsyncOperationFlattenedMethod.

// Used by CSharp (and indirectly by Java via the overload above)
public StaticLangApiMethodView generateAsyncOperationFlattenedMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams, ClientMethodType type, boolean requiresOperationMethod, SampleContext sampleContext) {
    MethodModel method = context.getMethodModel();
    SurfaceNamer namer = context.getNamer();
    StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
    setCommonFields(context, methodViewBuilder);
    methodViewBuilder.name(namer.getAsyncApiMethodName(context.getMethodModel(), context.getMethodConfig().getVisibility()));
    methodViewBuilder.exampleName(namer.getAsyncApiMethodExampleName(method));
    methodViewBuilder.callableName(namer.getCallableName(method));
    setFlattenedMethodFields(context, additionalParams, Synchronicity.Async, methodViewBuilder, context.getCallingForms(), sampleContext);
    if (requiresOperationMethod) {
        methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context));
    }
    TypeModel returnType = context.getLongRunningConfig().getReturnType();
    methodViewBuilder.responseTypeName(context.getTypeTable().getAndSaveNicknameFor(returnType));
    methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context));
    return methodViewBuilder.type(type).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) TypeModel(com.google.api.codegen.config.TypeModel)

Example 59 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.

the class StaticLangApiMethodTransformer method generateRequestObjectMethod.

// Used by: C# (and indirectly by Java via the overload above)
public StaticLangApiMethodView generateRequestObjectMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams, SampleContext sampleContext) {
    MethodModel method = context.getMethodModel();
    SurfaceNamer namer = context.getNamer();
    StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
    setCommonFields(context, methodViewBuilder);
    methodViewBuilder.name(namer.getApiMethodName(method, context.getMethodConfig().getVisibility()));
    methodViewBuilder.exampleName(namer.getApiMethodExampleName(context.getInterfaceConfig(), method));
    setRequestObjectMethodFields(context, namer.getCallableMethodName(method), Synchronicity.Sync, additionalParams, methodViewBuilder, context.getCallingForms(), sampleContext);
    setStaticLangReturnTypeName(context, methodViewBuilder);
    return methodViewBuilder.type(ClientMethodType.RequestObjectMethod).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)

Example 60 with StaticLangApiMethodView

use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.

the class StaticLangApiMethodTransformer method generateGrpcStreamingRequestObjectMethod.

// Used by: C# and Go
public StaticLangApiMethodView generateGrpcStreamingRequestObjectMethod(MethodContext context, SampleContext sampleContext) {
    MethodModel method = context.getMethodModel();
    SurfaceNamer namer = context.getNamer();
    StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
    setCommonFields(context, methodViewBuilder);
    methodViewBuilder.name(namer.getGrpcStreamingApiMethodName(method, context.getMethodConfig().getVisibility()));
    methodViewBuilder.exampleName(namer.getGrpcStreamingApiMethodExampleName(context.getInterfaceConfig(), method));
    setRequestObjectMethodFields(context, namer.getCallableMethodName(method), Synchronicity.Sync, methodViewBuilder, context.getCallingForms(), sampleContext);
    setStaticLangGrpcStreamingReturnTypeName(context, methodViewBuilder);
    return methodViewBuilder.type(ClientMethodType.RequestObjectMethod).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)

Aggregations

StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)71 MethodModel (com.google.api.codegen.config.MethodModel)43 Builder (com.google.api.codegen.viewmodel.StaticLangApiMethodView.Builder)35 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)22 ArrayList (java.util.ArrayList)14 FieldConfig (com.google.api.codegen.config.FieldConfig)12 MethodConfig (com.google.api.codegen.config.MethodConfig)12 PageStreamingConfig (com.google.api.codegen.config.PageStreamingConfig)10 TypeModel (com.google.api.codegen.config.TypeModel)10 InterfaceContext (com.google.api.codegen.config.InterfaceContext)9 MethodContext (com.google.api.codegen.config.MethodContext)9 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)8 ParamWithSimpleDoc (com.google.api.codegen.transformer.ParamWithSimpleDoc)6 GapicInterfaceContext (com.google.api.codegen.config.GapicInterfaceContext)4 InterfaceConfig (com.google.api.codegen.config.InterfaceConfig)4 ViewModel (com.google.api.codegen.viewmodel.ViewModel)4 GapicMethodContext (com.google.api.codegen.config.GapicMethodContext)3 GapicProductConfig (com.google.api.codegen.config.GapicProductConfig)3 ProtoApiModel (com.google.api.codegen.config.ProtoApiModel)3 ImportTypeTable (com.google.api.codegen.transformer.ImportTypeTable)3