Tabnine Logo
LookupService
Code IndexAdd Tabnine to your IDE (free)

How to use
LookupService
in
com.netflix.spinnaker.halyard.config.services.v1

Best Java code snippets using com.netflix.spinnaker.halyard.config.services.v1.LookupService (Showing top 20 results out of 315)

origin: com.netflix.spinnaker.halyard/halyard-config

/**
 * Given a node filter and a node type, find all nodes that match both the filter and the type of the Node.
 * @param filter is the filter to lookup by.
 * @param clazz is the class of the node type we want to find.
 * @return the nodes matching the filter and clazz.
 */
public <T extends Node> List<T> getMatchingNodesOfType(NodeFilter filter, Class<T> clazz) {
 Halconfig halconfig = parser.getHalconfig();
 return getMatchingNodes(halconfig, filter)
   .stream()
   .filter(clazz::isInstance)
   .map(n -> (T) n)
   .collect(Collectors.toList());
}
origin: com.netflix.spinnaker.halyard/halyard-config

 public <T extends Node> T getSingularNodeOrDefault(NodeFilter filter, Class<T> clazz, Supplier<T> defaultNode, Consumer<T> setDefault) {
  List<T> matching = getMatchingNodesOfType(filter, clazz);

  switch (matching.size()) {
   case 0:
    T node = defaultNode.get();
    setDefault.accept(node);
    return node;
   case 1:
    return matching.get(0);
   default:
    throw new RuntimeException("It shouldn't be possible to have multiple " + clazz.getCanonicalName() + " nodes. This is a bug.");
  }
 }
}
origin: spinnaker/halyard

public RoleProvider getRoleProvider(String deploymentName, String roleProviderName) {
 NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setSecurity().setRoleProvider(roleProviderName);
 return lookupService.getSingularNodeOrDefault(filter,
   RoleProvider.class,
   () -> {
    try {
     return GroupMembership.translateRoleProviderType(roleProviderName).newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
     throw new RuntimeException(e);
    }
   },
   n -> setRoleProvider(deploymentName, n));
}
origin: spinnaker/halyard

 public <T extends Node> T getSingularNodeOrDefault(NodeFilter filter, Class<T> clazz, Supplier<T> defaultNode, Consumer<T> setDefault) {
  List<T> matching = getMatchingNodesOfType(filter, clazz);

  switch (matching.size()) {
   case 0:
    T node = defaultNode.get();
    setDefault.accept(node);
    return node;
   case 1:
    return matching.get(0);
   default:
    throw new RuntimeException("It shouldn't be possible to have multiple " + clazz.getCanonicalName() + " nodes. This is a bug.");
  }
 }
}
origin: spinnaker/halyard

public AuthnMethod getAuthnMethod(String deploymentName, String methodName) {
 NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setSecurity().setAuthnMethod(methodName);
 return lookupService.getSingularNodeOrDefault(filter,
   AuthnMethod.class,
   () -> {
    try {
     return AuthnMethod.translateAuthnMethodName(methodName).newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
     throw new RuntimeException(e);
    }
   },
   n -> setAuthnMethod(deploymentName, n));
}
origin: spinnaker/halyard

/**
 * Given a node filter and a node type, find all nodes that match both the filter and the type of the Node.
 * @param filter is the filter to lookup by.
 * @param clazz is the class of the node type we want to find.
 * @return the nodes matching the filter and clazz.
 */
public <T extends Node> List<T> getMatchingNodesOfType(NodeFilter filter, Class<T> clazz) {
 Halconfig halconfig = parser.getHalconfig();
 return getMatchingNodes(halconfig, filter)
   .stream()
   .filter(clazz::isInstance)
   .map(n -> (T) n)
   .collect(Collectors.toList());
}
origin: com.netflix.spinnaker.halyard/halyard-config

public <T extends Node> FieldOptions options(NodeFilter filter, Class<T> nodeClass, String field) {
 ConfigProblemSetBuilder problemSetBuilder = new ConfigProblemSetBuilder(applicationContext);
 List<T> nodes = lookupService.getMatchingNodesOfType(filter, nodeClass);
 List<String> options = nodes.stream().map(n -> {
  problemSetBuilder.setNode(n);
  return n.fieldOptions(problemSetBuilder, field);
 }).reduce(new ArrayList<>(), (a, b) -> {
  a.addAll(b);
  return a;
 });
 return new FieldOptions().setOptions(options).setProblemSet(problemSetBuilder.build());
}
origin: com.netflix.spinnaker.halyard/halyard-config

public RoleProvider getRoleProvider(String deploymentName, String roleProviderName) {
 NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setSecurity().setRoleProvider(roleProviderName);
 return lookupService.getSingularNodeOrDefault(filter,
   RoleProvider.class,
   () -> {
    try {
     return GroupMembership.translateRoleProviderType(roleProviderName).newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
     throw new RuntimeException(e);
    }
   },
   n -> setRoleProvider(deploymentName, n));
}
origin: com.netflix.spinnaker.halyard/halyard-config

/**
 * @param node is the node whose children we want to find.
 * @param filter is the filter to lookup by.
 * @return the children of the input node matching the filter.
 */
private List<Node> getMatchingNodes(Node node, NodeFilter filter) {
 log.trace("Checking for leaf nodes of node " + node.getNodeName());
 List<Node> result = new ArrayList<>();
 NodeIterator children = node.getChildren();
 Node recurse = children.getNext(filter);
 while (recurse != null) {
  result.addAll(getMatchingNodes(recurse, filter));
  recurse = children.getNext(filter);
 }
 // If we have visited this node, it must have matched the filter.
 result.add(node);
 return result;
}
origin: spinnaker/halyard

public <T extends Node> FieldOptions options(NodeFilter filter, Class<T> nodeClass, String field) {
 ConfigProblemSetBuilder problemSetBuilder = new ConfigProblemSetBuilder(applicationContext);
 List<T> nodes = lookupService.getMatchingNodesOfType(filter, nodeClass);
 List<String> options = nodes.stream().map(n -> {
  problemSetBuilder.setNode(n);
  return n.fieldOptions(problemSetBuilder, field);
 }).reduce(new ArrayList<>(), (a, b) -> {
  a.addAll(b);
  return a;
 });
 return new FieldOptions().setOptions(options).setProblemSet(problemSetBuilder.build());
}
origin: com.netflix.spinnaker.halyard/halyard-config

public AuthnMethod getAuthnMethod(String deploymentName, String methodName) {
 NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setSecurity().setAuthnMethod(methodName);
 return lookupService.getSingularNodeOrDefault(filter,
   AuthnMethod.class,
   () -> {
    try {
     return AuthnMethod.translateAuthnMethodName(methodName).newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
     throw new RuntimeException(e);
    }
   },
   n -> setAuthnMethod(deploymentName, n));
}
origin: spinnaker/halyard

/**
 * @param node is the node whose children we want to find.
 * @param filter is the filter to lookup by.
 * @return the children of the input node matching the filter.
 */
private List<Node> getMatchingNodes(Node node, NodeFilter filter) {
 log.trace("Checking for leaf nodes of node " + node.getNodeName());
 List<Node> result = new ArrayList<>();
 NodeIterator children = node.getChildren();
 Node recurse = children.getNext(filter);
 while (recurse != null) {
  result.addAll(getMatchingNodes(recurse, filter));
  recurse = children.getNext(filter);
 }
 // If we have visited this node, it must have matched the filter.
 result.add(node);
 return result;
}
origin: spinnaker/halyard

public DeploymentEnvironment getDeploymentEnvironment(String deploymentName) {
 NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setDeploymentEnvironment();
 List<DeploymentEnvironment> matching = lookupService.getMatchingNodesOfType(filter, DeploymentEnvironment.class);
 switch (matching.size()) {
  case 0:
   DeploymentEnvironment deploymentEnvironment = new DeploymentEnvironment();
   setDeploymentEnvironment(deploymentName, deploymentEnvironment);
   return deploymentEnvironment;
  case 1:
   return matching.get(0);
  default:
   throw new RuntimeException("It shouldn't be possible to have multiple deploymentEnvironment nodes. This is a bug.");
 }
}
origin: spinnaker/halyard

public Canary getCanary(String deploymentName) {
 NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setCanary();
 return lookupService.getSingularNodeOrDefault(filter,
   Canary.class,
   Canary::new,
   n -> setCanary(deploymentName, n));
}
origin: spinnaker/halyard

public Features getFeatures(String deploymentName) {
 NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setFeatures();
 List<Features> matching = lookupService.getMatchingNodesOfType(filter, Features.class);
 switch (matching.size()) {
  case 0:
   Features features = new Features();
   setFeatures(deploymentName, features);
   return features;
  case 1:
   return matching.get(0);
  default:
   throw new RuntimeException("It shouldn't be possible to have multiple features nodes. This is a bug.");
 }
}
origin: com.netflix.spinnaker.halyard/halyard-config

public Security getSecurity(String deploymentName) {
 NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setSecurity();
 return lookupService.getSingularNodeOrDefault(filter,
   Security.class,
   Security::new,
   n -> setSecurity(deploymentName, n));
}
origin: com.netflix.spinnaker.halyard/halyard-config

public DeploymentEnvironment getDeploymentEnvironment(String deploymentName) {
 NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setDeploymentEnvironment();
 List<DeploymentEnvironment> matching = lookupService.getMatchingNodesOfType(filter, DeploymentEnvironment.class);
 switch (matching.size()) {
  case 0:
   DeploymentEnvironment deploymentEnvironment = new DeploymentEnvironment();
   setDeploymentEnvironment(deploymentName, deploymentEnvironment);
   return deploymentEnvironment;
  case 1:
   return matching.get(0);
  default:
   throw new RuntimeException("It shouldn't be possible to have multiple deploymentEnvironment nodes. This is a bug.");
 }
}
origin: com.netflix.spinnaker.halyard/halyard-config

public Canary getCanary(String deploymentName) {
 NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setCanary();
 return lookupService.getSingularNodeOrDefault(filter,
   Canary.class,
   Canary::new,
   n -> setCanary(deploymentName, n));
}
origin: spinnaker/halyard

public MetricStores getMetricStores(String deploymentName) {
 NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setMetricStores();
 List<MetricStores> matching = lookupService.getMatchingNodesOfType(filter, MetricStores.class);
 switch (matching.size()) {
  case 0:
   MetricStores metricStores = new MetricStores();
   setMetricStores(deploymentName, metricStores);
   return metricStores;
  case 1:
   return matching.get(0);
  default:
   throw new RuntimeException("It shouldn't be possible to have multiple metricStores nodes. This is a bug.");
 }
}
origin: spinnaker/halyard

private Artifacts getArtifacts(String deploymentName) {
 NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setArtifacts();
 return lookupService.getSingularNodeOrDefault(filter,
   Artifacts.class,
   Artifacts::new,
   n -> setArtifacts(deploymentName, n));
}
com.netflix.spinnaker.halyard.config.services.v1LookupService

Most used methods

  • getMatchingNodes
  • getMatchingNodesOfType
    Given a node filter and a node type, find all nodes that match both the filter and the type of the N
  • getSingularNodeOrDefault

Popular in Java

  • Parsing JSON documents to java classes using gson
  • runOnUiThread (Activity)
  • requestLocationUpdates (LocationManager)
  • onRequestPermissionsResult (Fragment)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • String (java.lang)
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Option (scala)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now