use of com.google.api.codegen.config.MethodConfig in project toolkit by googleapis.
the class JavaDiscoGapicRequestToViewTransformer method getRequestObjectParams.
private RequestObjectParamView getRequestObjectParams(DiscoGapicInterfaceContext context, MethodModel method) {
MethodConfig methodConfig = context.getMethodConfig(method);
// Generate the ResourceName methods.
if (methodConfig.isFlattening()) {
for (FlatteningConfig flatteningGroup : methodConfig.getFlatteningConfigs()) {
MethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup);
Iterable<FieldConfig> fieldConfigs = flattenedMethodContext.getFlatteningConfig().getFlattenedFieldConfigs().values();
for (FieldConfig fieldConfig : fieldConfigs) {
if (context.getFeatureConfig().useResourceNameFormatOption(fieldConfig)) {
return resourceObjectTransformer.generateRequestObjectParam(flattenedMethodContext, fieldConfig);
}
}
}
}
return null;
}
use of com.google.api.codegen.config.MethodConfig in project toolkit by googleapis.
the class ApiCallableTransformer method generateApiCallableSettings.
public List<ApiCallSettingsView> generateApiCallableSettings(MethodContext context) {
List<ApiCallSettingsView> settings = new ArrayList<>();
MethodConfig methodConfig = context.getMethodConfig();
if (methodConfig.isGrpcStreaming()) {
settings.add(generateApiCallableSettings(context, ApiCallableImplType.of(methodConfig.getGrpcStreamingType())));
} else if (methodConfig.isPageStreaming()) {
settings.add(generateApiCallableSettings(context, ApiCallableImplType.PagedApiCallable));
} else if (methodConfig.isBatching()) {
settings.add(generateApiCallableSettings(context, ApiCallableImplType.BatchingApiCallable));
} else if (methodConfig.isLongRunningOperation()) {
if (context.getFeatureConfig().enableRawOperationCallSettings()) {
settings.add(generateApiCallableSettings(context, ApiCallableImplType.SimpleApiCallable));
}
settings.add(generateApiCallableSettings(context, ApiCallableImplType.OperationApiCallable));
} else {
settings.add(generateApiCallableSettings(context, ApiCallableImplType.SimpleApiCallable));
}
return settings;
}
use of com.google.api.codegen.config.MethodConfig 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.MethodConfig 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);
}
use of com.google.api.codegen.config.MethodConfig in project toolkit by googleapis.
the class DynamicLangApiMethodTransformer method generateMethodDoc.
private ApiMethodDocView generateMethodDoc(GapicMethodContext context) {
ApiMethodDocView.Builder docBuilder = ApiMethodDocView.newBuilder();
SurfaceNamer surfaceNamer = context.getNamer();
MethodModel method = context.getMethodModel();
MethodConfig methodConfig = context.getMethodConfig();
docBuilder.mainDocLines(surfaceNamer.getDocLines(method, methodConfig));
docBuilder.paramDocs(apiMethodParamTransformer.generateParamDocs(context));
docBuilder.returnTypeName(surfaceNamer.getDynamicLangReturnTypeName(context));
docBuilder.returnsDocLines(surfaceNamer.getReturnDocLines(context.getSurfaceInterfaceContext(), context, Synchronicity.Sync));
if (methodConfig.isPageStreaming()) {
docBuilder.pageStreamingResourceTypeName(surfaceNamer.getTypeNameDoc(context.getTypeTable(), methodConfig.getPageStreaming().getResourcesField().getType()));
}
docBuilder.throwsDocLines(surfaceNamer.getThrowsDocLines(methodConfig));
return docBuilder.build();
}
Aggregations