diff --git a/github/github-accessors.go b/github/github-accessors.go index 942ec6a96bd..356487e0e1e 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -1134,6 +1134,14 @@ func (a *AuditEntry) GetCreatedAt() Timestamp { return *a.CreatedAt } +// GetData returns the Data field. +func (a *AuditEntry) GetData() *AuditEntryData { + if a == nil { + return nil + } + return a.Data +} + // GetDeployKeyFingerprint returns the DeployKeyFingerprint field if it's non-nil, zero value otherwise. func (a *AuditEntry) GetDeployKeyFingerprint() string { if a == nil || a.DeployKeyFingerprint == nil { @@ -1278,14 +1286,6 @@ func (a *AuditEntry) GetOAuthApplicationID() int64 { return *a.OAuthApplicationID } -// GetOldName returns the OldName field if it's non-nil, zero value otherwise. -func (a *AuditEntry) GetOldName() string { - if a == nil || a.OldName == nil { - return "" - } - return *a.OldName -} - // GetOldPermission returns the OldPermission field if it's non-nil, zero value otherwise. func (a *AuditEntry) GetOldPermission() string { if a == nil || a.OldPermission == nil { @@ -1598,6 +1598,14 @@ func (a *AuditEntry) GetWorkflowRunID() int64 { return *a.WorkflowRunID } +// GetOldName returns the OldName field if it's non-nil, zero value otherwise. +func (a *AuditEntryData) GetOldName() string { + if a == nil || a.OldName == nil { + return "" + } + return *a.OldName +} + // GetApp returns the App field. func (a *Authorization) GetApp() *AuthorizationApp { if a == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 4eafaf25229..40942da40b3 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -1334,6 +1334,13 @@ func TestAuditEntry_GetCreatedAt(tt *testing.T) { a.GetCreatedAt() } +func TestAuditEntry_GetData(tt *testing.T) { + a := &AuditEntry{} + a.GetData() + a = nil + a.GetData() +} + func TestAuditEntry_GetDeployKeyFingerprint(tt *testing.T) { var zeroValue string a := &AuditEntry{DeployKeyFingerprint: &zeroValue} @@ -1514,16 +1521,6 @@ func TestAuditEntry_GetOAuthApplicationID(tt *testing.T) { a.GetOAuthApplicationID() } -func TestAuditEntry_GetOldName(tt *testing.T) { - var zeroValue string - a := &AuditEntry{OldName: &zeroValue} - a.GetOldName() - a = &AuditEntry{} - a.GetOldName() - a = nil - a.GetOldName() -} - func TestAuditEntry_GetOldPermission(tt *testing.T) { var zeroValue string a := &AuditEntry{OldPermission: &zeroValue} @@ -1914,6 +1911,16 @@ func TestAuditEntry_GetWorkflowRunID(tt *testing.T) { a.GetWorkflowRunID() } +func TestAuditEntryData_GetOldName(tt *testing.T) { + var zeroValue string + a := &AuditEntryData{OldName: &zeroValue} + a.GetOldName() + a = &AuditEntryData{} + a.GetOldName() + a = nil + a.GetOldName() +} + func TestAuthorization_GetApp(tt *testing.T) { a := &Authorization{} a.GetApp() diff --git a/github/orgs_audit_log.go b/github/orgs_audit_log.go index a86910533b1..d7de77127c5 100644 --- a/github/orgs_audit_log.go +++ b/github/orgs_audit_log.go @@ -78,7 +78,6 @@ type AuditEntry struct { Message *string `json:"message,omitempty"` Name *string `json:"name,omitempty"` OAuthApplicationID *int64 `json:"oauth_application_id,omitempty"` - OldName *string `json:"old_name,omitempty"` // The previous name of the repository, for a name change OldUser *string `json:"old_user,omitempty"` OldPermission *string `json:"old_permission,omitempty"` // The permission level for membership changes, for example `admin` or `read`. OpenSSHPublicKey *string `json:"openssh_public_key,omitempty"` @@ -122,6 +121,13 @@ type AuditEntry struct { Visibility *string `json:"visibility,omitempty"` // The repository visibility, for example `public` or `private`. WorkflowID *int64 `json:"workflow_id,omitempty"` WorkflowRunID *int64 `json:"workflow_run_id,omitempty"` + + Data *AuditEntryData `json:"data,omitempty"` +} + +// AuditEntryData represents additional information stuffed into a `data` field. +type AuditEntryData struct { + OldName *string `json:"old_name,omitempty"` // The previous name of the repository, for a name change } // GetAuditLog gets the audit-log entries for an organization. diff --git a/github/orgs_audit_log_test.go b/github/orgs_audit_log_test.go index a5873ee4d38..2995de5023c 100644 --- a/github/orgs_audit_log_test.go +++ b/github/orgs_audit_log_test.go @@ -256,7 +256,6 @@ func TestAuditEntry_Marshal(t *testing.T) { LimitedAvailability: Bool(false), Message: String("m"), Name: String("n"), - OldName: String("on"), OldPermission: String("op"), OldUser: String("ou"), OpenSSHPublicKey: String("osshpk"), @@ -300,6 +299,9 @@ func TestAuditEntry_Marshal(t *testing.T) { Visibility: String("v"), WorkflowID: Int64(1), WorkflowRunID: Int64(1), + Data: &AuditEntryData{ + OldName: String("on"), + }, } want := `{ @@ -346,7 +348,6 @@ func TestAuditEntry_Marshal(t *testing.T) { "limited_availability": false, "message": "m", "name": "n", - "old_name": "on", "old_permission": "op", "old_user": "ou", "openssh_public_key": "osshpk", @@ -393,7 +394,10 @@ func TestAuditEntry_Marshal(t *testing.T) { "user_agent": "ua", "visibility": "v", "workflow_id": 1, - "workflow_run_id": 1 + "workflow_run_id": 1, + "data": { + "old_name": "on" + } }` testJSONMarshal(t, u, want)