use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class BatchingTransformer method generateDescriptorClasses.
public List<BatchingDescriptorClassView> generateDescriptorClasses(InterfaceContext context) {
List<BatchingDescriptorClassView> descriptors = new ArrayList<>();
for (MethodModel method : context.getInterfaceConfigMethods()) {
MethodConfig methodConfig = context.getMethodConfig(method);
if (methodConfig == null) {
continue;
}
if (!methodConfig.isBatching()) {
continue;
}
descriptors.add(generateDescriptorClass(context.asRequestMethodContext(method)));
}
return descriptors;
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class DiscoGapicInterfaceContext method getInterfaceConfigMethods.
/**
* Returns a list of methods for this interface. Memoize the result.
*/
@Override
public List<MethodModel> getInterfaceConfigMethods() {
if (interfaceMethods != null) {
return interfaceMethods;
}
ImmutableList.Builder<MethodModel> methodBuilder = ImmutableList.builder();
for (MethodConfig methodConfig : getInterfaceConfig().getMethodConfigs()) {
MethodModel method = methodConfig.getMethodModel();
if (isSupported(method)) {
methodBuilder.add(method);
}
}
interfaceMethods = methodBuilder.build();
return interfaceMethods;
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class GapicInterfaceContext method getInterfaceConfigMethods.
/**
* Returns a list of methods for this interface that have method configs. Memoize the result.
*/
@Override
public List<MethodModel> getInterfaceConfigMethods() {
if (interfaceMethods != null) {
return interfaceMethods;
}
ImmutableList.Builder<MethodModel> methodBuilder = ImmutableList.builder();
for (MethodConfig methodConfig : getInterfaceConfig().getMethodConfigs()) {
methodBuilder.add(new ProtoMethodModel(((GapicMethodConfig) methodConfig).getMethod()));
}
interfaceMethods = methodBuilder.build();
return interfaceMethods;
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class MockServiceTransformer method createMockGrpcMethodViews.
public List<MockGrpcMethodView> createMockGrpcMethodViews(InterfaceContext context) {
if (!context.getProductConfig().getTransportProtocol().equals(TransportProtocol.GRPC)) {
return ImmutableList.of();
}
List<MethodModel> methods = context.getInterfaceMethods();
ArrayList<MockGrpcMethodView> mocks = new ArrayList<>(methods.size());
for (MethodModel method : methods) {
if (context.getMethodConfig(method) == null) {
continue;
}
MethodContext methodContext = context.asRequestMethodContext(method);
String requestTypeName = method.getAndSaveRequestTypeName(methodContext.getTypeTable(), methodContext.getNamer());
String responseTypeName = method.getAndSaveResponseTypeName(methodContext.getTypeTable(), methodContext.getNamer());
MethodConfig methodConfig = methodContext.getMethodConfig();
mocks.add(MockGrpcMethodView.newBuilder().name(methodContext.getNamer().getApiMethodName(method, VisibilityConfig.PUBLIC)).requestTypeName(requestTypeName).responseTypeName(responseTypeName).grpcStreamingType(methodConfig.getGrpcStreamingType()).streamHandleTypeName(methodContext.getNamer().getStreamingServerName(method)).build());
}
return mocks;
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class PageStreamingTransformer method generateFactoryClass.
private PagedListResponseFactoryClassView generateFactoryClass(MethodContext context) {
SurfaceNamer namer = context.getNamer();
MethodModel method = context.getMethodModel();
ImportTypeTable typeTable = context.getTypeTable();
PageStreamingConfig pageStreaming = context.getMethodConfig().getPageStreaming();
FieldModel resourceField = pageStreaming.getResourcesField();
FieldConfig resourceFieldConfig = pageStreaming.getResourcesFieldConfig();
PagedListResponseFactoryClassView.Builder factory = PagedListResponseFactoryClassView.newBuilder();
factory.name(namer.getPagedListResponseFactoryConstName(method));
factory.requestTypeName(method.getAndSaveRequestTypeName(typeTable, namer));
factory.responseTypeName(method.getAndSaveResponseTypeName(typeTable, namer));
factory.resourceTypeName(typeTable.getAndSaveNicknameForElementType(resourceField));
factory.pagedListResponseTypeName(namer.getAndSavePagedResponseTypeName(context, resourceFieldConfig));
factory.pageStreamingDescriptorName(namer.getPageStreamingDescriptorConstName(method));
return factory.build();
}
Aggregations