use of com.google.api.codegen.config.GapicMethodConfig in project toolkit by googleapis.
the class GapicInterfaceContext method getMethodConfig.
/**
* Returns the MethodConfig object of the given gRPC method.
*
* <p>If the method is a gRPC re-route method, returns the MethodConfig of the original method.
*/
public GapicMethodConfig getMethodConfig(MethodModel method) {
Interface originalInterface = getInterface();
if (getGrpcRerouteMap().containsKey(originalInterface)) {
originalInterface = getGrpcRerouteMap().get(originalInterface);
}
InterfaceConfig originalInterfaceConfig = getProductConfig().getInterfaceConfig(originalInterface);
if (originalInterfaceConfig != null) {
return (GapicMethodConfig) originalInterfaceConfig.getMethodConfig(method);
} else {
throw new IllegalArgumentException("Interface config does not exist for method: " + method.getSimpleName());
}
}
use of com.google.api.codegen.config.GapicMethodConfig in project toolkit by googleapis.
the class GapicContext method getSupportedMethodsV2.
/**
* Returns a list of RPC methods supported by the context, taking into account GRPC interface
* rerouting. TODO replace getSupportedMethods with this when all languages are migrated.
*/
public List<Method> getSupportedMethodsV2(Interface apiInterface) {
GapicInterfaceConfig interfaceConfig = getApiConfig().getInterfaceConfig(apiInterface);
if (interfaceConfig == null) {
throw new IllegalStateException("Service not configured in GAPIC config: " + apiInterface.getFullName());
}
List<Method> methods = new ArrayList<>(interfaceConfig.getMethodConfigs().size());
for (MethodConfig methodConfig : interfaceConfig.getMethodConfigs()) {
Method method = ((GapicMethodConfig) methodConfig).getMethod();
if (isSupported(method)) {
methods.add(method);
}
}
return methods;
}
use of com.google.api.codegen.config.GapicMethodConfig in project toolkit by googleapis.
the class NodeJSSurfaceNamer method getReturnDocLines.
/**
* Return JSDoc callback comment and return type comment for the given method.
*/
@Override
public List<String> getReturnDocLines(TransformationContext context, MethodContext methodContext, Synchronicity synchronicity) {
GapicMethodConfig methodConfig = (GapicMethodConfig) methodContext.getMethodConfig();
Method method = methodConfig.getMethod();
if (method.getRequestStreaming() && method.getResponseStreaming()) {
return bidiStreamingReturnDocLines(method);
} else if (method.getResponseStreaming()) {
return responseStreamingReturnDocLines(method);
}
List<String> callbackLines = returnCallbackDocLines(context.getImportTypeTable(), methodConfig);
List<String> returnObjectLines = returnObjectDocLines(context.getImportTypeTable(), methodConfig);
return ImmutableList.<String>builder().addAll(callbackLines).addAll(returnObjectLines).build();
}
use of com.google.api.codegen.config.GapicMethodConfig in project toolkit by googleapis.
the class PythonGapicSurfaceTransformer method addMethodImports.
private void addMethodImports(GapicMethodContext context) {
ModelTypeTable typeTable = context.getTypeTable();
GapicMethodConfig methodConfig = context.getMethodConfig();
if (methodConfig.isLongRunningOperation()) {
typeTable.getAndSaveNicknameFor(methodConfig.getLongRunningConfig().getReturnType());
typeTable.getAndSaveNicknameFor(methodConfig.getLongRunningConfig().getMetadataType());
}
typeTable.getAndSaveNicknameFor(context.getMethod().getInputType());
addFieldsImports(typeTable, methodConfig.getRequiredFields());
addFieldsImports(typeTable, methodConfig.getOptionalFields());
}
use of com.google.api.codegen.config.GapicMethodConfig in project toolkit by googleapis.
the class PythonSurfaceNamer method getReturnDocLines.
@Override
public List<String> getReturnDocLines(TransformationContext context, MethodContext methodContext, Synchronicity synchronicity) {
MethodConfig methodConfig = methodContext.getMethodConfig();
TypeRef outputType = ((GapicMethodConfig) methodConfig).getMethod().getOutputType();
if (ServiceMessages.s_isEmptyType(outputType)) {
return ImmutableList.<String>of();
}
String returnTypeName = methodConfig.isLongRunningOperation() ? "google.gax._OperationFuture" : getModelTypeFormatter().getFullNameFor(outputType);
String classInfo = PythonDocstringUtil.napoleonType(returnTypeName, getVersionedDirectoryNamespace());
if (((GapicMethodConfig) methodConfig).getMethod().getResponseStreaming()) {
return ImmutableList.of("Iterable[" + classInfo + "].");
}
if (methodConfig.isPageStreaming()) {
FieldModel fieldModel = methodConfig.getPageStreaming().getResourcesField();
return ImmutableList.of("A :class:`~google.gax.PageIterator` instance. By default, this", "is an iterable of " + annotateWithClass(getResponseTypeNameForElementType(fieldModel.getType())) + " instances.", "This object can also be configured to iterate over the pages", "of the response through the `options` parameter.");
}
return ImmutableList.of(String.format("A %s instance.", annotateWithClass(classInfo)));
}
Aggregations