use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class CSharpSurfaceNamer method getAndSavePagedResponseTypeName.
@Override
public String getAndSavePagedResponseTypeName(MethodContext methodContext, FieldConfig resourceFieldConfig) {
ImportTypeTable typeTable = methodContext.getTypeTable();
String inputTypeName = methodContext.getMethodModel().getAndSaveRequestTypeName(methodContext.getTypeTable(), methodContext.getNamer());
String outputTypeName = methodContext.getMethodModel().getAndSaveResponseTypeName(methodContext.getTypeTable(), methodContext.getNamer());
String resourceTypeName = getResourceTypeName(typeTable, resourceFieldConfig);
return typeTable.getAndSaveNicknameForContainer("Google.Api.Gax.PagedEnumerable", inputTypeName, outputTypeName, resourceTypeName);
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class GoGapicSurfaceTransformer method addXExampleImports.
@VisibleForTesting
void addXExampleImports(InterfaceContext context, Iterable<? extends MethodModel> methods) {
ImportTypeTable typeTable = context.getImportTypeTable();
typeTable.saveNicknameFor("context;;;");
typeTable.saveNicknameFor(context.getProductConfig().getPackageName() + ";" + context.getNamer().getLocalPackageName() + ";;");
for (MethodModel method : methods) {
method.getAndSaveRequestTypeName(context.getImportTypeTable(), context.getNamer());
}
addContextImports(context, ImportContext.EXAMPLE, methods);
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class CSharpSampleImportTransformer method addSampleBodyImports.
@Override
protected void addSampleBodyImports(MethodContext context, CallingForm form) {
ImportTypeTable typeTable = context.getTypeTable();
MethodModel method = context.getMethodModel();
SurfaceNamer namer = context.getNamer();
if (namer.usesAsyncAwaitPattern(form)) {
typeTable.saveNicknameFor("System.Threading.Tasks.Task");
}
switch(form) {
case RequestPaged:
case FlattenedPaged:
case RequestPagedAll:
case FlattenedPagedAll:
typeTable.saveNicknameFor("Google.Api.Gax.PagedEnumerable");
break;
case RequestAsyncPaged:
case FlattenedAsyncPaged:
case RequestAsyncPagedAll:
case FlattenedAsyncPagedAll:
typeTable.saveNicknameFor("Google.Api.Gax.PagedAsyncEnumerable");
break;
case RequestPagedPageSize:
case FlattenedPagedPageSize:
typeTable.saveNicknameFor("Google.Api.Gax.Page");
break;
}
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class CSharpSampleImportTransformer method addOutputImports.
@Override
protected void addOutputImports(MethodContext context, OutputContext outputContext) {
ImportTypeTable typeTable = context.getTypeTable();
OutputTransformer.ScopeTable scopeTable = outputContext.scopeTable();
for (TypeModel type : scopeTable.allTypes()) {
if (type == null) {
saveResourceTypeName(context);
} else {
typeTable.getAndSaveNicknameFor(type);
}
}
if (outputContext.hasMaps()) {
typeTable.getAndSaveNicknameFor("System.Collections.Generic.KeyValuePair");
}
if (outputContext.hasBytesFileOutput()) {
typeTable.getAndSaveNicknameFor("System.Linq.Enumerable");
typeTable.getAndSaveNicknameFor("System.IO.File");
}
if (outputContext.hasStringFileOutput()) {
typeTable.getAndSaveNicknameFor("System.IO.File");
}
if (outputContext.hasPrints()) {
typeTable.getAndSaveNicknameFor("System.Console");
}
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class JavaApiMethodTransformer method generateGrpcStreamingMethods.
private List<StaticLangApiMethodView> generateGrpcStreamingMethods(MethodContext methodContext, @Nullable SampleContext sampleContext) {
List<StaticLangApiMethodView> apiMethods = new ArrayList<>();
InterfaceContext interfaceContext = methodContext.getSurfaceInterfaceContext();
List<CallingForm> callingForms;
ImportTypeTable typeTable = interfaceContext.getImportTypeTable();
MethodConfig methodConfig = methodContext.getMethodConfig();
switch(methodConfig.getGrpcStreamingType()) {
case BidiStreaming:
typeTable.saveNicknameFor("com.google.api.gax.rpc.BidiStreamingCallable");
callingForms = Collections.singletonList(CallingForm.CallableStreamingBidi);
break;
case ClientStreaming:
typeTable.saveNicknameFor("com.google.api.gax.rpc.ClientStreamingCallable");
callingForms = Collections.singletonList(CallingForm.CallableStreamingClient);
break;
case ServerStreaming:
typeTable.saveNicknameFor("com.google.api.gax.rpc.ServerStreamingCallable");
callingForms = Collections.singletonList(CallingForm.CallableStreamingServer);
break;
default:
throw new IllegalArgumentException("Invalid streaming type: " + methodConfig.getGrpcStreamingType());
}
apiMethods.add(generateCallableMethod(methodContext.withCallingForms(callingForms), sampleContext));
return apiMethods;
}
Aggregations