-
Notifications
You must be signed in to change notification settings - Fork 475
Add support for name in badges #898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution.
* @return a Badge instance for the edited badge | ||
* @throws GitLabApiException if any exception occurs | ||
*/ | ||
public Badge editBadge(Object groupIdOrPath, Long badgeId, String name, String linkUrl, String imageUrl) throws GitLabApiException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I check on the current documentation of group badges and I don't find the edit with name.
I did not try against latest versions of GitLab. Did you tried?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you cannot directly edit based on name and that is not what this code is doing.
It is still using badgeId
to find the badge, and then setting name
and other values to that requested.
The name only really matters on creation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see what you mean now.
I will go and check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have submitted a merge request to update the API documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roadSurfer thanks.
* @return All badges of the GitLab item, case insensitively filtered on name. | ||
* @throws GitLabApiException If any problem is encountered | ||
*/ | ||
public List<Badge> getBadges(Object groupIdOrPath, String name) throws GitLabApiException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitLab4j is mostly a wrapper around GitLab API. Actually it seems that there is no possibility to find badges by name. The best way to implement this is to add a filter directly on GitLab. You can create an issue here https://gitlab.com/gitlab-org/gitlab/-/issues
Then when implementing, I will be happy to add the support of this filter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops! Accidentally hit "Resolve conversation". Sorry. Information on adding/editing badges with names can now be found in the Group and Project API docs after 109473 was merged. Also modified my code to use the documented I think that's all the required changes. |
For a recent project I wanted to be able to set badge names and find them again based on that name, as this was simply more convenient than UUID.
To facilitate this, I have added a few methods to
ProjectAPI
andGroupAPI
and ensured the interface remains backwards compatible.