xanzy / go-gitlab

GitLab Go SDK
Apache License 2.0
2.37k stars 940 forks source link

Add State to ListProjectAccessTokensOptions #1983

Open elchenberg opened 1 month ago

elchenberg commented 1 month ago

GitLab 17.2 added the state attribute to the ListProjectAccessTokens API: https://docs.gitlab.com/ee/api/project_access_tokens.html#list-project-access-tokens

I am not very experienced with Go but since it seems to be a small change I might give it a try and open a pull request if it is okay with you:

diff --git a/project_access_tokens.go b/project_access_tokens.go
index 2d6057e..4191a2d 100644
--- a/project_access_tokens.go
+++ b/project_access_tokens.go
@@ -56,7 +56,11 @@ func (v ProjectAccessToken) String() string {
 //
 // GitLab API docs:
 // https://docs.gitlab.com/ee/api/project_access_tokens.html#list-project-access-tokens
-type ListProjectAccessTokensOptions ListOptions
+type ListProjectAccessTokensOptions struct {
+       ListOptions
+       // Limit results to tokens with specified state. Valid values are active and inactive. By default both states are returned.
+       State *string `url:"state,omitempty" json:"state,omitempty"`
+}

 // ListProjectAccessTokens gets a list of all project access tokens in a
 // project.
svanharmelen commented 1 month ago

Go right ahead and give it a shot. I'm sure it will be fine 👍🏻