Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,11 @@ linters:
- Subscription
- TeamAddTeamMembershipOptions
- TeamAddTeamRepoOptions
- TeamLDAPMapping
- TeamProjectOptions
- UpdateCodespaceOptions
- UpdateDefaultSetupConfigurationOptions
- UpdateProjectItemOptions
- User
- UserLDAPMapping
- UserSuspendOptions
- WorkflowsPermissionsOpt
# Body type names exempt from the "Options" suffix rule.
Expand Down
18 changes: 15 additions & 3 deletions github/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ func (m TeamLDAPMapping) String() string {
return Stringify(m)
}

// UpdateTeamLDAPMappingRequest represents a request to update the mapping
// between a GitHub team and an LDAP group.
type UpdateTeamLDAPMappingRequest struct {
LDAPDN string `json:"ldap_dn"`
}

// UserLDAPMapping represents the mapping between a GitHub user and an LDAP user.
type UserLDAPMapping struct {
ID *int64 `json:"id,omitempty"`
Expand All @@ -62,6 +68,12 @@ func (m UserLDAPMapping) String() string {
return Stringify(m)
}

// UpdateUserLDAPMappingRequest represents a request to update the mapping
// between a GitHub user and an LDAP user.
type UpdateUserLDAPMappingRequest struct {
LDAPDN string `json:"ldap_dn"`
}

// Enterprise represents the GitHub enterprise profile.
type Enterprise struct {
ID *int `json:"id,omitempty"`
Expand All @@ -85,7 +97,7 @@ func (m Enterprise) String() string {
// GitHub API docs: https://docs.github.com/enterprise-server@3.21/rest/enterprise-admin/ldap#update-ldap-mapping-for-a-user
//
//meta:operation PATCH /admin/ldap/users/{username}/mapping
func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, body *UserLDAPMapping) (*UserLDAPMapping, *Response, error) {
func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, body UpdateUserLDAPMappingRequest) (*UserLDAPMapping, *Response, error) {
u := fmt.Sprintf("admin/ldap/users/%v/mapping", user)
req, err := s.client.NewRequest(ctx, "PATCH", u, body)
if err != nil {
Expand All @@ -106,8 +118,8 @@ func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, b
// GitHub API docs: https://docs.github.com/enterprise-server@3.21/rest/enterprise-admin/ldap#update-ldap-mapping-for-a-team
//
//meta:operation PATCH /admin/ldap/teams/{team_id}/mapping
func (s *AdminService) UpdateTeamLDAPMapping(ctx context.Context, team int64, body *TeamLDAPMapping) (*TeamLDAPMapping, *Response, error) {
u := fmt.Sprintf("admin/ldap/teams/%v/mapping", team)
func (s *AdminService) UpdateTeamLDAPMapping(ctx context.Context, teamID int64, body UpdateTeamLDAPMappingRequest) (*TeamLDAPMapping, *Response, error) {
u := fmt.Sprintf("admin/ldap/teams/%v/mapping", teamID)
req, err := s.client.NewRequest(ctx, "PATCH", u, body)
if err != nil {
return nil, nil, err
Expand Down
8 changes: 4 additions & 4 deletions github/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func TestAdminService_UpdateUserLDAPMapping(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)

input := &UserLDAPMapping{
LDAPDN: Ptr("uid=asdf,ou=users,dc=github,dc=com"),
input := UpdateUserLDAPMappingRequest{
LDAPDN: "uid=asdf,ou=users,dc=github,dc=com",
}

mux.HandleFunc("/admin/ldap/users/u/mapping", func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -60,8 +60,8 @@ func TestAdminService_UpdateTeamLDAPMapping(t *testing.T) {
t.Parallel()
client, mux, _ := setup(t)

input := &TeamLDAPMapping{
LDAPDN: Ptr("cn=Enterprise Ops,ou=teams,dc=github,dc=com"),
input := UpdateTeamLDAPMappingRequest{
LDAPDN: "cn=Enterprise Ops,ou=teams,dc=github,dc=com",
}

mux.HandleFunc("/admin/ldap/teams/1/mapping", func(w http.ResponseWriter, r *http.Request) {
Expand Down
16 changes: 16 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading