use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generateCallableMethod.
public StaticLangApiMethodView generateCallableMethod(MethodContext context) {
MethodModel method = context.getMethodModel();
SurfaceNamer namer = context.getNamer();
StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
setCommonFields(context, methodViewBuilder);
methodViewBuilder.name(namer.getCallableMethodName(method));
methodViewBuilder.exampleName(context.getNamer().getCallableMethodExampleName(method));
setCallableMethodFields(context, namer.getCallableName(method), methodViewBuilder);
methodViewBuilder.responseTypeName(context.getMethodModel().getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer()));
return methodViewBuilder.type(ClientMethodType.CallableMethod).build();
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generatePagedFlattenedAsyncMethod.
public StaticLangApiMethodView generatePagedFlattenedAsyncMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams) {
MethodModel methodModel = context.getMethodModel();
SurfaceNamer namer = context.getNamer();
StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
setCommonFields(context, methodViewBuilder);
methodViewBuilder.name(namer.getAsyncApiMethodName(methodModel, context.getMethodConfig().getVisibility()));
methodViewBuilder.exampleName(namer.getAsyncApiMethodExampleName(methodModel));
setListMethodFields(context, Synchronicity.Async, methodViewBuilder);
setFlattenedMethodFields(context, additionalParams, Synchronicity.Async, methodViewBuilder);
return methodViewBuilder.type(ClientMethodType.PagedFlattenedAsyncMethod).build();
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generateFlattenedAsyncMethod.
public StaticLangApiMethodView generateFlattenedAsyncMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams, ClientMethodType type) {
MethodModel method = context.getMethodModel();
SurfaceNamer namer = context.getNamer();
StaticLangApiMethodView.Builder methodViewBuilder = StaticLangApiMethodView.newBuilder();
setCommonFields(context, methodViewBuilder);
methodViewBuilder.name(namer.getAsyncApiMethodName(method, context.getMethodConfig().getVisibility()));
methodViewBuilder.exampleName(namer.getCallableMethodExampleName(method));
methodViewBuilder.callableName(namer.getCallableName(method));
setFlattenedMethodFields(context, additionalParams, Synchronicity.Async, methodViewBuilder);
setStaticLangAsyncReturnTypeName(context, methodViewBuilder);
return methodViewBuilder.type(type).build();
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generateOperationFlattenedMethod.
public StaticLangApiMethodView generateOperationFlattenedMethod(MethodContext context, List<ParamWithSimpleDoc> additionalParams) {
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));
methodViewBuilder.callableName(namer.getCallableName(method));
setFlattenedMethodFields(context, additionalParams, Synchronicity.Sync, methodViewBuilder);
methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context));
TypeModel returnType = context.getMethodConfig().getLongRunningConfig().getReturnType();
methodViewBuilder.responseTypeName(context.getTypeTable().getAndSaveNicknameFor(returnType));
return methodViewBuilder.type(ClientMethodType.OperationFlattenedMethod).build();
}
use of com.google.api.codegen.viewmodel.StaticLangApiMethodView in project toolkit by googleapis.
the class GoGapicSurfaceTransformer method generateApiMethods.
@VisibleForTesting
List<StaticLangApiMethodView> generateApiMethods(InterfaceContext context, Iterable<MethodModel> methods) {
List<StaticLangApiMethodView> apiMethods = new ArrayList<>();
for (MethodModel method : methods) {
MethodConfig methodConfig = context.getMethodConfig(method);
MethodContext methodContext = context.asRequestMethodContext(method);
if (method.getRequestStreaming() || method.getResponseStreaming()) {
apiMethods.add(apiMethodTransformer.generateGrpcStreamingRequestObjectMethod(methodContext));
} else if (methodConfig.isPageStreaming()) {
apiMethods.add(apiMethodTransformer.generatePagedRequestObjectMethod(methodContext));
} else if (methodConfig.isLongRunningOperation()) {
apiMethods.add(apiMethodTransformer.generateOperationRequestObjectMethod(methodContext));
} else {
apiMethods.add(apiMethodTransformer.generateRequestObjectMethod(methodContext));
}
}
return apiMethods;
}
Aggregations