use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class ApiCallableTransformer method generatePagedApiCallable.
private ApiCallableView generatePagedApiCallable(MethodContext context) {
MethodConfig methodConfig = context.getMethodConfig();
SurfaceNamer namer = context.getNamer();
MethodModel method = context.getMethodModel();
PageStreamingConfig pageStreaming = methodConfig.getPageStreaming();
ApiCallableView.Builder pagedApiCallableBuilder = ApiCallableView.newBuilder();
pagedApiCallableBuilder.type(ApiCallableImplType.PagedApiCallable);
pagedApiCallableBuilder.interfaceTypeName(namer.getApiCallableTypeName(ServiceMethodType.UnaryMethod));
String pagedResponseTypeName = namer.getAndSavePagedResponseTypeName(context, pageStreaming.getResourcesFieldConfig());
pagedApiCallableBuilder.requestTypeName(method.getAndSaveRequestTypeName(context.getTypeTable(), context.getNamer()));
pagedApiCallableBuilder.responseTypeName(pagedResponseTypeName);
pagedApiCallableBuilder.name(namer.getPagedCallableName(method));
pagedApiCallableBuilder.methodName(namer.getApiMethodName(method, context.getMethodConfig().getVisibility()));
pagedApiCallableBuilder.asyncMethodName(namer.getAsyncApiMethodName(method, VisibilityConfig.PUBLIC));
pagedApiCallableBuilder.memberName(namer.getSettingsMemberName(method));
pagedApiCallableBuilder.settingsFunctionName(namer.getSettingsFunctionName(method));
pagedApiCallableBuilder.grpcClientVarName(namer.getReroutedGrpcClientVarName(methodConfig));
setCommonApiCallableFields(context, pagedApiCallableBuilder);
return pagedApiCallableBuilder.build();
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class ApiCallableTransformer method generateMethodDescriptors.
public List<MethodDescriptorView> generateMethodDescriptors(InterfaceContext context) {
List<MethodDescriptorView> callables = new ArrayList<>();
boolean excludeMixins = !context.getFeatureConfig().enableMixins();
for (MethodModel method : context.getSupportedMethods()) {
if (excludeMixins && context.getMethodConfig(method).getRerouteToGrpcInterface() != null) {
continue;
}
callables.add(generateMethodDescriptor(context.asRequestMethodContext(method)));
}
return callables;
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class ApiCallableTransformer method generateStaticLangApiCallables.
public List<ApiCallableView> generateStaticLangApiCallables(InterfaceContext context) {
List<ApiCallableView> callableMembers = new ArrayList<>();
boolean excludeMixins = !context.getFeatureConfig().enableMixins();
for (MethodModel method : context.getSupportedMethods()) {
if (excludeMixins && context.getMethodConfig(method).getRerouteToGrpcInterface() != null) {
continue;
}
callableMembers.addAll(generateStaticLangApiCallables(context.asRequestMethodContext(method)));
}
return callableMembers;
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class BatchingTransformer method generateDescriptorClass.
private BatchingDescriptorClassView generateDescriptorClass(MethodContext context) {
SurfaceNamer namer = context.getNamer();
MethodModel method = context.getMethodModel();
BatchingConfig batching = context.getMethodConfig().getBatching();
FieldModel batchedField = batching.getBatchedField();
FieldModel subresponseField = batching.getSubresponseField();
BatchingDescriptorClassView.Builder desc = BatchingDescriptorClassView.newBuilder();
desc.name(context.getNamer().getBatchingDescriptorConstName(context.getMethodModel()));
desc.requestTypeName(method.getAndSaveRequestTypeName(context.getTypeTable(), context.getNamer()));
desc.responseTypeName(method.getAndSaveResponseTypeName(context.getTypeTable(), context.getNamer()));
desc.batchedFieldTypeName(context.getTypeTable().getAndSaveNicknameFor(batchedField));
desc.partitionKeys(generatePartitionKeys(context));
desc.discriminatorFieldCopies(generateDiscriminatorFieldCopies(context));
desc.batchedFieldGetFunction(namer.getFieldGetFunctionName(batchedField));
desc.batchedFieldSetFunction(namer.getFieldSetFunctionName(batchedField));
desc.batchedFieldCountGetFunction(namer.getFieldCountGetFunctionName(batchedField));
if (subresponseField != null) {
desc.subresponseTypeName(context.getTypeTable().getAndSaveNicknameFor(subresponseField));
desc.subresponseByIndexGetFunction(namer.getByIndexGetFunctionName(subresponseField));
desc.subresponseSetFunction(namer.getFieldSetFunctionName(subresponseField));
}
return desc.build();
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class DiscoGapicInterfaceContext method createWithInterface.
public static DiscoGapicInterfaceContext createWithInterface(InterfaceModel interfaceModel, GapicProductConfig productConfig, ImportTypeTable typeTable, SurfaceNamer namer, FeatureConfig featureConfig) {
Preconditions.checkArgument(typeTable instanceof SchemaTypeTable);
ImmutableList.Builder<MethodModel> interfaceMethods = new ImmutableList.Builder<>();
for (MethodConfig method : productConfig.getInterfaceConfig(interfaceModel.getFullName()).getMethodConfigs()) {
interfaceMethods.add(method.getMethodModel());
}
return new AutoValue_DiscoGapicInterfaceContext(productConfig, (SchemaTypeTable) typeTable, new DiscoGapicNamer(), (DiscoInterfaceModel) interfaceModel, namer, featureConfig);
}
Aggregations