// Copyright 2023 The go-github AUTHORS. All rights reserved.//// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package githubimport ()// CodespacesService handles communication with the Codespaces related// methods of the GitHub API.//// GitHub API docs: https://docs.github.com/rest/codespaces/typeCodespacesServiceservice// Codespace represents a codespace.//// GitHub API docs: https://docs.github.com/rest/codespacestypeCodespacestruct { ID *int64`json:"id,omitempty"` Name *string`json:"name,omitempty"` DisplayName *string`json:"display_name,omitempty"` EnvironmentID *string`json:"environment_id,omitempty"` Owner *User`json:"owner,omitempty"` BillableOwner *User`json:"billable_owner,omitempty"` Repository *Repository`json:"repository,omitempty"` Machine *CodespacesMachine`json:"machine,omitempty"` DevcontainerPath *string`json:"devcontainer_path,omitempty"` Prebuild *bool`json:"prebuild,omitempty"` CreatedAt *Timestamp`json:"created_at,omitempty"` UpdatedAt *Timestamp`json:"updated_at,omitempty"` LastUsedAt *Timestamp`json:"last_used_at,omitempty"` State *string`json:"state,omitempty"` URL *string`json:"url,omitempty"` GitStatus *CodespacesGitStatus`json:"git_status,omitempty"` Location *string`json:"location,omitempty"` IdleTimeoutMinutes *int`json:"idle_timeout_minutes,omitempty"` WebURL *string`json:"web_url,omitempty"` MachinesURL *string`json:"machines_url,omitempty"` StartURL *string`json:"start_url,omitempty"` StopURL *string`json:"stop_url,omitempty"` PullsURL *string`json:"pulls_url,omitempty"` RecentFolders []string`json:"recent_folders,omitempty"` RuntimeConstraints *CodespacesRuntimeConstraints`json:"runtime_constraints,omitempty"` PendingOperation *bool`json:"pending_operation,omitempty"` PendingOperationDisabledReason *string`json:"pending_operation_disabled_reason,omitempty"` IdleTimeoutNotice *string`json:"idle_timeout_notice,omitempty"` RetentionPeriodMinutes *int`json:"retention_period_minutes,omitempty"` RetentionExpiresAt *Timestamp`json:"retention_expires_at,omitempty"` LastKnownStopNotice *string`json:"last_known_stop_notice,omitempty"`}// CodespacesGitStatus represents the git status of a codespace.typeCodespacesGitStatusstruct { Ahead *int`json:"ahead,omitempty"` Behind *int`json:"behind,omitempty"` HasUnpushedChanges *bool`json:"has_unpushed_changes,omitempty"` HasUncommittedChanges *bool`json:"has_uncommitted_changes,omitempty"` Ref *string`json:"ref,omitempty"`}// CodespacesMachine represents the machine type of a codespace.typeCodespacesMachinestruct { Name *string`json:"name,omitempty"` DisplayName *string`json:"display_name,omitempty"` OperatingSystem *string`json:"operating_system,omitempty"` StorageInBytes *int64`json:"storage_in_bytes,omitempty"` MemoryInBytes *int64`json:"memory_in_bytes,omitempty"` CPUs *int`json:"cpus,omitempty"` PrebuildAvailability *string`json:"prebuild_availability,omitempty"`}// CodespacesRuntimeConstraints represents the runtime constraints of a codespace.typeCodespacesRuntimeConstraintsstruct { AllowedPortPrivacySettings []string`json:"allowed_port_privacy_settings,omitempty"`}// ListCodespaces represents the response from the list codespaces endpoints.typeListCodespacesstruct { TotalCount *int`json:"total_count,omitempty"` Codespaces []*Codespace`json:"codespaces"`}// ListInRepo lists codespaces for a user in a repository.//// Lists the codespaces associated with a specified repository and the authenticated user.// You must authenticate using an access token with the codespace scope to use this endpoint.// GitHub Apps must have read access to the codespaces repository permission to use this endpoint.//// GitHub API docs: https://docs.github.com/rest/codespaces/codespaces#list-codespaces-in-a-repository-for-the-authenticated-user////meta:operation GET /repos/{owner}/{repo}/codespacesfunc ( *CodespacesService) ( context.Context, , string, *ListOptions) (*ListCodespaces, *Response, error) { := fmt.Sprintf("repos/%v/%v/codespaces", , ) , := addOptions(, )if != nil {returnnil, nil, } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, }var *ListCodespaces , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// ListCodespacesOptions represents the options for listing codespaces for a user.typeListCodespacesOptionsstruct {ListOptions RepositoryID int64`url:"repository_id,omitempty"`}// List lists codespaces for an authenticated user.//// Lists the authenticated user's codespaces.// You must authenticate using an access token with the codespace scope to use this endpoint.// GitHub Apps must have read access to the codespaces repository permission to use this endpoint.//// GitHub API docs: https://docs.github.com/rest/codespaces/codespaces#list-codespaces-for-the-authenticated-user////meta:operation GET /user/codespacesfunc ( *CodespacesService) ( context.Context, *ListCodespacesOptions) (*ListCodespaces, *Response, error) { := "user/codespaces" , := addOptions(, )if != nil {returnnil, nil, } , := .client.NewRequest("GET", , nil)if != nil {returnnil, nil, }var *ListCodespaces , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// CreateCodespaceOptions represents options for the creation of a codespace in a repository.typeCreateCodespaceOptionsstruct { Ref *string`json:"ref,omitempty"`// Geo represents the geographic area for this codespace. // If not specified, the value is assigned by IP. // This property replaces location, which is being deprecated. // Geo can be one of: `EuropeWest`, `SoutheastAsia`, `UsEast`, `UsWest`. Geo *string`json:"geo,omitempty"` ClientIP *string`json:"client_ip,omitempty"` Machine *string`json:"machine,omitempty"` DevcontainerPath *string`json:"devcontainer_path,omitempty"` MultiRepoPermissionsOptOut *bool`json:"multi_repo_permissions_opt_out,omitempty"` WorkingDirectory *string`json:"working_directory,omitempty"` IdleTimeoutMinutes *int`json:"idle_timeout_minutes,omitempty"` DisplayName *string`json:"display_name,omitempty"`// RetentionPeriodMinutes represents the duration in minutes after codespace has gone idle in which it will be deleted. // Must be integer minutes between 0 and 43200 (30 days). RetentionPeriodMinutes *int`json:"retention_period_minutes,omitempty"`}// CreateInRepo creates a codespace in a repository.//// Creates a codespace owned by the authenticated user in the specified repository.// You must authenticate using an access token with the codespace scope to use this endpoint.// GitHub Apps must have write access to the codespaces repository permission to use this endpoint.//// GitHub API docs: https://docs.github.com/rest/codespaces/codespaces#create-a-codespace-in-a-repository////meta:operation POST /repos/{owner}/{repo}/codespacesfunc ( *CodespacesService) ( context.Context, , string, *CreateCodespaceOptions) (*Codespace, *Response, error) { := fmt.Sprintf("repos/%v/%v/codespaces", , ) , := .client.NewRequest("POST", , )if != nil {returnnil, nil, }var *Codespace , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// Start starts a codespace.//// You must authenticate using an access token with the codespace scope to use this endpoint.// GitHub Apps must have write access to the codespaces_lifecycle_admin repository permission to use this endpoint.//// GitHub API docs: https://docs.github.com/rest/codespaces/codespaces#start-a-codespace-for-the-authenticated-user////meta:operation POST /user/codespaces/{codespace_name}/startfunc ( *CodespacesService) ( context.Context, string) (*Codespace, *Response, error) { := fmt.Sprintf("user/codespaces/%v/start", ) , := .client.NewRequest("POST", , nil)if != nil {returnnil, nil, }var *Codespace , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// Stop stops a codespace.//// You must authenticate using an access token with the codespace scope to use this endpoint.// GitHub Apps must have write access to the codespaces_lifecycle_admin repository permission to use this endpoint.//// GitHub API docs: https://docs.github.com/rest/codespaces/codespaces#stop-a-codespace-for-the-authenticated-user////meta:operation POST /user/codespaces/{codespace_name}/stopfunc ( *CodespacesService) ( context.Context, string) (*Codespace, *Response, error) { := fmt.Sprintf("user/codespaces/%v/stop", ) , := .client.NewRequest("POST", , nil)if != nil {returnnil, nil, }var *Codespace , := .client.Do(, , &)if != nil {returnnil, , }return , , nil}// Delete deletes a codespace.//// You must authenticate using an access token with the codespace scope to use this endpoint.// GitHub Apps must have write access to the codespaces repository permission to use this endpoint.//// GitHub API docs: https://docs.github.com/rest/codespaces/codespaces#delete-a-codespace-for-the-authenticated-user////meta:operation DELETE /user/codespaces/{codespace_name}func ( *CodespacesService) ( context.Context, string) (*Response, error) { := fmt.Sprintf("user/codespaces/%v", ) , := .client.NewRequest("DELETE", , nil)if != nil {returnnil, }return .client.Do(, , nil)}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.