From 77e2c91eafe46513e39921a85301d2a30848aef0 Mon Sep 17 00:00:00 2001 From: Ackberry Date: Sat, 11 Jul 2026 15:04:34 -0400 Subject: [PATCH 01/14] feat: add Copilot Space struct and Copilot Spaces List struct --- github/copilot.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/github/copilot.go b/github/copilot.go index d5f0f085b8f..8917f8a6cad 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -21,6 +21,27 @@ import ( // GitHub API docs: https://docs.github.com/rest/copilot?apiVersion=2022-11-28 type CopilotService service +// CopilotSpace represents a Copilot Space. +type CopilotSpace struct { + ID *int64 `json:"id,omitempty"` + Number *int `json:"number,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + GeneralInstructions *string `json:"general_instructions,omitempty"` + Owner *User `json:"owner,omitempty"` + Creator *User `json:"creator,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + APIURL *string `json:"api_url,omitempty"` + BaseRole *string `json:"base_role,omitempty"` +} + +// CopilotSpacesList represents a list of Copilot Spaces. +type CopilotSpacesList struct { + Spaces []*CopilotSpace `json:"spaces,omitempty"` +} + // CopilotOrganizationDetails represents the details of an organization's Copilot for Business subscription. type CopilotOrganizationDetails struct { SeatBreakdown *CopilotSeatBreakdown `json:"seat_breakdown"` From 689f7bc9911ecf6ec137f5783c87de49e98bae24 Mon Sep 17 00:00:00 2001 From: Ackberry Date: Sat, 11 Jul 2026 15:53:06 -0400 Subject: [PATCH 02/14] Add ListOrganizationCopilotSpaces --- github/copilot.go | 26 +++++++++++++ github/copilot_test.go | 88 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) diff --git a/github/copilot.go b/github/copilot.go index 8917f8a6cad..577dd644578 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -42,6 +42,32 @@ type CopilotSpacesList struct { Spaces []*CopilotSpace `json:"spaces,omitempty"` } +// ListOrganizationCopilotSpaces lists Copilot Spaces for an organization. +// +// GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces#list-organization-copilot-spaces +// +//meta:operation GET /orgs/{org}/copilot-spaces +func (s *CopilotService) ListOrganizationCopilotSpaces(ctx context.Context, org string, opts *ListCursorOptions) (*CopilotSpacesList, *Response, error) { + u := fmt.Sprintf("orgs/%v/copilot-spaces", org) + u, err := addOptions(u, opts) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest(ctx, "GET", u, nil) + if err != nil { + return nil, nil, err + } + + var spaces *CopilotSpacesList + resp, err := s.client.Do(req, &spaces) + if err != nil { + return nil, resp, err + } + + return spaces, resp, nil +} + // CopilotOrganizationDetails represents the details of an organization's Copilot for Business subscription. type CopilotOrganizationDetails struct { SeatBreakdown *CopilotSeatBreakdown `json:"seat_breakdown"` diff --git a/github/copilot_test.go b/github/copilot_test.go index 8f3cfef2fac..cd6c8449ad9 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -1045,6 +1045,94 @@ func TestCopilotService_RemoveCopilotUsers(t *testing.T) { }) } +func TestCopilotService_ListOrganizationCopilotSpaces(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/orgs/o/copilot-spaces", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{ + "per_page": "100", + "after": "cursor", + }) + fmt.Fprint(w, `{ + "spaces": [ + { + "id": 12, + "number": 6, + "name": "Test Planning Space", + "description": "A space for planning", + "general_instructions": "use this space for team planning", + "owner": { + "login": "octo-org", + "id": 1, + "type": "Organization" + }, + "creator": { + "login": "octocat", + "id": 2, + "type": "User" + }, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, + "html_url": "https://github.com/copilot/spaces/octo-org/3", + "api_url": "https://api.github.com/orgs/octo-org/copilot-spaces/3", + "base_role": "read" + } + ] + }`) + }) + + ctx := t.Context() + opts := &ListCursorOptions{PerPage: 100, After: "cursor"} + got, _, err := client.Copilot.ListOrganizationCopilotSpaces(ctx, "o", opts) + if err != nil { + t.Errorf("Copilot.ListOrganizationCopilotSpaces returned error: %v", err) + } + want := &CopilotSpacesList{ + Spaces: []*CopilotSpace{ + { + ID: Ptr(int64(12)), + Number: Ptr(6), + Name: Ptr("Test Planning Space"), + Description: Ptr("A space for planning"), + GeneralInstructions: Ptr("use this space for team planning"), + Owner: &User{ + Login: Ptr("octo-org"), + ID: Ptr(int64(1)), + Type: Ptr("Organization"), + }, + Creator: &User{ + Login: Ptr("octocat"), + ID: Ptr(int64(2)), + Type: Ptr("User"), + }, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), + HTMLURL: Ptr("https://github.com/copilot/spaces/octo-org/3"), + APIURL: Ptr("https://api.github.com/orgs/octo-org/copilot-spaces/3"), + BaseRole: Ptr("read"), + }, + }, + } + + assertNoDiff(t, want, got) + + const methodName = "ListOrganizationCopilotSpaces" + + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Copilot.ListOrganizationCopilotSpaces(ctx, "\n", opts) + return err + }) + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Copilot.ListOrganizationCopilotSpaces(ctx, "o", opts) + if got != nil { + t.Errorf("Copilot.ListOrganizationCopilotSpaces returned %+v, want nil", got) + } + return resp, err + }) +} + func TestCopilotService_GetSeatDetails(t *testing.T) { t.Parallel() client, mux, _ := setup(t) From 269ba4d31c312086ebf9613dc1044b37ea86cca8 Mon Sep 17 00:00:00 2001 From: Ackberry Date: Sat, 11 Jul 2026 16:03:47 -0400 Subject: [PATCH 03/14] Add GetOrganizationCopilotSpace --- github/copilot.go | 21 ++++++++++++ github/copilot_test.go | 77 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/github/copilot.go b/github/copilot.go index 577dd644578..86cc7cf5e01 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -68,6 +68,27 @@ func (s *CopilotService) ListOrganizationCopilotSpaces(ctx context.Context, org return spaces, resp, nil } +// GetOrganizationCopilotSpace gets a Copilot Space for an organization. +// +// GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces#get-an-organization-copilot-space +// +//meta:operation GET /orgs/{org}/copilot-spaces/{space_number} +func (s *CopilotService) GetOrganizationCopilotSpace(ctx context.Context, org string, spaceNumber int) (*CopilotSpace, *Response, error) { + u := fmt.Sprintf("orgs/%v/copilot-spaces/%v", org, spaceNumber) + + req, err := s.client.NewRequest(ctx, "GET", u, nil) + if err != nil { + return nil, nil, err + } + + var space *CopilotSpace + resp, err := s.client.Do(req, &space) + if err != nil { + return nil, resp, err + } + return space, resp, nil +} + // CopilotOrganizationDetails represents the details of an organization's Copilot for Business subscription. type CopilotOrganizationDetails struct { SeatBreakdown *CopilotSeatBreakdown `json:"seat_breakdown"` diff --git a/github/copilot_test.go b/github/copilot_test.go index cd6c8449ad9..a8083f46478 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -1133,6 +1133,83 @@ func TestCopilotService_ListOrganizationCopilotSpaces(t *testing.T) { }) } +func TestCopilotService_GetOrganizationCopilotSpace(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/orgs/o/copilot-spaces/6", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + fmt.Fprint(w, `{ + "id": 12, + "number": 6, + "name": "Test Planning Space", + "description": "A space for planning", + "general_instructions": "use this space for team planning", + "owner": { + "login": "octo-org", + "id": 1, + "type": "Organization" + }, + "creator": { + "login": "octocat", + "id": 2, + "type": "User" + }, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, + "html_url": "https://github.com/copilot/spaces/octo-org/6", + "api_url": "https://api.github.com/orgs/octo-org/copilot-spaces/6", + "base_role": "read" + }`) + }) + + ctx := t.Context() + got, _, err := client.Copilot.GetOrganizationCopilotSpace(ctx, "o", 6) + if err != nil { + t.Errorf("Copilot.GetOrganizationCopilotSpace returned error: %v", err) + } + + want := &CopilotSpace{ + ID: Ptr(int64(12)), + Number: Ptr(6), + Name: Ptr("Test Planning Space"), + Description: Ptr("A space for planning"), + GeneralInstructions: Ptr("use this space for team planning"), + Owner: &User{ + Login: Ptr("octo-org"), + ID: Ptr(int64(1)), + Type: Ptr("Organization"), + }, + Creator: &User{ + Login: Ptr("octocat"), + ID: Ptr(int64(2)), + Type: Ptr("User"), + }, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), + HTMLURL: Ptr("https://github.com/copilot/spaces/octo-org/6"), + APIURL: Ptr("https://api.github.com/orgs/octo-org/copilot-spaces/6"), + BaseRole: Ptr("read"), + } + + assertNoDiff(t, want, got) + + const methodName = "GetOrganizationCopilotSpace" + + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Copilot.GetOrganizationCopilotSpace(ctx, "\n", 6) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Copilot.GetOrganizationCopilotSpace(ctx, "o", 6) + if got != nil { + t.Errorf("Copilot.GetOrganizationCopilotSpace returned %+v, want nil", got) + } + return resp, err + }) +} + func TestCopilotService_GetSeatDetails(t *testing.T) { t.Parallel() client, mux, _ := setup(t) From 4d1bc89f935e52c4e8b2926f5bdddfa494c0c41c Mon Sep 17 00:00:00 2001 From: Ackberry Date: Mon, 13 Jul 2026 01:35:48 -0400 Subject: [PATCH 04/14] Add CreateOrganizationCopilotSpace --- github/copilot.go | 63 +++++++++++++++++----- github/copilot_test.go | 115 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+), 12 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 86cc7cf5e01..882e071d30e 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -23,18 +23,35 @@ type CopilotService service // CopilotSpace represents a Copilot Space. type CopilotSpace struct { - ID *int64 `json:"id,omitempty"` - Number *int `json:"number,omitempty"` - Name *string `json:"name,omitempty"` - Description *string `json:"description,omitempty"` - GeneralInstructions *string `json:"general_instructions,omitempty"` - Owner *User `json:"owner,omitempty"` - Creator *User `json:"creator,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - UpdatedAt *Timestamp `json:"updated_at,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` - APIURL *string `json:"api_url,omitempty"` - BaseRole *string `json:"base_role,omitempty"` + ID *int64 `json:"id,omitempty"` + Number *int `json:"number,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + GeneralInstructions *string `json:"general_instructions,omitempty"` + Owner *User `json:"owner,omitempty"` + Creator *User `json:"creator,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + APIURL *string `json:"api_url,omitempty"` + BaseRole *string `json:"base_role,omitempty"` + ResourcesAttributes []*CopilotSpaceResource `json:"resources_attributes,omitempty"` +} + +// CopilotSpaceResource represents a resource attached to a Copilot Space. +type CopilotSpaceResource struct { + ID *int64 `json:"id,omitempty"` + ResourceType *string `json:"resource_type,omitempty"` + Metadata map[string]any `json:"metadata,omitempty"` +} + +// CopilotSpaceRequest represents a request to create or update a Copilot Space. +type CopilotSpaceRequest struct { + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + GeneralInstructions *string `json:"general_instructions,omitempty"` + BaseRole *string `json:"base_role,omitempty"` + ResourcesAttributes []*CopilotSpaceResource `json:"resources_attributes,omitempty"` } // CopilotSpacesList represents a list of Copilot Spaces. @@ -89,6 +106,28 @@ func (s *CopilotService) GetOrganizationCopilotSpace(ctx context.Context, org st return space, resp, nil } +// CreateOrganizationCopilotSpace creates a Copilot Space for an organization. +// +// GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces#create-an-organization-copilot-space +// +//meta:operation POST /orgs/{org}/copilot-spaces +func (s *CopilotService) CreateOrganizationCopilotSpace(ctx context.Context, org string, body CopilotSpaceRequest) (*CopilotSpace, *Response, error) { + u := fmt.Sprintf("orgs/%v/copilot-spaces", org) + + req, err := s.client.NewRequest(ctx, "POST", u, body) + if err != nil { + return nil, nil, err + } + + var space *CopilotSpace + resp, err := s.client.Do(req, &space) + if err != nil { + return nil, resp, err + } + + return space, resp, nil +} + // CopilotOrganizationDetails represents the details of an organization's Copilot for Business subscription. type CopilotOrganizationDetails struct { SeatBreakdown *CopilotSeatBreakdown `json:"seat_breakdown"` diff --git a/github/copilot_test.go b/github/copilot_test.go index a8083f46478..94f0070808e 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -1210,6 +1210,121 @@ func TestCopilotService_GetOrganizationCopilotSpace(t *testing.T) { }) } +func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + input := CopilotSpaceRequest{ + Name: Ptr("Team Planning Space"), + Description: Ptr("Organization space for team planning"), + GeneralInstructions: Ptr("Help the team with planning tasks"), + BaseRole: Ptr("no_access"), + ResourcesAttributes: []*CopilotSpaceResource{ + { + ResourceType: Ptr("free_text"), + Metadata: map[string]any{ + "name": "Team Guidelines", + "text": "Our team follows agile methodology", + }, + }, + }, + } + + want := &CopilotSpace{ + ID: Ptr(int64(12)), + Number: Ptr(6), + Name: Ptr("Team Planning Space"), + Description: Ptr("Organization space for team planning"), + GeneralInstructions: Ptr("Help the team with planning tasks"), + Owner: &User{ + Login: Ptr("octo-org"), + ID: Ptr(int64(1)), + Type: Ptr("Organization"), + }, + Creator: &User{ + Login: Ptr("octocat"), + ID: Ptr(int64(2)), + Type: Ptr("User"), + }, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), + HTMLURL: Ptr("https://github.com/copilot/spaces/octo-org/6"), + APIURL: Ptr("https://api.github.com/orgs/octo-org/copilot-spaces/6"), + BaseRole: Ptr("no_access"), + ResourcesAttributes: []*CopilotSpaceResource{ + { + ID: Ptr(int64(101)), + ResourceType: Ptr("free_text"), + Metadata: map[string]any{ + "name": "Team Guidelines", + "text": "Our team follows agile methodology", + }, + }, + }, + } + + mux.HandleFunc("/orgs/o/copilot-spaces", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "POST") + testJSONBody(t, r, input) + + fmt.Fprint(w, `{ + "id": 12, + "number": 6, + "name": "Team Planning Space", + "description": "Organization space for team planning", + "general_instructions": "Help the team with planning tasks", + "owner": { + "login": "octo-org", + "id": 1, + "type": "Organization" + }, + "creator": { + "login": "octocat", + "id": 2, + "type": "User" + }, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, + "html_url": "https://github.com/copilot/spaces/octo-org/6", + "api_url": "https://api.github.com/orgs/octo-org/copilot-spaces/6", + "base_role": "no_access", + "resources_attributes": [ + { + "id": 101, + "resource_type": "free_text", + "metadata": { + "name": "Team Guidelines", + "text": "Our team follows agile methodology" + } + } + ] + }`) + }) + + ctx := t.Context() + got, _, err := client.Copilot.CreateOrganizationCopilotSpace(ctx, "o", input) + if err != nil { + t.Errorf("Copilot.CreateOrganizationCopilotSpace returned error: %v", err) + } + + assertNoDiff(t, want, got) + + const methodName = "CreateOrganizationCopilotSpace" + + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Copilot.CreateOrganizationCopilotSpace(ctx, "\n", input) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Copilot.CreateOrganizationCopilotSpace(ctx, "o", input) + if got != nil { + t.Errorf("Copilot.CreateOrganizationCopilotSpace returned %+v, want nil", got) + } + return resp, err + }) +} + func TestCopilotService_GetSeatDetails(t *testing.T) { t.Parallel() client, mux, _ := setup(t) From 3fdf8c7a083a7b51a1adfe77cbfabbb148c42822 Mon Sep 17 00:00:00 2001 From: Ackberry Date: Mon, 13 Jul 2026 01:52:13 -0400 Subject: [PATCH 05/14] Add UpdateOrganizationCopilotSpace --- github/copilot.go | 23 ++++++++ github/copilot_test.go | 116 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+) diff --git a/github/copilot.go b/github/copilot.go index 882e071d30e..d7b468a1a70 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -103,6 +103,7 @@ func (s *CopilotService) GetOrganizationCopilotSpace(ctx context.Context, org st if err != nil { return nil, resp, err } + return space, resp, nil } @@ -128,6 +129,28 @@ func (s *CopilotService) CreateOrganizationCopilotSpace(ctx context.Context, org return space, resp, nil } +// UpdateOrganizationCopilotSpace updates a Copilot Space for an organization. +// +// GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces#set-an-organization-copilot-space +// +//meta:operation PUT /orgs/{org}/copilot-spaces/{space_number} +func (s *CopilotService) UpdateOrganizationCopilotSpace(ctx context.Context, org string, spaceNumber int, body CopilotSpaceRequest) (*CopilotSpace, *Response, error) { + u := fmt.Sprintf("orgs/%v/copilot-spaces/%v", org, spaceNumber) + + req, err := s.client.NewRequest(ctx, "PUT", u, body) + if err != nil { + return nil, nil, err + } + + var space *CopilotSpace + resp, err := s.client.Do(req, &space) + if err != nil { + return nil, resp, err + } + + return space, resp, nil +} + // CopilotOrganizationDetails represents the details of an organization's Copilot for Business subscription. type CopilotOrganizationDetails struct { SeatBreakdown *CopilotSeatBreakdown `json:"seat_breakdown"` diff --git a/github/copilot_test.go b/github/copilot_test.go index 94f0070808e..04ee667390c 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -1325,6 +1325,122 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) { }) } +func TestCopilotService_UpdateOrganizationCopilotSpace(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + input := CopilotSpaceRequest{ + Name: Ptr("Team Planning Space"), + Description: Ptr("Updated organization space for team planning"), + GeneralInstructions: Ptr("Help the team with updated planning tasks"), + BaseRole: Ptr("read"), + ResourcesAttributes: []*CopilotSpaceResource{ + { + ID: Ptr(int64(101)), + ResourceType: Ptr("free_text"), + Metadata: map[string]any{ + "name": "Updated Team Guidelines", + "text": "Our team now follows updated agile methodology", + }, + }, + }, + } + + want := &CopilotSpace{ + ID: Ptr(int64(12)), + Number: Ptr(6), + Name: Ptr("Team Planning Space"), + Description: Ptr("Updated organization space for team planning"), + GeneralInstructions: Ptr("Help the team with updated planning tasks"), + Owner: &User{ + Login: Ptr("octo-org"), + ID: Ptr(int64(1)), + Type: Ptr("Organization"), + }, + Creator: &User{ + Login: Ptr("octocat"), + ID: Ptr(int64(2)), + Type: Ptr("User"), + }, + CreatedAt: refTimestamp(1136178000), + UpdatedAt: refTimestamp(1136178001), + HTMLURL: Ptr("https://github.com/copilot/spaces/octo-org/6"), + APIURL: Ptr("https://api.github.com/orgs/octo-org/copilot-spaces/6"), + BaseRole: Ptr("read"), + ResourcesAttributes: []*CopilotSpaceResource{ + { + ID: Ptr(int64(101)), + ResourceType: Ptr("free_text"), + Metadata: map[string]any{ + "name": "Updated Team Guidelines", + "text": "Our team now follows updated agile methodology", + }, + }, + }, + } + + mux.HandleFunc("/orgs/o/copilot-spaces/6", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "PUT") + testJSONBody(t, r, input) + + fmt.Fprint(w, `{ + "id": 12, + "number": 6, + "name": "Team Planning Space", + "description": "Updated organization space for team planning", + "general_instructions": "Help the team with updated planning tasks", + "owner": { + "login": "octo-org", + "id": 1, + "type": "Organization" + }, + "creator": { + "login": "octocat", + "id": 2, + "type": "User" + }, + "created_at": `+refTimeStr(1136178000)+`, + "updated_at": `+refTimeStr(1136178001)+`, + "html_url": "https://github.com/copilot/spaces/octo-org/6", + "api_url": "https://api.github.com/orgs/octo-org/copilot-spaces/6", + "base_role": "read", + "resources_attributes": [ + { + "id": 101, + "resource_type": "free_text", + "metadata": { + "name": "Updated Team Guidelines", + "text": "Our team now follows updated agile methodology" + } + } + ] + }`) + }) + + ctx := t.Context() + got, _, err := client.Copilot.UpdateOrganizationCopilotSpace(ctx, "o", 6, input) + if err != nil { + t.Errorf("Copilot.UpdateOrganizationCopilotSpace returned error: %v", err) + } + + assertNoDiff(t, want, got) + + const methodName = "UpdateOrganizationCopilotSpace" + + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Copilot.UpdateOrganizationCopilotSpace(ctx, "\n", 6, input) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + got, resp, err := client.Copilot.UpdateOrganizationCopilotSpace(ctx, "o", 6, input) + if got != nil { + t.Errorf("Copilot.UpdateOrganizationCopilotSpace returned %+v, want nil", got) + } + return resp, err + }) +} + func TestCopilotService_GetSeatDetails(t *testing.T) { t.Parallel() client, mux, _ := setup(t) From 971a8dbaeebb0bef47a16392aed9a48fc8bca33e Mon Sep 17 00:00:00 2001 From: Ackberry Date: Mon, 13 Jul 2026 01:57:53 -0400 Subject: [PATCH 06/14] Add DeleteOrganizationCopilotSpace --- github/copilot.go | 16 ++++++++++++++++ github/copilot_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/github/copilot.go b/github/copilot.go index d7b468a1a70..390f19784d7 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -151,6 +151,22 @@ func (s *CopilotService) UpdateOrganizationCopilotSpace(ctx context.Context, org return space, resp, nil } +// DeleteOrganizationCopilotSpace deletes a Copilot Space for an organization. +// +// GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces#delete-an-organization-copilot-space +// +//meta:operation DELETE /orgs/{org}/copilot-spaces/{space_number} +func (s *CopilotService) DeleteOrganizationCopilotSpace(ctx context.Context, org string, spaceNumber int) (*Response, error) { + u := fmt.Sprintf("orgs/%v/copilot-spaces/%v", org, spaceNumber) + + req, err := s.client.NewRequest(ctx, "DELETE", u, nil) + if err != nil { + return nil, err + } + + return s.client.Do(req, nil) +} + // CopilotOrganizationDetails represents the details of an organization's Copilot for Business subscription. type CopilotOrganizationDetails struct { SeatBreakdown *CopilotSeatBreakdown `json:"seat_breakdown"` diff --git a/github/copilot_test.go b/github/copilot_test.go index 04ee667390c..bad5b5da200 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -1441,6 +1441,32 @@ func TestCopilotService_UpdateOrganizationCopilotSpace(t *testing.T) { }) } +func TestCopilotService_DeleteOrganizationCopilotSpace(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + + mux.HandleFunc("/orgs/o/copilot-spaces/6", func(_ http.ResponseWriter, r *http.Request) { + testMethod(t, r, "DELETE") + }) + + ctx := t.Context() + _, err := client.Copilot.DeleteOrganizationCopilotSpace(ctx, "o", 6) + if err != nil { + t.Errorf("Copilot.DeleteOrganizationCopilotSpace returned error: %v", err) + } + + const methodName = "DeleteOrganizationCopilotSpace" + + testBadOptions(t, methodName, func() (err error) { + _, err = client.Copilot.DeleteOrganizationCopilotSpace(ctx, "\n", 6) + return err + }) + + testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { + return client.Copilot.DeleteOrganizationCopilotSpace(ctx, "o", 6) + }) +} + func TestCopilotService_GetSeatDetails(t *testing.T) { t.Parallel() client, mux, _ := setup(t) From 72e0005187af51d25d3b9f861938645fdeb3cd4c Mon Sep 17 00:00:00 2001 From: Ackberry Date: Mon, 13 Jul 2026 11:56:42 -0400 Subject: [PATCH 07/14] Regenerate Copilot Spaces generated files --- github/copilot.go | 10 +- github/github-accessors.go | 176 ++++++++++++++++++++++++ github/github-accessors_test.go | 236 ++++++++++++++++++++++++++++++++ github/github-iterators.go | 35 +++++ github/github-iterators_test.go | 72 ++++++++++ 5 files changed, 524 insertions(+), 5 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 390f19784d7..07967e31d09 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -61,7 +61,7 @@ type CopilotSpacesList struct { // ListOrganizationCopilotSpaces lists Copilot Spaces for an organization. // -// GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces#list-organization-copilot-spaces +// GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces?apiVersion=2022-11-28#list-organization-copilot-spaces // //meta:operation GET /orgs/{org}/copilot-spaces func (s *CopilotService) ListOrganizationCopilotSpaces(ctx context.Context, org string, opts *ListCursorOptions) (*CopilotSpacesList, *Response, error) { @@ -87,7 +87,7 @@ func (s *CopilotService) ListOrganizationCopilotSpaces(ctx context.Context, org // GetOrganizationCopilotSpace gets a Copilot Space for an organization. // -// GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces#get-an-organization-copilot-space +// GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces?apiVersion=2022-11-28#get-an-organization-copilot-space // //meta:operation GET /orgs/{org}/copilot-spaces/{space_number} func (s *CopilotService) GetOrganizationCopilotSpace(ctx context.Context, org string, spaceNumber int) (*CopilotSpace, *Response, error) { @@ -109,7 +109,7 @@ func (s *CopilotService) GetOrganizationCopilotSpace(ctx context.Context, org st // CreateOrganizationCopilotSpace creates a Copilot Space for an organization. // -// GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces#create-an-organization-copilot-space +// GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces?apiVersion=2022-11-28#create-an-organization-copilot-space // //meta:operation POST /orgs/{org}/copilot-spaces func (s *CopilotService) CreateOrganizationCopilotSpace(ctx context.Context, org string, body CopilotSpaceRequest) (*CopilotSpace, *Response, error) { @@ -131,7 +131,7 @@ func (s *CopilotService) CreateOrganizationCopilotSpace(ctx context.Context, org // UpdateOrganizationCopilotSpace updates a Copilot Space for an organization. // -// GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces#set-an-organization-copilot-space +// GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces?apiVersion=2022-11-28#set-an-organization-copilot-space // //meta:operation PUT /orgs/{org}/copilot-spaces/{space_number} func (s *CopilotService) UpdateOrganizationCopilotSpace(ctx context.Context, org string, spaceNumber int, body CopilotSpaceRequest) (*CopilotSpace, *Response, error) { @@ -153,7 +153,7 @@ func (s *CopilotService) UpdateOrganizationCopilotSpace(ctx context.Context, org // DeleteOrganizationCopilotSpace deletes a Copilot Space for an organization. // -// GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces#delete-an-organization-copilot-space +// GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces?apiVersion=2022-11-28#delete-an-organization-copilot-space // //meta:operation DELETE /orgs/{org}/copilot-spaces/{space_number} func (s *CopilotService) DeleteOrganizationCopilotSpace(ctx context.Context, org string, spaceNumber int) (*Response, error) { diff --git a/github/github-accessors.go b/github/github-accessors.go index a4215e8fbc7..5d5bdc3f935 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -9958,6 +9958,182 @@ func (c *CopilotSeatDetails) GetUpdatedAt() Timestamp { return *c.UpdatedAt } +// GetAPIURL returns the APIURL field if it's non-nil, zero value otherwise. +func (c *CopilotSpace) GetAPIURL() string { + if c == nil || c.APIURL == nil { + return "" + } + return *c.APIURL +} + +// GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. +func (c *CopilotSpace) GetBaseRole() string { + if c == nil || c.BaseRole == nil { + return "" + } + return *c.BaseRole +} + +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (c *CopilotSpace) GetCreatedAt() Timestamp { + if c == nil || c.CreatedAt == nil { + return Timestamp{} + } + return *c.CreatedAt +} + +// GetCreator returns the Creator field. +func (c *CopilotSpace) GetCreator() *User { + if c == nil { + return nil + } + return c.Creator +} + +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (c *CopilotSpace) GetDescription() string { + if c == nil || c.Description == nil { + return "" + } + return *c.Description +} + +// GetGeneralInstructions returns the GeneralInstructions field if it's non-nil, zero value otherwise. +func (c *CopilotSpace) GetGeneralInstructions() string { + if c == nil || c.GeneralInstructions == nil { + return "" + } + return *c.GeneralInstructions +} + +// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. +func (c *CopilotSpace) GetHTMLURL() string { + if c == nil || c.HTMLURL == nil { + return "" + } + return *c.HTMLURL +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (c *CopilotSpace) GetID() int64 { + if c == nil || c.ID == nil { + return 0 + } + return *c.ID +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (c *CopilotSpace) GetName() string { + if c == nil || c.Name == nil { + return "" + } + return *c.Name +} + +// GetNumber returns the Number field if it's non-nil, zero value otherwise. +func (c *CopilotSpace) GetNumber() int { + if c == nil || c.Number == nil { + return 0 + } + return *c.Number +} + +// GetOwner returns the Owner field. +func (c *CopilotSpace) GetOwner() *User { + if c == nil { + return nil + } + return c.Owner +} + +// GetResourcesAttributes returns the ResourcesAttributes slice if it's non-nil, nil otherwise. +func (c *CopilotSpace) GetResourcesAttributes() []*CopilotSpaceResource { + if c == nil || c.ResourcesAttributes == nil { + return nil + } + return c.ResourcesAttributes +} + +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (c *CopilotSpace) GetUpdatedAt() Timestamp { + if c == nil || c.UpdatedAt == nil { + return Timestamp{} + } + return *c.UpdatedAt +} + +// GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceRequest) GetBaseRole() string { + if c == nil || c.BaseRole == nil { + return "" + } + return *c.BaseRole +} + +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceRequest) GetDescription() string { + if c == nil || c.Description == nil { + return "" + } + return *c.Description +} + +// GetGeneralInstructions returns the GeneralInstructions field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceRequest) GetGeneralInstructions() string { + if c == nil || c.GeneralInstructions == nil { + return "" + } + return *c.GeneralInstructions +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceRequest) GetName() string { + if c == nil || c.Name == nil { + return "" + } + return *c.Name +} + +// GetResourcesAttributes returns the ResourcesAttributes slice if it's non-nil, nil otherwise. +func (c *CopilotSpaceRequest) GetResourcesAttributes() []*CopilotSpaceResource { + if c == nil || c.ResourcesAttributes == nil { + return nil + } + return c.ResourcesAttributes +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceResource) GetID() int64 { + if c == nil || c.ID == nil { + return 0 + } + return *c.ID +} + +// GetMetadata returns the Metadata map if it's non-nil, an empty map otherwise. +func (c *CopilotSpaceResource) GetMetadata() map[string]any { + if c == nil || c.Metadata == nil { + return map[string]any{} + } + return c.Metadata +} + +// GetResourceType returns the ResourceType field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceResource) GetResourceType() string { + if c == nil || c.ResourceType == nil { + return "" + } + return *c.ResourceType +} + +// GetSpaces returns the Spaces slice if it's non-nil, nil otherwise. +func (c *CopilotSpacesList) GetSpaces() []*CopilotSpace { + if c == nil || c.Spaces == nil { + return nil + } + return c.Spaces +} + // GetCodeAcceptanceActivityCount returns the CodeAcceptanceActivityCount field if it's non-nil, zero value otherwise. func (c *CopilotUserDailyMetrics) GetCodeAcceptanceActivityCount() int { if c == nil || c.CodeAcceptanceActivityCount == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 04b0e9c8b2a..10fae4d50cf 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -12632,6 +12632,242 @@ func TestCopilotSeatDetails_GetUpdatedAt(tt *testing.T) { c.GetUpdatedAt() } +func TestCopilotSpace_GetAPIURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotSpace{APIURL: &zeroValue} + c.GetAPIURL() + c = &CopilotSpace{} + c.GetAPIURL() + c = nil + c.GetAPIURL() +} + +func TestCopilotSpace_GetBaseRole(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotSpace{BaseRole: &zeroValue} + c.GetBaseRole() + c = &CopilotSpace{} + c.GetBaseRole() + c = nil + c.GetBaseRole() +} + +func TestCopilotSpace_GetCreatedAt(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + c := &CopilotSpace{CreatedAt: &zeroValue} + c.GetCreatedAt() + c = &CopilotSpace{} + c.GetCreatedAt() + c = nil + c.GetCreatedAt() +} + +func TestCopilotSpace_GetCreator(tt *testing.T) { + tt.Parallel() + c := &CopilotSpace{} + c.GetCreator() + c = nil + c.GetCreator() +} + +func TestCopilotSpace_GetDescription(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotSpace{Description: &zeroValue} + c.GetDescription() + c = &CopilotSpace{} + c.GetDescription() + c = nil + c.GetDescription() +} + +func TestCopilotSpace_GetGeneralInstructions(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotSpace{GeneralInstructions: &zeroValue} + c.GetGeneralInstructions() + c = &CopilotSpace{} + c.GetGeneralInstructions() + c = nil + c.GetGeneralInstructions() +} + +func TestCopilotSpace_GetHTMLURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotSpace{HTMLURL: &zeroValue} + c.GetHTMLURL() + c = &CopilotSpace{} + c.GetHTMLURL() + c = nil + c.GetHTMLURL() +} + +func TestCopilotSpace_GetID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + c := &CopilotSpace{ID: &zeroValue} + c.GetID() + c = &CopilotSpace{} + c.GetID() + c = nil + c.GetID() +} + +func TestCopilotSpace_GetName(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotSpace{Name: &zeroValue} + c.GetName() + c = &CopilotSpace{} + c.GetName() + c = nil + c.GetName() +} + +func TestCopilotSpace_GetNumber(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &CopilotSpace{Number: &zeroValue} + c.GetNumber() + c = &CopilotSpace{} + c.GetNumber() + c = nil + c.GetNumber() +} + +func TestCopilotSpace_GetOwner(tt *testing.T) { + tt.Parallel() + c := &CopilotSpace{} + c.GetOwner() + c = nil + c.GetOwner() +} + +func TestCopilotSpace_GetResourcesAttributes(tt *testing.T) { + tt.Parallel() + zeroValue := []*CopilotSpaceResource{} + c := &CopilotSpace{ResourcesAttributes: zeroValue} + c.GetResourcesAttributes() + c = &CopilotSpace{} + c.GetResourcesAttributes() + c = nil + c.GetResourcesAttributes() +} + +func TestCopilotSpace_GetUpdatedAt(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + c := &CopilotSpace{UpdatedAt: &zeroValue} + c.GetUpdatedAt() + c = &CopilotSpace{} + c.GetUpdatedAt() + c = nil + c.GetUpdatedAt() +} + +func TestCopilotSpaceRequest_GetBaseRole(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotSpaceRequest{BaseRole: &zeroValue} + c.GetBaseRole() + c = &CopilotSpaceRequest{} + c.GetBaseRole() + c = nil + c.GetBaseRole() +} + +func TestCopilotSpaceRequest_GetDescription(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotSpaceRequest{Description: &zeroValue} + c.GetDescription() + c = &CopilotSpaceRequest{} + c.GetDescription() + c = nil + c.GetDescription() +} + +func TestCopilotSpaceRequest_GetGeneralInstructions(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotSpaceRequest{GeneralInstructions: &zeroValue} + c.GetGeneralInstructions() + c = &CopilotSpaceRequest{} + c.GetGeneralInstructions() + c = nil + c.GetGeneralInstructions() +} + +func TestCopilotSpaceRequest_GetName(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotSpaceRequest{Name: &zeroValue} + c.GetName() + c = &CopilotSpaceRequest{} + c.GetName() + c = nil + c.GetName() +} + +func TestCopilotSpaceRequest_GetResourcesAttributes(tt *testing.T) { + tt.Parallel() + zeroValue := []*CopilotSpaceResource{} + c := &CopilotSpaceRequest{ResourcesAttributes: zeroValue} + c.GetResourcesAttributes() + c = &CopilotSpaceRequest{} + c.GetResourcesAttributes() + c = nil + c.GetResourcesAttributes() +} + +func TestCopilotSpaceResource_GetID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + c := &CopilotSpaceResource{ID: &zeroValue} + c.GetID() + c = &CopilotSpaceResource{} + c.GetID() + c = nil + c.GetID() +} + +func TestCopilotSpaceResource_GetMetadata(tt *testing.T) { + tt.Parallel() + zeroValue := map[string]any{} + c := &CopilotSpaceResource{Metadata: zeroValue} + c.GetMetadata() + c = &CopilotSpaceResource{} + c.GetMetadata() + c = nil + c.GetMetadata() +} + +func TestCopilotSpaceResource_GetResourceType(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotSpaceResource{ResourceType: &zeroValue} + c.GetResourceType() + c = &CopilotSpaceResource{} + c.GetResourceType() + c = nil + c.GetResourceType() +} + +func TestCopilotSpacesList_GetSpaces(tt *testing.T) { + tt.Parallel() + zeroValue := []*CopilotSpace{} + c := &CopilotSpacesList{Spaces: zeroValue} + c.GetSpaces() + c = &CopilotSpacesList{} + c.GetSpaces() + c = nil + c.GetSpaces() +} + func TestCopilotUserDailyMetrics_GetCodeAcceptanceActivityCount(tt *testing.T) { tt.Parallel() var zeroValue int diff --git a/github/github-iterators.go b/github/github-iterators.go index 05120877ca5..d5d75885836 100644 --- a/github/github-iterators.go +++ b/github/github-iterators.go @@ -2533,6 +2533,41 @@ func (s *CopilotService) ListOrganizationCodingAgentRepositoriesIter(ctx context } } +// ListOrganizationCopilotSpacesIter returns an iterator that paginates through all results of ListOrganizationCopilotSpaces. +func (s *CopilotService) ListOrganizationCopilotSpacesIter(ctx context.Context, org string, opts *ListCursorOptions) iter.Seq2[*CopilotSpace, error] { + return func(yield func(*CopilotSpace, error) bool) { + // Create a copy of opts to avoid mutating the caller's struct + if opts == nil { + opts = &ListCursorOptions{} + } else { + opts = Ptr(*opts) + } + + for { + results, resp, err := s.ListOrganizationCopilotSpaces(ctx, org, opts) + if err != nil { + yield(nil, err) + return + } + + var iterItems []*CopilotSpace + if results != nil { + iterItems = results.Spaces + } + for _, item := range iterItems { + if !yield(item, nil) { + return + } + } + + if resp.After == "" { + break + } + opts.After = resp.After + } + } +} + // ListOrgAlertsIter returns an iterator that paginates through all results of ListOrgAlerts. func (s *DependabotService) ListOrgAlertsIter(ctx context.Context, org string, opts *ListAlertsOptions) iter.Seq2[*DependabotAlert, error] { return func(yield func(*DependabotAlert, error) bool) { diff --git a/github/github-iterators_test.go b/github/github-iterators_test.go index 75bc9f90c2b..f4a9703a9b9 100644 --- a/github/github-iterators_test.go +++ b/github/github-iterators_test.go @@ -5415,6 +5415,78 @@ func TestCopilotService_ListOrganizationCodingAgentRepositoriesIter(t *testing.T } } +func TestCopilotService_ListOrganizationCopilotSpacesIter(t *testing.T) { + t.Parallel() + client, mux, _ := setup(t) + var callNum int + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + callNum++ + switch callNum { + case 1: + w.Header().Set("Link", `; rel="next"`) + fmt.Fprint(w, `{"spaces": [{},{},{}]}`) + case 2: + fmt.Fprint(w, `{"spaces": [{},{},{},{}]}`) + case 3: + fmt.Fprint(w, `{"spaces": [{},{}]}`) + case 4: + w.WriteHeader(http.StatusNotFound) + case 5: + fmt.Fprint(w, `{"spaces": [{},{}]}`) + } + }) + + iter := client.Copilot.ListOrganizationCopilotSpacesIter(t.Context(), "", nil) + var gotItems int + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 7; gotItems != want { + t.Errorf("client.Copilot.ListOrganizationCopilotSpacesIter call 1 got %v items; want %v", gotItems, want) + } + + opts := &ListCursorOptions{} + iter = client.Copilot.ListOrganizationCopilotSpacesIter(t.Context(), "", opts) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + } + if want := 2; gotItems != want { + t.Errorf("client.Copilot.ListOrganizationCopilotSpacesIter call 2 got %v items; want %v", gotItems, want) + } + + iter = client.Copilot.ListOrganizationCopilotSpacesIter(t.Context(), "", nil) + gotItems = 0 + for _, err := range iter { + gotItems++ + if err == nil { + t.Error("expected error; got nil") + } + } + if gotItems != 1 { + t.Errorf("client.Copilot.ListOrganizationCopilotSpacesIter call 3 got %v items; want 1 (an error)", gotItems) + } + + iter = client.Copilot.ListOrganizationCopilotSpacesIter(t.Context(), "", nil) + gotItems = 0 + iter(func(item *CopilotSpace, err error) bool { + gotItems++ + if err != nil { + t.Errorf("Unexpected error: %v", err) + } + return false + }) + if gotItems != 1 { + t.Errorf("client.Copilot.ListOrganizationCopilotSpacesIter call 4 got %v items; want 1 (an error)", gotItems) + } +} + func TestDependabotService_ListOrgAlertsIter(t *testing.T) { t.Parallel() client, mux, _ := setup(t) From 235515785ea6d0b6c192065f47804eb4c457556f Mon Sep 17 00:00:00 2001 From: Ackberry Date: Mon, 13 Jul 2026 12:44:57 -0400 Subject: [PATCH 08/14] Use values for required Copilot Space fields --- github/copilot.go | 22 ++++----- github/copilot_test.go | 80 ++++++++++++++++----------------- github/github-accessors.go | 56 +++++++++++------------ github/github-accessors_test.go | 40 ++++------------- 4 files changed, 87 insertions(+), 111 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 07967e31d09..fc5e1bdf327 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -23,18 +23,18 @@ type CopilotService service // CopilotSpace represents a Copilot Space. type CopilotSpace struct { - ID *int64 `json:"id,omitempty"` - Number *int `json:"number,omitempty"` - Name *string `json:"name,omitempty"` + ID int64 `json:"id"` + Number int `json:"number"` + Name string `json:"name"` Description *string `json:"description,omitempty"` GeneralInstructions *string `json:"general_instructions,omitempty"` - Owner *User `json:"owner,omitempty"` - Creator *User `json:"creator,omitempty"` - CreatedAt *Timestamp `json:"created_at,omitempty"` - UpdatedAt *Timestamp `json:"updated_at,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` - APIURL *string `json:"api_url,omitempty"` - BaseRole *string `json:"base_role,omitempty"` + Owner User `json:"owner"` + Creator User `json:"creator"` + CreatedAt Timestamp `json:"created_at"` + UpdatedAt Timestamp `json:"updated_at"` + HTMLURL string `json:"html_url"` + APIURL string `json:"api_url"` + BaseRole string `json:"base_role"` ResourcesAttributes []*CopilotSpaceResource `json:"resources_attributes,omitempty"` } @@ -56,7 +56,7 @@ type CopilotSpaceRequest struct { // CopilotSpacesList represents a list of Copilot Spaces. type CopilotSpacesList struct { - Spaces []*CopilotSpace `json:"spaces,omitempty"` + Spaces []*CopilotSpace `json:"spaces"` } // ListOrganizationCopilotSpaces lists Copilot Spaces for an organization. diff --git a/github/copilot_test.go b/github/copilot_test.go index bad5b5da200..8018031c7d1 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -1092,26 +1092,26 @@ func TestCopilotService_ListOrganizationCopilotSpaces(t *testing.T) { want := &CopilotSpacesList{ Spaces: []*CopilotSpace{ { - ID: Ptr(int64(12)), - Number: Ptr(6), - Name: Ptr("Test Planning Space"), + ID: int64(12), + Number: 6, + Name: "Test Planning Space", Description: Ptr("A space for planning"), GeneralInstructions: Ptr("use this space for team planning"), - Owner: &User{ + Owner: User{ Login: Ptr("octo-org"), ID: Ptr(int64(1)), Type: Ptr("Organization"), }, - Creator: &User{ + Creator: User{ Login: Ptr("octocat"), ID: Ptr(int64(2)), Type: Ptr("User"), }, - CreatedAt: refTimestamp(1136178000), - UpdatedAt: refTimestamp(1136178001), - HTMLURL: Ptr("https://github.com/copilot/spaces/octo-org/3"), - APIURL: Ptr("https://api.github.com/orgs/octo-org/copilot-spaces/3"), - BaseRole: Ptr("read"), + CreatedAt: *refTimestamp(1136178000), + UpdatedAt: *refTimestamp(1136178001), + HTMLURL: "https://github.com/copilot/spaces/octo-org/3", + APIURL: "https://api.github.com/orgs/octo-org/copilot-spaces/3", + BaseRole: "read", }, }, } @@ -1170,26 +1170,26 @@ func TestCopilotService_GetOrganizationCopilotSpace(t *testing.T) { } want := &CopilotSpace{ - ID: Ptr(int64(12)), - Number: Ptr(6), - Name: Ptr("Test Planning Space"), + ID: int64(12), + Number: 6, + Name: "Test Planning Space", Description: Ptr("A space for planning"), GeneralInstructions: Ptr("use this space for team planning"), - Owner: &User{ + Owner: User{ Login: Ptr("octo-org"), ID: Ptr(int64(1)), Type: Ptr("Organization"), }, - Creator: &User{ + Creator: User{ Login: Ptr("octocat"), ID: Ptr(int64(2)), Type: Ptr("User"), }, - CreatedAt: refTimestamp(1136178000), - UpdatedAt: refTimestamp(1136178001), - HTMLURL: Ptr("https://github.com/copilot/spaces/octo-org/6"), - APIURL: Ptr("https://api.github.com/orgs/octo-org/copilot-spaces/6"), - BaseRole: Ptr("read"), + CreatedAt: *refTimestamp(1136178000), + UpdatedAt: *refTimestamp(1136178001), + HTMLURL: "https://github.com/copilot/spaces/octo-org/6", + APIURL: "https://api.github.com/orgs/octo-org/copilot-spaces/6", + BaseRole: "read", } assertNoDiff(t, want, got) @@ -1231,26 +1231,26 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) { } want := &CopilotSpace{ - ID: Ptr(int64(12)), - Number: Ptr(6), - Name: Ptr("Team Planning Space"), + ID: int64(12), + Number: 6, + Name: "Team Planning Space", Description: Ptr("Organization space for team planning"), GeneralInstructions: Ptr("Help the team with planning tasks"), - Owner: &User{ + Owner: User{ Login: Ptr("octo-org"), ID: Ptr(int64(1)), Type: Ptr("Organization"), }, - Creator: &User{ + Creator: User{ Login: Ptr("octocat"), ID: Ptr(int64(2)), Type: Ptr("User"), }, - CreatedAt: refTimestamp(1136178000), - UpdatedAt: refTimestamp(1136178001), - HTMLURL: Ptr("https://github.com/copilot/spaces/octo-org/6"), - APIURL: Ptr("https://api.github.com/orgs/octo-org/copilot-spaces/6"), - BaseRole: Ptr("no_access"), + CreatedAt: *refTimestamp(1136178000), + UpdatedAt: *refTimestamp(1136178001), + HTMLURL: "https://github.com/copilot/spaces/octo-org/6", + APIURL: "https://api.github.com/orgs/octo-org/copilot-spaces/6", + BaseRole: "no_access", ResourcesAttributes: []*CopilotSpaceResource{ { ID: Ptr(int64(101)), @@ -1347,26 +1347,26 @@ func TestCopilotService_UpdateOrganizationCopilotSpace(t *testing.T) { } want := &CopilotSpace{ - ID: Ptr(int64(12)), - Number: Ptr(6), - Name: Ptr("Team Planning Space"), + ID: int64(12), + Number: 6, + Name: "Team Planning Space", Description: Ptr("Updated organization space for team planning"), GeneralInstructions: Ptr("Help the team with updated planning tasks"), - Owner: &User{ + Owner: User{ Login: Ptr("octo-org"), ID: Ptr(int64(1)), Type: Ptr("Organization"), }, - Creator: &User{ + Creator: User{ Login: Ptr("octocat"), ID: Ptr(int64(2)), Type: Ptr("User"), }, - CreatedAt: refTimestamp(1136178000), - UpdatedAt: refTimestamp(1136178001), - HTMLURL: Ptr("https://github.com/copilot/spaces/octo-org/6"), - APIURL: Ptr("https://api.github.com/orgs/octo-org/copilot-spaces/6"), - BaseRole: Ptr("read"), + CreatedAt: *refTimestamp(1136178000), + UpdatedAt: *refTimestamp(1136178001), + HTMLURL: "https://github.com/copilot/spaces/octo-org/6", + APIURL: "https://api.github.com/orgs/octo-org/copilot-spaces/6", + BaseRole: "read", ResourcesAttributes: []*CopilotSpaceResource{ { ID: Ptr(int64(101)), diff --git a/github/github-accessors.go b/github/github-accessors.go index 5d5bdc3f935..2fef4813514 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -9958,34 +9958,34 @@ func (c *CopilotSeatDetails) GetUpdatedAt() Timestamp { return *c.UpdatedAt } -// GetAPIURL returns the APIURL field if it's non-nil, zero value otherwise. +// GetAPIURL returns the APIURL field. func (c *CopilotSpace) GetAPIURL() string { - if c == nil || c.APIURL == nil { + if c == nil { return "" } - return *c.APIURL + return c.APIURL } -// GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. +// GetBaseRole returns the BaseRole field. func (c *CopilotSpace) GetBaseRole() string { - if c == nil || c.BaseRole == nil { + if c == nil { return "" } - return *c.BaseRole + return c.BaseRole } -// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +// GetCreatedAt returns the CreatedAt field. func (c *CopilotSpace) GetCreatedAt() Timestamp { - if c == nil || c.CreatedAt == nil { + if c == nil { return Timestamp{} } - return *c.CreatedAt + return c.CreatedAt } // GetCreator returns the Creator field. -func (c *CopilotSpace) GetCreator() *User { +func (c *CopilotSpace) GetCreator() User { if c == nil { - return nil + return User{} } return c.Creator } @@ -10006,42 +10006,42 @@ func (c *CopilotSpace) GetGeneralInstructions() string { return *c.GeneralInstructions } -// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. +// GetHTMLURL returns the HTMLURL field. func (c *CopilotSpace) GetHTMLURL() string { - if c == nil || c.HTMLURL == nil { + if c == nil { return "" } - return *c.HTMLURL + return c.HTMLURL } -// GetID returns the ID field if it's non-nil, zero value otherwise. +// GetID returns the ID field. func (c *CopilotSpace) GetID() int64 { - if c == nil || c.ID == nil { + if c == nil { return 0 } - return *c.ID + return c.ID } -// GetName returns the Name field if it's non-nil, zero value otherwise. +// GetName returns the Name field. func (c *CopilotSpace) GetName() string { - if c == nil || c.Name == nil { + if c == nil { return "" } - return *c.Name + return c.Name } -// GetNumber returns the Number field if it's non-nil, zero value otherwise. +// GetNumber returns the Number field. func (c *CopilotSpace) GetNumber() int { - if c == nil || c.Number == nil { + if c == nil { return 0 } - return *c.Number + return c.Number } // GetOwner returns the Owner field. -func (c *CopilotSpace) GetOwner() *User { +func (c *CopilotSpace) GetOwner() User { if c == nil { - return nil + return User{} } return c.Owner } @@ -10054,12 +10054,12 @@ func (c *CopilotSpace) GetResourcesAttributes() []*CopilotSpaceResource { return c.ResourcesAttributes } -// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +// GetUpdatedAt returns the UpdatedAt field. func (c *CopilotSpace) GetUpdatedAt() Timestamp { - if c == nil || c.UpdatedAt == nil { + if c == nil { return Timestamp{} } - return *c.UpdatedAt + return c.UpdatedAt } // GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 10fae4d50cf..54760a3fcf2 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -12634,10 +12634,7 @@ func TestCopilotSeatDetails_GetUpdatedAt(tt *testing.T) { func TestCopilotSpace_GetAPIURL(tt *testing.T) { tt.Parallel() - var zeroValue string - c := &CopilotSpace{APIURL: &zeroValue} - c.GetAPIURL() - c = &CopilotSpace{} + c := &CopilotSpace{} c.GetAPIURL() c = nil c.GetAPIURL() @@ -12645,10 +12642,7 @@ func TestCopilotSpace_GetAPIURL(tt *testing.T) { func TestCopilotSpace_GetBaseRole(tt *testing.T) { tt.Parallel() - var zeroValue string - c := &CopilotSpace{BaseRole: &zeroValue} - c.GetBaseRole() - c = &CopilotSpace{} + c := &CopilotSpace{} c.GetBaseRole() c = nil c.GetBaseRole() @@ -12656,10 +12650,7 @@ func TestCopilotSpace_GetBaseRole(tt *testing.T) { func TestCopilotSpace_GetCreatedAt(tt *testing.T) { tt.Parallel() - var zeroValue Timestamp - c := &CopilotSpace{CreatedAt: &zeroValue} - c.GetCreatedAt() - c = &CopilotSpace{} + c := &CopilotSpace{} c.GetCreatedAt() c = nil c.GetCreatedAt() @@ -12697,10 +12688,7 @@ func TestCopilotSpace_GetGeneralInstructions(tt *testing.T) { func TestCopilotSpace_GetHTMLURL(tt *testing.T) { tt.Parallel() - var zeroValue string - c := &CopilotSpace{HTMLURL: &zeroValue} - c.GetHTMLURL() - c = &CopilotSpace{} + c := &CopilotSpace{} c.GetHTMLURL() c = nil c.GetHTMLURL() @@ -12708,10 +12696,7 @@ func TestCopilotSpace_GetHTMLURL(tt *testing.T) { func TestCopilotSpace_GetID(tt *testing.T) { tt.Parallel() - var zeroValue int64 - c := &CopilotSpace{ID: &zeroValue} - c.GetID() - c = &CopilotSpace{} + c := &CopilotSpace{} c.GetID() c = nil c.GetID() @@ -12719,10 +12704,7 @@ func TestCopilotSpace_GetID(tt *testing.T) { func TestCopilotSpace_GetName(tt *testing.T) { tt.Parallel() - var zeroValue string - c := &CopilotSpace{Name: &zeroValue} - c.GetName() - c = &CopilotSpace{} + c := &CopilotSpace{} c.GetName() c = nil c.GetName() @@ -12730,10 +12712,7 @@ func TestCopilotSpace_GetName(tt *testing.T) { func TestCopilotSpace_GetNumber(tt *testing.T) { tt.Parallel() - var zeroValue int - c := &CopilotSpace{Number: &zeroValue} - c.GetNumber() - c = &CopilotSpace{} + c := &CopilotSpace{} c.GetNumber() c = nil c.GetNumber() @@ -12760,10 +12739,7 @@ func TestCopilotSpace_GetResourcesAttributes(tt *testing.T) { func TestCopilotSpace_GetUpdatedAt(tt *testing.T) { tt.Parallel() - var zeroValue Timestamp - c := &CopilotSpace{UpdatedAt: &zeroValue} - c.GetUpdatedAt() - c = &CopilotSpace{} + c := &CopilotSpace{} c.GetUpdatedAt() c = nil c.GetUpdatedAt() From 3b1a5406207dd9d371d21e80cc5c88b80524536a Mon Sep 17 00:00:00 2001 From: Ackberry Date: Sat, 18 Jul 2026 16:08:41 -0400 Subject: [PATCH 09/14] Split Copilot Spaces request structs --- github/copilot.go | 32 ++++-- github/copilot_test.go | 30 +++--- github/github-accessors.go | 134 +++++++++++++++++++----- github/github-accessors_test.go | 178 +++++++++++++++++++++++++------- 4 files changed, 288 insertions(+), 86 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index fc5e1bdf327..453d236d55b 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -40,13 +40,31 @@ type CopilotSpace struct { // CopilotSpaceResource represents a resource attached to a Copilot Space. type CopilotSpaceResource struct { - ID *int64 `json:"id,omitempty"` - ResourceType *string `json:"resource_type,omitempty"` - Metadata map[string]any `json:"metadata,omitempty"` + ID *int64 `json:"id,omitempty"` + ResourceType *string `json:"resource_type,omitempty"` + Metadata *CopilotSpaceMetadata `json:"metadata,omitempty"` } -// CopilotSpaceRequest represents a request to create or update a Copilot Space. -type CopilotSpaceRequest struct { +// CopilotSpaceMetadata represents metadata specific to a Copilot Space resource type. +type CopilotSpaceMetadata struct { + RepositoryID *int64 `json:"repository_id,omitempty"` + FilePath *string `json:"file_path,omitempty"` + Text *string `json:"text,omitempty"` + Name *string `json:"name,omitempty"` + Number *int `json:"number,omitempty"` +} + +// CreateOrganizationCopilotSpaceRequest represents a request to create a Copilot Space. +type CreateOrganizationCopilotSpaceRequest struct { + Name string `json:"name"` + Description *string `json:"description,omitempty"` + GeneralInstructions *string `json:"general_instructions,omitempty"` + BaseRole *string `json:"base_role,omitempty"` + ResourcesAttributes []*CopilotSpaceResource `json:"resources_attributes,omitempty"` +} + +// UpdateOrganizationCopilotSpaceRequest represents a request to update a Copilot Space. +type UpdateOrganizationCopilotSpaceRequest struct { Name *string `json:"name,omitempty"` Description *string `json:"description,omitempty"` GeneralInstructions *string `json:"general_instructions,omitempty"` @@ -112,7 +130,7 @@ func (s *CopilotService) GetOrganizationCopilotSpace(ctx context.Context, org st // GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces?apiVersion=2022-11-28#create-an-organization-copilot-space // //meta:operation POST /orgs/{org}/copilot-spaces -func (s *CopilotService) CreateOrganizationCopilotSpace(ctx context.Context, org string, body CopilotSpaceRequest) (*CopilotSpace, *Response, error) { +func (s *CopilotService) CreateOrganizationCopilotSpace(ctx context.Context, org string, body CreateOrganizationCopilotSpaceRequest) (*CopilotSpace, *Response, error) { u := fmt.Sprintf("orgs/%v/copilot-spaces", org) req, err := s.client.NewRequest(ctx, "POST", u, body) @@ -134,7 +152,7 @@ func (s *CopilotService) CreateOrganizationCopilotSpace(ctx context.Context, org // GitHub API docs: https://docs.github.com/rest/copilot-spaces/copilot-spaces?apiVersion=2022-11-28#set-an-organization-copilot-space // //meta:operation PUT /orgs/{org}/copilot-spaces/{space_number} -func (s *CopilotService) UpdateOrganizationCopilotSpace(ctx context.Context, org string, spaceNumber int, body CopilotSpaceRequest) (*CopilotSpace, *Response, error) { +func (s *CopilotService) UpdateOrganizationCopilotSpace(ctx context.Context, org string, spaceNumber int, body UpdateOrganizationCopilotSpaceRequest) (*CopilotSpace, *Response, error) { u := fmt.Sprintf("orgs/%v/copilot-spaces/%v", org, spaceNumber) req, err := s.client.NewRequest(ctx, "PUT", u, body) diff --git a/github/copilot_test.go b/github/copilot_test.go index 8018031c7d1..706c5d0495b 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -1214,17 +1214,17 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := CopilotSpaceRequest{ - Name: Ptr("Team Planning Space"), + input := CreateOrganizationCopilotSpaceRequest{ + Name: "Team Planning Space", Description: Ptr("Organization space for team planning"), GeneralInstructions: Ptr("Help the team with planning tasks"), BaseRole: Ptr("no_access"), ResourcesAttributes: []*CopilotSpaceResource{ { ResourceType: Ptr("free_text"), - Metadata: map[string]any{ - "name": "Team Guidelines", - "text": "Our team follows agile methodology", + Metadata: &CopilotSpaceMetadata{ + Name: Ptr("Team Guidelines"), + Text: Ptr("Our team follows agile methodology"), }, }, }, @@ -1255,9 +1255,9 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) { { ID: Ptr(int64(101)), ResourceType: Ptr("free_text"), - Metadata: map[string]any{ - "name": "Team Guidelines", - "text": "Our team follows agile methodology", + Metadata: &CopilotSpaceMetadata{ + Name: Ptr("Team Guidelines"), + Text: Ptr("Our team follows agile methodology"), }, }, }, @@ -1329,7 +1329,7 @@ func TestCopilotService_UpdateOrganizationCopilotSpace(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - input := CopilotSpaceRequest{ + input := UpdateOrganizationCopilotSpaceRequest{ Name: Ptr("Team Planning Space"), Description: Ptr("Updated organization space for team planning"), GeneralInstructions: Ptr("Help the team with updated planning tasks"), @@ -1338,9 +1338,9 @@ func TestCopilotService_UpdateOrganizationCopilotSpace(t *testing.T) { { ID: Ptr(int64(101)), ResourceType: Ptr("free_text"), - Metadata: map[string]any{ - "name": "Updated Team Guidelines", - "text": "Our team now follows updated agile methodology", + Metadata: &CopilotSpaceMetadata{ + Name: Ptr("Team Guidelines"), + Text: Ptr("Our team follows agile methodology"), }, }, }, @@ -1371,9 +1371,9 @@ func TestCopilotService_UpdateOrganizationCopilotSpace(t *testing.T) { { ID: Ptr(int64(101)), ResourceType: Ptr("free_text"), - Metadata: map[string]any{ - "name": "Updated Team Guidelines", - "text": "Our team now follows updated agile methodology", + Metadata: &CopilotSpaceMetadata{ + Name: Ptr("Updated Team Guidelines"), + Text: Ptr("Our team now follows updated agile methodology"), }, }, }, diff --git a/github/github-accessors.go b/github/github-accessors.go index 2fef4813514..41b9cf2db1b 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -10062,44 +10062,44 @@ func (c *CopilotSpace) GetUpdatedAt() Timestamp { return c.UpdatedAt } -// GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. -func (c *CopilotSpaceRequest) GetBaseRole() string { - if c == nil || c.BaseRole == nil { +// GetFilePath returns the FilePath field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceMetadata) GetFilePath() string { + if c == nil || c.FilePath == nil { return "" } - return *c.BaseRole + return *c.FilePath } -// GetDescription returns the Description field if it's non-nil, zero value otherwise. -func (c *CopilotSpaceRequest) GetDescription() string { - if c == nil || c.Description == nil { +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceMetadata) GetName() string { + if c == nil || c.Name == nil { return "" } - return *c.Description + return *c.Name } -// GetGeneralInstructions returns the GeneralInstructions field if it's non-nil, zero value otherwise. -func (c *CopilotSpaceRequest) GetGeneralInstructions() string { - if c == nil || c.GeneralInstructions == nil { - return "" +// GetNumber returns the Number field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceMetadata) GetNumber() int { + if c == nil || c.Number == nil { + return 0 } - return *c.GeneralInstructions + return *c.Number } -// GetName returns the Name field if it's non-nil, zero value otherwise. -func (c *CopilotSpaceRequest) GetName() string { - if c == nil || c.Name == nil { - return "" +// GetRepositoryID returns the RepositoryID field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceMetadata) GetRepositoryID() int64 { + if c == nil || c.RepositoryID == nil { + return 0 } - return *c.Name + return *c.RepositoryID } -// GetResourcesAttributes returns the ResourcesAttributes slice if it's non-nil, nil otherwise. -func (c *CopilotSpaceRequest) GetResourcesAttributes() []*CopilotSpaceResource { - if c == nil || c.ResourcesAttributes == nil { - return nil +// GetText returns the Text field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceMetadata) GetText() string { + if c == nil || c.Text == nil { + return "" } - return c.ResourcesAttributes + return *c.Text } // GetID returns the ID field if it's non-nil, zero value otherwise. @@ -10110,10 +10110,10 @@ func (c *CopilotSpaceResource) GetID() int64 { return *c.ID } -// GetMetadata returns the Metadata map if it's non-nil, an empty map otherwise. -func (c *CopilotSpaceResource) GetMetadata() map[string]any { - if c == nil || c.Metadata == nil { - return map[string]any{} +// GetMetadata returns the Metadata field. +func (c *CopilotSpaceResource) GetMetadata() *CopilotSpaceMetadata { + if c == nil { + return nil } return c.Metadata } @@ -11534,6 +11534,46 @@ func (c *CreateMilestoneRequest) GetTitle() string { return c.Title } +// GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. +func (c *CreateOrganizationCopilotSpaceRequest) GetBaseRole() string { + if c == nil || c.BaseRole == nil { + return "" + } + return *c.BaseRole +} + +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (c *CreateOrganizationCopilotSpaceRequest) GetDescription() string { + if c == nil || c.Description == nil { + return "" + } + return *c.Description +} + +// GetGeneralInstructions returns the GeneralInstructions field if it's non-nil, zero value otherwise. +func (c *CreateOrganizationCopilotSpaceRequest) GetGeneralInstructions() string { + if c == nil || c.GeneralInstructions == nil { + return "" + } + return *c.GeneralInstructions +} + +// GetName returns the Name field. +func (c *CreateOrganizationCopilotSpaceRequest) GetName() string { + if c == nil { + return "" + } + return c.Name +} + +// GetResourcesAttributes returns the ResourcesAttributes slice if it's non-nil, nil otherwise. +func (c *CreateOrganizationCopilotSpaceRequest) GetResourcesAttributes() []*CopilotSpaceResource { + if c == nil || c.ResourcesAttributes == nil { + return nil + } + return c.ResourcesAttributes +} + // GetAccountID returns the AccountID field if it's non-nil, zero value otherwise. func (c *CreateOrganizationPrivateRegistry) GetAccountID() string { if c == nil || c.AccountID == nil { @@ -43670,6 +43710,46 @@ func (u *UpdateMilestoneRequest) GetTitle() string { return *u.Title } +// GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. +func (u *UpdateOrganizationCopilotSpaceRequest) GetBaseRole() string { + if u == nil || u.BaseRole == nil { + return "" + } + return *u.BaseRole +} + +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (u *UpdateOrganizationCopilotSpaceRequest) GetDescription() string { + if u == nil || u.Description == nil { + return "" + } + return *u.Description +} + +// GetGeneralInstructions returns the GeneralInstructions field if it's non-nil, zero value otherwise. +func (u *UpdateOrganizationCopilotSpaceRequest) GetGeneralInstructions() string { + if u == nil || u.GeneralInstructions == nil { + return "" + } + return *u.GeneralInstructions +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (u *UpdateOrganizationCopilotSpaceRequest) GetName() string { + if u == nil || u.Name == nil { + return "" + } + return *u.Name +} + +// GetResourcesAttributes returns the ResourcesAttributes slice if it's non-nil, nil otherwise. +func (u *UpdateOrganizationCopilotSpaceRequest) GetResourcesAttributes() []*CopilotSpaceResource { + if u == nil || u.ResourcesAttributes == nil { + return nil + } + return u.ResourcesAttributes +} + // GetAccountID returns the AccountID field if it's non-nil, zero value otherwise. func (u *UpdateOrganizationPrivateRegistry) GetAccountID() string { if u == nil || u.AccountID == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 54760a3fcf2..ee283a5a3cc 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -12745,59 +12745,59 @@ func TestCopilotSpace_GetUpdatedAt(tt *testing.T) { c.GetUpdatedAt() } -func TestCopilotSpaceRequest_GetBaseRole(tt *testing.T) { +func TestCopilotSpaceMetadata_GetFilePath(tt *testing.T) { tt.Parallel() var zeroValue string - c := &CopilotSpaceRequest{BaseRole: &zeroValue} - c.GetBaseRole() - c = &CopilotSpaceRequest{} - c.GetBaseRole() + c := &CopilotSpaceMetadata{FilePath: &zeroValue} + c.GetFilePath() + c = &CopilotSpaceMetadata{} + c.GetFilePath() c = nil - c.GetBaseRole() + c.GetFilePath() } -func TestCopilotSpaceRequest_GetDescription(tt *testing.T) { +func TestCopilotSpaceMetadata_GetName(tt *testing.T) { tt.Parallel() var zeroValue string - c := &CopilotSpaceRequest{Description: &zeroValue} - c.GetDescription() - c = &CopilotSpaceRequest{} - c.GetDescription() + c := &CopilotSpaceMetadata{Name: &zeroValue} + c.GetName() + c = &CopilotSpaceMetadata{} + c.GetName() c = nil - c.GetDescription() + c.GetName() } -func TestCopilotSpaceRequest_GetGeneralInstructions(tt *testing.T) { +func TestCopilotSpaceMetadata_GetNumber(tt *testing.T) { tt.Parallel() - var zeroValue string - c := &CopilotSpaceRequest{GeneralInstructions: &zeroValue} - c.GetGeneralInstructions() - c = &CopilotSpaceRequest{} - c.GetGeneralInstructions() + var zeroValue int + c := &CopilotSpaceMetadata{Number: &zeroValue} + c.GetNumber() + c = &CopilotSpaceMetadata{} + c.GetNumber() c = nil - c.GetGeneralInstructions() + c.GetNumber() } -func TestCopilotSpaceRequest_GetName(tt *testing.T) { +func TestCopilotSpaceMetadata_GetRepositoryID(tt *testing.T) { tt.Parallel() - var zeroValue string - c := &CopilotSpaceRequest{Name: &zeroValue} - c.GetName() - c = &CopilotSpaceRequest{} - c.GetName() + var zeroValue int64 + c := &CopilotSpaceMetadata{RepositoryID: &zeroValue} + c.GetRepositoryID() + c = &CopilotSpaceMetadata{} + c.GetRepositoryID() c = nil - c.GetName() + c.GetRepositoryID() } -func TestCopilotSpaceRequest_GetResourcesAttributes(tt *testing.T) { +func TestCopilotSpaceMetadata_GetText(tt *testing.T) { tt.Parallel() - zeroValue := []*CopilotSpaceResource{} - c := &CopilotSpaceRequest{ResourcesAttributes: zeroValue} - c.GetResourcesAttributes() - c = &CopilotSpaceRequest{} - c.GetResourcesAttributes() + var zeroValue string + c := &CopilotSpaceMetadata{Text: &zeroValue} + c.GetText() + c = &CopilotSpaceMetadata{} + c.GetText() c = nil - c.GetResourcesAttributes() + c.GetText() } func TestCopilotSpaceResource_GetID(tt *testing.T) { @@ -12813,10 +12813,7 @@ func TestCopilotSpaceResource_GetID(tt *testing.T) { func TestCopilotSpaceResource_GetMetadata(tt *testing.T) { tt.Parallel() - zeroValue := map[string]any{} - c := &CopilotSpaceResource{Metadata: zeroValue} - c.GetMetadata() - c = &CopilotSpaceResource{} + c := &CopilotSpaceResource{} c.GetMetadata() c = nil c.GetMetadata() @@ -14604,6 +14601,58 @@ func TestCreateMilestoneRequest_GetTitle(tt *testing.T) { c.GetTitle() } +func TestCreateOrganizationCopilotSpaceRequest_GetBaseRole(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateOrganizationCopilotSpaceRequest{BaseRole: &zeroValue} + c.GetBaseRole() + c = &CreateOrganizationCopilotSpaceRequest{} + c.GetBaseRole() + c = nil + c.GetBaseRole() +} + +func TestCreateOrganizationCopilotSpaceRequest_GetDescription(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateOrganizationCopilotSpaceRequest{Description: &zeroValue} + c.GetDescription() + c = &CreateOrganizationCopilotSpaceRequest{} + c.GetDescription() + c = nil + c.GetDescription() +} + +func TestCreateOrganizationCopilotSpaceRequest_GetGeneralInstructions(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateOrganizationCopilotSpaceRequest{GeneralInstructions: &zeroValue} + c.GetGeneralInstructions() + c = &CreateOrganizationCopilotSpaceRequest{} + c.GetGeneralInstructions() + c = nil + c.GetGeneralInstructions() +} + +func TestCreateOrganizationCopilotSpaceRequest_GetName(tt *testing.T) { + tt.Parallel() + c := &CreateOrganizationCopilotSpaceRequest{} + c.GetName() + c = nil + c.GetName() +} + +func TestCreateOrganizationCopilotSpaceRequest_GetResourcesAttributes(tt *testing.T) { + tt.Parallel() + zeroValue := []*CopilotSpaceResource{} + c := &CreateOrganizationCopilotSpaceRequest{ResourcesAttributes: zeroValue} + c.GetResourcesAttributes() + c = &CreateOrganizationCopilotSpaceRequest{} + c.GetResourcesAttributes() + c = nil + c.GetResourcesAttributes() +} + func TestCreateOrganizationPrivateRegistry_GetAccountID(tt *testing.T) { tt.Parallel() var zeroValue string @@ -54696,6 +54745,61 @@ func TestUpdateMilestoneRequest_GetTitle(tt *testing.T) { u.GetTitle() } +func TestUpdateOrganizationCopilotSpaceRequest_GetBaseRole(tt *testing.T) { + tt.Parallel() + var zeroValue string + u := &UpdateOrganizationCopilotSpaceRequest{BaseRole: &zeroValue} + u.GetBaseRole() + u = &UpdateOrganizationCopilotSpaceRequest{} + u.GetBaseRole() + u = nil + u.GetBaseRole() +} + +func TestUpdateOrganizationCopilotSpaceRequest_GetDescription(tt *testing.T) { + tt.Parallel() + var zeroValue string + u := &UpdateOrganizationCopilotSpaceRequest{Description: &zeroValue} + u.GetDescription() + u = &UpdateOrganizationCopilotSpaceRequest{} + u.GetDescription() + u = nil + u.GetDescription() +} + +func TestUpdateOrganizationCopilotSpaceRequest_GetGeneralInstructions(tt *testing.T) { + tt.Parallel() + var zeroValue string + u := &UpdateOrganizationCopilotSpaceRequest{GeneralInstructions: &zeroValue} + u.GetGeneralInstructions() + u = &UpdateOrganizationCopilotSpaceRequest{} + u.GetGeneralInstructions() + u = nil + u.GetGeneralInstructions() +} + +func TestUpdateOrganizationCopilotSpaceRequest_GetName(tt *testing.T) { + tt.Parallel() + var zeroValue string + u := &UpdateOrganizationCopilotSpaceRequest{Name: &zeroValue} + u.GetName() + u = &UpdateOrganizationCopilotSpaceRequest{} + u.GetName() + u = nil + u.GetName() +} + +func TestUpdateOrganizationCopilotSpaceRequest_GetResourcesAttributes(tt *testing.T) { + tt.Parallel() + zeroValue := []*CopilotSpaceResource{} + u := &UpdateOrganizationCopilotSpaceRequest{ResourcesAttributes: zeroValue} + u.GetResourcesAttributes() + u = &UpdateOrganizationCopilotSpaceRequest{} + u.GetResourcesAttributes() + u = nil + u.GetResourcesAttributes() +} + func TestUpdateOrganizationPrivateRegistry_GetAccountID(tt *testing.T) { tt.Parallel() var zeroValue string From 19cdac9aa6a655c58bdb975d546fd6a0eaa05a75 Mon Sep 17 00:00:00 2001 From: Ackberry Date: Tue, 21 Jul 2026 16:23:48 -0400 Subject: [PATCH 10/14] Add Copilot Space resource fields --- github/copilot.go | 24 ++++++--- github/copilot_test.go | 28 +++++++++++ github/github-accessors.go | 64 ++++++++++++++++++++++++ github/github-accessors_test.go | 88 +++++++++++++++++++++++++++++++++ 4 files changed, 196 insertions(+), 8 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 453d236d55b..7c811ebf76f 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -40,18 +40,26 @@ type CopilotSpace struct { // CopilotSpaceResource represents a resource attached to a Copilot Space. type CopilotSpaceResource struct { - ID *int64 `json:"id,omitempty"` - ResourceType *string `json:"resource_type,omitempty"` - Metadata *CopilotSpaceMetadata `json:"metadata,omitempty"` + ID *int64 `json:"id,omitempty"` + ResourceType *string `json:"resource_type,omitempty"` + Metadata *CopilotSpaceMetadata `json:"metadata,omitempty"` + CopilotChatAttachmentID *string `json:"copilot_chat_attachment_id,omitempty"` + CreatedAt *Timestamp `json:"created_at,omitempty"` + UpdatedAt *Timestamp `json:"updated_at,omitempty"` } // CopilotSpaceMetadata represents metadata specific to a Copilot Space resource type. type CopilotSpaceMetadata struct { - RepositoryID *int64 `json:"repository_id,omitempty"` - FilePath *string `json:"file_path,omitempty"` - Text *string `json:"text,omitempty"` - Name *string `json:"name,omitempty"` - Number *int `json:"number,omitempty"` + RepositoryID *int64 `json:"repository_id,omitempty"` + FilePath *string `json:"file_path,omitempty"` + Text *string `json:"text,omitempty"` + Name *string `json:"name,omitempty"` + Number *int `json:"number,omitempty"` + CopilotChatAttachmentID *string `json:"copilot_chat_attachment_id,omitempty"` + MediaType *string `json:"media_type,omitempty"` + URL *string `json:"url,omitempty"` + Height *int `json:"height,omitempty"` + Width *int `json:"width,omitempty"` } // CreateOrganizationCopilotSpaceRequest represents a request to create a Copilot Space. diff --git a/github/copilot_test.go b/github/copilot_test.go index 706c5d0495b..d9f3820a923 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -1260,6 +1260,20 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) { Text: Ptr("Our team follows agile methodology"), }, }, + { + ID: Ptr(int64(125)), + ResourceType: Ptr("media_content"), + CopilotChatAttachmentID: Ptr("attachment-123"), + Metadata: &CopilotSpaceMetadata{ + CopilotChatAttachmentID: Ptr("attachment-123"), + MediaType: Ptr("image/png"), + URL: Ptr("https://test.com/image.png"), + Height: Ptr(640), + Width: Ptr(480), + }, + CreatedAt: refTimestamp(1676450100), + UpdatedAt: refTimestamp(1676450400), + }, }, } @@ -1296,6 +1310,20 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) { "name": "Team Guidelines", "text": "Our team follows agile methodology" } + }, + { + "id": 125, + "resource_type": "media_content", + "copilot_chat_attachment_id": "attachment-123", + "metadata": { + "copilot_chat_attachment_id": "attachment-123", + "media_type": "image/png", + "url": "https://test.com/image.png", + "height": 640, + "width": 480 + }, + "created_at": "2023-02-15T08:35:00Z", + "updated_at": "2023-02-15T08:40:00Z" } ] }`) diff --git a/github/github-accessors.go b/github/github-accessors.go index 41b9cf2db1b..eaf49d278e3 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -10062,6 +10062,14 @@ func (c *CopilotSpace) GetUpdatedAt() Timestamp { return c.UpdatedAt } +// GetCopilotChatAttachmentID returns the CopilotChatAttachmentID field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceMetadata) GetCopilotChatAttachmentID() string { + if c == nil || c.CopilotChatAttachmentID == nil { + return "" + } + return *c.CopilotChatAttachmentID +} + // GetFilePath returns the FilePath field if it's non-nil, zero value otherwise. func (c *CopilotSpaceMetadata) GetFilePath() string { if c == nil || c.FilePath == nil { @@ -10070,6 +10078,22 @@ func (c *CopilotSpaceMetadata) GetFilePath() string { return *c.FilePath } +// GetHeight returns the Height field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceMetadata) GetHeight() int { + if c == nil || c.Height == nil { + return 0 + } + return *c.Height +} + +// GetMediaType returns the MediaType field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceMetadata) GetMediaType() string { + if c == nil || c.MediaType == nil { + return "" + } + return *c.MediaType +} + // GetName returns the Name field if it's non-nil, zero value otherwise. func (c *CopilotSpaceMetadata) GetName() string { if c == nil || c.Name == nil { @@ -10102,6 +10126,38 @@ func (c *CopilotSpaceMetadata) GetText() string { return *c.Text } +// GetURL returns the URL field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceMetadata) GetURL() string { + if c == nil || c.URL == nil { + return "" + } + return *c.URL +} + +// GetWidth returns the Width field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceMetadata) GetWidth() int { + if c == nil || c.Width == nil { + return 0 + } + return *c.Width +} + +// GetCopilotChatAttachmentID returns the CopilotChatAttachmentID field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceResource) GetCopilotChatAttachmentID() string { + if c == nil || c.CopilotChatAttachmentID == nil { + return "" + } + return *c.CopilotChatAttachmentID +} + +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceResource) GetCreatedAt() Timestamp { + if c == nil || c.CreatedAt == nil { + return Timestamp{} + } + return *c.CreatedAt +} + // GetID returns the ID field if it's non-nil, zero value otherwise. func (c *CopilotSpaceResource) GetID() int64 { if c == nil || c.ID == nil { @@ -10126,6 +10182,14 @@ func (c *CopilotSpaceResource) GetResourceType() string { return *c.ResourceType } +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (c *CopilotSpaceResource) GetUpdatedAt() Timestamp { + if c == nil || c.UpdatedAt == nil { + return Timestamp{} + } + return *c.UpdatedAt +} + // GetSpaces returns the Spaces slice if it's non-nil, nil otherwise. func (c *CopilotSpacesList) GetSpaces() []*CopilotSpace { if c == nil || c.Spaces == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index ee283a5a3cc..e74f5ec1b26 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -12745,6 +12745,17 @@ func TestCopilotSpace_GetUpdatedAt(tt *testing.T) { c.GetUpdatedAt() } +func TestCopilotSpaceMetadata_GetCopilotChatAttachmentID(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotSpaceMetadata{CopilotChatAttachmentID: &zeroValue} + c.GetCopilotChatAttachmentID() + c = &CopilotSpaceMetadata{} + c.GetCopilotChatAttachmentID() + c = nil + c.GetCopilotChatAttachmentID() +} + func TestCopilotSpaceMetadata_GetFilePath(tt *testing.T) { tt.Parallel() var zeroValue string @@ -12756,6 +12767,28 @@ func TestCopilotSpaceMetadata_GetFilePath(tt *testing.T) { c.GetFilePath() } +func TestCopilotSpaceMetadata_GetHeight(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &CopilotSpaceMetadata{Height: &zeroValue} + c.GetHeight() + c = &CopilotSpaceMetadata{} + c.GetHeight() + c = nil + c.GetHeight() +} + +func TestCopilotSpaceMetadata_GetMediaType(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotSpaceMetadata{MediaType: &zeroValue} + c.GetMediaType() + c = &CopilotSpaceMetadata{} + c.GetMediaType() + c = nil + c.GetMediaType() +} + func TestCopilotSpaceMetadata_GetName(tt *testing.T) { tt.Parallel() var zeroValue string @@ -12800,6 +12833,50 @@ func TestCopilotSpaceMetadata_GetText(tt *testing.T) { c.GetText() } +func TestCopilotSpaceMetadata_GetURL(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotSpaceMetadata{URL: &zeroValue} + c.GetURL() + c = &CopilotSpaceMetadata{} + c.GetURL() + c = nil + c.GetURL() +} + +func TestCopilotSpaceMetadata_GetWidth(tt *testing.T) { + tt.Parallel() + var zeroValue int + c := &CopilotSpaceMetadata{Width: &zeroValue} + c.GetWidth() + c = &CopilotSpaceMetadata{} + c.GetWidth() + c = nil + c.GetWidth() +} + +func TestCopilotSpaceResource_GetCopilotChatAttachmentID(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CopilotSpaceResource{CopilotChatAttachmentID: &zeroValue} + c.GetCopilotChatAttachmentID() + c = &CopilotSpaceResource{} + c.GetCopilotChatAttachmentID() + c = nil + c.GetCopilotChatAttachmentID() +} + +func TestCopilotSpaceResource_GetCreatedAt(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + c := &CopilotSpaceResource{CreatedAt: &zeroValue} + c.GetCreatedAt() + c = &CopilotSpaceResource{} + c.GetCreatedAt() + c = nil + c.GetCreatedAt() +} + func TestCopilotSpaceResource_GetID(tt *testing.T) { tt.Parallel() var zeroValue int64 @@ -12830,6 +12907,17 @@ func TestCopilotSpaceResource_GetResourceType(tt *testing.T) { c.GetResourceType() } +func TestCopilotSpaceResource_GetUpdatedAt(tt *testing.T) { + tt.Parallel() + var zeroValue Timestamp + c := &CopilotSpaceResource{UpdatedAt: &zeroValue} + c.GetUpdatedAt() + c = &CopilotSpaceResource{} + c.GetUpdatedAt() + c = nil + c.GetUpdatedAt() +} + func TestCopilotSpacesList_GetSpaces(tt *testing.T) { tt.Parallel() zeroValue := []*CopilotSpace{} From 9e6afc7c11c0f3ab8e8b0e91e69219759cd50a19 Mon Sep 17 00:00:00 2001 From: Ackberry Date: Wed, 22 Jul 2026 15:09:26 -0400 Subject: [PATCH 11/14] Use integer Copilot chat attachment IDs --- github/copilot.go | 4 ++-- github/copilot_test.go | 8 ++++---- github/github-accessors.go | 8 ++++---- github/github-accessors_test.go | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 7c811ebf76f..3fefd1071ce 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -43,7 +43,7 @@ type CopilotSpaceResource struct { ID *int64 `json:"id,omitempty"` ResourceType *string `json:"resource_type,omitempty"` Metadata *CopilotSpaceMetadata `json:"metadata,omitempty"` - CopilotChatAttachmentID *string `json:"copilot_chat_attachment_id,omitempty"` + CopilotChatAttachmentID *int64 `json:"copilot_chat_attachment_id,omitempty"` CreatedAt *Timestamp `json:"created_at,omitempty"` UpdatedAt *Timestamp `json:"updated_at,omitempty"` } @@ -55,7 +55,7 @@ type CopilotSpaceMetadata struct { Text *string `json:"text,omitempty"` Name *string `json:"name,omitempty"` Number *int `json:"number,omitempty"` - CopilotChatAttachmentID *string `json:"copilot_chat_attachment_id,omitempty"` + CopilotChatAttachmentID *int64 `json:"copilot_chat_attachment_id,omitempty"` MediaType *string `json:"media_type,omitempty"` URL *string `json:"url,omitempty"` Height *int `json:"height,omitempty"` diff --git a/github/copilot_test.go b/github/copilot_test.go index d9f3820a923..98dd66185b9 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -1263,9 +1263,9 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) { { ID: Ptr(int64(125)), ResourceType: Ptr("media_content"), - CopilotChatAttachmentID: Ptr("attachment-123"), + CopilotChatAttachmentID: Ptr(int64(123)), Metadata: &CopilotSpaceMetadata{ - CopilotChatAttachmentID: Ptr("attachment-123"), + CopilotChatAttachmentID: Ptr(int64(123)), MediaType: Ptr("image/png"), URL: Ptr("https://test.com/image.png"), Height: Ptr(640), @@ -1314,9 +1314,9 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) { { "id": 125, "resource_type": "media_content", - "copilot_chat_attachment_id": "attachment-123", + "copilot_chat_attachment_id": 123, "metadata": { - "copilot_chat_attachment_id": "attachment-123", + "copilot_chat_attachment_id": 123, "media_type": "image/png", "url": "https://test.com/image.png", "height": 640, diff --git a/github/github-accessors.go b/github/github-accessors.go index eaf49d278e3..5089e44b397 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -10063,9 +10063,9 @@ func (c *CopilotSpace) GetUpdatedAt() Timestamp { } // GetCopilotChatAttachmentID returns the CopilotChatAttachmentID field if it's non-nil, zero value otherwise. -func (c *CopilotSpaceMetadata) GetCopilotChatAttachmentID() string { +func (c *CopilotSpaceMetadata) GetCopilotChatAttachmentID() int64 { if c == nil || c.CopilotChatAttachmentID == nil { - return "" + return 0 } return *c.CopilotChatAttachmentID } @@ -10143,9 +10143,9 @@ func (c *CopilotSpaceMetadata) GetWidth() int { } // GetCopilotChatAttachmentID returns the CopilotChatAttachmentID field if it's non-nil, zero value otherwise. -func (c *CopilotSpaceResource) GetCopilotChatAttachmentID() string { +func (c *CopilotSpaceResource) GetCopilotChatAttachmentID() int64 { if c == nil || c.CopilotChatAttachmentID == nil { - return "" + return 0 } return *c.CopilotChatAttachmentID } diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index e74f5ec1b26..a612f4d78f8 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -12747,7 +12747,7 @@ func TestCopilotSpace_GetUpdatedAt(tt *testing.T) { func TestCopilotSpaceMetadata_GetCopilotChatAttachmentID(tt *testing.T) { tt.Parallel() - var zeroValue string + var zeroValue int64 c := &CopilotSpaceMetadata{CopilotChatAttachmentID: &zeroValue} c.GetCopilotChatAttachmentID() c = &CopilotSpaceMetadata{} @@ -12857,7 +12857,7 @@ func TestCopilotSpaceMetadata_GetWidth(tt *testing.T) { func TestCopilotSpaceResource_GetCopilotChatAttachmentID(tt *testing.T) { tt.Parallel() - var zeroValue string + var zeroValue int64 c := &CopilotSpaceResource{CopilotChatAttachmentID: &zeroValue} c.GetCopilotChatAttachmentID() c = &CopilotSpaceResource{} From a4346e9cf57499eff47561b8c14a3c39c200d5fe Mon Sep 17 00:00:00 2001 From: Deep Akbari Date: Wed, 5 Aug 2026 12:39:30 +0530 Subject: [PATCH 12/14] Update github/copilot_test.go Co-authored-by: Dhananjay Mishra --- github/copilot_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/github/copilot_test.go b/github/copilot_test.go index 98dd66185b9..f7c8c5b6166 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -1116,7 +1116,9 @@ func TestCopilotService_ListOrganizationCopilotSpaces(t *testing.T) { }, } - assertNoDiff(t, want, got) + if !cmp.Equal(got, want) { + t.Errorf("Copilot.ListOrganizationCopilotSpaces returned %+v, want %+v", got, want) + } const methodName = "ListOrganizationCopilotSpaces" From e619ca2cbc36ec3fe11700c23b3b409e9de94dfe Mon Sep 17 00:00:00 2001 From: Deep Akbari Date: Wed, 5 Aug 2026 12:39:39 +0530 Subject: [PATCH 13/14] Update github/copilot_test.go Co-authored-by: Dhananjay Mishra --- github/copilot_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/copilot_test.go b/github/copilot_test.go index f7c8c5b6166..8dec8fdd5a5 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -1269,7 +1269,7 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) { Metadata: &CopilotSpaceMetadata{ CopilotChatAttachmentID: Ptr(int64(123)), MediaType: Ptr("image/png"), - URL: Ptr("https://test.com/image.png"), + URL: Ptr("https://example.com/image.png"), Height: Ptr(640), Width: Ptr(480), }, From ed01b3224e6e8014f161e0cc548e696b27f1a39b Mon Sep 17 00:00:00 2001 From: Ackberry Date: Thu, 6 Aug 2026 00:49:15 +0530 Subject: [PATCH 14/14] Split Copilot Space resource attributes --- github/copilot.go | 34 ++++++++++++------ github/copilot_test.go | 34 ++++++++++++------ github/github-accessors.go | 52 +++++++++++++++++++++++++-- github/github-accessors_test.go | 64 +++++++++++++++++++++++++++++++-- 4 files changed, 159 insertions(+), 25 deletions(-) diff --git a/github/copilot.go b/github/copilot.go index 3fefd1071ce..aa80a07170b 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -48,6 +48,20 @@ type CopilotSpaceResource struct { UpdatedAt *Timestamp `json:"updated_at,omitempty"` } +// CreateCopilotSpaceResourceAttributes represents a resource to attach when creating a Copilot Space. +type CreateCopilotSpaceResourceAttributes struct { + ResourceType *string `json:"resource_type,omitempty"` + Metadata *CopilotSpaceMetadata `json:"metadata,omitempty"` +} + +// UpdateCopilotSpaceResourceAttributes represents a resource to attach, update, or remove when updating a Copilot Space. +type UpdateCopilotSpaceResourceAttributes struct { + ID *int64 `json:"id,omitempty"` + ResourceType *string `json:"resource_type,omitempty"` + Metadata *CopilotSpaceMetadata `json:"metadata,omitempty"` + Destroy *bool `json:"_destroy,omitempty"` +} + // CopilotSpaceMetadata represents metadata specific to a Copilot Space resource type. type CopilotSpaceMetadata struct { RepositoryID *int64 `json:"repository_id,omitempty"` @@ -64,20 +78,20 @@ type CopilotSpaceMetadata struct { // CreateOrganizationCopilotSpaceRequest represents a request to create a Copilot Space. type CreateOrganizationCopilotSpaceRequest struct { - Name string `json:"name"` - Description *string `json:"description,omitempty"` - GeneralInstructions *string `json:"general_instructions,omitempty"` - BaseRole *string `json:"base_role,omitempty"` - ResourcesAttributes []*CopilotSpaceResource `json:"resources_attributes,omitempty"` + Name string `json:"name"` + Description *string `json:"description,omitempty"` + GeneralInstructions *string `json:"general_instructions,omitempty"` + BaseRole *string `json:"base_role,omitempty"` + ResourcesAttributes []*CreateCopilotSpaceResourceAttributes `json:"resources_attributes,omitempty"` } // UpdateOrganizationCopilotSpaceRequest represents a request to update a Copilot Space. type UpdateOrganizationCopilotSpaceRequest struct { - Name *string `json:"name,omitempty"` - Description *string `json:"description,omitempty"` - GeneralInstructions *string `json:"general_instructions,omitempty"` - BaseRole *string `json:"base_role,omitempty"` - ResourcesAttributes []*CopilotSpaceResource `json:"resources_attributes,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + GeneralInstructions *string `json:"general_instructions,omitempty"` + BaseRole *string `json:"base_role,omitempty"` + ResourcesAttributes []*UpdateCopilotSpaceResourceAttributes `json:"resources_attributes,omitempty"` } // CopilotSpacesList represents a list of Copilot Spaces. diff --git a/github/copilot_test.go b/github/copilot_test.go index 8dec8fdd5a5..1038e17d56a 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -562,7 +562,9 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) { }, } - assertNoDiff(t, want, got) + if !cmp.Equal(want, got) { + t.Errorf("CopilotService returned %+v, want %+v", got, want) + } const methodName = "ListCopilotSeats" @@ -1194,7 +1196,9 @@ func TestCopilotService_GetOrganizationCopilotSpace(t *testing.T) { BaseRole: "read", } - assertNoDiff(t, want, got) + if !cmp.Equal(want, got) { + t.Errorf("CopilotService returned %+v, want %+v", got, want) + } const methodName = "GetOrganizationCopilotSpace" @@ -1221,7 +1225,7 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) { Description: Ptr("Organization space for team planning"), GeneralInstructions: Ptr("Help the team with planning tasks"), BaseRole: Ptr("no_access"), - ResourcesAttributes: []*CopilotSpaceResource{ + ResourcesAttributes: []*CreateCopilotSpaceResourceAttributes{ { ResourceType: Ptr("free_text"), Metadata: &CopilotSpaceMetadata{ @@ -1273,8 +1277,8 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) { Height: Ptr(640), Width: Ptr(480), }, - CreatedAt: refTimestamp(1676450100), - UpdatedAt: refTimestamp(1676450400), + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, }, }, } @@ -1320,12 +1324,12 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) { "metadata": { "copilot_chat_attachment_id": 123, "media_type": "image/png", - "url": "https://test.com/image.png", + "url": "https://example.com/image.png", "height": 640, "width": 480 }, - "created_at": "2023-02-15T08:35:00Z", - "updated_at": "2023-02-15T08:40:00Z" + "created_at": `+referenceTimeStr+`, + "updated_at": `+referenceTimeStr+` } ] }`) @@ -1337,7 +1341,9 @@ func TestCopilotService_CreateOrganizationCopilotSpace(t *testing.T) { t.Errorf("Copilot.CreateOrganizationCopilotSpace returned error: %v", err) } - assertNoDiff(t, want, got) + if !cmp.Equal(want, got) { + t.Errorf("CopilotService returned %+v, want %+v", got, want) + } const methodName = "CreateOrganizationCopilotSpace" @@ -1364,7 +1370,7 @@ func TestCopilotService_UpdateOrganizationCopilotSpace(t *testing.T) { Description: Ptr("Updated organization space for team planning"), GeneralInstructions: Ptr("Help the team with updated planning tasks"), BaseRole: Ptr("read"), - ResourcesAttributes: []*CopilotSpaceResource{ + ResourcesAttributes: []*UpdateCopilotSpaceResourceAttributes{ { ID: Ptr(int64(101)), ResourceType: Ptr("free_text"), @@ -1373,6 +1379,10 @@ func TestCopilotService_UpdateOrganizationCopilotSpace(t *testing.T) { Text: Ptr("Our team follows agile methodology"), }, }, + { + ID: Ptr(int64(102)), + Destroy: Ptr(true), + }, }, } @@ -1453,7 +1463,9 @@ func TestCopilotService_UpdateOrganizationCopilotSpace(t *testing.T) { t.Errorf("Copilot.UpdateOrganizationCopilotSpace returned error: %v", err) } - assertNoDiff(t, want, got) + if !cmp.Equal(want, got) { + t.Errorf("CopilotService returned %+v, want %+v", got, want) + } const methodName = "UpdateOrganizationCopilotSpace" diff --git a/github/github-accessors.go b/github/github-accessors.go index 5089e44b397..fc6d471b1f8 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -11142,6 +11142,22 @@ func (c *CreateCommitOptions) GetSigner() MessageSigner { return c.Signer } +// GetMetadata returns the Metadata field. +func (c *CreateCopilotSpaceResourceAttributes) GetMetadata() *CopilotSpaceMetadata { + if c == nil { + return nil + } + return c.Metadata +} + +// GetResourceType returns the ResourceType field if it's non-nil, zero value otherwise. +func (c *CreateCopilotSpaceResourceAttributes) GetResourceType() string { + if c == nil || c.ResourceType == nil { + return "" + } + return *c.ResourceType +} + // GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. func (c *CreateCustomOrgRoleRequest) GetBaseRole() string { if c == nil || c.BaseRole == nil { @@ -11631,7 +11647,7 @@ func (c *CreateOrganizationCopilotSpaceRequest) GetName() string { } // GetResourcesAttributes returns the ResourcesAttributes slice if it's non-nil, nil otherwise. -func (c *CreateOrganizationCopilotSpaceRequest) GetResourcesAttributes() []*CopilotSpaceResource { +func (c *CreateOrganizationCopilotSpaceRequest) GetResourcesAttributes() []*CreateCopilotSpaceResourceAttributes { if c == nil || c.ResourcesAttributes == nil { return nil } @@ -43382,6 +43398,38 @@ func (u *UpdateConnectedExternalGroupRequest) GetGroupID() int64 { return u.GroupID } +// GetDestroy returns the Destroy field if it's non-nil, zero value otherwise. +func (u *UpdateCopilotSpaceResourceAttributes) GetDestroy() bool { + if u == nil || u.Destroy == nil { + return false + } + return *u.Destroy +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (u *UpdateCopilotSpaceResourceAttributes) GetID() int64 { + if u == nil || u.ID == nil { + return 0 + } + return *u.ID +} + +// GetMetadata returns the Metadata field. +func (u *UpdateCopilotSpaceResourceAttributes) GetMetadata() *CopilotSpaceMetadata { + if u == nil { + return nil + } + return u.Metadata +} + +// GetResourceType returns the ResourceType field if it's non-nil, zero value otherwise. +func (u *UpdateCopilotSpaceResourceAttributes) GetResourceType() string { + if u == nil || u.ResourceType == nil { + return "" + } + return *u.ResourceType +} + // GetBaseRole returns the BaseRole field if it's non-nil, zero value otherwise. func (u *UpdateCustomOrgRoleRequest) GetBaseRole() string { if u == nil || u.BaseRole == nil { @@ -43807,7 +43855,7 @@ func (u *UpdateOrganizationCopilotSpaceRequest) GetName() string { } // GetResourcesAttributes returns the ResourcesAttributes slice if it's non-nil, nil otherwise. -func (u *UpdateOrganizationCopilotSpaceRequest) GetResourcesAttributes() []*CopilotSpaceResource { +func (u *UpdateOrganizationCopilotSpaceRequest) GetResourcesAttributes() []*UpdateCopilotSpaceResourceAttributes { if u == nil || u.ResourcesAttributes == nil { return nil } diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index a612f4d78f8..ddaf8d2627c 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -14119,6 +14119,25 @@ func TestCreateCommitOptions_GetSigner(tt *testing.T) { c.GetSigner() } +func TestCreateCopilotSpaceResourceAttributes_GetMetadata(tt *testing.T) { + tt.Parallel() + c := &CreateCopilotSpaceResourceAttributes{} + c.GetMetadata() + c = nil + c.GetMetadata() +} + +func TestCreateCopilotSpaceResourceAttributes_GetResourceType(tt *testing.T) { + tt.Parallel() + var zeroValue string + c := &CreateCopilotSpaceResourceAttributes{ResourceType: &zeroValue} + c.GetResourceType() + c = &CreateCopilotSpaceResourceAttributes{} + c.GetResourceType() + c = nil + c.GetResourceType() +} + func TestCreateCustomOrgRoleRequest_GetBaseRole(tt *testing.T) { tt.Parallel() var zeroValue string @@ -14732,7 +14751,7 @@ func TestCreateOrganizationCopilotSpaceRequest_GetName(tt *testing.T) { func TestCreateOrganizationCopilotSpaceRequest_GetResourcesAttributes(tt *testing.T) { tt.Parallel() - zeroValue := []*CopilotSpaceResource{} + zeroValue := []*CreateCopilotSpaceResourceAttributes{} c := &CreateOrganizationCopilotSpaceRequest{ResourcesAttributes: zeroValue} c.GetResourcesAttributes() c = &CreateOrganizationCopilotSpaceRequest{} @@ -54303,6 +54322,47 @@ func TestUpdateConnectedExternalGroupRequest_GetGroupID(tt *testing.T) { u.GetGroupID() } +func TestUpdateCopilotSpaceResourceAttributes_GetDestroy(tt *testing.T) { + tt.Parallel() + var zeroValue bool + u := &UpdateCopilotSpaceResourceAttributes{Destroy: &zeroValue} + u.GetDestroy() + u = &UpdateCopilotSpaceResourceAttributes{} + u.GetDestroy() + u = nil + u.GetDestroy() +} + +func TestUpdateCopilotSpaceResourceAttributes_GetID(tt *testing.T) { + tt.Parallel() + var zeroValue int64 + u := &UpdateCopilotSpaceResourceAttributes{ID: &zeroValue} + u.GetID() + u = &UpdateCopilotSpaceResourceAttributes{} + u.GetID() + u = nil + u.GetID() +} + +func TestUpdateCopilotSpaceResourceAttributes_GetMetadata(tt *testing.T) { + tt.Parallel() + u := &UpdateCopilotSpaceResourceAttributes{} + u.GetMetadata() + u = nil + u.GetMetadata() +} + +func TestUpdateCopilotSpaceResourceAttributes_GetResourceType(tt *testing.T) { + tt.Parallel() + var zeroValue string + u := &UpdateCopilotSpaceResourceAttributes{ResourceType: &zeroValue} + u.GetResourceType() + u = &UpdateCopilotSpaceResourceAttributes{} + u.GetResourceType() + u = nil + u.GetResourceType() +} + func TestUpdateCustomOrgRoleRequest_GetBaseRole(tt *testing.T) { tt.Parallel() var zeroValue string @@ -54879,7 +54939,7 @@ func TestUpdateOrganizationCopilotSpaceRequest_GetName(tt *testing.T) { func TestUpdateOrganizationCopilotSpaceRequest_GetResourcesAttributes(tt *testing.T) { tt.Parallel() - zeroValue := []*CopilotSpaceResource{} + zeroValue := []*UpdateCopilotSpaceResourceAttributes{} u := &UpdateOrganizationCopilotSpaceRequest{ResourcesAttributes: zeroValue} u.GetResourcesAttributes() u = &UpdateOrganizationCopilotSpaceRequest{}