-
Notifications
You must be signed in to change notification settings - Fork 963
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
Feature Request: Get Groups by Custom Attribute #1617
Comments
Going with the |
If supported and documented it should probably become a field in the appropriate options struct. |
https://docs.gitlab.com/ee/api/groups.html#list-groups looks to be documented at the end of the type ListGroupsOptions struct {
...
CustomAttributes map[string]string `url:"custom_attributes,omitempty" json:"-"`
} |
So this is turning out to be a little trickier to implement than I thought with adding the CustomAttributes as a field in the I'm trying to follow the examples go-querystring has of using nested structs to encode nested values in order to get Maybe my test is wrong (and I'm sure I'm making some dumb mistakes after a long day of writing code at work lol) but testing the params results in: gitlab_test.go:89: Request query: custom_attributes=%7Bvalue%7D, want custom_attributes[key]=value when the struct for type ListGroupsOptions struct {
...
CustomAttributes interface{} `url:"custom_attributes,omitempty" json:"-"`
} and in the tests opts := &ListGroupsOptions{
CustomAttributes: struct {
Key string `url:"key"`
}{
Key: "value",
},
} the brackets |
not sure if this is any helpful, but i used this included helper in q := url.Values{} encoded := q.Encode() |
All the endpoints on https://docs.gitlab.com/ee/api/custom_attributes.html are covered within https://github.com/xanzy/go-gitlab/blob/main/custom_attributes.go, so this issue could be closed |
Thanks for the heads up @heidiberry 👍🏻 |
@svanharmelen @heidiberry |
@adrianliechti Ah I thought you were wanting the API from the docs linked in the description. Are you talking about the |
I think I've found what you were meaning now, the custom_attributes[key]=value pattern. Yes you are right, this isn't currently supported |
I should still have the code that implements this, might be a little stale. I completely forgot to come back to finishing this lol |
I'll reopen the issue 😏 |
According the GitLab Docs, there is a handy query to get groups by custom attributes:
You can filter by custom attributes](https://docs.gitlab.com/ee/api/custom_attributes.html with:
GET /groups?custom_attributes[key]=value&custom_attributes[other_key]=other_value
I have not found this option in the current version (of this amazing lib).
Could you consider an option to do it? Maybe using a map on the ListGroupsOptions? or by having a RequestOptionFunc WithCustomQuery(key, value)
In the meantime, I used this workaround:
The text was updated successfully, but these errors were encountered: