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) 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) 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) 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 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 CodespaceFields = []string{
"displayName",
"name",
"owner",
"repository",
"state",
"gitStatus",
"createdAt",
"lastUsedAt",
"machineName",
"vscsTarget",
}
CodespaceFields is the list of exportable fields for a codespace.
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 ¶
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 ¶
GetCodespaceBillableOwner returns the billable owner and expected default values for codespaces created by the user for a given repository.
func (*API) GetCodespaceRepoSuggestions ¶
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) GetOrgMemberCodespace ¶
func (*API) GetRepository ¶
GetRepository returns the repository associated with the given owner and name.
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 ¶
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) StartCodespace ¶
StartCodespace starts a codespace for the user. If the codespace is already running, the returned error from the API is ignored.
type AcceptPermissionsRequiredError ¶
type AcceptPermissionsRequiredError struct { Message string `json:"message"` AllowPermissionsURL string `json:"allow_permissions_url"` }
func (AcceptPermissionsRequiredError) Error ¶
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"` 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"` }
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 ¶
type CodespaceConnection ¶
type CodespaceGitStatus ¶
type CodespaceMachine ¶
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 }
CreateCodespaceParams are the required parameters for provisioning a Codespace.
type DevContainerEntry ¶
type EditCodespaceParams ¶
type ListCodespacesOptions ¶
type RepoSearchParameters ¶
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"` }
Repository represents a GitHub repository.