/** Provides a TypeName for the given TypeRef. */ @Override public TypeName getTypeName(InterfaceModel interfaceModel) { return getTypeName(((ProtoInterfaceModel) interfaceModel).getInterface()); }
@Override public String getFullNameFor(InterfaceModel type) { return getFullNameFor(((ProtoInterfaceModel) type).getInterface()); }
public Interface getInterface() { return getInterfaceModel().getInterface(); }
public Interface getInterface() { return getInterfaceModel().getInterface(); }
public Interface getInterface() { return getInterfaceModel().getInterface(); }
@Override public String getFullNameFor(InterfaceModel interfaceModel) { return typeNameConverter .getTypeName(((ProtoInterfaceModel) interfaceModel).getInterface()) .getFullName(); }
@VisibleForTesting List<String> getAuthScopes(ProtoParser protoParser, List<ProtoInterfaceModel> interfaces) { Set<String> result = new TreeSet<>(); // Get scopes from protofile. interfaces.forEach(i -> result.addAll(protoParser.getAuthScopes(i.getInterface()))); Service config = protoModel.getServiceConfig(); Authentication auth = config.getAuthentication(); for (AuthenticationRule rule : auth.getRulesList()) { // Scopes form a union and the union is used for down-scoping, so adding more scopes that // are subsets of the others already in the union essentially has no effect. // We are doing this for implementation simplicity so we don't have to compute which scopes // are subsets of the others. String scopesString = rule.getOauth().getCanonicalScopes(); for (String scope : scopesString.split(",")) { result.add(scope.trim()); } } return new ArrayList<>(result); }
@Override public Map<String, String> getResourceToEntityNameMap(InterfaceModel apiInterface) { Interface protoInterface = ((ProtoInterfaceModel) apiInterface).getInterface();
@Override public GapicInterfaceConfig getInterfaceConfig() { return getProductConfig().getInterfaceConfig(getInterfaceModel().getInterface()); }
private Set<String> generateImportFilenames(GapicInterfaceContext context) { Set<String> filenames = new TreeSet<>(); filenames.add(context.getInterface().getFile().getSimpleName()); for (MethodModel method : context.getSupportedMethods()) { Interface targetInterface = context.asRequestMethodContext(method).getTargetInterface().getInterface(); filenames.add(targetInterface.getFile().getSimpleName()); } return filenames; }
public static GapicInterfaceContext create( InterfaceModel apiInterface, GapicProductConfig productConfig, ModelTypeTable typeTable, SurfaceNamer namer, FeatureConfig featureConfig) { ProtoInterfaceModel protoInterface = (ProtoInterfaceModel) apiInterface; return new AutoValue_GapicInterfaceContext( protoInterface, productConfig, typeTable, namer, featureConfig, createGrpcRerouteMap(protoInterface.getInterface().getModel(), productConfig)); }
/** * The type name of the Grpc container class. This needs to match what Grpc generates for the * particular language. */ public String getGrpcContainerTypeName(InterfaceModel apiInterface) { String fullName = JavaModelTypeNameConverter.getGrpcTypeName( ((ProtoInterfaceModel) apiInterface).getInterface()) .getFullName(); NamePath namePath = getTypeNameConverter().getNamePath(fullName); String publicClassName = publicClassName(Name.upperCamelKeepUpperAcronyms(namePath.getHead(), "Grpc")); return qualifiedName(namePath.withHead(publicClassName)); }
@Override public GapicMethodContext cloneWithEmptyTypeTable() { return create( getSurfaceInterfaceContext(), getInterfaceModel().getInterface(), getProductConfig(), getTypeTable().cloneEmpty(), getNamer(), getMethodConfig(), getFlatteningConfig(), getFeatureConfig()); }
@Override public MethodContext withResourceNamesInSamplesOnly() { return create( getSurfaceInterfaceContext(), getInterfaceModel().getInterface(), getProductConfig(), getTypeTable(), getNamer(), getMethodConfig(), getFlatteningConfig() == null ? null : getFlatteningConfig().withResourceNamesInSamplesOnly(), getFeatureConfig()); } }
/** * The type name of the Grpc service class This needs to match what Grpc generates for the * particular language. */ @Override public String getGrpcServiceClassName(InterfaceModel apiInterface) { String fullName = JavaModelTypeNameConverter.getGrpcTypeName( ((ProtoInterfaceModel) apiInterface).getInterface()) .getFullName(); NamePath namePath = getTypeNameConverter().getNamePath(fullName); String grpcContainerName = publicClassName(Name.upperCamelKeepUpperAcronyms(namePath.getHead(), "Grpc")); String serviceClassName = publicClassName(Name.upperCamelKeepUpperAcronyms(apiInterface.getSimpleName(), "ImplBase")); return qualifiedName(namePath.withHead(grpcContainerName).append(serviceClassName)); }