use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generateOperationCallableMethod.
public StaticLangApiMethodView generateOperationCallableMethod(MethodContext context) {
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);
TypeModel returnType = context.getMethodConfig().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.config.MethodModel in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generateUnpagedListCallableMethod.
public StaticLangApiMethodView generateUnpagedListCallableMethod(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(namer.getCallableMethodExampleName(method));
setListMethodFields(context, Synchronicity.Sync, methodViewBuilder);
setCallableMethodFields(context, namer.getCallableName(method), methodViewBuilder);
String getResourceListCallName = namer.getFieldGetFunctionName(context.getFeatureConfig(), context.getMethodConfig().getPageStreaming().getResourcesFieldConfig());
String resourceListParseFunction = "";
PageStreamingConfig pageStreaming = context.getMethodConfig().getPageStreaming();
FieldConfig resourceFieldConfig = pageStreaming.getResourcesFieldConfig();
if (context.getFeatureConfig().useResourceNameConverters(resourceFieldConfig)) {
resourceListParseFunction = namer.getResourceTypeParseListMethodName(context.getTypeTable(), resourceFieldConfig);
}
UnpagedListCallableMethodDetailView unpagedListCallableDetails = UnpagedListCallableMethodDetailView.newBuilder().resourceListGetFunction(getResourceListCallName).resourceListParseFunction(resourceListParseFunction).build();
methodViewBuilder.unpagedListCallableMethod(unpagedListCallableDetails);
methodViewBuilder.responseTypeName(context.getMethodModel().getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer()));
return methodViewBuilder.type(ClientMethodType.UnpagedListCallableMethod).build();
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generateRequestObjectAsyncMethod.
public StaticLangApiMethodView generateRequestObjectAsyncMethod(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.getAsyncApiMethodExampleName(method));
setRequestObjectMethodFields(context, namer.getCallableAsyncMethodName(method), Synchronicity.Async, additionalParams, methodViewBuilder);
setStaticLangAsyncReturnTypeName(context, methodViewBuilder);
return methodViewBuilder.type(type).build();
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method setListMethodFields.
private void setListMethodFields(MethodContext context, Synchronicity synchronicity, StaticLangApiMethodView.Builder methodViewBuilder) {
MethodModel method = context.getMethodModel();
ImportTypeTable typeTable = context.getTypeTable();
SurfaceNamer namer = context.getNamer();
PageStreamingConfig pageStreaming = context.getMethodConfig().getPageStreaming();
String requestTypeName = method.getAndSaveRequestTypeName(context.getTypeTable(), context.getNamer());
String responseTypeName = method.getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer());
FieldConfig resourceFieldConfig = pageStreaming.getResourcesFieldConfig();
FieldModel resourceField = resourceFieldConfig.getField();
String resourceTypeName;
if (context.getFeatureConfig().useResourceNameFormatOption(resourceFieldConfig)) {
resourceTypeName = namer.getAndSaveElementResourceTypeName(typeTable, resourceFieldConfig);
} else {
resourceTypeName = typeTable.getAndSaveNicknameForElementType(resourceField);
}
String iterateMethodName = context.getNamer().getPagedResponseIterateMethod(context.getFeatureConfig(), resourceFieldConfig);
String resourceFieldName = context.getNamer().getFieldName(resourceField);
List<String> resourceFieldGetFunctionNames = resourceField.getPagedResponseResourceMethods(context.getFeatureConfig(), resourceFieldConfig, context.getNamer());
methodViewBuilder.listMethod(ListMethodDetailView.newBuilder().requestTypeName(requestTypeName).responseTypeName(responseTypeName).resourceTypeName(resourceTypeName).iterateMethodName(iterateMethodName).resourceFieldName(resourceFieldName).resourcesFieldGetFunctions(resourceFieldGetFunctionNames).build());
switch(synchronicity) {
case Sync:
methodViewBuilder.responseTypeName(namer.getAndSavePagedResponseTypeName(context, resourceFieldConfig));
break;
case Async:
methodViewBuilder.responseTypeName(namer.getAndSaveAsyncPagedResponseTypeName(context, resourceFieldConfig));
break;
}
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generatePagedRequestObjectMethod.
public StaticLangApiMethodView generatePagedRequestObjectMethod(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));
setListMethodFields(context, Synchronicity.Sync, methodViewBuilder);
setRequestObjectMethodFields(context, namer.getPagedCallableMethodName(method), Synchronicity.Sync, additionalParams, methodViewBuilder);
return methodViewBuilder.type(ClientMethodType.PagedRequestObjectMethod).build();
}
Aggregations