Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Support more options for list PATs #1977

Merged
merged 5 commits into from
Aug 8, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion personal_access_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ func (p PersonalAccessToken) String() string {
// https://docs.gitlab.com/ee/api/personal_access_tokens.html#list-personal-access-tokens
type ListPersonalAccessTokensOptions struct {
ListOptions
UserID *int `url:"user_id,omitempty" json:"user_id,omitempty"`
CreatedAfter *time.Time `url:"created_after,omitempty" json:"created_after,omitempty"`
CreatedBefore *time.Time `url:"created_before,omitempty" json:"created_before,omitempty"`
LastUsedAfter *time.Time `url:"last_used_after,omitempty" json:"last_used_after,omitempty"`
LastUsedBefore *time.Time `url:"last_used_before,omitempty" json:"last_used_before,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess these *time.Time fields should be *ISOTime looking at the docs. Can you check/confirm?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I check gitlab api document and confirm that you are right,we need to use *ISOTime instead of *time.Time
I have change the type

Revoked *bool `url:"revoked,omitempty" json:"revoked,omitempty"`
Search *string `url:"search,omitempty" json:"search,omitempty"`
State *string `url:"state,omitempty" json:"state,omitempty"`
UserID *int `url:"user_id,omitempty" json:"user_id,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this should be an interface{} as it can be either a string or an in. Not sure if we have that elsewhere and already have something for that more specific than an interface{}...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We declare user id as type int in all our sdk golang code. Even through gitlab list PATs api support user id as type string in query string paramers as well, I think it's better to just declare user id as type int.
Supporting type string may increase complexity and inconsistency

}

// ListPersonalAccessTokens gets a list of all personal access tokens.
Expand Down
Loading