From 6dbc3f4ec0a62509ab49552654de33f46d50abe6 Mon Sep 17 00:00:00 2001 From: Ackberry Date: Sat, 11 Jul 2026 15:04:34 -0400 Subject: [PATCH 01/11] 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 c2207db4bf6aafb457e3ba227c045cf9d313a7b0 Mon Sep 17 00:00:00 2001 From: Ackberry Date: Sat, 11 Jul 2026 15:53:06 -0400 Subject: [PATCH 02/11] 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 bfeaa035fcc68bbdfab1cb31fd8031983556d32d Mon Sep 17 00:00:00 2001 From: Ackberry Date: Sat, 11 Jul 2026 16:03:47 -0400 Subject: [PATCH 03/11] 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 377b890ab4f35a507ef2ccbb2cec8327533ebd2f Mon Sep 17 00:00:00 2001 From: Ackberry Date: Mon, 13 Jul 2026 01:35:48 -0400 Subject: [PATCH 04/11] 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 960c32f12d328ddf87b833b99b7a9f5ca9863547 Mon Sep 17 00:00:00 2001 From: Ackberry Date: Mon, 13 Jul 2026 01:52:13 -0400 Subject: [PATCH 05/11] 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 80a149ba2fdd4a0edf0ea64049fb146517b2e388 Mon Sep 17 00:00:00 2001 From: Ackberry Date: Mon, 13 Jul 2026 01:57:53 -0400 Subject: [PATCH 06/11] 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 95cab7fccd9c9bfe96bdd44c1356d73d7bcf578e Mon Sep 17 00:00:00 2001 From: Ackberry Date: Mon, 13 Jul 2026 11:56:42 -0400 Subject: [PATCH 07/11] 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 630f6f82b94..5b968f950b4 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -9926,6 +9926,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 a3e50ffc4d1..53a3c91b774 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -12597,6 +12597,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 dc2841ba541..9f5753417e3 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 233c57b6c1a..cf67a981115 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 b468faa89fcfa7887acb92dad2e0e5d58ddb6843 Mon Sep 17 00:00:00 2001 From: Ackberry Date: Mon, 13 Jul 2026 12:44:57 -0400 Subject: [PATCH 08/11] 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 5b968f950b4..339dfef7c74 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -9926,34 +9926,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 } @@ -9974,42 +9974,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 } @@ -10022,12 +10022,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 53a3c91b774..5f6c424574a 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -12599,10 +12599,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() @@ -12610,10 +12607,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() @@ -12621,10 +12615,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() @@ -12662,10 +12653,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() @@ -12673,10 +12661,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() @@ -12684,10 +12669,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() @@ -12695,10 +12677,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() @@ -12725,10 +12704,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 91519769c207b7ace3f40c61270720bd1ed0ccb8 Mon Sep 17 00:00:00 2001 From: Ackberry Date: Sat, 18 Jul 2026 16:08:41 -0400 Subject: [PATCH 09/11] 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 8bdcbb7ede7..b15f175bb4b 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -10030,44 +10030,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. @@ -10078,10 +10078,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 } @@ -11326,6 +11326,46 @@ func (c *CreateJITConfigRequest) GetWorkFolder() string { return *c.WorkFolder } +// 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 { @@ -42710,6 +42750,46 @@ func (u *UpdateHostedRunnerRequest) GetSize() string { return *u.Size } +// 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 420371f67ab..71de8858290 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -12710,59 +12710,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) { @@ -12778,10 +12778,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() @@ -14348,6 +14345,58 @@ func TestCreateJITConfigRequest_GetWorkFolder(tt *testing.T) { c.GetWorkFolder() } +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 @@ -53547,6 +53596,61 @@ func TestUpdateHostedRunnerRequest_GetSize(tt *testing.T) { u.GetSize() } +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 7201cb64747a0717a6b04ed13626b8eec46849ac Mon Sep 17 00:00:00 2001 From: Ackberry Date: Tue, 21 Jul 2026 16:23:48 -0400 Subject: [PATCH 10/11] 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 e0bacbb07cc..5b14a108432 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -10070,6 +10070,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 { @@ -10078,6 +10086,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 { @@ -10110,6 +10134,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 { @@ -10134,6 +10190,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 856e6ccfd74..c3ab23df7ca 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -12762,6 +12762,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 @@ -12773,6 +12784,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 @@ -12817,6 +12850,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 @@ -12847,6 +12924,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 75594e3dc699c02a61d96d57d6a7bdff0631f573 Mon Sep 17 00:00:00 2001 From: Ackberry Date: Wed, 22 Jul 2026 15:09:26 -0400 Subject: [PATCH 11/11] 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 b62be859821..3731e4a60f8 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -10047,9 +10047,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 } @@ -10127,9 +10127,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 a202a42b4b5..8eb47d0ca7a 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -12731,7 +12731,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{} @@ -12841,7 +12841,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{}