Repository: google/go-github
Pull request #3404 (2024-12-25 17:21:12)

Update PersonalAccessToken struct
According to REST API: https://docs.github.com/en/rest/orgs/personal-access-tokens?apiVersion=2022-11-28#list-fine-grained-personal-access-tokens-with-access-to-organization-resources

There are some fields which are not getting captured by PersonalAccessToken struct. The fields are:

token_id
token_name

For issue: https://github.com/google/go-github/issues/3403

google-cla[bot]: Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this [failed invocation](https://github.com/google/go-github/pull/3404/checks?check_run_id=34865595644) of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/google/go-github/pull/3404?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 92.21%. Comparing base [(`2b8c7fa`)](https://app.codecov.io/gh/google/go-github/commit/2b8c7fa86fcd1cb4a89a44c8e7b5a49fe4be8a45?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) to head [(`9f22826`)](https://app.codecov.io/gh/google/go-github/commit/9f22826ce1e6e434433b9e35b8ea62836ba4d589?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> Report is 208 commits behind head on master.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #3404      +/-   ##
==========================================
- Coverage   97.72%   92.21%   -5.51%     
==========================================
  Files         153      173      +20     
  Lines       13390    14770    +1380     
==========================================
+ Hits        13085    13620     +535     
- Misses        215     1060     +845     
  Partials       90       90              
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/google/go-github/pull/3404?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).

gmlewis: @R4vio - please run step 4 in CONTRIBUTING.md and push the changes.  (`go generate ./...`)
R4vio: @gmlewis, did the steps in CONTRIBUTING.md, seems it was missing some accessors.

Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 0800c02c..cf70ac59 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -15342,6 +15342,14 @@ func (p *PersonalAccessToken) GetTokenExpiresAt() Timestamp {
 	return *p.TokenExpiresAt
 }
 
+// GetTokenID returns the TokenID field if it's non-nil, zero value otherwise.
+func (p *PersonalAccessToken) GetTokenID() int64 {
+	if p == nil || p.TokenID == nil {
+		return 0
+	}
+	return *p.TokenID
+}
+
 // GetTokenLastUsedAt returns the TokenLastUsedAt field if it's non-nil, zero value otherwise.
 func (p *PersonalAccessToken) GetTokenLastUsedAt() Timestamp {
 	if p == nil || p.TokenLastUsedAt == nil {
@@ -15350,6 +15358,14 @@ func (p *PersonalAccessToken) GetTokenLastUsedAt() Timestamp {
 	return *p.TokenLastUsedAt
 }
 
+// GetTokenName returns the TokenName field if it's non-nil, zero value otherwise.
+func (p *PersonalAccessToken) GetTokenName() string {
+	if p == nil || p.TokenName == nil {
+		return ""
+	}
+	return *p.TokenName
+}
+
 // GetOrg returns the Org map if it's non-nil, an empty map otherwise.
 func (p *PersonalAccessTokenPermissions) GetOrg() map[string]string {
 	if p == nil || p.Org == nil {
diff --git a/github/orgs_personal_access_tokens.go b/github/orgs_personal_access_tokens.go
index af083744..276fbbb4 100644
--- a/github/orgs_personal_access_tokens.go
+++ b/github/orgs_personal_access_tokens.go
@@ -44,6 +44,12 @@ type PersonalAccessToken struct {
 	// Date and time when the associated fine-grained personal access token expires.
 	TokenExpiresAt *Timestamp `json:"token_expires_at"`
 
+	// TokenID
+	TokenID *int64 `json:"token_id"`
+
+	// TokenName
+	TokenName *string `json:"token_name"`
+
 	// Date and time when the associated fine-grained personal access token was last used for authentication.
 	TokenLastUsedAt *Timestamp `json:"token_last_used_at"`
 }


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 4b5c9dcb..ff7530bc 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -19849,6 +19849,17 @@ func TestPersonalAccessToken_GetTokenExpiresAt(tt *testing.T) {
 	p.GetTokenExpiresAt()
 }
 
+func TestPersonalAccessToken_GetTokenID(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue int64
+	p := &PersonalAccessToken{TokenID: &zeroValue}
+	p.GetTokenID()
+	p = &PersonalAccessToken{}
+	p.GetTokenID()
+	p = nil
+	p.GetTokenID()
+}
+
 func TestPersonalAccessToken_GetTokenLastUsedAt(tt *testing.T) {
 	tt.Parallel()
 	var zeroValue Timestamp
@@ -19860,6 +19871,17 @@ func TestPersonalAccessToken_GetTokenLastUsedAt(tt *testing.T) {
 	p.GetTokenLastUsedAt()
 }
 
+func TestPersonalAccessToken_GetTokenName(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	p := &PersonalAccessToken{TokenName: &zeroValue}
+	p.GetTokenName()
+	p = &PersonalAccessToken{}
+	p.GetTokenName()
+	p = nil
+	p.GetTokenName()
+}
+
 func TestPersonalAccessTokenPermissions_GetOrg(tt *testing.T) {
 	tt.Parallel()
 	zeroValue := map[string]string{}