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;
}
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();
}
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();
}
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();
}
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();
}
Aggregations