Repository: google/go-github
Pull request #2718 (2023-03-27 08:59:43)

Add added_by and last_used fields to keys
Fixes #2717 by adding fields and accessors

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/2718/checks?check_run_id=12297166494) 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.
gmlewis: Closing and reopening... hoping to re-trigger the stuck GitHub Actions...
gmlewis: Reopening...

<img width="2559" alt="stuck-github-actions-2023-03-27_13-54-01" src="https://user-images.githubusercontent.com/6598971/228025712-d1229190-c955-491b-b269-e22c587f5e8b.png">

gmlewis: Bravo - tests are now running.

Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index beeb2def..3d42907b 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -8646,6 +8646,14 @@ func (j *Jobs) GetTotalCount() int {
 	return *j.TotalCount
 }
 
+// GetAddedBy returns the AddedBy field if it's non-nil, zero value otherwise.
+func (k *Key) GetAddedBy() string {
+	if k == nil || k.AddedBy == nil {
+		return ""
+	}
+	return *k.AddedBy
+}
+
 // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise.
 func (k *Key) GetCreatedAt() Timestamp {
 	if k == nil || k.CreatedAt == nil {
@@ -8670,6 +8678,14 @@ func (k *Key) GetKey() string {
 	return *k.Key
 }
 
+// GetLastUsed returns the LastUsed field if it's non-nil, zero value otherwise.
+func (k *Key) GetLastUsed() Timestamp {
+	if k == nil || k.LastUsed == nil {
+		return Timestamp{}
+	}
+	return *k.LastUsed
+}
+
 // GetReadOnly returns the ReadOnly field if it's non-nil, zero value otherwise.
 func (k *Key) GetReadOnly() bool {
 	if k == nil || k.ReadOnly == nil {
diff --git a/github/users_keys.go b/github/users_keys.go
index 59d26cde..b49b8e4b 100644
--- a/github/users_keys.go
+++ b/github/users_keys.go
@@ -19,6 +19,8 @@ type Key struct {
 	ReadOnly  *bool      `json:"read_only,omitempty"`
 	Verified  *bool      `json:"verified,omitempty"`
 	CreatedAt *Timestamp `json:"created_at,omitempty"`
+	AddedBy   *string    `json:"added_by,omitempty"`
+	LastUsed  *Timestamp `json:"last_used,omitempty"`
 }
 
 func (k Key) String() string {


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 3cc4001e..20ba7425 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -10130,6 +10130,16 @@ func TestJobs_GetTotalCount(tt *testing.T) {
 	j.GetTotalCount()
 }
 
+func TestKey_GetAddedBy(tt *testing.T) {
+	var zeroValue string
+	k := &Key{AddedBy: &zeroValue}
+	k.GetAddedBy()
+	k = &Key{}
+	k.GetAddedBy()
+	k = nil
+	k.GetAddedBy()
+}
+
 func TestKey_GetCreatedAt(tt *testing.T) {
 	var zeroValue Timestamp
 	k := &Key{CreatedAt: &zeroValue}
@@ -10160,6 +10170,16 @@ func TestKey_GetKey(tt *testing.T) {
 	k.GetKey()
 }
 
+func TestKey_GetLastUsed(tt *testing.T) {
+	var zeroValue Timestamp
+	k := &Key{LastUsed: &zeroValue}
+	k.GetLastUsed()
+	k = &Key{}
+	k.GetLastUsed()
+	k = nil
+	k.GetLastUsed()
+}
+
 func TestKey_GetReadOnly(tt *testing.T) {
 	var zeroValue bool
 	k := &Key{ReadOnly: &zeroValue}
diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go
index f83ce4ce..60052554 100644
--- a/github/github-stringify_test.go
+++ b/github/github-stringify_test.go
@@ -795,8 +795,10 @@ func TestKey_String(t *testing.T) {
 		ReadOnly:  Bool(false),
 		Verified:  Bool(false),
 		CreatedAt: &Timestamp{},
+		AddedBy:   String(""),
+		LastUsed:  &Timestamp{},
 	}
-	want := `github.Key{ID:0, Key:"", URL:"", Title:"", ReadOnly:false, Verified:false, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}`
+	want := `github.Key{ID:0, Key:"", URL:"", Title:"", ReadOnly:false, Verified:false, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, AddedBy:"", LastUsed:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}`
 	if got := v.String(); got != want {
 		t.Errorf("Key.String = %v, want %v", got, want)
 	}