Search in sources :

Example 1 with DiscoGapicNamer

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);
}
Also used : DiscoGapicMethodConfig(com.google.api.codegen.config.DiscoGapicMethodConfig) MethodConfig(com.google.api.codegen.config.MethodConfig) DiscoveryMethodModel(com.google.api.codegen.config.DiscoveryMethodModel) MethodModel(com.google.api.codegen.config.MethodModel) ImmutableList(com.google.common.collect.ImmutableList) DiscoGapicNamer(com.google.api.codegen.discogapic.transformer.DiscoGapicNamer)

Example 2 with DiscoGapicNamer

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);
}
Also used : ResourceNameMessageConfigProto(com.google.api.codegen.ResourceNameMessageConfigProto) Schema(com.google.api.codegen.discovery.Schema) Method(com.google.api.codegen.discovery.Method) ImmutableMap(com.google.common.collect.ImmutableMap) DiscoGapicNamer(com.google.api.codegen.discogapic.transformer.DiscoGapicNamer)

Aggregations

DiscoGapicNamer (com.google.api.codegen.discogapic.transformer.DiscoGapicNamer)2 ResourceNameMessageConfigProto (com.google.api.codegen.ResourceNameMessageConfigProto)1 DiscoGapicMethodConfig (com.google.api.codegen.config.DiscoGapicMethodConfig)1 DiscoveryMethodModel (com.google.api.codegen.config.DiscoveryMethodModel)1 MethodConfig (com.google.api.codegen.config.MethodConfig)1 MethodModel (com.google.api.codegen.config.MethodModel)1 Method (com.google.api.codegen.discovery.Method)1 Schema (com.google.api.codegen.discovery.Schema)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1