From 20ace5be613cdb33adeb7ce4b084e98b631f0b9b Mon Sep 17 00:00:00 2001 From: Alejandro Date: Fri, 28 Nov 2025 15:17:29 +0100 Subject: [PATCH 1/9] Convert spaces to tabs --- github/enterprise_scim_test.go | 260 ++++++++++++++++----------------- 1 file changed, 130 insertions(+), 130 deletions(-) diff --git a/github/enterprise_scim_test.go b/github/enterprise_scim_test.go index adf9099ccea..37e08d917a6 100644 --- a/github/enterprise_scim_test.go +++ b/github/enterprise_scim_test.go @@ -42,27 +42,27 @@ func TestSCIMEnterpriseGroups_Marshal(t *testing.T) { want := `{ "schemas": ["` + SCIMSchemasURINamespacesListResponse + `"], - "totalResults": 1, - "itemsPerPage": 1, - "startIndex": 1, - "Resources": [{ - "schemas": ["` + SCIMSchemasURINamespacesGroups + `"], - "id": "idgn1", - "externalId": "eidgn1", - "displayName": "gn1", - "meta": { - "resourceType": "Group", - "created": ` + referenceTimeStr + `, - "lastModified": ` + referenceTimeStr + `, - "location": "https://api.github.com/scim/v2/enterprises/ee/Groups/idgn1" - }, - "members": [{ - "value": "idm1", - "$ref": "https://api.github.com/scim/v2/enterprises/ee/Users/idm1", - "display": "m1" - }] - }] - }` + "totalResults": 1, + "itemsPerPage": 1, + "startIndex": 1, + "Resources": [{ + "schemas": ["` + SCIMSchemasURINamespacesGroups + `"], + "id": "idgn1", + "externalId": "eidgn1", + "displayName": "gn1", + "meta": { + "resourceType": "Group", + "created": ` + referenceTimeStr + `, + "lastModified": ` + referenceTimeStr + `, + "location": "https://api.github.com/scim/v2/enterprises/ee/Groups/idgn1" + }, + "members": [{ + "value": "idm1", + "$ref": "https://api.github.com/scim/v2/enterprises/ee/Users/idm1", + "display": "m1" + }] + }] + }` testJSONMarshal(t, u, want) } @@ -115,47 +115,47 @@ func TestSCIMEnterpriseUsers_Marshal(t *testing.T) { } want := `{ - "schemas": ["` + SCIMSchemasURINamespacesListResponse + `"], - "TotalResults": 1, - "itemsPerPage": 1, - "StartIndex": 1, - "Resources": [{ - "active": true, - "emails": [{ - "primary": true, - "type": "work", - "value": "un1@email.com" - }], - "roles": [{ - "display": "rd1", - "primary": true, - "type": "rt1", - "value": "rv1" - }], - "schemas": ["` + SCIMSchemasURINamespacesUser + `"], - "userName": "un1", - "groups": [{ - "value": "idgn1", - "$ref": "https://api.github.com/scim/v2/enterprises/ee/Groups/idgn1", - "display": "gn1" - }], - "id": "idun1", - "externalId": "eidun1", - "name": { - "givenName": "gnn1", - "familyName": "fnn1", - "formatted": "f1", - "middleName": "mn1" - }, - "displayName": "dun1", - "meta": { - "resourceType": "User", - "created": ` + referenceTimeStr + `, - "lastModified": ` + referenceTimeStr + `, - "location": "https://api.github.com/scim/v2/enterprises/ee/User/idun1" - } - }] - }` + "schemas": ["` + SCIMSchemasURINamespacesListResponse + `"], + "TotalResults": 1, + "itemsPerPage": 1, + "StartIndex": 1, + "Resources": [{ + "active": true, + "emails": [{ + "primary": true, + "type": "work", + "value": "un1@email.com" + }], + "roles": [{ + "display": "rd1", + "primary": true, + "type": "rt1", + "value": "rv1" + }], + "schemas": ["` + SCIMSchemasURINamespacesUser + `"], + "userName": "un1", + "groups": [{ + "value": "idgn1", + "$ref": "https://api.github.com/scim/v2/enterprises/ee/Groups/idgn1", + "display": "gn1" + }], + "id": "idun1", + "externalId": "eidun1", + "name": { + "givenName": "gnn1", + "familyName": "fnn1", + "formatted": "f1", + "middleName": "mn1" + }, + "displayName": "dun1", + "meta": { + "resourceType": "User", + "created": ` + referenceTimeStr + `, + "lastModified": ` + referenceTimeStr + `, + "location": "https://api.github.com/scim/v2/enterprises/ee/User/idun1" + } + }] + }` testJSONMarshal(t, u, want) } @@ -172,10 +172,10 @@ func TestListProvisionedSCIMGroupsEnterpriseOptions_Marshal(t *testing.T) { } want := `{ - "filter": "f", - "excludedAttributes": "ea", - "startIndex": 5, - "count": 9 + "filter": "f", + "excludedAttributes": "ea", + "startIndex": 5, + "count": 9 }` testJSONMarshal(t, u, want) @@ -192,9 +192,9 @@ func TestListProvisionedSCIMUsersEnterpriseOptions_Marshal(t *testing.T) { } want := `{ - "filter": "f", - "startIndex": 3, - "count": 7 + "filter": "f", + "startIndex": 3, + "count": 7 }` testJSONMarshal(t, u, want) @@ -223,15 +223,15 @@ func TestSCIMEnterpriseGroupAttributes_Marshal(t *testing.T) { } want := `{ - "schemas": ["s1"], - "externalId": "eid", + "schemas": ["s1"], + "externalId": "eid", "displayName": "dn", - "members" : [{ - "value": "v", - "$ref": "r", - "display": "d" - }], - "id": "id", + "members" : [{ + "value": "v", + "$ref": "r", + "display": "d" + }], + "id": "id", "meta": { "resourceType": "rt", "created": ` + referenceTimeStr + `, @@ -259,27 +259,27 @@ func TestEnterpriseService_ListProvisionedSCIMGroups(t *testing.T) { w.WriteHeader(http.StatusOK) _, _ = w.Write([]byte(`{ "schemas": ["` + SCIMSchemasURINamespacesListResponse + `"], - "totalResults": 1, - "itemsPerPage": 1, - "startIndex": 1, - "Resources": [{ - "schemas": ["` + SCIMSchemasURINamespacesGroups + `"], - "id": "914a", - "externalId": "de88", - "displayName": "gn1", - "meta": { - "resourceType": "Group", - "created": ` + referenceTimeStr + `, - "lastModified": ` + referenceTimeStr + `, - "location": "https://api.github.com/scim/v2/enterprises/ee/Groups/914a" - }, - "members": [{ - "value": "e7f9", - "$ref": "https://api.github.com/scim/v2/enterprises/ee/Users/e7f9", - "display": "d1" - }] - }] - }`)) + "totalResults": 1, + "itemsPerPage": 1, + "startIndex": 1, + "Resources": [{ + "schemas": ["` + SCIMSchemasURINamespacesGroups + `"], + "id": "914a", + "externalId": "de88", + "displayName": "gn1", + "meta": { + "resourceType": "Group", + "created": ` + referenceTimeStr + `, + "lastModified": ` + referenceTimeStr + `, + "location": "https://api.github.com/scim/v2/enterprises/ee/Groups/914a" + }, + "members": [{ + "value": "e7f9", + "$ref": "https://api.github.com/scim/v2/enterprises/ee/Users/e7f9", + "display": "d1" + }] + }] + }`)) }) ctx := t.Context() @@ -348,38 +348,38 @@ func TestEnterpriseService_ListProvisionedSCIMUsers(t *testing.T) { }) w.WriteHeader(http.StatusOK) _, _ = w.Write([]byte(`{ - "schemas": ["` + SCIMSchemasURINamespacesListResponse + `"], - "totalResults": 1, - "itemsPerPage": 1, - "startIndex": 1, - "Resources": [ - { - "schemas": ["` + SCIMSchemasURINamespacesUser + `"], - "id": "5fc0", - "externalId": "00u1", - "userName": "octocat@github.com", - "displayName": "Mona Octocat", - "name": { - "givenName": "Mona", - "familyName": "Octocat", - "formatted": "Mona Octocat" - }, - "emails": [ - { - "value": "octocat@github.com", - "primary": true - } - ], - "active": true, - "meta": { - "resourceType": "User", - "created": ` + referenceTimeStr + `, - "lastModified": ` + referenceTimeStr + `, - "location": "https://api.github.com/scim/v2/organizations/octo-org/Users/5fc0" - } - } - ] - }`)) + "schemas": ["` + SCIMSchemasURINamespacesListResponse + `"], + "totalResults": 1, + "itemsPerPage": 1, + "startIndex": 1, + "Resources": [ + { + "schemas": ["` + SCIMSchemasURINamespacesUser + `"], + "id": "5fc0", + "externalId": "00u1", + "userName": "octocat@github.com", + "displayName": "Mona Octocat", + "name": { + "givenName": "Mona", + "familyName": "Octocat", + "formatted": "Mona Octocat" + }, + "emails": [ + { + "value": "octocat@github.com", + "primary": true + } + ], + "active": true, + "meta": { + "resourceType": "User", + "created": ` + referenceTimeStr + `, + "lastModified": ` + referenceTimeStr + `, + "location": "https://api.github.com/scim/v2/organizations/octo-org/Users/5fc0" + } + } + ] + }`)) }) ctx := t.Context() From d5993815311305e3cd247234b580fa818884d78f Mon Sep 17 00:00:00 2001 From: Alejandro Date: Fri, 28 Nov 2025 16:05:42 +0100 Subject: [PATCH 2/9] Improve unit-test --- github/enterprise_scim_test.go | 57 +++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/github/enterprise_scim_test.go b/github/enterprise_scim_test.go index 37e08d917a6..1dd4410137e 100644 --- a/github/enterprise_scim_test.go +++ b/github/enterprise_scim_test.go @@ -6,6 +6,7 @@ package github import ( + "fmt" "net/http" "testing" @@ -257,20 +258,20 @@ func TestEnterpriseService_ListProvisionedSCIMGroups(t *testing.T) { "filter": `externalId eq "914a"`, }) w.WriteHeader(http.StatusOK) - _, _ = w.Write([]byte(`{ - "schemas": ["` + SCIMSchemasURINamespacesListResponse + `"], + fmt.Fprint(w, `{ + "schemas": ["`+SCIMSchemasURINamespacesListResponse+`"], "totalResults": 1, "itemsPerPage": 1, "startIndex": 1, "Resources": [{ - "schemas": ["` + SCIMSchemasURINamespacesGroups + `"], + "schemas": ["`+SCIMSchemasURINamespacesGroups+`"], "id": "914a", "externalId": "de88", "displayName": "gn1", "meta": { "resourceType": "Group", - "created": ` + referenceTimeStr + `, - "lastModified": ` + referenceTimeStr + `, + "created": `+referenceTimeStr+`, + "lastModified": `+referenceTimeStr+`, "location": "https://api.github.com/scim/v2/enterprises/ee/Groups/914a" }, "members": [{ @@ -279,7 +280,7 @@ func TestEnterpriseService_ListProvisionedSCIMGroups(t *testing.T) { "display": "d1" }] }] - }`)) + }`) }) ctx := t.Context() @@ -289,12 +290,12 @@ func TestEnterpriseService_ListProvisionedSCIMGroups(t *testing.T) { Count: Ptr(3), Filter: Ptr(`externalId eq "914a"`), } - groups, _, err := client.Enterprise.ListProvisionedSCIMGroups(ctx, "ee", opts) + got, _, err := client.Enterprise.ListProvisionedSCIMGroups(ctx, "ee", opts) if err != nil { t.Fatalf("Enterprise.ListProvisionedSCIMGroups returned unexpected error: %v", err) } - want := SCIMEnterpriseGroups{ + want := &SCIMEnterpriseGroups{ Schemas: []string{SCIMSchemasURINamespacesListResponse}, TotalResults: Ptr(1), ItemsPerPage: Ptr(1), @@ -318,7 +319,7 @@ func TestEnterpriseService_ListProvisionedSCIMGroups(t *testing.T) { }}, } - if diff := cmp.Diff(want, *groups); diff != "" { + if diff := cmp.Diff(want, got); diff != "" { t.Errorf("Enterprise.ListProvisionedSCIMGroups diff mismatch (-want +got):\n%v", diff) } @@ -329,8 +330,11 @@ func TestEnterpriseService_ListProvisionedSCIMGroups(t *testing.T) { }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - _, r, err := client.Enterprise.ListProvisionedSCIMGroups(ctx, "o", opts) - return r, err + got, resp, err := client.Enterprise.ListProvisionedSCIMGroups(ctx, "ee", opts) + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err }) } @@ -338,7 +342,7 @@ func TestEnterpriseService_ListProvisionedSCIMUsers(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/scim/v2/enterprises/octo-org/Users", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/scim/v2/enterprises/ee/Users", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testHeader(t, r, "Accept", mediaTypeSCIM) testFormValues(t, r, values{ @@ -347,14 +351,14 @@ func TestEnterpriseService_ListProvisionedSCIMUsers(t *testing.T) { "filter": `userName eq "octocat@github.com"`, }) w.WriteHeader(http.StatusOK) - _, _ = w.Write([]byte(`{ - "schemas": ["` + SCIMSchemasURINamespacesListResponse + `"], + fmt.Fprint(w, `{ + "schemas": ["`+SCIMSchemasURINamespacesListResponse+`"], "totalResults": 1, "itemsPerPage": 1, "startIndex": 1, "Resources": [ { - "schemas": ["` + SCIMSchemasURINamespacesUser + `"], + "schemas": ["`+SCIMSchemasURINamespacesUser+`"], "id": "5fc0", "externalId": "00u1", "userName": "octocat@github.com", @@ -373,13 +377,13 @@ func TestEnterpriseService_ListProvisionedSCIMUsers(t *testing.T) { "active": true, "meta": { "resourceType": "User", - "created": ` + referenceTimeStr + `, - "lastModified": ` + referenceTimeStr + `, - "location": "https://api.github.com/scim/v2/organizations/octo-org/Users/5fc0" + "created": `+referenceTimeStr+`, + "lastModified": `+referenceTimeStr+`, + "location": "https://api.github.com/scim/v2/enterprises/ee/Users/5fc0" } } ] - }`)) + }`) }) ctx := t.Context() @@ -388,12 +392,12 @@ func TestEnterpriseService_ListProvisionedSCIMUsers(t *testing.T) { Count: Ptr(3), Filter: Ptr(`userName eq "octocat@github.com"`), } - users, _, err := client.Enterprise.ListProvisionedSCIMUsers(ctx, "octo-org", opts) + got, _, err := client.Enterprise.ListProvisionedSCIMUsers(ctx, "ee", opts) if err != nil { t.Fatalf("Enterprise.ListProvisionedSCIMUsers returned unexpected error: %v", err) } - want := SCIMEnterpriseUsers{ + want := &SCIMEnterpriseUsers{ Schemas: []string{SCIMSchemasURINamespacesListResponse}, TotalResults: Ptr(1), ItemsPerPage: Ptr(1), @@ -418,12 +422,12 @@ func TestEnterpriseService_ListProvisionedSCIMUsers(t *testing.T) { ResourceType: "User", Created: &Timestamp{referenceTime}, LastModified: &Timestamp{referenceTime}, - Location: Ptr("https://api.github.com/scim/v2/organizations/octo-org/Users/5fc0"), + Location: Ptr("https://api.github.com/scim/v2/enterprises/ee/Users/5fc0"), }, }}, } - if diff := cmp.Diff(want, *users); diff != "" { + if diff := cmp.Diff(want, got); diff != "" { t.Errorf("Enterprise.ListProvisionedSCIMUsers diff mismatch (-want +got):\n%v", diff) } @@ -434,7 +438,10 @@ func TestEnterpriseService_ListProvisionedSCIMUsers(t *testing.T) { }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - _, r, err := client.Enterprise.ListProvisionedSCIMUsers(ctx, "o", opts) - return r, err + got, resp, err := client.Enterprise.ListProvisionedSCIMUsers(ctx, "ee", opts) + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err }) } From 6f7e415b9e5937f7bfde7dc405a4e6f6bb7d6fcf Mon Sep 17 00:00:00 2001 From: Alejandro Date: Fri, 28 Nov 2025 17:02:31 +0100 Subject: [PATCH 3/9] Add patch methods for User & Group --- github/enterprise_scim.go | 63 ++++++++++ github/enterprise_scim_test.go | 213 ++++++++++++++++++++++++++++++++ github/github-accessors.go | 16 +++ github/github-accessors_test.go | 22 ++++ 4 files changed, 314 insertions(+) diff --git a/github/enterprise_scim.go b/github/enterprise_scim.go index 806954360a0..4c69f4092cf 100644 --- a/github/enterprise_scim.go +++ b/github/enterprise_scim.go @@ -22,6 +22,10 @@ const SCIMSchemasURINamespacesUser = "urn:ietf:params:scim:schemas:core:2.0:User // This constant represents the standard SCIM namespace for list responses used in paginated queries, as defined by RFC 7644. const SCIMSchemasURINamespacesListResponse = "urn:ietf:params:scim:api:messages:2.0:ListResponse" +// SCIMSchemasURINamespacesPatchOp is the SCIM schema URI namespace for patch operations. +// This constant represents the standard SCIM namespace for patch operations as defined by RFC 7644. +const SCIMSchemasURINamespacesPatchOp = "urn:ietf:params:scim:api:messages:2.0:PatchOp" + // SCIMEnterpriseGroupAttributes represents supported SCIM Enterprise group attributes. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#supported-scim-group-attributes @@ -140,6 +144,21 @@ type ListProvisionedSCIMUsersEnterpriseOptions struct { Count *int `url:"count,omitempty"` } +// SCIMEnterpriseAttributeOptions represents options for UpdateAttributeSCIMGroup or UpdateAttributeSCIMUser. +// +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#update-an-attribute-for-a-scim-enterprise-group +type SCIMEnterpriseAttributeOptions struct { + Schemas []string `json:"schemas"` // The URIs that are used to indicate the namespaces for a SCIM patch operation. + Operations []SCIMEnterpriseAttributeOperations `json:"Operations"` // Set of operations to be performed. +} + +// SCIMEnterpriseAttributeOperations represents operations for UpdateAttributeSCIMGroup or UpdateAttributeSCIMUser. +type SCIMEnterpriseAttributeOperations struct { + Op string `json:"op"` // Can be one of: add, replace, remove + Path *string `json:"path,omitempty"` // Path to the attribute being modified (Filters are not supported). + Value *string `json:"value,omitempty"` // New value for the attribute being modified. +} + // ListProvisionedSCIMGroups lists provisioned SCIM groups in an enterprise. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#list-provisioned-scim-groups-for-an-enterprise @@ -193,3 +212,47 @@ func (s *EnterpriseService) ListProvisionedSCIMUsers(ctx context.Context, enterp return users, resp, nil } + +// UpdateAttributeSCIMGroup Update a provisioned group’s individual attributes. +// +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#update-an-attribute-for-a-scim-enterprise-group +// +//meta:operation PATCH /scim/v2/enterprises/{enterprise}/Groups/{scim_group_id} +func (s *EnterpriseService) UpdateAttributeSCIMGroup(ctx context.Context, enterprise, scimGroupID string, opts SCIMEnterpriseAttributeOptions) (*SCIMEnterpriseGroupAttributes, *Response, error) { + u := fmt.Sprintf("scim/v2/enterprises/%v/Groups/%v", enterprise, scimGroupID) + req, err := s.client.NewRequest("PATCH", u, opts) + if err != nil { + return nil, nil, err + } + req.Header.Set("Accept", mediaTypeSCIM) + + group := new(SCIMEnterpriseGroupAttributes) + resp, err := s.client.Do(ctx, req, group) + if err != nil { + return nil, resp, err + } + + return group, resp, nil +} + +// UpdateAttributeSCIMUser Update a provisioned user's individual attributes. +// +// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#update-an-attribute-for-a-scim-enterprise-user +// +//meta:operation PATCH /scim/v2/enterprises/{enterprise}/Users/{scim_user_id} +func (s *EnterpriseService) UpdateAttributeSCIMUser(ctx context.Context, enterprise, scimUserID string, opts SCIMEnterpriseAttributeOptions) (*SCIMEnterpriseUserAttributes, *Response, error) { + u := fmt.Sprintf("scim/v2/enterprises/%v/Users/%v", enterprise, scimUserID) + req, err := s.client.NewRequest("PATCH", u, opts) + if err != nil { + return nil, nil, err + } + req.Header.Set("Accept", mediaTypeSCIM) + + user := new(SCIMEnterpriseUserAttributes) + resp, err := s.client.Do(ctx, req, user) + if err != nil { + return nil, resp, err + } + + return user, resp, nil +} diff --git a/github/enterprise_scim_test.go b/github/enterprise_scim_test.go index 1dd4410137e..27fa0c30964 100644 --- a/github/enterprise_scim_test.go +++ b/github/enterprise_scim_test.go @@ -244,6 +244,37 @@ func TestSCIMEnterpriseGroupAttributes_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } +func TestSCIMEnterpriseAttributeOptions_Marshal(t *testing.T) { + t.Parallel() + testJSONMarshal(t, &SCIMEnterpriseAttributeOptions{}, "{}") + + u := &SCIMEnterpriseAttributeOptions{ + Schemas: []string{"s"}, + Operations: []SCIMEnterpriseAttributeOperations{{ + Op: "o1", + Path: Ptr("p1"), + Value: Ptr("v1"), + }, + { + Op: "o2", + }}, + } + + want := `{ + "schemas": ["s"], + "Operations": [{ + "op": "o1", + "path": "p1", + "value": "v1" + }, + { + "op": "o2" + }] + }` + + testJSONMarshal(t, u, want) +} + func TestEnterpriseService_ListProvisionedSCIMGroups(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -445,3 +476,185 @@ func TestEnterpriseService_ListProvisionedSCIMUsers(t *testing.T) { return resp, err }) } + +func TestEnterpriseService_UpdateAttributeSCIMGroup(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/scim/v2/enterprises/ee/Groups/abcd", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "PATCH") + testHeader(t, r, "Accept", mediaTypeSCIM) + testBody(t, r, `{"schemas":["`+SCIMSchemasURINamespacesPatchOp+`"],"Operations":[{"op":"replace","path":"displayName","value":"Employees"}]}`+"\n") + w.WriteHeader(http.StatusOK) + fmt.Fprint(w, `{ + "schemas": ["`+SCIMSchemasURINamespacesGroups+`"], + "id": "abcd", + "externalId": "8aa1", + "displayName": "Employees", + "members": [{ + "value": "879d", + "$ref": "https://api.github.localhost/scim/v2/enterprises/ee/Users/879d", + "display": "User 1" + }], + "meta": { + "resourceType": "Group", + "created": `+referenceTimeStr+`, + "lastModified": `+referenceTimeStr+`, + "location": "https://api.github.localhost/scim/v2/enterprises/ee/Groups/abcd" + } + }`) + }) + want := &SCIMEnterpriseGroupAttributes{ + Schemas: []string{SCIMSchemasURINamespacesGroups}, + ID: Ptr("abcd"), + ExternalID: Ptr("8aa1"), + DisplayName: Ptr("Employees"), + Members: []*SCIMEnterpriseDisplayReference{{ + Value: "879d", + Ref: "https://api.github.localhost/scim/v2/enterprises/ee/Users/879d", + Display: Ptr("User 1"), + }}, + Meta: &SCIMEnterpriseMeta{ + ResourceType: "Group", + Created: &Timestamp{referenceTime}, + LastModified: &Timestamp{referenceTime}, + Location: Ptr("https://api.github.localhost/scim/v2/enterprises/ee/Groups/abcd"), + }, + } + + ctx := t.Context() + input := SCIMEnterpriseAttributeOptions{ + Schemas: []string{SCIMSchemasURINamespacesPatchOp}, + Operations: []SCIMEnterpriseAttributeOperations{{ + Op: "replace", + Path: Ptr("displayName"), + Value: Ptr("Employees"), + }}, + } + got, _, err := client.Enterprise.UpdateAttributeSCIMGroup(ctx, "ee", "abcd", input) + if err != nil { + t.Fatalf("Enterprise.UpdateAttributeSCIMGroup returned unexpected error: %v", err) + } + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("Enterprise.UpdateAttributeSCIMGroup diff mismatch (-want +got):\n%v", diff) + } + + const methodName = "UpdateAttributeSCIMGroup" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Enterprise.UpdateAttributeSCIMGroup(ctx, "\n", "\n", SCIMEnterpriseAttributeOptions{}) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Enterprise.UpdateAttributeSCIMGroup(ctx, "ee", "abcd", input) + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err + }) +} + +func TestEnterpriseService_UpdateAttributeSCIMUser(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/scim/v2/enterprises/ee/Users/7fce", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "PATCH") + testHeader(t, r, "Accept", mediaTypeSCIM) + testBody(t, r, `{"schemas":["`+SCIMSchemasURINamespacesPatchOp+`"],"Operations":[{"op":"replace","path":"emails[type eq 'work'].value","value":"updatedEmail@email.com"},{"op":"replace","path":"name.familyName","value":"updatedFamilyName"}]}`+"\n") + w.WriteHeader(http.StatusOK) + fmt.Fprint(w, `{ + "schemas": ["`+SCIMSchemasURINamespacesUser+`"], + "id": "7fce", + "externalId": "e123", + "active": true, + "userName": "e123", + "name": { + "formatted": "John Doe X", + "familyName": "updatedFamilyName", + "givenName": "John", + "middleName": "X" + }, + "displayName": "John Doe", + "emails": [{ + "value": "john@email.com", + "type": "work", + "primary": true + }], + "roles": [{ + "value": "User", + "primary": false + }], + "meta": { + "resourceType": "User", + "created": `+referenceTimeStr+`, + "lastModified": `+referenceTimeStr+`, + "location": "https://api.github.localhost/scim/v2/enterprises/ee/Users/7fce" + } + }`) + }) + want := &SCIMEnterpriseUserAttributes{ + Schemas: []string{SCIMSchemasURINamespacesUser}, + ID: Ptr("7fce"), + ExternalID: "e123", + Active: true, + UserName: "e123", + DisplayName: "John Doe", + Name: &SCIMEnterpriseUserName{ + Formatted: Ptr("John Doe X"), + FamilyName: "updatedFamilyName", + GivenName: "John", + MiddleName: Ptr("X"), + }, + Emails: []*SCIMEnterpriseUserEmail{{ + Value: "john@email.com", + Type: "work", + Primary: true, + }}, + Roles: []*SCIMEnterpriseUserRole{{ + Value: "User", + Primary: Ptr(false), + }}, + Meta: &SCIMEnterpriseMeta{ + ResourceType: "User", + Created: &Timestamp{referenceTime}, + LastModified: &Timestamp{referenceTime}, + Location: Ptr("https://api.github.localhost/scim/v2/enterprises/ee/Users/7fce"), + }, + } + + ctx := t.Context() + input := SCIMEnterpriseAttributeOptions{ + Schemas: []string{SCIMSchemasURINamespacesPatchOp}, + Operations: []SCIMEnterpriseAttributeOperations{{ + Op: "replace", + Path: Ptr("emails[type eq 'work'].value"), + Value: Ptr("updatedEmail@email.com"), + }, { + Op: "replace", + Path: Ptr("name.familyName"), + Value: Ptr("updatedFamilyName"), + }}, + } + got, _, err := client.Enterprise.UpdateAttributeSCIMUser(ctx, "ee", "7fce", input) + if err != nil { + t.Fatalf("Enterprise.UpdateAttributeSCIMUser returned unexpected error: %v", err) + } + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("Enterprise.UpdateAttributeSCIMUser diff mismatch (-want +got):\n%v", diff) + } + + const methodName = "UpdateAttributeSCIMUser" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Enterprise.UpdateAttributeSCIMUser(ctx, "\n", "\n", SCIMEnterpriseAttributeOptions{}) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Enterprise.UpdateAttributeSCIMUser(ctx, "ee", "7fce", input) + if got != nil { + t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) + } + return resp, err + }) +} diff --git a/github/github-accessors.go b/github/github-accessors.go index b95be28e733..83a8c586fe5 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -26230,6 +26230,22 @@ func (s *ScanningAnalysis) GetWarning() string { return *s.Warning } +// GetPath returns the Path field if it's non-nil, zero value otherwise. +func (s *SCIMEnterpriseAttributeOperations) GetPath() string { + if s == nil || s.Path == nil { + return "" + } + return *s.Path +} + +// GetValue returns the Value field if it's non-nil, zero value otherwise. +func (s *SCIMEnterpriseAttributeOperations) GetValue() string { + if s == nil || s.Value == nil { + return "" + } + return *s.Value +} + // GetDisplay returns the Display field if it's non-nil, zero value otherwise. func (s *SCIMEnterpriseDisplayReference) GetDisplay() string { if s == nil || s.Display == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 9abcb49dcde..647216b4c9d 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -33848,6 +33848,28 @@ func TestScanningAnalysis_GetWarning(tt *testing.T) { s.GetWarning() } +func TestSCIMEnterpriseAttributeOperations_GetPath(tt *testing.T) { + tt.Parallel() + var zeroValue string + s := &SCIMEnterpriseAttributeOperations{Path: &zeroValue} + s.GetPath() + s = &SCIMEnterpriseAttributeOperations{} + s.GetPath() + s = nil + s.GetPath() +} + +func TestSCIMEnterpriseAttributeOperations_GetValue(tt *testing.T) { + tt.Parallel() + var zeroValue string + s := &SCIMEnterpriseAttributeOperations{Value: &zeroValue} + s.GetValue() + s = &SCIMEnterpriseAttributeOperations{} + s.GetValue() + s = nil + s.GetValue() +} + func TestSCIMEnterpriseDisplayReference_GetDisplay(tt *testing.T) { tt.Parallel() var zeroValue string From 9ce1cd413b688d88fc7b5b92223dd253ba613474 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Mon, 1 Dec 2025 14:06:56 +0100 Subject: [PATCH 4/9] Fix lint error with gofumpt --- github/enterprise_scim_test.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/github/enterprise_scim_test.go b/github/enterprise_scim_test.go index 27fa0c30964..2724926df66 100644 --- a/github/enterprise_scim_test.go +++ b/github/enterprise_scim_test.go @@ -250,14 +250,16 @@ func TestSCIMEnterpriseAttributeOptions_Marshal(t *testing.T) { u := &SCIMEnterpriseAttributeOptions{ Schemas: []string{"s"}, - Operations: []SCIMEnterpriseAttributeOperations{{ - Op: "o1", - Path: Ptr("p1"), - Value: Ptr("v1"), - }, + Operations: []SCIMEnterpriseAttributeOperations{ + { + Op: "o1", + Path: Ptr("p1"), + Value: Ptr("v1"), + }, { Op: "o2", - }}, + }, + }, } want := `{ From 1cc1753837200b9d0c7e574f535c440f2ae48abb Mon Sep 17 00:00:00 2001 From: Alejandro Date: Mon, 1 Dec 2025 16:29:04 +0100 Subject: [PATCH 5/9] Fix lint error with sliceofpointers --- github/enterprise_scim.go | 4 ++-- github/enterprise_scim_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/github/enterprise_scim.go b/github/enterprise_scim.go index 4c69f4092cf..3a8fd91160e 100644 --- a/github/enterprise_scim.go +++ b/github/enterprise_scim.go @@ -148,8 +148,8 @@ type ListProvisionedSCIMUsersEnterpriseOptions struct { // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#update-an-attribute-for-a-scim-enterprise-group type SCIMEnterpriseAttributeOptions struct { - Schemas []string `json:"schemas"` // The URIs that are used to indicate the namespaces for a SCIM patch operation. - Operations []SCIMEnterpriseAttributeOperations `json:"Operations"` // Set of operations to be performed. + Schemas []string `json:"schemas"` // The URIs that are used to indicate the namespaces for a SCIM patch operation. + Operations []*SCIMEnterpriseAttributeOperations `json:"Operations,omitempty"` // Set of operations to be performed. } // SCIMEnterpriseAttributeOperations represents operations for UpdateAttributeSCIMGroup or UpdateAttributeSCIMUser. diff --git a/github/enterprise_scim_test.go b/github/enterprise_scim_test.go index 2724926df66..49af4f2fee8 100644 --- a/github/enterprise_scim_test.go +++ b/github/enterprise_scim_test.go @@ -250,7 +250,7 @@ func TestSCIMEnterpriseAttributeOptions_Marshal(t *testing.T) { u := &SCIMEnterpriseAttributeOptions{ Schemas: []string{"s"}, - Operations: []SCIMEnterpriseAttributeOperations{ + Operations: []*SCIMEnterpriseAttributeOperations{ { Op: "o1", Path: Ptr("p1"), @@ -527,7 +527,7 @@ func TestEnterpriseService_UpdateAttributeSCIMGroup(t *testing.T) { ctx := t.Context() input := SCIMEnterpriseAttributeOptions{ Schemas: []string{SCIMSchemasURINamespacesPatchOp}, - Operations: []SCIMEnterpriseAttributeOperations{{ + Operations: []*SCIMEnterpriseAttributeOperations{{ Op: "replace", Path: Ptr("displayName"), Value: Ptr("Employees"), @@ -628,7 +628,7 @@ func TestEnterpriseService_UpdateAttributeSCIMUser(t *testing.T) { ctx := t.Context() input := SCIMEnterpriseAttributeOptions{ Schemas: []string{SCIMSchemasURINamespacesPatchOp}, - Operations: []SCIMEnterpriseAttributeOperations{{ + Operations: []*SCIMEnterpriseAttributeOperations{{ Op: "replace", Path: Ptr("emails[type eq 'work'].value"), Value: Ptr("updatedEmail@email.com"), From 97e018894fc3a94b4964d79578e691caee5f4862 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Mon, 1 Dec 2025 16:50:10 +0100 Subject: [PATCH 6/9] Fix lint error with sliceofpointers (bis) --- github/enterprise_scim.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/enterprise_scim.go b/github/enterprise_scim.go index 3a8fd91160e..ade96abb986 100644 --- a/github/enterprise_scim.go +++ b/github/enterprise_scim.go @@ -148,8 +148,8 @@ type ListProvisionedSCIMUsersEnterpriseOptions struct { // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#update-an-attribute-for-a-scim-enterprise-group type SCIMEnterpriseAttributeOptions struct { - Schemas []string `json:"schemas"` // The URIs that are used to indicate the namespaces for a SCIM patch operation. - Operations []*SCIMEnterpriseAttributeOperations `json:"Operations,omitempty"` // Set of operations to be performed. + Schemas []string `json:"schemas"` // The URIs that are used to indicate the namespaces for a SCIM patch operation. + Operations []*SCIMEnterpriseAttributeOperations `json:"Operations"` // Set of operations to be performed. } // SCIMEnterpriseAttributeOperations represents operations for UpdateAttributeSCIMGroup or UpdateAttributeSCIMUser. From 7810fbdfbc0301223eeb648a979e4319b85d6765 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Tue, 2 Dec 2025 09:56:54 +0100 Subject: [PATCH 7/9] Rename struct and methods; update attributes related --- github/enterprise_scim.go | 26 +++++++++---------- github/enterprise_scim_test.go | 44 ++++++++++++++++----------------- github/github-accessors.go | 4 +-- github/github-accessors_test.go | 12 ++++----- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/github/enterprise_scim.go b/github/enterprise_scim.go index ade96abb986..aa8931cf560 100644 --- a/github/enterprise_scim.go +++ b/github/enterprise_scim.go @@ -144,17 +144,17 @@ type ListProvisionedSCIMUsersEnterpriseOptions struct { Count *int `url:"count,omitempty"` } -// SCIMEnterpriseAttributeOptions represents options for UpdateAttributeSCIMGroup or UpdateAttributeSCIMUser. +// SCIMEnterpriseAttribute represents attribute operations for UpdateSCIMGroupAttribute or UpdateSCIMUserAttribute. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#update-an-attribute-for-a-scim-enterprise-group -type SCIMEnterpriseAttributeOptions struct { - Schemas []string `json:"schemas"` // The URIs that are used to indicate the namespaces for a SCIM patch operation. - Operations []*SCIMEnterpriseAttributeOperations `json:"Operations"` // Set of operations to be performed. +type SCIMEnterpriseAttribute struct { + Schemas []string `json:"schemas"` // The URIs that are used to indicate the namespaces for a SCIM patch operation. + Operations []*SCIMEnterpriseAttributeOperation `json:"Operations"` // Set of operations to be performed. } -// SCIMEnterpriseAttributeOperations represents operations for UpdateAttributeSCIMGroup or UpdateAttributeSCIMUser. -type SCIMEnterpriseAttributeOperations struct { - Op string `json:"op"` // Can be one of: add, replace, remove +// SCIMEnterpriseAttributeOperation represents an operation for UpdateSCIMGroupAttribute or UpdateSCIMUserAttribute. +type SCIMEnterpriseAttributeOperation struct { + Op string `json:"op"` // Can be one of: `add`, `replace`, `remove`. Path *string `json:"path,omitempty"` // Path to the attribute being modified (Filters are not supported). Value *string `json:"value,omitempty"` // New value for the attribute being modified. } @@ -213,14 +213,14 @@ func (s *EnterpriseService) ListProvisionedSCIMUsers(ctx context.Context, enterp return users, resp, nil } -// UpdateAttributeSCIMGroup Update a provisioned group’s individual attributes. +// UpdateSCIMGroupAttribute Updates a provisioned group’s individual attributes. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#update-an-attribute-for-a-scim-enterprise-group // //meta:operation PATCH /scim/v2/enterprises/{enterprise}/Groups/{scim_group_id} -func (s *EnterpriseService) UpdateAttributeSCIMGroup(ctx context.Context, enterprise, scimGroupID string, opts SCIMEnterpriseAttributeOptions) (*SCIMEnterpriseGroupAttributes, *Response, error) { +func (s *EnterpriseService) UpdateSCIMGroupAttribute(ctx context.Context, enterprise, scimGroupID string, attribute SCIMEnterpriseAttribute) (*SCIMEnterpriseGroupAttributes, *Response, error) { u := fmt.Sprintf("scim/v2/enterprises/%v/Groups/%v", enterprise, scimGroupID) - req, err := s.client.NewRequest("PATCH", u, opts) + req, err := s.client.NewRequest("PATCH", u, attribute) if err != nil { return nil, nil, err } @@ -235,14 +235,14 @@ func (s *EnterpriseService) UpdateAttributeSCIMGroup(ctx context.Context, enterp return group, resp, nil } -// UpdateAttributeSCIMUser Update a provisioned user's individual attributes. +// UpdateSCIMUserAttribute Updates a provisioned user's individual attributes. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#update-an-attribute-for-a-scim-enterprise-user // //meta:operation PATCH /scim/v2/enterprises/{enterprise}/Users/{scim_user_id} -func (s *EnterpriseService) UpdateAttributeSCIMUser(ctx context.Context, enterprise, scimUserID string, opts SCIMEnterpriseAttributeOptions) (*SCIMEnterpriseUserAttributes, *Response, error) { +func (s *EnterpriseService) UpdateSCIMUserAttribute(ctx context.Context, enterprise, scimUserID string, attribute SCIMEnterpriseAttribute) (*SCIMEnterpriseUserAttributes, *Response, error) { u := fmt.Sprintf("scim/v2/enterprises/%v/Users/%v", enterprise, scimUserID) - req, err := s.client.NewRequest("PATCH", u, opts) + req, err := s.client.NewRequest("PATCH", u, attribute) if err != nil { return nil, nil, err } diff --git a/github/enterprise_scim_test.go b/github/enterprise_scim_test.go index 49af4f2fee8..4f65c27ff71 100644 --- a/github/enterprise_scim_test.go +++ b/github/enterprise_scim_test.go @@ -244,13 +244,13 @@ func TestSCIMEnterpriseGroupAttributes_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } -func TestSCIMEnterpriseAttributeOptions_Marshal(t *testing.T) { +func TestSCIMEnterpriseAttribute_Marshal(t *testing.T) { t.Parallel() - testJSONMarshal(t, &SCIMEnterpriseAttributeOptions{}, "{}") + testJSONMarshal(t, &SCIMEnterpriseAttribute{}, "{}") - u := &SCIMEnterpriseAttributeOptions{ + u := &SCIMEnterpriseAttribute{ Schemas: []string{"s"}, - Operations: []*SCIMEnterpriseAttributeOperations{ + Operations: []*SCIMEnterpriseAttributeOperation{ { Op: "o1", Path: Ptr("p1"), @@ -479,7 +479,7 @@ func TestEnterpriseService_ListProvisionedSCIMUsers(t *testing.T) { }) } -func TestEnterpriseService_UpdateAttributeSCIMGroup(t *testing.T) { +func TestEnterpriseService_UpdateSCIMGroupAttribute(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -525,30 +525,30 @@ func TestEnterpriseService_UpdateAttributeSCIMGroup(t *testing.T) { } ctx := t.Context() - input := SCIMEnterpriseAttributeOptions{ + input := SCIMEnterpriseAttribute{ Schemas: []string{SCIMSchemasURINamespacesPatchOp}, - Operations: []*SCIMEnterpriseAttributeOperations{{ + Operations: []*SCIMEnterpriseAttributeOperation{{ Op: "replace", Path: Ptr("displayName"), Value: Ptr("Employees"), }}, } - got, _, err := client.Enterprise.UpdateAttributeSCIMGroup(ctx, "ee", "abcd", input) + got, _, err := client.Enterprise.UpdateSCIMGroupAttribute(ctx, "ee", "abcd", input) if err != nil { - t.Fatalf("Enterprise.UpdateAttributeSCIMGroup returned unexpected error: %v", err) + t.Fatalf("Enterprise.UpdateSCIMGroupAttribute returned unexpected error: %v", err) } if diff := cmp.Diff(want, got); diff != "" { - t.Errorf("Enterprise.UpdateAttributeSCIMGroup diff mismatch (-want +got):\n%v", diff) + t.Errorf("Enterprise.UpdateSCIMGroupAttribute diff mismatch (-want +got):\n%v", diff) } - const methodName = "UpdateAttributeSCIMGroup" + const methodName = "UpdateSCIMGroupAttribute" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Enterprise.UpdateAttributeSCIMGroup(ctx, "\n", "\n", SCIMEnterpriseAttributeOptions{}) + _, _, err = client.Enterprise.UpdateSCIMGroupAttribute(ctx, "\n", "\n", SCIMEnterpriseAttribute{}) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Enterprise.UpdateAttributeSCIMGroup(ctx, "ee", "abcd", input) + got, resp, err := client.Enterprise.UpdateSCIMGroupAttribute(ctx, "ee", "abcd", input) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } @@ -556,7 +556,7 @@ func TestEnterpriseService_UpdateAttributeSCIMGroup(t *testing.T) { }) } -func TestEnterpriseService_UpdateAttributeSCIMUser(t *testing.T) { +func TestEnterpriseService_UpdateSCIMUserAttribute(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -626,9 +626,9 @@ func TestEnterpriseService_UpdateAttributeSCIMUser(t *testing.T) { } ctx := t.Context() - input := SCIMEnterpriseAttributeOptions{ + input := SCIMEnterpriseAttribute{ Schemas: []string{SCIMSchemasURINamespacesPatchOp}, - Operations: []*SCIMEnterpriseAttributeOperations{{ + Operations: []*SCIMEnterpriseAttributeOperation{{ Op: "replace", Path: Ptr("emails[type eq 'work'].value"), Value: Ptr("updatedEmail@email.com"), @@ -638,22 +638,22 @@ func TestEnterpriseService_UpdateAttributeSCIMUser(t *testing.T) { Value: Ptr("updatedFamilyName"), }}, } - got, _, err := client.Enterprise.UpdateAttributeSCIMUser(ctx, "ee", "7fce", input) + got, _, err := client.Enterprise.UpdateSCIMUserAttribute(ctx, "ee", "7fce", input) if err != nil { - t.Fatalf("Enterprise.UpdateAttributeSCIMUser returned unexpected error: %v", err) + t.Fatalf("Enterprise.UpdateSCIMUserAttribute returned unexpected error: %v", err) } if diff := cmp.Diff(want, got); diff != "" { - t.Errorf("Enterprise.UpdateAttributeSCIMUser diff mismatch (-want +got):\n%v", diff) + t.Errorf("Enterprise.UpdateSCIMUserAttribute diff mismatch (-want +got):\n%v", diff) } - const methodName = "UpdateAttributeSCIMUser" + const methodName = "UpdateSCIMUserAttribute" testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Enterprise.UpdateAttributeSCIMUser(ctx, "\n", "\n", SCIMEnterpriseAttributeOptions{}) + _, _, err = client.Enterprise.UpdateSCIMUserAttribute(ctx, "\n", "\n", SCIMEnterpriseAttribute{}) return err }) testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { - got, resp, err := client.Enterprise.UpdateAttributeSCIMUser(ctx, "ee", "7fce", input) + got, resp, err := client.Enterprise.UpdateSCIMUserAttribute(ctx, "ee", "7fce", input) if got != nil { t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) } diff --git a/github/github-accessors.go b/github/github-accessors.go index 83a8c586fe5..a46121fbc3e 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -26231,7 +26231,7 @@ func (s *ScanningAnalysis) GetWarning() string { } // GetPath returns the Path field if it's non-nil, zero value otherwise. -func (s *SCIMEnterpriseAttributeOperations) GetPath() string { +func (s *SCIMEnterpriseAttributeOperation) GetPath() string { if s == nil || s.Path == nil { return "" } @@ -26239,7 +26239,7 @@ func (s *SCIMEnterpriseAttributeOperations) GetPath() string { } // GetValue returns the Value field if it's non-nil, zero value otherwise. -func (s *SCIMEnterpriseAttributeOperations) GetValue() string { +func (s *SCIMEnterpriseAttributeOperation) GetValue() string { if s == nil || s.Value == nil { return "" } diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 647216b4c9d..0343e438c5f 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -33848,23 +33848,23 @@ func TestScanningAnalysis_GetWarning(tt *testing.T) { s.GetWarning() } -func TestSCIMEnterpriseAttributeOperations_GetPath(tt *testing.T) { +func TestSCIMEnterpriseAttributeOperation_GetPath(tt *testing.T) { tt.Parallel() var zeroValue string - s := &SCIMEnterpriseAttributeOperations{Path: &zeroValue} + s := &SCIMEnterpriseAttributeOperation{Path: &zeroValue} s.GetPath() - s = &SCIMEnterpriseAttributeOperations{} + s = &SCIMEnterpriseAttributeOperation{} s.GetPath() s = nil s.GetPath() } -func TestSCIMEnterpriseAttributeOperations_GetValue(tt *testing.T) { +func TestSCIMEnterpriseAttributeOperation_GetValue(tt *testing.T) { tt.Parallel() var zeroValue string - s := &SCIMEnterpriseAttributeOperations{Value: &zeroValue} + s := &SCIMEnterpriseAttributeOperation{Value: &zeroValue} s.GetValue() - s = &SCIMEnterpriseAttributeOperations{} + s = &SCIMEnterpriseAttributeOperation{} s.GetValue() s = nil s.GetValue() From 89b971fd44091493df5f89377dfdb41d356fa505 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Tue, 2 Dec 2025 09:58:59 +0100 Subject: [PATCH 8/9] Fix documentation erratas and extend it --- github/enterprise_scim.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/github/enterprise_scim.go b/github/enterprise_scim.go index aa8931cf560..639ed5cf172 100644 --- a/github/enterprise_scim.go +++ b/github/enterprise_scim.go @@ -26,14 +26,14 @@ const SCIMSchemasURINamespacesListResponse = "urn:ietf:params:scim:api:messages: // This constant represents the standard SCIM namespace for patch operations as defined by RFC 7644. const SCIMSchemasURINamespacesPatchOp = "urn:ietf:params:scim:api:messages:2.0:PatchOp" -// SCIMEnterpriseGroupAttributes represents supported SCIM Enterprise group attributes. +// SCIMEnterpriseGroupAttributes represents supported SCIM Enterprise group attributes, and represents the result of calling UpdateSCIMGroupAttribute. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#supported-scim-group-attributes type SCIMEnterpriseGroupAttributes struct { DisplayName *string `json:"displayName,omitempty"` // Human-readable name for a group. Members []*SCIMEnterpriseDisplayReference `json:"members,omitempty"` // List of members who are assigned to the group in SCIM provider ExternalID *string `json:"externalId,omitempty"` // This identifier is generated by a SCIM provider. Must be unique per user. - // Bellow: Only populated as a result of calling SetSCIMInformationForProvisionedGroup: + // Bellow: Only populated as a result of calling UpdateSCIMGroupAttribute: Schemas []string `json:"schemas,omitempty"` // The URIs that are used to indicate the namespaces of the SCIM schemas. ID *string `json:"id,omitempty"` // The internally generated id for the group object. Meta *SCIMEnterpriseMeta `json:"meta,omitempty"` // The metadata associated with the creation/updates to the group. @@ -80,7 +80,8 @@ type ListProvisionedSCIMGroupsEnterpriseOptions struct { Count *int `url:"count,omitempty"` } -// SCIMEnterpriseUserAttributes represents supported SCIM enterprise user attributes. +// SCIMEnterpriseUserAttributes represents supported SCIM enterprise user attributes, and represents the result of calling UpdateSCIMUserAttribute. +// // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#supported-scim-user-attributes type SCIMEnterpriseUserAttributes struct { DisplayName string `json:"displayName"` // Human-readable name for a user @@ -91,7 +92,7 @@ type SCIMEnterpriseUserAttributes struct { ExternalID string `json:"externalId"` // This identifier is generated by a SCIM provider. Must be unique per user. Active bool `json:"active"` // Indicates whether the identity is active (true) or should be suspended (false). Schemas []string `json:"schemas"` // The URIs that are used to indicate the namespaces of the SCIM schemas. - // Bellow: Only populated as a result of calling SetSCIMInformationForProvisionedUser: + // Bellow: Only populated as a result of calling UpdateSCIMUserAttribute: ID *string `json:"id,omitempty"` // Identifier generated by the GitHub's SCIM endpoint. Groups []*SCIMEnterpriseDisplayReference `json:"groups,omitempty"` // List of groups who are assigned to the user in SCIM provider Meta *SCIMEnterpriseMeta `json:"meta,omitempty"` // The metadata associated with the creation/updates to the user. @@ -120,7 +121,7 @@ type SCIMEnterpriseUserRole struct { Primary *bool `json:"primary,omitempty"` // Is the role a primary role for the user? } -// SCIMEnterpriseUsers represents the result of calling ProvisionSCIMEnterpriseUser. +// SCIMEnterpriseUsers represents the result of calling ListProvisionedSCIMUsers. type SCIMEnterpriseUsers struct { Schemas []string `json:"schemas,omitempty"` TotalResults *int `json:"totalResults,omitempty"` @@ -129,7 +130,7 @@ type SCIMEnterpriseUsers struct { Resources []*SCIMEnterpriseUserAttributes `json:"Resources,omitempty"` } -// ListProvisionedSCIMUsersEnterpriseOptions represents query parameters for ListSCIMProvisionedUsers. +// ListProvisionedSCIMUsersEnterpriseOptions represents query parameters for ListProvisionedSCIMUsers. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#list-scim-provisioned-identities-for-an-enterprise type ListProvisionedSCIMUsersEnterpriseOptions struct { From 4a2c0b8350d957ee07ab838e06a35f23aceda30f Mon Sep 17 00:00:00 2001 From: Alejandro Date: Tue, 2 Dec 2025 14:45:14 +0100 Subject: [PATCH 9/9] Minor tweak --- github/enterprise_scim.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/enterprise_scim.go b/github/enterprise_scim.go index 639ed5cf172..3243841a88c 100644 --- a/github/enterprise_scim.go +++ b/github/enterprise_scim.go @@ -214,7 +214,7 @@ func (s *EnterpriseService) ListProvisionedSCIMUsers(ctx context.Context, enterp return users, resp, nil } -// UpdateSCIMGroupAttribute Updates a provisioned group’s individual attributes. +// UpdateSCIMGroupAttribute updates a provisioned group’s individual attributes. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#update-an-attribute-for-a-scim-enterprise-group // @@ -236,7 +236,7 @@ func (s *EnterpriseService) UpdateSCIMGroupAttribute(ctx context.Context, enterp return group, resp, nil } -// UpdateSCIMUserAttribute Updates a provisioned user's individual attributes. +// UpdateSCIMUserAttribute updates a provisioned user's individual attributes. // // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/scim#update-an-attribute-for-a-scim-enterprise-user //