The API lacks support of the global snippets feature. The projects snippets are nice, but disabled per default, and thus users will more easily tend to publish snippets on global scope, than within projects.
Proposal
Update the /snippets endpoint which would help adding/deleting/modifying/listing all global snippets. Eventually, unifying with the projects snippets could be a good idea.
Links / references
I guess that's a case for the v9 API updates goals: #20070 (closed) (though if it could be backported to a future v8 that would be )
as I'm trying to offer an homogeneous and simple interface across github/gitlab/bitbucket, the lack of a global snippet API is a big problem. I'd rather drop project_snippets support altogether and only support global ones from CLI (or maybe keep listing/fetching them).
My main issues are that:
listing need iterating over list of projects, and then list of snippets (which takes forever, and needs pagination handling) ;
creation of a snippet will need a special CLI parameter just for gitlab
I need to retrieve the project_id from the name each time I need to access a snippet
Basically snippets from CLI can be very convenient, and without a good API, they are impossible to use Here's how it's currently working with github:
ok, so I have pushed an MR, cf !6373 (merged) with the implementation. Still have issues figuring out:
authentication when creating a new snippet…
how to implement search (looks like there's a SearchService would it work with snippets as well?)
how to correctly implement /snippets/public (like /snippets/search) so that those methods aren't returning 404.
Also, for consistency with the UI (which enables listing of another user's public snippets), I wanted to add a /users/:id/snippets to get the list of a given user's snippets, but I figured that actually it's not fitting the current API design… (or there would be a /users/:id/projects etc.). What would be the best way to list a user's snippets, then?
/snippets/user/:id? (imho, that does not feels right)
/snippets/search?user=:id? (that's not very REST, as user is a resource)
@guyzmo thanks! Please do open a new issue - the feature has been implemented, we just need to fix the docs. (Also, feel free to submit an MR if you have the time )