private static ImmutableMap<String, String> createMethodRetryNamesFromConfigProto( InterfaceConfigProto interfaceConfigProto) { ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); // Add each method name from config proto and its non-empty retry code name. // Sample entry: {"ListShelves", "non_idempotent"} for (MethodConfigProto method : interfaceConfigProto.getMethodsList()) { if (!Strings.isNullOrEmpty(method.getRetryCodesName())) { builder.put(method.getName(), method.getRetryCodesName()); } } return builder.build(); }
/** Return a list of configs for method in the order given by the GAPIC interface config. */ static <T> List<T> createMethodConfigs( ImmutableMap<String, T> methodConfigMap, InterfaceConfigProto interfaceConfigProto) { if (interfaceConfigProto.equals(InterfaceConfigProto.getDefaultInstance())) { // InterfaceConfigProto was not given, so just return the order in methodConfigMap. return methodConfigMap.values().asList(); } List<T> methodConfigs = new ArrayList<>(); for (MethodConfigProto methodConfigProto : interfaceConfigProto.getMethodsList()) { methodConfigs.add(methodConfigMap.get(methodConfigProto.getName())); } return methodConfigs; }
public static String getRetryParamsName( MethodConfigProto methodConfigProto, DiagCollector diagCollector, Set<String> retryParamsConfigNames) { String retryParamsName = methodConfigProto.getRetryParamsName(); if (Strings.isNullOrEmpty(retryParamsName)) { return RETRY_PARAMS_DEFAULT_NAME; } if (!retryParamsConfigNames.isEmpty() && !retryParamsConfigNames.contains(retryParamsName)) { diagCollector.addDiag( Diag.error( SimpleLocation.TOPLEVEL, "Retry parameters config used but not defined: %s (in method %s)", retryParamsName, methodConfigProto.getName())); return null; } return retryParamsName; }
public SampleSpec(MethodConfigProto methodConfigProto) { specified = methodConfigProto.hasSamples(); sampleConfiguration = methodConfigProto.getSamples(); valueSets = methodConfigProto.getSampleValueSetsList(); HashSet<String> ids = new HashSet<>(); for (SampleValueSet valueSet : valueSets) { String id = valueSet.getId(); if (!ids.add(id)) { throw new IllegalArgumentException( String.format( "in method \"%s\": duplicate value set id: \"%s\"", methodConfigProto.getName(), id)); } } }
/** Find the methods that should be generated on the surface when a GAPIC config was given. */ @Nullable private static ImmutableMap<Method, MethodConfigProto> findMethodsToGenerateWithConfigYaml( Interface apiInterface, InterfaceConfigProto interfaceConfigProto, DiagCollector diagCollector) { ImmutableMap.Builder<Method, MethodConfigProto> methodsToSurface = ImmutableMap.builder(); // Get the set of methods defined by the GAPIC config. Only these methods will be generated. for (MethodConfigProto methodConfigProto : interfaceConfigProto.getMethodsList()) { Interface targetInterface = GapicInterfaceConfig.getTargetInterface( apiInterface, methodConfigProto.getRerouteToGrpcInterface()); Method protoMethod = targetInterface.lookupMethod(methodConfigProto.getName()); if (protoMethod == null) { diagCollector.addDiag( Diag.error( SimpleLocation.TOPLEVEL, "method not found: %s", methodConfigProto.getName())); continue; } methodsToSurface.put(protoMethod, methodConfigProto); } if (diagCollector.getErrorCount() > 0) { return null; } return methodsToSurface.build(); }
Method method = lookupMethod(model.getDocument(), methodConfigProto.getName()); if (method == null) { model .addDiag( Diag.error( SimpleLocation.TOPLEVEL, "method not found: %s", methodConfigProto.getName())); continue; continue; methodConfigMapBuilder.put(methodConfigProto.getName(), methodConfig);
String retryCodesName = retryCodesConfig.getMethodRetryNames().get(methodConfigProto.getName());