@Override public String getFullNameFor(InterfaceModel type) { return type.getFullName(); }
private ConfigNode generateMethodsValueNode( ConfigNode parentNode, InterfaceModel apiInterface, final Map<String, String> collectionNameMap) { return ListTransformer.generateList( apiInterface.getMethods(), parentNode, (startLine, method) -> generateMethodNode(startLine, method, collectionNameMap)); }
@Override public String getServicePhraseName(InterfaceConfig interfaceConfig) { return interfaceConfig.getInterfaceModel().getParentFullName() + " " + interfaceConfig.getInterfaceModel().getSimpleName() + " API"; }
/** The class name of the mock gRPC service implementation for the given API interface. */ public String getMockGrpcServiceImplName(InterfaceModel apiInterface) { return publicClassName( Name.upperCamelKeepUpperAcronyms("Mock", apiInterface.getSimpleName(), "Impl")); }
ArrayList<VersionIndexRequireView> requireViews = new ArrayList<>(); for (InterfaceModel apiInterface : apiInterfaces) { Name serviceName = namer.getReducedServiceName(apiInterface.getSimpleName()); String localName = hasVersion ? serviceName.join(version).toLowerCamel() : serviceName.toLowerCamel(); ApiMethodView exampleMethod = methodGenerator .generateApiMethods(context, apiInterface.getApiModel().hasMultipleServices()) .get(0); VersionIndexRequireView require =
public List<InterfaceModel> getGrpcInterfacesToMock( ApiModel model, GapicProductConfig productConfig) { Map<String, InterfaceModel> interfaces = new LinkedHashMap<>(); if (!productConfig.getTransportProtocol().equals(TransportProtocol.GRPC)) { return ImmutableList.of(); } for (InterfaceModel apiInterface : model.getInterfaces()) { if (!productConfig.hasInterfaceConfig(apiInterface)) { continue; } if (!apiInterface.isReachable()) { continue; } interfaces.putAll(getGrpcInterfacesForService(model, productConfig, apiInterface)); } return new ArrayList<>(interfaces.values()); }
GrpcStubView generateGrpcStub( InterfaceContext context, InterfaceModel targetInterface, List<MethodModel> methods) { SurfaceNamer namer = context.getNamer(); GrpcStubView.Builder stub = GrpcStubView.newBuilder(); stub.name(namer.getStubName(targetInterface)); stub.fullyQualifiedType(namer.getFullyQualifiedStubType(targetInterface)); stub.createStubFunctionName(namer.getCreateStubFunctionName(targetInterface)); String grpcClientTypeName = namer.getAndSaveNicknameForGrpcClientTypeName( context.getImportTypeTable(), targetInterface); stub.grpcClientTypeName(grpcClientTypeName); List<String> methodNames = new ArrayList<>(); for (MethodModel method : methods) { methodNames.add( namer.getApiMethodName(method, context.getMethodConfig(method).getVisibility())); } stub.methodNames(methodNames); stub.stubMethodsArrayName(namer.getStubMethodsArrayName(targetInterface)); stub.namespace(namer.getNamespace(targetInterface)); stub.protoFileName(targetInterface.getFileSimpleName()); return stub.build(); } }
/** The name of the function that will create a stub. */ public String getCreateStubFunctionName(InterfaceModel apiInterface) { return privateMethodName( Name.upperCamel("Create", apiInterface.getSimpleName(), "Stub", "Function")); }
@Override public String getGrpcServiceClassName(InterfaceModel apiInterface) { return publicClassName(Name.upperCamel(apiInterface.getSimpleName())) + "." + publicClassName(Name.upperCamel(apiInterface.getSimpleName(), "Client")); }
@Override public String getFullNameFor(InterfaceModel type) { return type.getFullName(); }
public List<MethodView> generateMethods( InterfaceModel apiInterface, Map<String, String> collectionNameMap) { ImmutableList.Builder<MethodView> methods = ImmutableList.builder(); for (MethodModel method : apiInterface.getMethods()) { MethodView.Builder methodView = MethodView.newBuilder(); methodView.name(method.getRawName()); generateField(method, methodView); generatePageStreaming(method, methodView); generateRetry(method, methodView); generateFieldNamePatterns(method, methodView, collectionNameMap); methodView.timeoutMillis(String.valueOf(DEFAULT_MAX_RETRY_DELAY)); methods.add(methodView.build()); } return methods.build(); }
/** The class name of the mock gRPC service for the given API interface. */ public String getMockServiceClassName(InterfaceModel apiInterface) { return publicClassName(Name.upperCamelKeepUpperAcronyms("Mock", apiInterface.getSimpleName())); }
/** Returns the InterfaceConfig for the given API interface. */ @Override public InterfaceConfig getInterfaceConfig(InterfaceModel apiInterface) { return getInterfaceConfigMap().get(apiInterface.getFullName()); }
public static SmokeTestConfig createSmokeTestConfig( InterfaceModel apiInterface, SmokeTestConfigProto smokeTestConfigProto, DiagCollector diagCollector) { MethodModel testedMethod = null; for (MethodModel method : apiInterface.getMethods()) { if (method.getSimpleName().equals(smokeTestConfigProto.getMethod())) { testedMethod = method; break; } } if (testedMethod != null) { return new AutoValue_SmokeTestConfig( testedMethod, smokeTestConfigProto.getInitFieldsList(), smokeTestConfigProto.getFlatteningGroupName()); } else { diagCollector.addDiag( Diag.error(SimpleLocation.TOPLEVEL, "The configured smoke test method does not exist.")); return null; } } }
@Override public String getApiWrapperClassConstructorName(InterfaceConfig interfaceConfig) { return getApiWrapperClassName(interfaceConfig.getInterfaceModel().getSimpleName()); }
/** True if contains an InterfaceConfig for the specified API interface */ @Override public boolean hasInterfaceConfig(InterfaceModel apiInterface) { return getInterfaceConfigMap().containsKey(apiInterface.getFullName()); }
/** The class name of a variable to hold the mock gRPC service for the given API interface. */ public String getMockServiceVarName(InterfaceModel apiInterface) { return localVarName(Name.upperCamelKeepUpperAcronyms("Mock", apiInterface.getSimpleName())); }
@Override public TypeName getTypeName(InterfaceModel interfaceModel) { return new TypeName(interfaceModel.getFullName()); }
/** The name of the variable that will hold the stub for an API interface. */ public String getStubName(InterfaceModel apiInterface) { return privateFieldName(Name.upperCamel(apiInterface.getSimpleName(), "Stub")); }
@Override public String getGrpcStubCallString(InterfaceModel apiInterface, MethodModel method) { return '/' + apiInterface.getFullName() + '/' + getGrpcMethodName(method); }