Skip to content

Commit 4c72f52

Browse files
committed
Tweak the PR a little to make it consistent.
1 parent 62ef9b1 commit 4c72f52

30 files changed

+706
-772
lines changed

Diff for: examples/personal_access_tokens.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func patRevokeExample() {
3030
log.Fatal(err)
3131
}
3232

33-
resp, err := git.PersonalAccessTokens.DeletePersonalAccessToken(99999999)
33+
resp, err := git.PersonalAccessTokens.RevokePersonalAccessToken(99999999)
3434
if err != nil {
3535
log.Fatal(err)
3636
}

Diff for: personal_access_tokens.go

+26-13
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,39 @@ package gitlab
1919
import (
2020
"fmt"
2121
"net/http"
22+
"time"
2223
)
2324

24-
// PersonalAccessTokensService handles communication with the Personal Access Tokens related methods
25-
// of the GitLab API.
25+
// PersonalAccessTokensService handles communication with the personal access
26+
// tokens related methods of the GitLab API.
2627
//
2728
// GitLab API docs: https://docs.gitlab.com/ee/api/personal_access_tokens.html
2829
type PersonalAccessTokensService struct {
2930
client *Client
3031
}
3132

33+
// PersonalAccessToken represents a personal access token.
34+
//
35+
// GitLab API docs: https://docs.gitlab.com/ee/api/personal_access_tokens.html
36+
type PersonalAccessToken struct {
37+
ID int `json:"id"`
38+
Name string `json:"name"`
39+
Revoked bool `json:"revoked"`
40+
CreatedAt *time.Time `json:"created_at"`
41+
Scopes []string `json:"scopes"`
42+
UserID int `json:"user_id"`
43+
LastUsedAt *time.Time `json:"last_used_at,omitempty"`
44+
Active bool `json:"active"`
45+
ExpiresAt *ISOTime `json:"expires_at"`
46+
Token string `json:"token,omitempty"`
47+
}
48+
3249
func (p PersonalAccessToken) String() string {
3350
return Stringify(p)
3451
}
3552

36-
// ListPersonalAccessTokensOptions represents the available options for
37-
// listing Personal Access Tokens across a GitLab instance or for a specific user.
53+
// ListPersonalAccessTokensOptions represents the available
54+
// ListPersonalAccessTokens() options.
3855
//
3956
// GitLab API docs:
4057
// https://docs.gitlab.com/ee/api/personal_access_tokens.html#list-personal-access-tokens
@@ -43,15 +60,12 @@ type ListPersonalAccessTokensOptions struct {
4360
UserID *int `url:"user_id,omitempty" json:"user_id,omitempty"`
4461
}
4562

46-
// ListPersonalAccessTokens gets a list of all Personal Access Tokens in a
47-
// GitLab instance optionally scoped down to a single users tokens.
63+
// ListPersonalAccessTokens gets a list of all personal access tokens.
4864
//
4965
// GitLab API docs:
5066
// https://docs.gitlab.com/ee/api/personal_access_tokens.html#list-personal-access-tokens
5167
func (s *PersonalAccessTokensService) ListPersonalAccessTokens(opt *ListPersonalAccessTokensOptions, options ...RequestOptionFunc) ([]*PersonalAccessToken, *Response, error) {
52-
u := "personal_access_tokens"
53-
54-
req, err := s.client.NewRequest(http.MethodGet, u, opt, options)
68+
req, err := s.client.NewRequest(http.MethodGet, "personal_access_tokens", opt, options)
5569
if err != nil {
5670
return nil, nil, err
5771
}
@@ -65,13 +79,12 @@ func (s *PersonalAccessTokensService) ListPersonalAccessTokens(opt *ListPersonal
6579
return pats, resp, err
6680
}
6781

68-
// DeletePersonalAccessToken deletes a Personal Access Token.
82+
// RevokePersonalAccessToken revokes a personal access token.
6983
//
7084
// GitLab API docs:
7185
// https://docs.gitlab.com/ee/api/personal_access_tokens.html#revoke-a-personal-access-token
72-
func (s *PersonalAccessTokensService) DeletePersonalAccessToken(id int, options ...RequestOptionFunc) (*Response, error) {
73-
74-
u := fmt.Sprintf("personal_access_tokens/%d", id)
86+
func (s *PersonalAccessTokensService) RevokePersonalAccessToken(token int, options ...RequestOptionFunc) (*Response, error) {
87+
u := fmt.Sprintf("personal_access_tokens/%d", token)
7588

7689
req, err := s.client.NewRequest(http.MethodDelete, u, nil, options)
7790
if err != nil {

Diff for: personal_access_tokens_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ func TestDeletePersonalAccessToken(t *testing.T) {
157157
testMethod(t, r, http.MethodDelete)
158158
})
159159

160-
_, err := client.PersonalAccessTokens.DeletePersonalAccessToken(1)
160+
_, err := client.PersonalAccessTokens.RevokePersonalAccessToken(1)
161161
if err != nil {
162-
t.Errorf("PersonalAccessTokens.DeletePersonalAccessToken returned error: %v", err)
162+
t.Errorf("PersonalAccessTokens.RevokePersonalAccessToken returned error: %v", err)
163163
}
164164
}

Diff for: project_access_tokens.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ func (v ProjectAccessToken) String() string {
5050
return Stringify(v)
5151
}
5252

53-
// ListProjectAccessTokensOptions represents the available options for
54-
// listing Project Access Tokens in a project.
53+
// ListProjectAccessTokensOptions represents the available
54+
// ListProjectAccessTokens() options.
5555
//
5656
// GitLab API docs:
5757
// https://docs.gitlab.com/ee/api/resource_access_tokens.html#list-project-access-tokens
5858
type ListProjectAccessTokensOptions ListOptions
5959

60-
// ListProjectAccessTokens gets a list of all Project Access Tokens in a
60+
// ListProjectAccessTokens gets a list of all project access tokens in a
6161
// project.
6262
//
6363
// GitLab API docs:
@@ -95,7 +95,7 @@ type CreateProjectAccessTokenOptions struct {
9595
ExpiresAt *ISOTime `url:"expires_at,omitempty" json:"expires_at,omitempty"`
9696
}
9797

98-
// CreateProjectAccessToken creates a new Project Access Token.
98+
// CreateProjectAccessToken creates a new project access token.
9999
//
100100
// GitLab API docs:
101101
// https://docs.gitlab.com/ee/api/resource_access_tokens.html#create-a-project-access-token
@@ -120,11 +120,11 @@ func (s *ProjectAccessTokensService) CreateProjectAccessToken(pid interface{}, o
120120
return pat, resp, err
121121
}
122122

123-
// DeleteProjectAccessToken deletes a Project Access Token.
123+
// RevokeProjectAccessToken revokes a project access token.
124124
//
125125
// GitLab API docs:
126126
// https://docs.gitlab.com/ee/api/resource_access_tokens.html#revoke-a-project-access-token
127-
func (s *ProjectAccessTokensService) DeleteProjectAccessToken(pid interface{}, id int, options ...RequestOptionFunc) (*Response, error) {
127+
func (s *ProjectAccessTokensService) RevokeProjectAccessToken(pid interface{}, id int, options ...RequestOptionFunc) (*Response, error) {
128128
project, err := parseID(pid)
129129
if err != nil {
130130
return nil, err

Diff for: project_access_tokens_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ func TestDeleteProjectAccessToken(t *testing.T) {
118118
testMethod(t, r, http.MethodDelete)
119119
})
120120

121-
_, err := client.ProjectAccessTokens.DeleteProjectAccessToken("1", 1234)
121+
_, err := client.ProjectAccessTokens.RevokeProjectAccessToken("1", 1234)
122122
if err != nil {
123-
t.Errorf("ProjectAccessTokens.DeleteProjectAccessToken returned error: %v", err)
123+
t.Errorf("ProjectAccessTokens.RevokeProjectAccessToken returned error: %v", err)
124124
}
125125
}

Diff for: testdata/create_group_access_token.json

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
"name": "token 10",
44
"revoked": false,
55
"created_at": "2021-03-09T21:11:47.271Z",
6-
"scopes": [
7-
"api",
8-
"read_api",
9-
"read_repository",
10-
"write_repository"
11-
],
6+
"scopes": ["api", "read_api", "read_repository", "write_repository"],
127
"user_id": 2453,
138
"active": true,
149
"expires_at": null,

Diff for: testdata/create_project_access_token.json

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
{
2-
"id": 1876,
3-
"name": "token 10",
4-
"revoked": false,
5-
"created_at": "2021-03-09T21:11:47.271Z",
6-
"scopes": [
7-
"api",
8-
"read_api",
9-
"read_repository",
10-
"write_repository"
11-
],
12-
"user_id": 2453,
13-
"active": true,
14-
"expires_at": null,
15-
"token": "2UsevZE1x1ZdFZW4MNzH",
16-
"access_level": 40
2+
"id": 1876,
3+
"name": "token 10",
4+
"revoked": false,
5+
"created_at": "2021-03-09T21:11:47.271Z",
6+
"scopes": ["api", "read_api", "read_repository", "write_repository"],
7+
"user_id": 2453,
8+
"active": true,
9+
"expires_at": null,
10+
"token": "2UsevZE1x1ZdFZW4MNzH",
11+
"access_level": 40
1712
}

Diff for: testdata/get_branch.json

+20-22
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
{
2-
"name": "master",
3-
"merged": false,
4-
"protected": true,
5-
"default": true,
6-
"developers_can_push": false,
7-
"developers_can_merge": false,
8-
"can_push": true,
9-
"commit": {
10-
"author_email": "[email protected]",
11-
"author_name": "John Smith",
12-
"authored_date": "2012-06-27T05:51:39.000Z",
13-
"committed_date": "2012-06-28T03:44:20.000Z",
14-
"committer_email": "[email protected]",
15-
"committer_name": "John Smith",
16-
"id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",
17-
"short_id": "7b5c3cc",
18-
"title": "add projects API",
19-
"message": "add projects API",
20-
"parent_ids": [
21-
"4ad91d3c1144c406e50c7b33bae684bd6837faf8"
22-
]
23-
}
2+
"name": "master",
3+
"merged": false,
4+
"protected": true,
5+
"default": true,
6+
"developers_can_push": false,
7+
"developers_can_merge": false,
8+
"can_push": true,
9+
"commit": {
10+
"author_email": "[email protected]",
11+
"author_name": "John Smith",
12+
"authored_date": "2012-06-27T05:51:39.000Z",
13+
"committed_date": "2012-06-28T03:44:20.000Z",
14+
"committer_email": "[email protected]",
15+
"committer_name": "John Smith",
16+
"id": "7b5c3cc8be40ee161ae89a06bba6229da1032a0c",
17+
"short_id": "7b5c3cc",
18+
"title": "add projects API",
19+
"message": "add projects API",
20+
"parent_ids": ["4ad91d3c1144c406e50c7b33bae684bd6837faf8"]
21+
}
2422
}

Diff for: testdata/get_commit.json

+25-27
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
{
2-
"id": "6104942438c14ec7bd21c6cd5bd995272b3faff6",
3-
"short_id": "6104942438c",
4-
"title": "Sanitize for network graph",
5-
"author_name": "randx",
6-
"author_email": "[email protected]",
7-
"committer_name": "Dmitriy",
8-
"committer_email": "[email protected]",
9-
"message": "Sanitize for network graph",
10-
"parent_ids": [
11-
"ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"
12-
],
13-
"last_pipeline": {
14-
"id": 8,
15-
"ref": "master",
16-
"sha": "2dc6aa325a317eda67812f05600bdf0fcdc70ab0",
17-
"status": "created",
18-
"web_url": "https://gitlab.com/gitlab-org/gitlab-ce/pipelines/54268416",
19-
"created_at": "2019-11-04T15:38:53.154Z",
20-
"updated_at": "2019-11-04T15:39:03.935Z"
21-
},
22-
"stats": {
23-
"additions": 15,
24-
"deletions": 10,
25-
"total": 25
26-
},
27-
"status": "running",
28-
"project_id": 13083
2+
"id": "6104942438c14ec7bd21c6cd5bd995272b3faff6",
3+
"short_id": "6104942438c",
4+
"title": "Sanitize for network graph",
5+
"author_name": "randx",
6+
"author_email": "[email protected]",
7+
"committer_name": "Dmitriy",
8+
"committer_email": "[email protected]",
9+
"message": "Sanitize for network graph",
10+
"parent_ids": ["ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba"],
11+
"last_pipeline": {
12+
"id": 8,
13+
"ref": "master",
14+
"sha": "2dc6aa325a317eda67812f05600bdf0fcdc70ab0",
15+
"status": "created",
16+
"web_url": "https://gitlab.com/gitlab-org/gitlab-ce/pipelines/54268416",
17+
"created_at": "2019-11-04T15:38:53.154Z",
18+
"updated_at": "2019-11-04T15:39:03.935Z"
19+
},
20+
"stats": {
21+
"additions": 15,
22+
"deletions": 10,
23+
"total": 25
24+
},
25+
"status": "running",
26+
"project_id": 13083
2927
}

Diff for: testdata/get_merge_requests.json

+10-31
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[
22
{
33
"id": 35385049,
4-
"iid": 15442, "project_id": 278964,
4+
"iid": 15442,
5+
"project_id": 278964,
56
"title": "Draft: Use structured logging for DB load balancer",
67
"description": "## What does this MR do?\r\n\r\n<!--\r\n\r\nDescribe in detail what your merge request does and why.\r\n\r\nAre there any risks involved with the proposed change? What additional\r\ntest coverage is introduced to offset the risk?\r\n\r\nPlease keep this description up-to-date with any discussion that takes\r\nplace so that reviewers can understand your intent. This is especially\r\nimportant if they didn't participate in the discussion.\r\n\r\n-->\r\n\r\nRelates to https://gitlab.com/gitlab-org/gitlab-ee/issues/13547 and https://gitlab.com/gitlab-org/gitlab-ee/issues/13548\r\n\r\n## Does this MR meet the acceptance criteria?\r\n\r\n### Conformity\r\n\r\n- [ ] [Changelog entry](https://docs.gitlab.com/ee/development/changelog.html) \r\n- [ ] [Documentation created/updated](https://docs.gitlab.com/ee/development/documentation/feature-change-workflow.html) or [follow-up review issue created](https://gitlab.com/gitlab-org/gitlab-ce/issues/new?issuable_template=Doc%20Review)\r\n- [ ] [Code review guidelines](https://docs.gitlab.com/ee/development/code_review.html)\r\n- [ ] [Merge request performance guidelines](https://docs.gitlab.com/ee/development/merge_request_performance_guidelines.html)\r\n- [ ] [Style guides](https://gitlab.com/gitlab-org/gitlab-ee/blob/master/doc/development/contributing/style_guides.md)\r\n- [ ] [Database guides](https://docs.gitlab.com/ee/development/README.html#databases-guides)\r\n- [ ] [Separation of EE specific content](https://docs.gitlab.com/ee/development/ee_features.html#separation-of-ee-code)\r\n\r\n### Performance and Testing\r\n\r\n<!-- What risks does this change pose? How might it affect the quality/performance of the product?\r\nWhat additional test coverage or changes to tests will be needed?\r\nWill it require cross-browser testing?\r\nSee the test engineering process for further guidelines: https://about.gitlab.com/handbook/engineering/quality/test-engineering/ -->\r\n\r\n<!-- If cross-browser testing is not required, please remove the relevant item, or mark it as not needed: [-] -->\r\n\r\n- [ ] [Review and add/update tests for this feature/bug](https://docs.gitlab.com/ee/development/testing_guide/index.html). Consider [all test levels](https://docs.gitlab.com/ee/development/testing_guide/testing_levels.html). See the [Test Planning Process](https://about.gitlab.com/handbook/engineering/quality/guidelines/test-engineering/).\r\n- [ ] [Tested in all supported browsers](https://docs.gitlab.com/ee/install/requirements.html#supported-web-browsers)\r\n\r\n### Security\r\n\r\nIf this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in [the security review guidelines](https://about.gitlab.com/handbook/engineering/security/#when-to-request-a-security-review):\r\n\r\n- [ ] Label as ~security and @ mention `@gitlab-com/gl-security/appsec`\r\n- [ ] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods\r\n- [ ] Security reports checked/validated by a reviewer from the AppSec team",
78
"state": "opened",
@@ -43,14 +44,14 @@
4344
}
4445
],
4546
"reviewers": [
46-
{
47+
{
4748
"id": 2535118,
4849
"name": "Thong Kuah",
4950
"username": "tkuah",
5051
"state": "active",
5152
"avatar_url": "https://secure.gravatar.com/avatar/f7b51bdd49a4914d29504d7ff4c3f7b9?s=80&d=identicon",
5253
"web_url": "https://gitlab.com/tkuah"
53-
}
54+
}
5455
],
5556
"source_project_id": 278964,
5657
"target_project_id": 278964,
@@ -499,10 +500,7 @@
499500
],
500501
"source_project_id": 278964,
501502
"target_project_id": 278964,
502-
"labels": [
503-
"Community contribution",
504-
"devops::plan"
505-
],
503+
"labels": ["Community contribution", "devops::plan"],
506504
"work_in_progress": false,
507505
"milestone": {
508506
"id": 693521,
@@ -690,11 +688,7 @@
690688
],
691689
"source_project_id": 11495811,
692690
"target_project_id": 278964,
693-
"labels": [
694-
"devops::verify",
695-
"feature",
696-
"group::continuous integration"
697-
],
691+
"labels": ["devops::verify", "feature", "group::continuous integration"],
698692
"work_in_progress": false,
699693
"milestone": {
700694
"id": 693521,
@@ -963,11 +957,7 @@
963957
"assignees": [],
964958
"source_project_id": 278964,
965959
"target_project_id": 278964,
966-
"labels": [
967-
"QA",
968-
"Quality",
969-
"backstage"
970-
],
960+
"labels": ["QA", "Quality", "backstage"],
971961
"work_in_progress": false,
972962
"milestone": {
973963
"id": 693521,
@@ -1247,10 +1237,7 @@
12471237
],
12481238
"source_project_id": 278964,
12491239
"target_project_id": 278964,
1250-
"labels": [
1251-
"internationalization",
1252-
"master:broken"
1253-
],
1240+
"labels": ["internationalization", "master:broken"],
12541241
"work_in_progress": false,
12551242
"milestone": null,
12561243
"merge_when_pipeline_succeeds": true,
@@ -1417,11 +1404,7 @@
14171404
],
14181405
"source_project_id": 278964,
14191406
"target_project_id": 278964,
1420-
"labels": [
1421-
"backend",
1422-
"devops::release",
1423-
"feature"
1424-
],
1407+
"labels": ["backend", "devops::release", "feature"],
14251408
"work_in_progress": false,
14261409
"milestone": {
14271410
"id": 731038,
@@ -1747,11 +1730,7 @@
17471730
],
17481731
"source_project_id": 278964,
17491732
"target_project_id": 278964,
1750-
"labels": [
1751-
"bug",
1752-
"devops::secure",
1753-
"group::static analysis"
1754-
],
1733+
"labels": ["bug", "devops::secure", "group::static analysis"],
17551734
"work_in_progress": false,
17561735
"milestone": {
17571736
"id": 731038,

0 commit comments

Comments
 (0)