diff --git a/group_serviceaccounts.go b/group_serviceaccounts.go index 4acb0b180..3ccb41b5e 100644 --- a/group_serviceaccounts.go +++ b/group_serviceaccounts.go @@ -62,8 +62,9 @@ func (s *GroupsService) CreateServiceAccount(gid interface{}, options ...Request // GitLab API docs: // https://docs.gitlab.com/ee/api/groups.html#create-personal-access-token-for-service-account-user type CreateServiceAccountPersonalAccessTokenOptions struct { - Scopes *[]string `url:"scopes,omitempty" json:"scopes,omitempty"` - Name *string `url:"name,omitempty" json:"name,omitempty"` + Scopes *[]string `url:"scopes,omitempty" json:"scopes,omitempty"` + Name *string `url:"name,omitempty" json:"name,omitempty"` + ExpiresAt *ISOTime `url:"expires_at,omitempty" json:"expires_at,omitempty"` } // CreateServiceAccountPersonalAccessToken add a new Personal Access Token for a diff --git a/group_serviceaccounts_test.go b/group_serviceaccounts_test.go index e4793f610..b878c8eba 100644 --- a/group_serviceaccounts_test.go +++ b/group_serviceaccounts_test.go @@ -22,6 +22,8 @@ import ( "reflect" "testing" "time" + + "github.com/stretchr/testify/require" ) func TestCreateServiceAccount(t *testing.T) { @@ -72,9 +74,14 @@ func TestCreateServiceAccountPersonalAccessToken(t *testing.T) { "token":"random_token" }`) }) + + expireTime, err := ParseISOTime("2024-06-12") + require.NoError(t, err) + options := &CreateServiceAccountPersonalAccessTokenOptions{ - Scopes: Ptr([]string{"api"}), - Name: Ptr("service_account_token"), + Scopes: Ptr([]string{"api"}), + Name: Ptr("service_account_token"), + ExpiresAt: Ptr(expireTime), } pat, _, err := client.Groups.CreateServiceAccountPersonalAccessToken(1, 57, options) if err != nil {