use of com.google.api.codegen.discogapic.transformer.DiscoGapicNamer 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.discogapic.transformer.DiscoGapicNamer in project toolkit by googleapis.
the class ResourceNameMessageConfigs method createMessageResourceTypesConfig.
static ResourceNameMessageConfigs createMessageResourceTypesConfig(DiscoApiModel model, ConfigProto configProto, String defaultPackage, SurfaceNamer languageNamer) {
ImmutableMap.Builder<String, ResourceNameMessageConfig> builder = ImmutableMap.builder();
for (ResourceNameMessageConfigProto messageResourceTypesProto : configProto.getResourceNameGenerationList()) {
ResourceNameMessageConfig messageResourceTypeConfig = ResourceNameMessageConfig.createResourceNameMessageConfig(model.getDiagCollector(), messageResourceTypesProto, defaultPackage);
builder.put(messageResourceTypeConfig.messageName(), messageResourceTypeConfig);
}
ImmutableMap<String, ResourceNameMessageConfig> messageResourceTypeConfigMap = builder.build();
ListMultimap<String, FieldModel> fieldsByMessage = ArrayListMultimap.create();
DiscoGapicNamer discoGapicNamer = new DiscoGapicNamer();
for (Method method : model.getDocument().methods()) {
String fullName = discoGapicNamer.getRequestTypeName(method, languageNamer).getFullName();
ResourceNameMessageConfig messageConfig = messageResourceTypeConfigMap.get(fullName);
if (messageConfig == null) {
continue;
}
for (Schema property : method.parameters().values()) {
if (messageConfig.getEntityNameForField(property.getIdentifier()) != null) {
fieldsByMessage.put(fullName, DiscoveryField.create(property, model));
}
}
}
return new AutoValue_ResourceNameMessageConfigs(messageResourceTypeConfigMap, fieldsByMessage);
}
Aggregations