use of com.google.api.codegen.config.TypeModel in project toolkit by googleapis.
the class OutputTransformer method stringInterpolationView.
private OutputView.StringInterpolationView stringInterpolationView(MethodContext methodContext, SampleContext sampleContext, OutputContext outputContext, List<String> configs) {
String format = configs.get(0);
ImmutableList.Builder<String> builder = ImmutableList.builder();
for (String path : configs.subList(1, configs.size())) {
OutputView.VariableView variable = accessor(new Scanner(path), methodContext, sampleContext, outputContext.scopeTable());
TypeModel type = variable.type();
// resource names, but should include them as well for completeness
if (type != null) {
outputContext.stringFormattedVariableTypes().add(type);
}
String formattedArg = methodContext.getNamer().getFormattedPrintArgName(methodContext.getTypeTable(), type, variable.variable(), variable.accessors());
builder.add(formattedArg);
}
ImmutableList<String> args = builder.build();
ImmutableList<String> stringWithInterpolatedArgs = methodContext.getNamer().getInterpolatedFormatAndArgs(format, args);
return OutputView.StringInterpolationView.newBuilder().format(stringWithInterpolatedArgs.get(0)).args(stringWithInterpolatedArgs.subList(1, stringWithInterpolatedArgs.size())).build();
}
use of com.google.api.codegen.config.TypeModel 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.config.TypeModel 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.config.TypeModel in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generateOperationFlattenedMethod.
// Used by: C#
public StaticLangApiMethodView generateOperationFlattenedMethod(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));
methodViewBuilder.callableName(namer.getCallableName(method));
setFlattenedMethodFields(context, additionalParams, Synchronicity.Sync, methodViewBuilder, context.getCallingForms(), sampleContext);
methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context));
TypeModel returnType = context.getLongRunningConfig().getReturnType();
methodViewBuilder.responseTypeName(context.getTypeTable().getAndSaveNicknameFor(returnType));
return methodViewBuilder.type(ClientMethodType.OperationFlattenedMethod).build();
}
use of com.google.api.codegen.config.TypeModel in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method generateOperationRequestObjectMethod.
// Used by: C#
public StaticLangApiMethodView generateOperationRequestObjectMethod(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);
methodViewBuilder.operationMethod(lroTransformer.generateDetailView(context));
TypeModel returnType = context.getLongRunningConfig().getReturnType();
methodViewBuilder.responseTypeName(context.getTypeTable().getAndSaveNicknameFor(returnType));
return methodViewBuilder.type(ClientMethodType.OperationRequestObjectMethod).build();
}
Aggregations