Documentation ¶
Index ¶
- Constants
- Variables
- type API
- func (a *API) CreateCodespace(ctx context.Context, params *CreateCodespaceParams) (*Codespace, error)
- func (a *API) DeleteCodespace(ctx context.Context, codespaceName string, orgName string, userName string) error
- func (a *API) EditCodespace(ctx context.Context, codespaceName string, params *EditCodespaceParams) (*Codespace, error)
- func (a *API) GetCodespace(ctx context.Context, codespaceName string, includeConnection bool) (*Codespace, error)
- func (a *API) GetCodespaceBillableOwner(ctx context.Context, nwo string) (*User, error)
- func (a *API) GetCodespaceRepoSuggestions(ctx context.Context, partialSearch string, parameters RepoSearchParameters) ([]string, error)
- func (a *API) GetCodespaceRepositoryContents(ctx context.Context, codespace *Codespace, path string) ([]byte, error)
- func (a *API) GetCodespacesMachines(ctx context.Context, repoID int, branch, location string, ...) ([]*Machine, error)
- func (a *API) GetCodespacesPermissionsCheck(ctx context.Context, repoID int, branch string, devcontainerPath string) (bool, error)
- func (a *API) GetOrgMemberCodespace(ctx context.Context, orgName string, userName string, codespaceName string) (*Codespace, error)
- func (a *API) GetRepository(ctx context.Context, nwo string) (*Repository, error)
- func (a *API) GetUser(ctx context.Context) (*User, error)
- func (a *API) HTTPClient() (*http.Client, error)
- func (a *API) ListCodespaces(ctx context.Context, opts ListCodespacesOptions) (codespaces []*Codespace, err error)
- func (a *API) ListDevContainers(ctx context.Context, repoID int, branch string, limit int) (devcontainers []DevContainerEntry, err error)
- func (a *API) ServerURL() string
- func (a *API) StartCodespace(ctx context.Context, codespaceName string) error
- func (a *API) StopCodespace(ctx context.Context, codespaceName string, orgName string, userName string) error
- type AcceptPermissionsRequiredError
- type Codespace
- type CodespaceConnection
- type CodespaceGitStatus
- type CodespaceMachine
- type CreateCodespaceParams
- type DevContainerEntry
- type EditCodespaceParams
- type ListCodespacesOptions
- type Machine
- type RepoSearchParameters
- type Repository
- type RepositoryOwner
- type RuntimeConstraints
- type TunnelProperties
- type User
Constants ¶
const ( VSCSTargetLocal = "local" VSCSTargetDevelopment = "development" VSCSTargetPPE = "ppe" VSCSTargetProduction = "production" )
const ( // CodespaceStateAvailable is the state for a running codespace environment. CodespaceStateAvailable = "Available" // CodespaceStateShutdown is the state for a shutdown codespace environment. CodespaceStateShutdown = "Shutdown" // CodespaceStateStarting is the state for a starting codespace environment. CodespaceStateStarting = "Starting" // CodespaceStateRebuilding is the state for a rebuilding codespace environment. CodespaceStateRebuilding = "Rebuilding" )
Variables ¶
var ListCodespaceFields = []string{
"displayName",
"name",
"owner",
"repository",
"state",
"gitStatus",
"createdAt",
"lastUsedAt",
"machineName",
"vscsTarget",
}
ListCodespaceFields is the list of exportable fields for a codespace when using the `gh cs list` command.
var ViewCodespaceFields = []string{
"name",
"displayName",
"state",
"owner",
"billableOwner",
"location",
"repository",
"gitStatus",
"devcontainerPath",
"machineName",
"machineDisplayName",
"prebuild",
"createdAt",
"lastUsedAt",
"idleTimeoutMinutes",
"retentionPeriodDays",
"retentionExpiresAt",
"recentFolders",
"vscsTarget",
"environmentId",
}
ViewCodespaceFields is the list of exportable fields for a codespace when using the `gh cs view` command.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is the interface to the codespace service.
func New ¶
New creates a new API client connecting to the configured endpoints with the HTTP client.
func (*API) CreateCodespace ¶
func (a *API) CreateCodespace(ctx context.Context, params *CreateCodespaceParams) (*Codespace, error)
CreateCodespace creates a codespace with the given parameters and returns a non-nil error if it fails to create.
func (*API) DeleteCodespace ¶
func (a *API) DeleteCodespace(ctx context.Context, codespaceName string, orgName string, userName string) error
DeleteCodespace deletes the given codespace.
func (*API) EditCodespace ¶ added in v2.6.0
func (*API) GetCodespace ¶
func (a *API) GetCodespace(ctx context.Context, codespaceName string, includeConnection bool) (*Codespace, error)
GetCodespace returns the user codespace based on the provided name. If the codespace is not found, an error is returned. If includeConnection is true, it will return the connection information for the codespace.
func (*API) GetCodespaceBillableOwner ¶ added in v2.13.0
GetCodespaceBillableOwner returns the billable owner and expected default values for codespaces created by the user for a given repository.
func (*API) GetCodespaceRepoSuggestions ¶ added in v2.5.0
func (a *API) GetCodespaceRepoSuggestions(ctx context.Context, partialSearch string, parameters RepoSearchParameters) ([]string, error)
GetCodespaceRepoSuggestions searches for and returns repo names based on the provided search text.
func (*API) GetCodespaceRepositoryContents ¶
func (*API) GetCodespacesMachines ¶
func (a *API) GetCodespacesMachines(ctx context.Context, repoID int, branch, location string, devcontainerPath string) ([]*Machine, error)
GetCodespacesMachines returns the codespaces machines for the given repo, branch and location.
func (*API) GetCodespacesPermissionsCheck ¶ added in v2.37.0
func (a *API) GetCodespacesPermissionsCheck(ctx context.Context, repoID int, branch string, devcontainerPath string) (bool, error)
GetCodespacesPermissionsCheck returns a bool indicating whether the user has accepted permissions for the given repo and devcontainer path.
func (*API) GetOrgMemberCodespace ¶ added in v2.13.0
func (*API) GetRepository ¶
GetRepository returns the repository associated with the given owner and name.
func (*API) HTTPClient ¶ added in v2.36.0
HTTPClient returns the HTTP client used to make requests to the API.
func (*API) ListCodespaces ¶
func (a *API) ListCodespaces(ctx context.Context, opts ListCodespacesOptions) (codespaces []*Codespace, err error)
ListCodespaces returns a list of codespaces for the user. Pass a negative limit to request all pages from the API until all codespaces have been fetched.
func (*API) ListDevContainers ¶ added in v2.9.0
func (a *API) ListDevContainers(ctx context.Context, repoID int, branch string, limit int) (devcontainers []DevContainerEntry, err error)
ListDevContainers returns a list of valid devcontainer.json files for the repo. Pass a negative limit to request all pages from the API until all devcontainer.json files have been fetched.
func (*API) ServerURL ¶ added in v2.33.0
ServerURL returns the server url (not the API url), such as https://github.com
func (*API) StartCodespace ¶
StartCodespace starts a codespace for the user. If the codespace is already running, the returned error from the API is ignored.
type AcceptPermissionsRequiredError ¶ added in v2.5.2
type AcceptPermissionsRequiredError struct { Message string `json:"message"` AllowPermissionsURL string `json:"allow_permissions_url"` }
func (AcceptPermissionsRequiredError) Error ¶ added in v2.5.2
func (e AcceptPermissionsRequiredError) Error() string
type Codespace ¶
type Codespace struct { Name string `json:"name"` CreatedAt string `json:"created_at"` DisplayName string `json:"display_name"` LastUsedAt string `json:"last_used_at"` Owner User `json:"owner"` Repository Repository `json:"repository"` State string `json:"state"` GitStatus CodespaceGitStatus `json:"git_status"` Connection CodespaceConnection `json:"connection"` Machine CodespaceMachine `json:"machine"` RuntimeConstraints RuntimeConstraints `json:"runtime_constraints"` VSCSTarget string `json:"vscs_target"` PendingOperation bool `json:"pending_operation"` PendingOperationDisabledReason string `json:"pending_operation_disabled_reason"` IdleTimeoutNotice string `json:"idle_timeout_notice"` WebURL string `json:"web_url"` DevContainerPath string `json:"devcontainer_path"` Prebuild bool `json:"prebuild"` Location string `json:"location"` IdleTimeoutMinutes int `json:"idle_timeout_minutes"` RetentionPeriodMinutes int `json:"retention_period_minutes"` RetentionExpiresAt string `json:"retention_expires_at"` RecentFolders []string `json:"recent_folders"` BillableOwner User `json:"billable_owner"` EnvironmentId string `json:"environment_id"` }
Codespace represents a codespace. You can see more about the fields in this type in the codespaces api docs: https://docs.github.com/en/rest/reference/codespaces
func (*Codespace) ExportData ¶ added in v2.2.0
type CodespaceConnection ¶
type CodespaceConnection struct {
TunnelProperties TunnelProperties `json:"tunnelProperties"`
}
type CodespaceGitStatus ¶ added in v2.2.0
type CodespaceMachine ¶ added in v2.6.0
type CreateCodespaceParams ¶
type CreateCodespaceParams struct { RepositoryID int IdleTimeoutMinutes int RetentionPeriodMinutes *int Branch string Machine string Location string DevContainerPath string VSCSTarget string VSCSTargetURL string PermissionsOptOut bool DisplayName string }
CreateCodespaceParams are the required parameters for provisioning a Codespace.
type DevContainerEntry ¶ added in v2.9.0
type EditCodespaceParams ¶ added in v2.6.0
type ListCodespacesOptions ¶ added in v2.14.0
type RepoSearchParameters ¶ added in v2.5.0
type RepoSearchParameters struct { // The maximum number of repos to return. At most 100 repos are returned even if this value is greater than 100. MaxRepos int // The sort order for returned repos. Possible values are 'stars', 'forks', 'help-wanted-issues', or 'updated'. If empty the API's default ordering is used. Sort string }
RepoSearchParameters are the optional parameters for searching for repositories.
type Repository ¶
type Repository struct { ID int `json:"id"` FullName string `json:"full_name"` DefaultBranch string `json:"default_branch"` Owner RepositoryOwner `json:"owner"` }
Repository represents a GitHub repository.
type RepositoryOwner ¶ added in v2.29.0
RepositoryOwner represents owner of a repository
type RuntimeConstraints ¶ added in v2.36.0
type RuntimeConstraints struct {
AllowedPortPrivacySettings []string `json:"allowed_port_privacy_settings"`
}