Search in sources :

Example 21 with Exported

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;
}
Also used : Jenkins(jenkins.model.Jenkins) ArrayList(java.util.ArrayList) Map(java.util.Map) TreeMap(java.util.TreeMap) NonNull(edu.umd.cs.findbugs.annotations.NonNull) Exported(org.kohsuke.stapler.export.Exported)

Example 22 with Exported

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);
}
Also used : Jenkins(jenkins.model.Jenkins) HashSet(java.util.HashSet) Exported(org.kohsuke.stapler.export.Exported)

Example 23 with Exported

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();
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) Pod(io.fabric8.kubernetes.api.model.Pod) Exported(org.kohsuke.stapler.export.Exported)

Aggregations

Exported (org.kohsuke.stapler.export.Exported)23 HashSet (java.util.HashSet)5 ArrayList (java.util.ArrayList)4 Jenkins (jenkins.model.Jenkins)3 NonNull (edu.umd.cs.findbugs.annotations.NonNull)2 Executable (hudson.model.Queue.Executable)2 Cloud (hudson.slaves.Cloud)2 Pod (io.fabric8.kubernetes.api.model.Pod)2 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)2 Method (java.lang.reflect.Method)2 ParameterizedType (java.lang.reflect.ParameterizedType)2 Type (java.lang.reflect.Type)2 GregorianCalendar (java.util.GregorianCalendar)2 ObjectMetadataAction (jenkins.scm.api.metadata.ObjectMetadataAction)2 CheckForNull (edu.umd.cs.findbugs.annotations.CheckForNull)1 ExtensionPoint (hudson.ExtensionPoint)1 PluginWrapper (hudson.PluginWrapper)1 User (hudson.model.User)1 Entry (hudson.scm.ChangeLogSet.Entry)1 UserProperty (hudson.tasks.Mailer.UserProperty)1