Repository: google/go-github (go)

Issue:
Add support for `assignment` on teams and users assigned to organization roles
When listing teams or users assigned to an organization role the ~~`assigned`~~ `assignment` field isn't getting set and the team `parent` and user `inherited_from` are also not getting set. I assume that this is because these endpoints are being mapped back to `Team` and `User` structs instead of being a custom type. 

Pull request description:
feat: Add assignment for org role associations
Resolves #3364

This PR adds the `Assignment` field to `Team` & `User` and the `InheritedFrom` field to `User` when accessed in the context of an organization role.

Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 7fa93d8a..db906dab 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -24358,6 +24358,14 @@ func (t *TaskStep) GetStatus() string {
 	return *t.Status
 }
 
+// GetAssignment returns the Assignment field if it's non-nil, zero value otherwise.
+func (t *Team) GetAssignment() string {
+	if t == nil || t.Assignment == nil {
+		return ""
+	}
+	return *t.Assignment
+}
+
 // GetDescription returns the Description field if it's non-nil, zero value otherwise.
 func (t *Team) GetDescription() string {
 	if t == nil || t.Description == nil {
@@ -25654,6 +25662,14 @@ func (u *UpdateRunnerGroupRequest) GetVisibility() string {
 	return *u.Visibility
 }
 
+// GetAssignment returns the Assignment field if it's non-nil, zero value otherwise.
+func (u *User) GetAssignment() string {
+	if u == nil || u.Assignment == nil {
+		return ""
+	}
+	return *u.Assignment
+}
+
 // GetAvatarURL returns the AvatarURL field if it's non-nil, zero value otherwise.
 func (u *User) GetAvatarURL() string {
 	if u == nil || u.AvatarURL == nil {
@@ -25798,6 +25814,14 @@ func (u *User) GetID() int64 {
 	return *u.ID
 }
 
+// GetInheritedFrom returns the InheritedFrom field.
+func (u *User) GetInheritedFrom() *Team {
+	if u == nil {
+		return nil
+	}
+	return u.InheritedFrom
+}
+
 // GetLdapDn returns the LdapDn field if it's non-nil, zero value otherwise.
 func (u *User) GetLdapDn() string {
 	if u == nil || u.LdapDn == nil {
diff --git a/github/teams.go b/github/teams.go
index df248b65..651c2514 100644
--- a/github/teams.go
+++ b/github/teams.go
@@ -30,10 +30,6 @@ type Team struct {
 	// Permission specifies the default permission for repositories owned by the team.
 	Permission *string `json:"permission,omitempty"`
 
-	// Permissions identifies the permissions that a team has on a given
-	// repository. This is only populated when calling Repositories.ListTeams.
-	Permissions map[string]bool `json:"permissions,omitempty"`
-
 	// Privacy identifies the level of privacy this team should have.
 	// Possible values are:
 	//     secret - only visible to organization owners and members of this team
@@ -52,6 +48,15 @@ type Team struct {
 	// LDAPDN is only available in GitHub Enterprise and when the team
 	// membership is synchronized with LDAP.
 	LDAPDN *string `json:"ldap_dn,omitempty"`
+
+	// Permissions identifies the permissions that a team has on a given
+	// repository. This is only populated when calling Repositories.ListTeams.
+	Permissions map[string]bool `json:"permissions,omitempty"`
+
+	// Assignment identifies how a team was assigned to an organization role. Its
+	// possible values are: "direct", "indirect", "mixed". This is only populated when
+	// calling the ListTeamsAssignedToOrgRole method.
+	Assignment *string `json:"assignment,omitempty"`
 }
 
 func (t Team) String() string {
diff --git a/github/users.go b/github/users.go
index c1ab5552..60f1e06a 100644
--- a/github/users.go
+++ b/github/users.go
@@ -70,6 +70,14 @@ type User struct {
 	// repository. These are only populated when calling Repositories.ListCollaborators.
 	Permissions map[string]bool `json:"permissions,omitempty"`
 	RoleName    *string         `json:"role_name,omitempty"`
+
+	// Assignment identifies how a user was assigned to an organization role. Its
+	// possible values are: "direct", "indirect", "mixed". This is only populated when
+	// calling the ListUsersAssignedToOrgRole method.
+	Assignment *string `json:"assignment,omitempty"`
+	// InheritedFrom identifies the team that a user inherited their organization role
+	// from. This is only populated when calling the ListUsersAssignedToOrgRole method.
+	InheritedFrom *Team `json:"inherited_from,omitempty"`
 }
 
 func (u User) String() string {
diff --git a/openapi_operations.yaml b/openapi_operations.yaml
index 65a8ef0a..3539219e 100644
--- a/openapi_operations.yaml
+++ b/openapi_operations.yaml
@@ -47,7 +47,7 @@ operation_overrides:
     documentation_url: https://docs.github.com/rest/pages/pages#request-a-github-pages-build
   - name: GET /repos/{owner}/{repo}/pages/builds/{build_id}
     documentation_url: https://docs.github.com/rest/pages/pages#get-github-pages-build
-openapi_commit: a0508cecd18ab26b525527e4ba35bd9c6d725c4f
+openapi_commit: 4ab8513682637010cd3bb5d8ee3227cc5ce739d1
 openapi_operations:
   - name: GET /
     documentation_url: https://docs.github.com/rest/meta/meta#github-api-root
@@ -700,6 +700,30 @@ openapi_operations:
     openapi_files:
       - descriptions/ghec/ghec.json
       - descriptions/ghes-3.15/ghes-3.15.json
+  - name: GET /enterprises/{enterprise}/audit-log/stream-key
+    documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/audit-log#get-the-audit-log-stream-key-for-encrypting-secrets
+    openapi_files:
+      - descriptions/ghec/ghec.json
+  - name: GET /enterprises/{enterprise}/audit-log/streams
+    documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/audit-log#list-audit-log-stream-configurations-for-an-enterprise
+    openapi_files:
+      - descriptions/ghec/ghec.json
+  - name: POST /enterprises/{enterprise}/audit-log/streams
+    documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/audit-log#create-an-audit-log-streaming-configuration-for-an-enterprise
+    openapi_files:
+      - descriptions/ghec/ghec.json
+  - name: DELETE /enterprises/{enterprise}/audit-log/streams/{stream_id}
+    documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/audit-log#delete-an-audit-log-streaming-configuration-for-an-enterprise
+    openapi_files:
+      - descriptions/ghec/ghec.json
+  - name: GET /enterprises/{enterprise}/audit-log/streams/{stream_id}
+    documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/audit-log#list-one-audit-log-streaming-configuration-via-a-stream-id
+    openapi_files:
+      - descriptions/ghec/ghec.json
+  - name: PUT /enterprises/{enterprise}/audit-log/streams/{stream_id}
+    documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/audit-log#update-an-existing-audit-log-stream-configuration
+    openapi_files:
+      - descriptions/ghec/ghec.json
   - name: GET /enterprises/{enterprise}/code-scanning/alerts
     documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/code-scanning/code-scanning#list-code-scanning-alerts-for-an-enterprise
     openapi_files:
@@ -744,6 +768,26 @@ openapi_operations:
     documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/license#get-a-license-sync-status
     openapi_files:
       - descriptions/ghec/ghec.json
+  - name: GET /enterprises/{enterprise}/properties/schema
+    documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/custom-properties#get-custom-properties-for-an-enterprise
+    openapi_files:
+      - descriptions/ghec/ghec.json
+  - name: PATCH /enterprises/{enterprise}/properties/schema
+    documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/custom-properties#create-or-update-custom-properties-for-an-enterprise
+    openapi_files:
+      - descriptions/ghec/ghec.json
+  - name: DELETE /enterprises/{enterprise}/properties/schema/{custom_property_name}
+    documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/custom-properties#remove-a-custom-property-for-an-enterprise
+    openapi_files:
+      - descriptions/ghec/ghec.json
+  - name: GET /enterprises/{enterprise}/properties/schema/{custom_property_name}
+    documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/custom-properties#get-a-custom-property-for-an-enterprise
+    openapi_files:
+      - descriptions/ghec/ghec.json
+  - name: PUT /enterprises/{enterprise}/properties/schema/{custom_property_name}
+    documentation_url: https://docs.github.com/enterprise-cloud@latest//rest/enterprise-admin/custom-properties#create-or-update-a-custom-property-for-an-enterprise
+    openapi_files:
+      - descriptions/ghec/ghec.json
   - name: GET /enterprises/{enterprise}/secret-scanning/alerts
     documentation_url: https://docs.github.com/rest/secret-scanning/secret-scanning#list-secret-scanning-alerts-for-an-enterprise
     openapi_files:
@@ -999,7 +1043,7 @@ openapi_operations:
     openapi_files:
       - descriptions/ghes-3.15/ghes-3.15.json
   - name: POST /manage/v1/config/init
-    documentation_url: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/manage-ghes#initialize-instance-configuration-with-license-upload
+    documentation_url: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/manage-ghes#initialize-instance-configuration-with-license-and-password
     openapi_files:
       - descriptions/ghes-3.15/ghes-3.15.json
   - name: GET /manage/v1/config/license
@@ -1161,6 +1205,11 @@ openapi_operations:
     openapi_files:
       - descriptions/ghec/ghec.json
       - descriptions/ghes-3.15/ghes-3.15.json
+  - name: GET /organizations/{org}/settings/billing/usage
+    documentation_url: https://docs.github.com/rest/billing/enhanced-billing#get-billing-usage-report-for-an-organization
+    openapi_files:
+      - descriptions/api.github.com/api.github.com.json
+      - descriptions/ghec/ghec.json
   - name: DELETE /orgs/{org}
     documentation_url: https://docs.github.com/rest/orgs/orgs#delete-an-organization
     openapi_files:
@@ -4723,6 +4772,26 @@ openapi_operations:
       - descriptions/api.github.com/api.github.com.json
       - descriptions/ghec/ghec.json
       - descriptions/ghes-3.15/ghes-3.15.json
+  - name: DELETE /repos/{owner}/{repo}/issues/{issue_number}/sub_issue
+    documentation_url: https://docs.github.com/rest/issues/sub-issues#remove-sub-issue
+    openapi_files:
+      - descriptions/api.github.com/api.github.com.json
+      - descriptions/ghec/ghec.json
+  - name: GET /repos/{owner}/{repo}/issues/{issue_number}/sub_issues
+    documentation_url: https://docs.github.com/rest/issues/sub-issues#list-sub-issues
+    openapi_files:
+      - descriptions/api.github.com/api.github.com.json
+      - descriptions/ghec/ghec.json
+  - name: POST /repos/{owner}/{repo}/issues/{issue_number}/sub_issues
+    documentation_url: https://docs.github.com/rest/issues/sub-issues#add-sub-issue
+    openapi_files:
+      - descriptions/api.github.com/api.github.com.json
+      - descriptions/ghec/ghec.json
+  - name: PATCH /repos/{owner}/{repo}/issues/{issue_number}/sub_issues/priority
+    documentation_url: https://docs.github.com/rest/issues/sub-issues#reprioritize-sub-issue
+    openapi_files:
+      - descriptions/api.github.com/api.github.com.json
+      - descriptions/ghec/ghec.json
   - name: GET /repos/{owner}/{repo}/issues/{issue_number}/timeline
     documentation_url: https://docs.github.com/rest/issues/timeline#list-timeline-events-for-an-issue
     openapi_files:
@@ -5370,6 +5439,11 @@ openapi_operations:
       - descriptions/api.github.com/api.github.com.json
       - descriptions/ghec/ghec.json
       - descriptions/ghes-3.15/ghes-3.15.json
+  - name: GET /repos/{owner}/{repo}/secret-scanning/scan-history
+    documentation_url: https://docs.github.com/rest/secret-scanning/secret-scanning#get-secret-scanning-scan-history-for-a-repository
+    openapi_files:
+      - descriptions/api.github.com/api.github.com.json
+      - descriptions/ghec/ghec.json
   - name: GET /repos/{owner}/{repo}/security-advisories
     documentation_url: https://docs.github.com/rest/security-advisories/repository-advisories#list-repository-security-advisories
     openapi_files:
@@ -5776,49 +5850,49 @@ openapi_operations:
       - descriptions/ghec/ghec.json
       - descriptions/ghes-3.15/ghes-3.15.json
   - name: GET /setup/api/configcheck
-    documentation_url: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/management-console#get-the-configuration-status
+    documentation_url: https://docs.github.com/enterprise-server@3.14/rest/enterprise-admin/management-console#get-the-configuration-status
     openapi_files:
-      - descriptions/ghes-3.15/ghes-3.15.json
+      - descriptions/ghes-3.14/ghes-3.14.json
   - name: POST /setup/api/configure
-    documentation_url: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/management-console#start-a-configuration-process
+    documentation_url: https://docs.github.com/enterprise-server@3.14/rest/enterprise-admin/management-console#start-a-configuration-process
     openapi_files:
-      - descriptions/ghes-3.15/ghes-3.15.json
+      - descriptions/ghes-3.14/ghes-3.14.json
   - name: GET /setup/api/maintenance
-    documentation_url: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/management-console#get-the-maintenance-status
+    documentation_url: https://docs.github.com/enterprise-server@3.14/rest/enterprise-admin/management-console#get-the-maintenance-status
     openapi_files:
-      - descriptions/ghes-3.15/ghes-3.15.json
+      - descriptions/ghes-3.14/ghes-3.14.json
   - name: POST /setup/api/maintenance
-    documentation_url: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/management-console#enable-or-disable-maintenance-mode
+    documentation_url: https://docs.github.com/enterprise-server@3.14/rest/enterprise-admin/management-console#enable-or-disable-maintenance-mode
     openapi_files:
-      - descriptions/ghes-3.15/ghes-3.15.json
+      - descriptions/ghes-3.14/ghes-3.14.json
   - name: GET /setup/api/settings
-    documentation_url: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/management-console#get-settings
+    documentation_url: https://docs.github.com/enterprise-server@3.14/rest/enterprise-admin/management-console#get-settings
     openapi_files:
-      - descriptions/ghes-3.15/ghes-3.15.json
+      - descriptions/ghes-3.14/ghes-3.14.json
   - name: PUT /setup/api/settings
-    documentation_url: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/management-console#set-settings
+    documentation_url: https://docs.github.com/enterprise-server@3.14/rest/enterprise-admin/management-console#set-settings
     openapi_files:
-      - descriptions/ghes-3.15/ghes-3.15.json
+      - descriptions/ghes-3.14/ghes-3.14.json
   - name: DELETE /setup/api/settings/authorized-keys
-    documentation_url: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/management-console#remove-an-authorized-ssh-key
+    documentation_url: https://docs.github.com/enterprise-server@3.14/rest/enterprise-admin/management-console#remove-an-authorized-ssh-key
     openapi_files:
-      - descriptions/ghes-3.15/ghes-3.15.json
+      - descriptions/ghes-3.14/ghes-3.14.json
   - name: GET /setup/api/settings/authorized-keys
-    documentation_url: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/management-console#get-all-authorized-ssh-keys
+    documentation_url: https://docs.github.com/enterprise-server@3.14/rest/enterprise-admin/management-console#get-all-authorized-ssh-keys
     openapi_files:
-      - descriptions/ghes-3.15/ghes-3.15.json
+      - descriptions/ghes-3.14/ghes-3.14.json
   - name: POST /setup/api/settings/authorized-keys
-    documentation_url: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/management-console#add-an-authorized-ssh-key
+    documentation_url: https://docs.github.com/enterprise-server@3.14/rest/enterprise-admin/management-console#add-an-authorized-ssh-key
     openapi_files:
-      - descriptions/ghes-3.15/ghes-3.15.json
+      - descriptions/ghes-3.14/ghes-3.14.json
   - name: POST /setup/api/start
-    documentation_url: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/management-console#create-a-github-license
+    documentation_url: https://docs.github.com/enterprise-server@3.14/rest/enterprise-admin/management-console#create-a-github-license
     openapi_files:
-      - descriptions/ghes-3.15/ghes-3.15.json
+      - descriptions/ghes-3.14/ghes-3.14.json
   - name: POST /setup/api/upgrade
-    documentation_url: https://docs.github.com/enterprise-server@3.15/rest/enterprise-admin/management-console#upgrade-a-license
+    documentation_url: https://docs.github.com/enterprise-server@3.14/rest/enterprise-admin/management-console#upgrade-a-license
     openapi_files:
-      - descriptions/ghes-3.15/ghes-3.15.json
+      - descriptions/ghes-3.14/ghes-3.14.json
   - name: DELETE /teams/{team_id}
     documentation_url: https://docs.github.com/rest/teams/teams#delete-a-team-legacy
     openapi_files:


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 51c4f861..67b833a6 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -31190,6 +31190,17 @@ func TestTaskStep_GetStatus(tt *testing.T) {
 	t.GetStatus()
 }
 
+func TestTeam_GetAssignment(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	t := &Team{Assignment: &zeroValue}
+	t.GetAssignment()
+	t = &Team{}
+	t.GetAssignment()
+	t = nil
+	t.GetAssignment()
+}
+
 func TestTeam_GetDescription(tt *testing.T) {
 	tt.Parallel()
 	var zeroValue string
@@ -32858,6 +32869,17 @@ func TestUpdateRunnerGroupRequest_GetVisibility(tt *testing.T) {
 	u.GetVisibility()
 }
 
+func TestUser_GetAssignment(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	u := &User{Assignment: &zeroValue}
+	u.GetAssignment()
+	u = &User{}
+	u.GetAssignment()
+	u = nil
+	u.GetAssignment()
+}
+
 func TestUser_GetAvatarURL(tt *testing.T) {
 	tt.Parallel()
 	var zeroValue string
@@ -33056,6 +33078,14 @@ func TestUser_GetID(tt *testing.T) {
 	u.GetID()
 }
 
+func TestUser_GetInheritedFrom(tt *testing.T) {
+	tt.Parallel()
+	u := &User{}
+	u.GetInheritedFrom()
+	u = nil
+	u.GetInheritedFrom()
+}
+
 func TestUser_GetLdapDn(tt *testing.T) {
 	tt.Parallel()
 	var zeroValue string
diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go
index d311b87f..7ffee278 100644
--- a/github/github-stringify_test.go
+++ b/github/github-stringify_test.go
@@ -1974,8 +1974,9 @@ func TestTeam_String(t *testing.T) {
 		RepositoriesURL: String(""),
 		Parent:          &Team{},
 		LDAPDN:          String(""),
+		Assignment:      String(""),
 	}
-	want := `github.Team{ID:0, NodeID:"", Name:"", Description:"", URL:"", Slug:"", Permission:"", Privacy:"", MembersCount:0, ReposCount:0, Organization:github.Organization{}, HTMLURL:"", MembersURL:"", RepositoriesURL:"", Parent:github.Team{}, LDAPDN:""}`
+	want := `github.Team{ID:0, NodeID:"", Name:"", Description:"", URL:"", Slug:"", Permission:"", Privacy:"", MembersCount:0, ReposCount:0, Organization:github.Organization{}, HTMLURL:"", MembersURL:"", RepositoriesURL:"", Parent:github.Team{}, LDAPDN:"", Assignment:""}`
 	if got := v.String(); got != want {
 		t.Errorf("Team.String = %v, want %v", got, want)
 	}
@@ -2117,8 +2118,10 @@ func TestUser_String(t *testing.T) {
 		StarredURL:              String(""),
 		SubscriptionsURL:        String(""),
 		RoleName:                String(""),
+		Assignment:              String(""),
+		InheritedFrom:           &Team{},
 	}
-	want := `github.User{Login:"", ID:0, NodeID:"", AvatarURL:"", HTMLURL:"", GravatarID:"", Name:"", Company:"", Blog:"", Location:"", Email:"", Hireable:false, Bio:"", TwitterUsername:"", PublicRepos:0, PublicGists:0, Followers:0, Following:0, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, SuspendedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, Type:"", SiteAdmin:false, TotalPrivateRepos:0, OwnedPrivateRepos:0, PrivateGists:0, DiskUsage:0, Collaborators:0, TwoFactorAuthentication:false, Plan:github.Plan{}, LdapDn:"", URL:"", EventsURL:"", FollowingURL:"", FollowersURL:"", GistsURL:"", OrganizationsURL:"", ReceivedEventsURL:"", ReposURL:"", StarredURL:"", SubscriptionsURL:"", RoleName:""}`
+	want := `github.User{Login:"", ID:0, NodeID:"", AvatarURL:"", HTMLURL:"", GravatarID:"", Name:"", Company:"", Blog:"", Location:"", Email:"", Hireable:false, Bio:"", TwitterUsername:"", PublicRepos:0, PublicGists:0, Followers:0, Following:0, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, SuspendedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, Type:"", SiteAdmin:false, TotalPrivateRepos:0, OwnedPrivateRepos:0, PrivateGists:0, DiskUsage:0, Collaborators:0, TwoFactorAuthentication:false, Plan:github.Plan{}, LdapDn:"", URL:"", EventsURL:"", FollowingURL:"", FollowersURL:"", GistsURL:"", OrganizationsURL:"", ReceivedEventsURL:"", ReposURL:"", StarredURL:"", SubscriptionsURL:"", RoleName:"", Assignment:"", InheritedFrom:github.Team{}}`
 	if got := v.String(); got != want {
 		t.Errorf("User.String = %v, want %v", got, want)
 	}