use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class JavaSurfaceTestTransformer method addMockServiceImports.
private void addMockServiceImports(InterfaceContext context) {
ImportTypeTable typeTable = context.getImportTypeTable();
typeTable.saveNicknameFor("java.util.List");
typeTable.saveNicknameFor("com.google.api.core.BetaApi");
typeTable.saveNicknameFor("com.google.api.gax.grpc.testing.MockGrpcService");
if (context.getProductConfig().getTransportProtocol().equals(TransportProtocol.GRPC)) {
typeTable.saveNicknameFor("com.google.protobuf.AbstractMessage");
typeTable.saveNicknameFor("io.grpc.ServerServiceDefinition");
}
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class JavaSurfaceTestTransformer method addGrpcStreamingTestImports.
private void addGrpcStreamingTestImports(InterfaceContext context, GrpcStreamingType streamingType) {
ImportTypeTable typeTable = context.getImportTypeTable();
if (context.getProductConfig().getTransportProtocol().equals(TransportProtocol.GRPC)) {
typeTable.saveNicknameFor("com.google.api.gax.grpc.testing.MockStreamObserver");
typeTable.saveNicknameFor("com.google.api.gax.rpc.ApiStreamObserver");
switch(streamingType) {
case BidiStreaming:
typeTable.saveNicknameFor("com.google.api.gax.rpc.BidiStreamingCallable");
break;
case ClientStreaming:
typeTable.saveNicknameFor("com.google.api.gax.rpc.ClientStreamingCallable");
break;
case ServerStreaming:
typeTable.saveNicknameFor("com.google.api.gax.rpc.ServerStreamingCallable");
break;
default:
throw new IllegalArgumentException("Invalid streaming type: " + streamingType);
}
}
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class PhpSampleImportTransformer method addOutputImports.
@Override
protected void addOutputImports(MethodContext context, OutputContext outputContext) {
ImportTypeTable typeTable = context.getTypeTable();
outputContext.stringFormattedVariableTypes().stream().filter(TypeModel::isEnum).forEach(type -> typeTable.getAndSaveNicknameFor(type));
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class JavaSurfaceTestTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
SurfaceNamer namer = surfaceTransformer.createSurfaceNamer(productConfig);
boolean enableStringFormatFunctions = productConfig.getResourceNameMessageConfigs().isEmpty();
List<ViewModel> views = new ArrayList<>();
for (InterfaceModel apiInterface : model.getInterfaces()) {
ImportTypeTable typeTable = surfaceTransformer.createTypeTable(productConfig.getPackageName());
InterfaceContext context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable, enableStringFormatFunctions);
views.add(createUnitTestFileView(context));
if (context.getInterfaceConfig().getSmokeTestConfig() != null) {
context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable.cloneEmpty(), enableStringFormatFunctions);
views.add(createSmokeTestClassView(context));
}
}
for (InterfaceModel apiInterface : mockServiceTransformer.getGrpcInterfacesToMock(model, productConfig)) {
ImportTypeTable typeTable = surfaceTransformer.createTypeTable(productConfig.getPackageName());
InterfaceContext context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable, enableStringFormatFunctions);
views.add(createMockServiceImplFileView(context));
context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable.cloneEmpty(), enableStringFormatFunctions);
views.add(createMockServiceView(context));
}
return views;
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class CSharpSurfaceNamer method getAndSaveAsyncPagedResponseTypeName.
@Override
public String getAndSaveAsyncPagedResponseTypeName(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.PagedAsyncEnumerable", inputTypeName, outputTypeName, resourceTypeName);
}
Aggregations