Thanks. I don't understand why this *user* informations are not actually exposed on the /*user* api.
So, I create a new UserProperty called UserViewsProperty (source code in attachment) and integrate it in a plugin. This solution required me to create an empty config.jelly for the /user/configure page. My skills on Jenkins core being insufficient, I haven't really understood why. When I call the user api, I 've got now a new property called "userViews" In any case, it works but I'm interested in any comments or another type of solution. Le mercredi 13 janvier 2016 16:09:35 UTC+1, Daniel Beck a écrit : > > These are not exposed via the API. The MyViewsProperty is one of the empty > {} in 'property'. > > On 13.01.2016, at 15:52, Yohann Perraud <yohann....@gmail.com > <javascript:>> wrote: > > > Hi, > > > > Is there a way to retrieve the list of view for a user via the Rest API > ? > > > > I tried /user/<username>/my-views/api/json, /user/picadmin/api/json with > differents depth but it never return his views. > > I googled it and I 've found nothing. > > > > Thanks in advance. > > > > Yohann. > > > > > > > > -- > > You received this message because you are subscribed to the Google > Groups "Jenkins Users" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to jenkinsci-use...@googlegroups.com <javascript:>. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/jenkinsci-users/85cb952a-8012-4ce3-aeb5-e9dd2873dc9b%40googlegroups.com. > > > > For more options, visit https://groups.google.com/d/optout. > > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/994ffddb-c262-46bf-bcfc-0743dabf377a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
package fr.laposte.disfe.pic.adb.jenkins.plugin.property; import hudson.Extension; import hudson.model.UserProperty; import hudson.model.UserPropertyDescriptor; import hudson.model.MyViewsProperty; import hudson.model.User; import hudson.model.View; import java.util.ArrayList; import java.util.List; import net.sf.json.JSONObject; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.export.Exported; public class UserViewsProperty extends hudson.model.UserProperty { public UserViewsProperty() { } @Exported(name = "userViews"/* , inline = true */) public List<View> getUserViews() { final User user = User.current(); if (user != null && user.getProperty(MyViewsProperty.class) != null) { return new ArrayList<View>(user.getProperty(MyViewsProperty.class).getViews()); } return new ArrayList<View>(); } @Extension public static final class DescriptorImpl extends UserPropertyDescriptor { @Override public String getDisplayName() { return null; } @Override public UserProperty newInstance(final User user) { return new UserViewsProperty(); } @Override public UserProperty newInstance(final StaplerRequest req, final JSONObject formData) throws FormException { return null; } } }