Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
6dbc3f4
feat: add Copilot Space struct and Copilot Spaces List struct
Ackberry Jul 11, 2026
c2207db
Add ListOrganizationCopilotSpaces
Ackberry Jul 11, 2026
bfeaa03
Add GetOrganizationCopilotSpace
Ackberry Jul 11, 2026
377b890
Add CreateOrganizationCopilotSpace
Ackberry Jul 13, 2026
960c32f
Add UpdateOrganizationCopilotSpace
Ackberry Jul 13, 2026
80a149b
Add DeleteOrganizationCopilotSpace
Ackberry Jul 13, 2026
95cab7f
Regenerate Copilot Spaces generated files
Ackberry Jul 13, 2026
b468faa
Use values for required Copilot Space fields
Ackberry Jul 13, 2026
412faa6
Merge branch 'master' into feature/add-copilot-spaces
Ackberry Jul 17, 2026
9151976
Split Copilot Spaces request structs
Ackberry Jul 18, 2026
37da7af
Merge branch 'master' into feature/add-copilot-spaces
Ackberry Jul 18, 2026
dadb3eb
Merge branch 'master' into feature/add-copilot-spaces
Ackberry Jul 20, 2026
7201cb6
Add Copilot Space resource fields
Ackberry Jul 21, 2026
2c582e7
Merge master into Copilot Spaces branch
Ackberry Jul 21, 2026
b20d422
Merge branch 'master' into feature/add-copilot-spaces
Ackberry Jul 22, 2026
75594e3
Use integer Copilot chat attachment IDs
Ackberry Jul 22, 2026
ea0f9cc
Merge branch 'master' into feature/add-copilot-spaces
Ackberry Jul 24, 2026
f721449
Merge branch 'master' into feature/add-copilot-spaces
Ackberry Jul 28, 2026
78fd3ea
Merge branch 'master' into feature/add-copilot-spaces
Ackberry Jul 31, 2026
6b61f9d
Merge branch 'master' into feature/add-copilot-spaces
Ackberry Aug 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 172 additions & 0 deletions github/copilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,178 @@ 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"`
Number int `json:"number"`
Name string `json:"name"`
Description *string `json:"description,omitempty"`
GeneralInstructions *string `json:"general_instructions,omitempty"`
Owner User `json:"owner"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"owner" can be any of "Simple User" or "Organization Simple" according to response schema.

          "owner": {
            "anyOf": [
              {
                "title": "Simple User",
                "description": "A GitHub user.",
                "type": "object",
                "properties": {
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "email": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "login": {
                    "type": "string"
                  },
                  "id": {
                    "type": "integer",
                    "format": "int64"
                  },
                  "node_id": {
                    "type": "string"
                  },
                  "avatar_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "gravatar_id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "html_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "followers_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "following_url": {
                    "type": "string"
                  },
                  "gists_url": {
                    "type": "string"
                  },
                  "starred_url": {
                    "type": "string"
                  },
                  "subscriptions_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "organizations_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "repos_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "events_url": {
                    "type": "string"
                  },
                  "received_events_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "type": {
                    "type": "string"
                  },
                  "site_admin": {
                    "type": "boolean"
                  },
                  "starred_at": {
                    "type": "string"
                  },
                  "user_view_type": {
                    "type": "string"
                  }
                },
                "required": [
                  "avatar_url",
                  "events_url",
                  "followers_url",
                  "following_url",
                  "gists_url",
                  "gravatar_id",
                  "html_url",
                  "id",
                  "node_id",
                  "login",
                  "organizations_url",
                  "received_events_url",
                  "repos_url",
                  "site_admin",
                  "starred_url",
                  "subscriptions_url",
                  "type",
                  "url"
                ]
              },
              {
                "title": "Organization Simple",
                "description": "A GitHub organization.",
                "type": "object",
                "properties": {
                  "login": {
                    "type": "string"
                  },
                  "id": {
                    "type": "integer"
                  },
                  "node_id": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "repos_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "events_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "hooks_url": {
                    "type": "string"
                  },
                  "issues_url": {
                    "type": "string"
                  },
                  "members_url": {
                    "type": "string"
                  },
                  "public_members_url": {
                    "type": "string"
                  },
                  "avatar_url": {
                    "type": "string"
                  },
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "login",
                  "url",
                  "id",
                  "node_id",
                  "repos_url",
                  "events_url",
                  "hooks_url",
                  "issues_url",
                  "members_url",
                  "public_members_url",
                  "avatar_url",
                  "description"
                ]
              }
            ],

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"`
}

// 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"`
CopilotChatAttachmentID *int64 `json:"copilot_chat_attachment_id,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
}
Comment thread
Ackberry marked this conversation as resolved.

// 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"`
CopilotChatAttachmentID *int64 `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"`
}
Comment thread
Ackberry marked this conversation as resolved.

// 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"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CopilotSpaceResource doesn't match the schema.

type CopilotSpaceResource struct {
	ID                      *int64                `json:"id,omitempty"`
	ResourceType            *string               `json:"resource_type,omitempty"`
	Metadata                *CopilotSpaceMetadata `json:"metadata,omitempty"`
	CopilotChatAttachmentID *int64                `json:"copilot_chat_attachment_id,omitempty"`
	CreatedAt               *Timestamp            `json:"created_at,omitempty"`
	UpdatedAt               *Timestamp            `json:"updated_at,omitempty"`
}

Properties of resources_attributes:

Image

Properties of metadata:

Image

}

// 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"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as comment

}

// CopilotSpacesList represents a list of Copilot Spaces.
type CopilotSpacesList struct {
Spaces []*CopilotSpace `json:"spaces"`
}

// ListOrganizationCopilotSpaces lists Copilot Spaces for an organization.
//
// 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) {
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
}

// GetOrganizationCopilotSpace gets a Copilot Space for an organization.
//
// 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) {
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
}

// CreateOrganizationCopilotSpace creates a Copilot Space for an organization.
//
// 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 CreateOrganizationCopilotSpaceRequest) (*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
}

// UpdateOrganizationCopilotSpace updates a Copilot Space for an organization.
//
// 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 UpdateOrganizationCopilotSpaceRequest) (*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
}

// DeleteOrganizationCopilotSpace deletes a Copilot Space for an organization.
//
// 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) {
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"`
Expand Down
Loading
Loading