public static GapicMethodContext create( GapicInterfaceContext surfaceTransformerContext, Interface apiInterface, GapicProductConfig productConfig, ModelTypeTable typeTable, SurfaceNamer namer, GapicMethodConfig methodConfig, FlatteningConfig flatteningConfig, FeatureConfig featureConfig) { return new AutoValue_GapicMethodContext( productConfig, namer, flatteningConfig, featureConfig, methodConfig, surfaceTransformerContext, typeTable, new ProtoInterfaceModel(apiInterface)); }
@Override public ApiModel getApiModel() { return getInterfaceModel().getApiModel(); }
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)); }
/** Provides a TypeName for the given TypeRef. */ @Override public TypeName getTypeName(InterfaceModel interfaceModel) { return getTypeName(((ProtoInterfaceModel) interfaceModel).getInterface()); }
private List<ClientTestFileView> createUnitTestViews( ApiModel model, GapicProductConfig productConfig) { ImmutableList.Builder<ClientTestFileView> views = ImmutableList.builder(); SurfaceNamer namer = new RubySurfaceNamer(productConfig.getPackageName()); for (InterfaceModel apiInterface : model.getInterfaces()) { if (!productConfig.hasInterfaceConfig(apiInterface)) { continue; } GapicInterfaceContext context = createContext(apiInterface, productConfig); String testClassName = namer.getUnitTestClassName(context.getInterfaceConfig()); String outputPath = unitTestPathMapper.getOutputPath( context.getInterfaceModel().getFullName(), productConfig); ImportSectionView importSection = importSectionTransformer.generateTestImportSection(context); views.add( ClientTestFileView.newBuilder() .templateFileName(UNIT_TEST_TEMPLATE_FILE) .outputPath(namer.getSourceFilePath(outputPath, testClassName)) .testClass(createUnitTestClassView(context, model.hasMultipleServices())) .fileHeader( fileHeaderTransformer.generateFileHeader(productConfig, importSection, namer)) .apiVersion(packageConfig.apiVersion()) .build()); } return views.build(); }
List<ResourceProtoView> protos = new ArrayList<>(); String defaultPackageName = context.getInterfaceModel().getParentFullName(); for (Entry<String, Collection<FieldModel>> entry : fieldsByMessage.asMap().entrySet()) { String msgName = entry.getKey();
surfacePackageNamer.publicClassName( Name.upperCamelKeepUpperAcronyms( context.getInterfaceModel().getSimpleName()))) .testCases(createTestCaseViews(context)) .apiHasUnaryUnaryMethod(hasUnaryUnary(context.getInterfaceConfig()))
@Override public String getFullNameFor(InterfaceModel type) { return getFullNameFor(((ProtoInterfaceModel) type).getInterface()); }
private SmokeTestClassView createSmokeTestClassView(GapicInterfaceContext context) { String outputPath = PhpGapicCodePathMapper.newBuilder() .setPrefix("tests/System") .build() .getOutputPath(context.getInterfaceModel().getFullName(), context.getProductConfig()); SurfaceNamer namer = context.getNamer(); String name = namer.getSmokeTestClassName(context.getInterfaceConfig()); SmokeTestClassView.Builder testClass = createSmokeTestClassViewBuilder(context); testClass.name(name); testClass.outputPath(namer.getSourceFilePath(outputPath, name)); return testClass.build(); }
@Override public ProtoInterfaceModel getInterface(String interfaceName) { return new ProtoInterfaceModel(protoModel.getSymbolTable().lookupInterface(interfaceName)); }
public Interface getInterface() { return getInterfaceModel().getInterface(); }
String subPath = pathMapper.getSamplesOutputPath( context.getInterfaceModel().getFullName(), context.getProductConfig(), method.name()); for (MethodSampleView methodSample : method.samples()) { String callingForm = methodSample.callingForm().toLowerCamel();
private static SmokeTestConfig createSmokeTestConfig( DiagCollector diagCollector, Interface apiInterface, InterfaceConfigProto interfaceConfigProto) { if (interfaceConfigProto.hasSmokeTest()) { return SmokeTestConfig.createSmokeTestConfig( new ProtoInterfaceModel(apiInterface), interfaceConfigProto.getSmokeTest(), diagCollector); } else { return null; } }
public Interface getInterface() { return getInterfaceModel().getInterface(); }
String subPath = pathMapper.getSamplesOutputPath( context.getInterfaceModel().getFullName(), context.getProductConfig(), method.name()); for (MethodSampleView methodSample : method.samples()) { String callingForm = methodSample.callingForm().toLowerCamel();
@Override public ProtoInterfaceModel getTargetInterface() { return new ProtoInterfaceModel( GapicInterfaceConfig.getTargetInterface( getInterface(), getMethodConfig().getRerouteToGrpcInterface())); }
public Interface getInterface() { return getInterfaceModel().getInterface(); }
view.servicePhraseName(namer.getServicePhraseName(interfaceConfig)); String outputPath = pathMapper.getOutputPath(apiInterface.getFullName(), productConfig); String fileName = namer.getServiceFileName(context.getInterfaceConfig()); view.outputPath(outputPath + File.separator + fileName);
@Test public void testGetAuthScopes() { List<ProtoInterfaceModel> interfaces = Arrays.asList( new ProtoInterfaceModel(libraryService), new ProtoInterfaceModel(foodService)); List<String> scopes = apiModel.getAuthScopes(protoParser, interfaces); assertThat(scopes.size()).isEqualTo(6); assertThat(scopes.contains("https://www.googleapis.com/auth/calendar")).isTrue(); assertThat(scopes.contains("https://www.googleapis.com/auth/calendar.read")).isTrue(); assertThat(scopes.contains("https://www.googleapis.com/auth/default")).isTrue(); assertThat(scopes.contains("https://www.googleapis.com/auth/food")).isTrue(); assertThat(scopes.contains("https://www.googleapis.com/auth/library")).isTrue(); assertThat(scopes.contains("https://www.googleapis.com/auth/pumpkin")).isTrue(); } }
@Override public String getFullNameFor(InterfaceModel interfaceModel) { return typeNameConverter .getTypeName(((ProtoInterfaceModel) interfaceModel).getInterface()) .getFullName(); }