diff --git a/project_access_tokens.go b/project_access_tokens.go index ea545870d..e3625e596 100644 --- a/project_access_tokens.go +++ b/project_access_tokens.go @@ -34,15 +34,16 @@ type ProjectAccessTokensService struct { // // GitLab API docs: https://docs.gitlab.com/ee/api/resource_access_tokens.html type ProjectAccessToken struct { - ID int `json:"id"` - UserID int `json:"user_id"` - Name string `json:"name"` - Scopes []string `json:"scopes"` - CreatedAt *time.Time `json:"created_at"` - ExpiresAt *ISOTime `json:"expires_at"` - Active bool `json:"active"` - Revoked bool `json:"revoked"` - Token string `json:"token"` + ID int `json:"id"` + UserID int `json:"user_id"` + Name string `json:"name"` + Scopes []string `json:"scopes"` + CreatedAt *time.Time `json:"created_at"` + ExpiresAt *ISOTime `json:"expires_at"` + Active bool `json:"active"` + Revoked bool `json:"revoked"` + Token string `json:"token"` + AccessLevel int `json:"access_level"` } func (v ProjectAccessToken) String() string { @@ -88,9 +89,10 @@ func (s *ProjectAccessTokensService) ListProjectAccessTokens(pid interface{}, op // GitLab API docs: // https://docs.gitlab.com/ee/api/resource_access_tokens.html#create-a-project-access-token type CreateProjectAccessTokenOptions struct { - Name *string `url:"name,omitempty" json:"name,omitempty"` - Scopes []string `url:"scopes,omitempty" json:"scopes,omitempty"` - ExpiresAt *ISOTime `url:"expires_at,omitempty" json:"expires_at,omitempty"` + Name *string `url:"name,omitempty" json:"name,omitempty"` + Scopes []string `url:"scopes,omitempty" json:"scopes,omitempty"` + AccessLevel int `url:"access_level,omitempty" json:"access_level,omitempty"` + ExpiresAt *ISOTime `url:"expires_at,omitempty" json:"expires_at,omitempty"` } // CreateProjectAccessToken creates a new Project Access Token. diff --git a/project_access_tokens_test.go b/project_access_tokens_test.go index 942bbb7d1..7c57f9da8 100644 --- a/project_access_tokens_test.go +++ b/project_access_tokens_test.go @@ -48,22 +48,24 @@ func TestListProjectAccessTokens(t *testing.T) { want := []*ProjectAccessToken{ { - ID: 1876, - UserID: 2453, - Name: "token 10", - Scopes: []string{"api", "read_api", "read_repository", "write_repository"}, - CreatedAt: &time1, - Active: true, - Revoked: false, + ID: 1876, + UserID: 2453, + Name: "token 10", + Scopes: []string{"api", "read_api", "read_repository", "write_repository"}, + CreatedAt: &time1, + Active: true, + Revoked: false, + AccessLevel: 40, }, { - ID: 1877, - UserID: 2456, - Name: "token 8", - Scopes: []string{"api", "read_api", "read_repository", "write_repository"}, - CreatedAt: &time2, - Active: true, - Revoked: false, + ID: 1877, + UserID: 2456, + Name: "token 8", + Scopes: []string{"api", "read_api", "read_repository", "write_repository"}, + CreatedAt: &time2, + Active: true, + Revoked: false, + AccessLevel: 30, }, } @@ -91,15 +93,16 @@ func TestCreateProjectAccessToken(t *testing.T) { t.Errorf("ProjectAccessTokens.CreateProjectAccessToken returned error: %v", err) } want := &ProjectAccessToken{ - ID: 1876, - UserID: 2453, - Name: "token 10", - Scopes: []string{"api", "read_api", "read_repository", "write_repository"}, - ExpiresAt: nil, - CreatedAt: &time1, - Active: true, - Revoked: false, - Token: "2UsevZE1x1ZdFZW4MNzH", + ID: 1876, + UserID: 2453, + Name: "token 10", + Scopes: []string{"api", "read_api", "read_repository", "write_repository"}, + ExpiresAt: nil, + CreatedAt: &time1, + Active: true, + Revoked: false, + Token: "2UsevZE1x1ZdFZW4MNzH", + AccessLevel: 40, } if !reflect.DeepEqual(want, projectAccessToken) { diff --git a/testdata/create_project_access_token.json b/testdata/create_project_access_token.json index 232ca76cb..0a3768b33 100644 --- a/testdata/create_project_access_token.json +++ b/testdata/create_project_access_token.json @@ -12,5 +12,6 @@ "user_id": 2453, "active": true, "expires_at": null, - "token": "2UsevZE1x1ZdFZW4MNzH" + "token": "2UsevZE1x1ZdFZW4MNzH", + "access_level": 40 } diff --git a/testdata/list_project_access_tokens.json b/testdata/list_project_access_tokens.json index a801641c0..d1e382a0c 100644 --- a/testdata/list_project_access_tokens.json +++ b/testdata/list_project_access_tokens.json @@ -12,7 +12,8 @@ ], "user_id": 2453, "active": true, - "expires_at": null + "expires_at": null, + "access_level": 40 }, { "id": 1877, @@ -27,6 +28,7 @@ ], "user_id": 2456, "active": true, - "expires_at": null + "expires_at": null, + "access_level": 30 } ]