use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class PathTemplateTransformer method getSingleResourceNameConfigsUsedByInterface.
private List<SingleResourceNameConfig> getSingleResourceNameConfigsUsedByInterface(InterfaceContext context) {
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
Set<String> foundSet = new HashSet<>();
ImmutableList.Builder<SingleResourceNameConfig> resourceNameConfigsBuilder = ImmutableList.builder();
for (SingleResourceNameConfig config : interfaceConfig.getSingleResourceNameConfigs()) {
resourceNameConfigsBuilder.add(config);
foundSet.add(config.getEntityId());
}
for (MethodConfig methodConfig : interfaceConfig.getMethodConfigs()) {
MethodContext methodContext = context.asRequestMethodContext(methodConfig.getMethodModel());
for (String fieldNamePattern : methodConfig.getFieldNamePatterns().values()) {
SingleResourceNameConfig resourceNameConfig = methodContext.getSingleResourceNameConfig(fieldNamePattern);
if (resourceNameConfig != null && !foundSet.contains(resourceNameConfig.getEntityId())) {
resourceNameConfigsBuilder.add(resourceNameConfig);
foundSet.add(resourceNameConfig.getEntityId());
}
}
}
return resourceNameConfigsBuilder.build();
}
use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class StaticLangApiMethodTransformer method setCommonFields.
private void setCommonFields(MethodContext context, StaticLangApiMethodView.Builder methodViewBuilder) {
MethodModel method = context.getMethodModel();
SurfaceNamer namer = context.getNamer();
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
String requestTypeName = method.getAndSaveRequestTypeName(context.getTypeTable(), context.getNamer());
methodViewBuilder.serviceRequestTypeName(requestTypeName);
methodViewBuilder.serviceRequestTypeConstructor(namer.getTypeConstructor(requestTypeName));
methodViewBuilder.serviceConstructorName(namer.getApiWrapperClassConstructorName(context.getInterfaceConfig()));
setServiceResponseTypeName(context, methodViewBuilder);
methodViewBuilder.apiClassName(namer.getApiWrapperClassName(interfaceConfig));
methodViewBuilder.apiVariableName(namer.getApiWrapperVariableName(interfaceConfig));
methodViewBuilder.stubName(namer.getStubName(context.getTargetInterface()));
methodViewBuilder.settingsGetterName(namer.getSettingsFunctionName(method));
methodViewBuilder.callableName(context.getNamer().getCallableName(method));
methodViewBuilder.modifyMethodName(namer.getModifyMethodName(context));
methodViewBuilder.grpcStreamingType(context.getMethodConfig().getGrpcStreamingType());
methodViewBuilder.visibility(namer.getVisiblityKeyword(context.getMethodConfig().getVisibility()));
methodViewBuilder.releaseLevelAnnotation(namer.getReleaseAnnotation(context.getMethodConfig().getReleaseLevel()));
ServiceMessages messages = new ServiceMessages();
if (context.getMethodConfig().isLongRunningOperation()) {
methodViewBuilder.hasReturnValue(!context.getMethodConfig().getLongRunningConfig().getReturnType().isEmptyType());
} else {
methodViewBuilder.hasReturnValue(!method.isOutputTypeEmpty());
}
methodViewBuilder.headerRequestParams(headerRequestParamTransformer.generateHeaderRequestParams(context));
}
use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class CSharpGapicClientTransformer method generateSettingsClass.
private StaticLangSettingsView generateSettingsClass(GapicInterfaceContext context) {
StaticLangSettingsView.Builder settingsClass = StaticLangSettingsView.newBuilder();
settingsClass.doc(generateSettingsDoc(context));
String name = context.getNamer().getApiSettingsClassName(context.getInterfaceConfig());
settingsClass.name(name);
ApiModel model = context.getApiModel();
settingsClass.serviceAddress(model.getServiceAddress());
settingsClass.servicePort(model.getServicePort());
settingsClass.authScopes(model.getAuthScopes());
settingsClass.callSettings(generateCallSettings(context));
settingsClass.pageStreamingDescriptors(pageStreamingTransformer.generateDescriptorClasses(context));
settingsClass.pagedListResponseFactories(pageStreamingTransformer.generateFactoryClasses(context));
settingsClass.batchingDescriptors(batchingTransformer.generateDescriptorClasses(context));
settingsClass.retryCodesDefinitions(retryDefinitionsTransformer.generateRetryCodesDefinitions(context));
settingsClass.retryParamsDefinitions(retryDefinitionsTransformer.generateRetryParamsDefinitions(context));
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
settingsClass.hasDefaultServiceAddress(interfaceConfig.hasDefaultServiceAddress());
settingsClass.hasDefaultServiceScopes(interfaceConfig.hasDefaultServiceScopes());
settingsClass.hasDefaultInstance(interfaceConfig.hasDefaultInstance());
return settingsClass.build();
}
use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class GoGapicSurfaceTransformer method generateExample.
private StaticLangClientExampleFileView generateExample(InterfaceContext context) {
StaticLangClientExampleFileView.Builder view = StaticLangClientExampleFileView.newBuilder();
SurfaceNamer namer = context.getNamer();
InterfaceModel apiInterface = context.getInterfaceModel();
ProductConfig productConfig = context.getProductConfig();
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
view.templateFileName(SAMPLE_TEMPLATE_FILENAME);
String outputPath = pathMapper.getOutputPath(apiInterface.getFullName(), productConfig);
String fileName = namer.getExampleFileName(context.getInterfaceConfig());
view.outputPath(outputPath + File.separator + fileName);
view.clientTypeName(namer.getApiWrapperClassName(context.getInterfaceConfig()));
view.clientConstructorName(namer.getApiWrapperClassConstructorName(interfaceConfig));
view.clientConstructorExampleName(namer.getApiWrapperClassConstructorExampleName(interfaceConfig));
view.apiMethods(generateApiMethods(context, context.getPublicMethods()));
view.iamResources(iamResourceTransformer.generateIamResources(context));
// Examples are different from the API. In particular, we use short declaration
// and so we omit most type names. We only need
// - Context, to initialize the client
// - The VKit generated library, that's what the sample is for
// - The input types of the methods, to initialize the requests
// So, we clear all imports; addXExampleImports will add back the ones we want.
context.getImportTypeTable().getImports().clear();
addXExampleImports(context, context.getPublicMethods());
view.fileHeader(fileHeaderTransformer.generateFileHeader(context));
return view.build();
}
use of com.google.api.codegen.config.InterfaceConfig in project toolkit by googleapis.
the class JavaSurfaceTransformer method generateSettingsClass.
private StaticLangSettingsView generateSettingsClass(InterfaceContext context, GapicProductConfig productConfig, StaticLangApiMethodView exampleApiMethod, StaticLangStubSettingsView stubSettingsView) {
addSettingsImports(context);
SurfaceNamer namer = context.getNamer();
InterfaceConfig interfaceConfig = context.getInterfaceConfig();
StaticLangSettingsView.Builder xsettingsClass = StaticLangSettingsView.newBuilder();
String name = namer.getApiSettingsClassName(context.getInterfaceConfig());
xsettingsClass.doc(generateSettingsDoc(context, exampleApiMethod, productConfig, name, namer.getApiWrapperClassName(context.getInterfaceConfig())));
xsettingsClass.name(name);
xsettingsClass.releaseLevelAnnotation(stubSettingsView.releaseLevelAnnotation());
xsettingsClass.serviceAddress(stubSettingsView.serviceAddress());
xsettingsClass.servicePort(stubSettingsView.servicePort());
xsettingsClass.authScopes(stubSettingsView.authScopes());
xsettingsClass.callSettings(apiCallableTransformer.generateCallSettings(context));
xsettingsClass.pageStreamingDescriptors(stubSettingsView.pageStreamingDescriptors());
xsettingsClass.pagedListResponseFactories(stubSettingsView.pagedListResponseFactories());
xsettingsClass.batchingDescriptors(stubSettingsView.batchingDescriptors());
xsettingsClass.retryCodesDefinitions(stubSettingsView.retryCodesDefinitions());
xsettingsClass.hasDefaultServiceAddress(stubSettingsView.hasDefaultServiceAddress());
xsettingsClass.hasDefaultServiceScopes(stubSettingsView.hasDefaultServiceScopes());
xsettingsClass.hasDefaultInstance(stubSettingsView.hasDefaultInstance());
xsettingsClass.retryParamsDefinitions(stubSettingsView.retryParamsDefinitions());
xsettingsClass.instantiatingChannelProvider(stubSettingsView.instantiatingChannelProvider());
xsettingsClass.transportProtocol(stubSettingsView.transportProtocol());
xsettingsClass.useDefaultServicePortInEndpoint(stubSettingsView.useDefaultServicePortInEndpoint());
xsettingsClass.defaultTransportProviderBuilder(stubSettingsView.defaultTransportProviderBuilder());
xsettingsClass.stubSettingsName(getAndSaveNicknameForStubType(context, namer.getApiStubSettingsClassName(interfaceConfig)));
return xsettingsClass.build();
}
Aggregations