use of org.kohsuke.stapler.export.Exported in project jenkins by jenkinsci.
the class Fingerprint method _getUsages.
// this is for remote API
@Exported(name = "usage")
@NonNull
public List<RangeItem> _getUsages() {
List<RangeItem> r = new ArrayList<>();
final Jenkins instance = Jenkins.get();
for (Map.Entry<String, RangeSet> e : usages.entrySet()) {
final String itemName = e.getKey();
if (instance.hasPermission(Jenkins.ADMINISTER) || canDiscoverItem(itemName)) {
r.add(new RangeItem(itemName, e.getValue()));
}
}
return r;
}
use of org.kohsuke.stapler.export.Exported in project jenkins by jenkinsci.
the class Label method getNodes.
/**
* Gets all {@link Node}s that belong to this label.
*/
@Exported
public Set<Node> getNodes() {
Set<Node> nodes = this.nodes;
if (nodes != null)
return nodes;
Set<Node> r = new HashSet<>();
Jenkins h = Jenkins.get();
if (this.matches(h))
r.add(h);
for (Node n : h.getNodes()) {
if (this.matches(n))
r.add(n);
}
return this.nodes = Collections.unmodifiableSet(r);
}
use of org.kohsuke.stapler.export.Exported in project kubernetes-plugin by jenkinsci.
the class KubernetesComputer method getContainers.
@Exported
public List<Container> getContainers() throws KubernetesAuthException, IOException {
if (!Jenkins.get().hasPermission(Computer.EXTENDED_READ)) {
LOGGER.log(Level.FINE, " Computer {0} getContainers, lack of admin permission, returning empty list", this);
return Collections.emptyList();
}
KubernetesSlave slave = getNode();
if (slave == null) {
return Collections.emptyList();
}
KubernetesCloud cloud = slave.getKubernetesCloud();
KubernetesClient client = cloud.connect();
String namespace = StringUtils.defaultIfBlank(slave.getNamespace(), client.getNamespace());
Pod pod = client.pods().inNamespace(namespace).withName(getName()).get();
if (pod == null) {
return Collections.emptyList();
}
return pod.getSpec().getContainers();
}
Aggregations