coder

package
v1.39.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2023 License: GPL-3.0 Imports: 17 Imported by: 1

README

coder-sdk

coder-sdk is a Go client library for Coder. It is not yet stable and therefore we do not recommend depending on the current state of its public APIs.

Usage

go get cdr.dev/coder-cli/coder-sdk

Documentation

Overview

Package coder provides simple APIs for integrating Go applications with Coder.

Index

Constants

View Source
const MarketplaceExtensionPublicURL = "https://extensions.coder.com/api"

MarketplaceExtensionPublicURL is the URL of the coder.com public marketplace that serves open source Code OSS extensions.

View Source
const Me = "me"

Me is the user ID of the authenticated user.

View Source
const (
	// SkipTemplateOrg allows skipping checks on organizations.
	SkipTemplateOrg = "SKIP_ORG"
)
View Source
const (
	// TemplateScopeSite is the scope for a site wide policy template.
	TemplateScopeSite = "site"
)

Variables

View Source
var ErrAuthentication = xerrors.New("invalid authentication")

ErrAuthentication describes the error case in which the requester has invalid authentication.

View Source
var ErrNotFound = xerrors.New("resource not found")

ErrNotFound describes an error case in which the requested resource could not be found.

View Source
var ErrPermissions = xerrors.New("insufficient permissions")

ErrPermissions describes an error case in which the requester has insufficient permissions to access the requested resource.

Functions

func String added in v1.13.0

func String(s string) *string

String gives a string pointer.

Types

type APIError added in v1.12.1

type APIError struct {
	Err APIErrorMsg `json:"error"`
}

APIError is the expected payload format for API errors.

type APIErrorMsg added in v1.17.0

type APIErrorMsg struct {
	Msg     string          `json:"msg"`
	Code    string          `json:"code"`
	Details json.RawMessage `json:"details"`
}

APIErrorMsg contains the rich error information returned by API errors.

type APIToken added in v1.13.0

type APIToken struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Application bool      `json:"application"`
	UserID      string    `json:"user_id"`
	LastUsed    time.Time `json:"last_used"`
}

APIToken describes a Coder APIToken resource for use in API requests.

type AuthProviderType added in v1.13.0

type AuthProviderType string

AuthProviderType is an enum of each valid auth provider.

const (
	AuthProviderBuiltIn AuthProviderType = "built-in"
	AuthProviderSAML    AuthProviderType = "saml"
	AuthProviderOIDC    AuthProviderType = "oidc"
)

AuthProviderType enum.

type BuildLog added in v1.12.0

type BuildLog struct {
	ID          string `db:"id" json:"id"`
	WorkspaceID string `db:"workspace_id" json:"workspace_id"`
	// BuildID allows the frontend to separate the logs from the old build with the logs from the new.
	BuildID string       `db:"build_id" json:"build_id"`
	Time    time.Time    `db:"time" json:"time"`
	Type    BuildLogType `db:"type" json:"type"`
	Msg     string       `db:"msg" json:"msg"`
}

BuildLog defines a build log record for a Coder workspace.

type BuildLogFollowMsg added in v1.12.0

type BuildLogFollowMsg struct {
	BuildLog
	Err error
}

BuildLogFollowMsg wraps the base BuildLog and adds a field for collecting errors that may occur when follow or parsing.

type BuildLogType added in v1.11.0

type BuildLogType string

BuildLogType describes the type of an event.

const (
	// BuildLogTypeStart signals that a new build log has begun.
	BuildLogTypeStart BuildLogType = "start"
	// BuildLogTypeStage is a stage-level event for a workspace.
	// It can be thought of as a major step in the workspace's
	// lifecycle.
	BuildLogTypeStage BuildLogType = "stage"
	// BuildLogTypeError describes an error that has occurred.
	BuildLogTypeError BuildLogType = "error"
	// BuildLogTypeSubstage describes a subevent that occurs as
	// part of a stage. This can be the output from a user's
	// personalization script, or a long running command.
	BuildLogTypeSubstage BuildLogType = "substage"
	// BuildLogTypeDone signals that the build has completed.
	BuildLogTypeDone BuildLogType = "done"
)

type Client

type Client interface {
	// PushActivity pushes CLI activity to Coder.
	PushActivity(ctx context.Context, source, workspaceID string) error

	// Me gets the details of the authenticated user.
	Me(ctx context.Context) (*User, error)

	// UserByID get the details of a user by their id.
	UserByID(ctx context.Context, id string) (*User, error)

	// SSHKey gets the current SSH kepair of the authenticated user.
	SSHKey(ctx context.Context) (*SSHKey, error)

	// Users gets the list of user accounts.
	Users(ctx context.Context) ([]User, error)

	// UserByEmail gets a user by email.
	UserByEmail(ctx context.Context, email string) (*User, error)

	// UpdateUser applyes the partial update to the given user.
	UpdateUser(ctx context.Context, userID string, req UpdateUserReq) error

	// UpdateUXState applies a partial update of the user's UX State.
	UpdateUXState(ctx context.Context, userID string, uxsPartial map[string]interface{}) error

	// CreateUser creates a new user account.
	CreateUser(ctx context.Context, req CreateUserReq) error

	// DeleteUser deletes a user account.
	DeleteUser(ctx context.Context, userID string) error

	// SiteConfigAuth fetches the sitewide authentication configuration.
	SiteConfigAuth(ctx context.Context) (*ConfigAuth, error)

	// PutSiteConfigAuth sets the sitewide authentication configuration.
	PutSiteConfigAuth(ctx context.Context, req ConfigAuth) error

	// SiteConfigOAuth fetches the sitewide git provider OAuth configuration.
	SiteConfigOAuth(ctx context.Context) (*ConfigOAuth, error)

	// PutSiteConfigOAuth sets the sitewide git provider OAuth configuration.
	PutSiteConfigOAuth(ctx context.Context, req ConfigOAuth) error

	// SiteSetupModeEnabled fetches the current setup_mode state of a Coder deployment.
	SiteSetupModeEnabled(ctx context.Context) (bool, error)

	// SiteConfigExtensionMarketplace fetches the extension marketplace configuration.
	SiteConfigExtensionMarketplace(ctx context.Context) (*ConfigExtensionMarketplace, error)

	// PutSiteConfigExtensionMarketplace sets the extension marketplace configuration.
	PutSiteConfigExtensionMarketplace(ctx context.Context, req ConfigExtensionMarketplace) error

	// SiteConfigWorkspaces fetches the workspace configuration.
	SiteConfigWorkspaces(ctx context.Context) (*ConfigWorkspaces, error)

	// DeleteDevURL deletes the specified devurl.
	DeleteDevURL(ctx context.Context, workspaceID, urlID string) error

	// CreateDevURL inserts a new devurl for the authenticated user.
	CreateDevURL(ctx context.Context, workspaceID string, req CreateDevURLReq) error

	// DevURLs fetches the Dev URLs for a given workspace.
	DevURLs(ctx context.Context, workspaceID string) ([]DevURL, error)

	// PutDevURL updates an existing devurl for the authenticated user.
	PutDevURL(ctx context.Context, workspaceID, urlID string, req PutDevURLReq) error

	// CreateWorkspace sends a request to create a workspace.
	CreateWorkspace(ctx context.Context, req CreateWorkspaceRequest) (*Workspace, error)

	// ParseTemplate parses a template config. It support both remote repositories and local files.
	// If a local file is specified then all other values in the request are ignored.
	ParseTemplate(ctx context.Context, req ParseTemplateRequest) (*TemplateVersion, error)

	// CreateWorkspaceFromRepo sends a request to create a workspace from a repository.
	CreateWorkspaceFromRepo(ctx context.Context, orgID string, req TemplateVersion) (*Workspace, error)

	// Workspaces lists workspaces returned by the given filter.
	Workspaces(ctx context.Context) ([]Workspace, error)

	// UserWorkspacesByOrganization gets the list of workspaces owned by the given user.
	UserWorkspacesByOrganization(ctx context.Context, userID, orgID string) ([]Workspace, error)

	// DeleteWorkspace deletes the workspace.
	DeleteWorkspace(ctx context.Context, workspaceID string) error

	// StopWorkspace stops the workspace.
	StopWorkspace(ctx context.Context, workspaceID string) error

	// RebuildWorkspace requests that the given workspaceID is rebuilt with no changes to its specification.
	RebuildWorkspace(ctx context.Context, workspaceID string) error

	// EditWorkspace modifies the workspace specification and initiates a rebuild.
	EditWorkspace(ctx context.Context, workspaceID string, req UpdateWorkspaceReq) error

	// DialWsep dials a workspace's command execution interface
	// See https://github.com/cdr/wsep for details.
	DialWsep(ctx context.Context, baseURL *url.URL, workspaceID string) (*websocket.Conn, error)

	// DialExecutor gives a remote execution interface for performing commands inside a workspace.
	DialExecutor(ctx context.Context, baseURL *url.URL, workspaceID string) (wsep.Execer, error)

	// DialIDEStatus opens a websocket connection for cpu load metrics on the workspace.
	DialIDEStatus(ctx context.Context, baseURL *url.URL, workspaceID string) (*websocket.Conn, error)

	// DialWorkspaceBuildLog opens a websocket connection for the workspace build log messages.
	DialWorkspaceBuildLog(ctx context.Context, workspaceID string) (*websocket.Conn, error)

	// FollowWorkspaceBuildLog trails the build log of a Coder workspace.
	FollowWorkspaceBuildLog(ctx context.Context, workspaceID string) (<-chan BuildLogFollowMsg, error)

	// DialWorkspaceStats opens a websocket connection for workspace stats.
	DialWorkspaceStats(ctx context.Context, workspaceID string) (*websocket.Conn, error)

	// DialResourceLoad opens a websocket connection for cpu load metrics on the workspace.
	DialResourceLoad(ctx context.Context, workspaceID string) (*websocket.Conn, error)

	// WaitForWorkspaceReady will watch the build log and return when done.
	WaitForWorkspaceReady(ctx context.Context, workspaceID string) error

	// WorkspaceByID get the details of a workspace by its id.
	WorkspaceByID(ctx context.Context, id string) (*Workspace, error)

	// WorkspacesByWorkspaceProvider returns workspaces that belong to a particular workspace provider.
	WorkspacesByWorkspaceProvider(ctx context.Context, wpID string) ([]Workspace, error)

	// ImportImage creates a new image and optionally a new registry.
	ImportImage(ctx context.Context, req ImportImageReq) (*Image, error)

	// ImageByID returns an image entity, fetched by its ID.
	ImageByID(ctx context.Context, id string) (*Image, error)

	// OrganizationImages returns all of the images imported for orgID.
	OrganizationImages(ctx context.Context, orgID string) ([]Image, error)

	// UpdateImage applies a partial update to an image resource.
	UpdateImage(ctx context.Context, imageID string, req UpdateImageReq) error

	// UpdateImageTags refreshes the latest digests for all tags of the image.
	UpdateImageTags(ctx context.Context, imageID string) error

	// Organizations gets all Organizations.
	Organizations(ctx context.Context) ([]Organization, error)

	// OrganizationByID get the Organization by its ID.
	OrganizationByID(ctx context.Context, orgID string) (*Organization, error)

	// OrganizationMembers get all members of the given organization.
	OrganizationMembers(ctx context.Context, orgID string) ([]OrganizationUser, error)

	// UpdateOrganization applys a partial update of an Organization resource.
	UpdateOrganization(ctx context.Context, orgID string, req UpdateOrganizationReq) error

	// CreateOrganization creates a new Organization in Coder.
	CreateOrganization(ctx context.Context, req CreateOrganizationReq) error

	// DeleteOrganization deletes an organization.
	DeleteOrganization(ctx context.Context, orgID string) error

	// Registries fetches all registries in an organization.
	Registries(ctx context.Context, orgID string) ([]Registry, error)

	// RegistryByID fetches a registry resource by its ID.
	RegistryByID(ctx context.Context, registryID string) (*Registry, error)

	// UpdateRegistry applies a partial update to a registry resource.
	UpdateRegistry(ctx context.Context, registryID string, req UpdateRegistryReq) error

	// DeleteRegistry deletes a registry resource by its ID.
	DeleteRegistry(ctx context.Context, registryID string) error

	// CreateImageTag creates a new image tag resource.
	CreateImageTag(ctx context.Context, imageID string, req CreateImageTagReq) (*ImageTag, error)

	// DeleteImageTag deletes an image tag resource.
	DeleteImageTag(ctx context.Context, imageID, tag string) error

	// ImageTags fetch all image tags.
	ImageTags(ctx context.Context, imageID string) ([]ImageTag, error)

	// ImageTagByID fetch an image tag by ID.
	ImageTagByID(ctx context.Context, imageID, tagID string) (*ImageTag, error)

	// CreateAPIToken creates a new APIToken for making authenticated requests to Coder.
	CreateAPIToken(ctx context.Context, userID string, req CreateAPITokenReq) (string, error)

	// APITokens fetches all APITokens owned by the given user.
	APITokens(ctx context.Context, userID string) ([]APIToken, error)

	// APITokenByID fetches the metadata for a given APIToken.
	APITokenByID(ctx context.Context, userID, tokenID string) (*APIToken, error)

	// DeleteAPIToken deletes an APIToken.
	DeleteAPIToken(ctx context.Context, userID, tokenID string) error

	// RegenerateAPIToken regenerates the given APIToken and returns the new value.
	RegenerateAPIToken(ctx context.Context, userID, tokenID string) (string, error)

	// APIVersion parses the coder-version http header from an authenticated request.
	APIVersion(ctx context.Context) (string, error)

	// WorkspaceProviderByID fetches a workspace provider entity by its unique ID.
	WorkspaceProviderByID(ctx context.Context, id string) (*KubernetesProvider, error)

	// WorkspaceProviders fetches all workspace providers known to the Coder control plane.
	WorkspaceProviders(ctx context.Context) (*WorkspaceProviders, error)

	// CreateWorkspaceProvider creates a new WorkspaceProvider entity.
	CreateWorkspaceProvider(ctx context.Context, req CreateWorkspaceProviderReq) (*CreateWorkspaceProviderRes, error)

	// DeleteWorkspaceProviderByID deletes a workspace provider entity from the Coder control plane.
	DeleteWorkspaceProviderByID(ctx context.Context, id string) error

	// Token returns the API Token used to authenticate.
	Token() string

	// BaseURL returns the BaseURL configured for this Client.
	BaseURL() url.URL

	// CordonWorkspaceProvider prevents the provider from having any more workspaces placed on it.
	CordonWorkspaceProvider(ctx context.Context, id, reason string) error

	// UnCordonWorkspaceProvider changes an existing cordoned providers status to 'Ready';
	// allowing it to continue creating new workspaces and provisioning resources for them.
	UnCordonWorkspaceProvider(ctx context.Context, id string) error

	// RenameWorkspaceProvider changes an existing providers name field.
	RenameWorkspaceProvider(ctx context.Context, id string, name string) error

	// SetPolicyTemplate sets the workspace policy template
	SetPolicyTemplate(ctx context.Context, templateID string, templateScope TemplateScope, dryRun bool) (*SetPolicyTemplateResponse, error)

	// Satellites fetches all satellitess known to the Coder control plane.
	Satellites(ctx context.Context) ([]Satellite, error)

	// CreateSatellite creates a new satellite entity.
	CreateSatellite(ctx context.Context, req CreateSatelliteReq) (*Satellite, error)

	// DeleteSatelliteByID deletes a satellite entity from the Coder control plane.
	DeleteSatelliteByID(ctx context.Context, id string) error

	// UpdateLastConnectionAt updates the last connection at attribute of a workspace.
	UpdateLastConnectionAt(ctx context.Context, workspaceID string) error

	// ICEServers fetches the list of ICE servers advertised by the deployment.
	ICEServers(ctx context.Context) ([]webrtc.ICEServer, error)
}

Client wraps the Coder HTTP API. This is an interface to allow for mocking of coder-sdk client usage.

type ClientOptions added in v1.17.0

type ClientOptions struct {
	// BaseURL is the root URL of the Coder installation (required).
	BaseURL *url.URL

	// Client is the http.Client to use for requests (optional).
	//
	// If omitted, the http.DefaultClient will be used.
	HTTPClient *http.Client

	// Token is the API Token used to authenticate (optional).
	//
	// If Token is provided, the DefaultClient will use it to authenticate.
	// If it is not provided, the client requires another type of
	// credential, such as an Email/Password pair.
	Token string

	// Email used to authenticate with Coder.
	//
	// If you supply an Email and Password pair, NewClient will exchange
	// these credentials for a Token during initialization.  This is only
	// applicable for the built-in authentication provider. The client will
	// not retain these credentials in memory after NewClient returns.
	Email string

	// Password used to authenticate with Coder.
	//
	// If you supply an Email and Password pair, NewClient will exchange
	// these credentials for a Token during initialization.  This is only
	// applicable for the built-in authentication provider. The client will
	// not retain these credentials in memory after NewClient returns.
	Password string
}

ClientOptions contains options for the Coder SDK Client.

type ConfigAuth added in v1.13.0

type ConfigAuth struct {
	ProviderType *AuthProviderType `json:"provider_type"`
	OIDC         *ConfigOIDC       `json:"oidc"`
	SAML         *ConfigSAML       `json:"saml"`
}

ConfigAuth describes the authentication configuration for a Coder deployment.

type ConfigDevURLAccess added in v1.23.0

type ConfigDevURLAccess struct {
	Private bool `json:"private"`
	Org     bool `json:"org"`
	Authed  bool `json:"authed"`
	Public  bool `json:"public"`
}

type ConfigDormancy added in v1.23.0

type ConfigDormancy struct {
	// UserDormancyThresholdDays is not currently updatable.
	// UserDormancyThresholdDays int `json:"user_dormancy_threshold_days"`
	UserDeletionThresholdDays int `json:"user_deletion_threshold_days"`
}

type ConfigExtensionMarketplace added in v1.13.0

type ConfigExtensionMarketplace struct {
	URL  string                   `json:"url"`
	Type ExtensionMarketplaceType `json:"type"`
}

ConfigExtensionMarketplace describes the sitewide extension marketplace configuration.

type ConfigOAuth added in v1.13.0

type ConfigOAuth struct {
	BitbucketServer ConfigOAuthBitbucketServer `json:"bitbucket_server"`
	GitHub          ConfigOAuthGitHub          `json:"github"`
	GitLab          ConfigOAuthGitLab          `json:"gitlab"`
}

ConfigOAuth describes the aggregate git integration configuration for a Coder deployment.

type ConfigOAuthBitbucketServer added in v1.13.0

type ConfigOAuthBitbucketServer struct {
	BaseURL string `json:"base_url" diff:"oauth.bitbucket_server.base_url"`
}

ConfigOAuthBitbucketServer describes the Bitbucket integration configuration for a Coder deployment.

type ConfigOAuthGitHub added in v1.13.0

type ConfigOAuthGitHub struct {
	BaseURL      string `json:"base_url"`
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
}

ConfigOAuthGitHub describes the Github integration configuration for a Coder deployment.

type ConfigOAuthGitLab added in v1.13.0

type ConfigOAuthGitLab struct {
	BaseURL      string `json:"base_url"`
	ClientID     string `json:"client_id" `
	ClientSecret string `json:"client_secret"`
}

ConfigOAuthGitLab describes the GitLab integration configuration for a Coder deployment.

type ConfigOIDC added in v1.13.0

type ConfigOIDC struct {
	ClientID     *string `json:"client_id"`
	ClientSecret *string `json:"client_secret"`
	Issuer       *string `json:"issuer"`
}

ConfigOIDC describes the OIDC configuration for single-signon support in Coder.

type ConfigSAML added in v1.13.0

type ConfigSAML struct {
	IdentityProviderMetadataURL *string `json:"idp_metadata_url"`
	SignatureAlgorithm          *string `json:"signature_algorithm"`
	NameIDFormat                *string `json:"name_id_format"`
	PrivateKey                  *string `json:"private_key"`
	PublicKeyCertificate        *string `json:"public_key_certificate"`
}

ConfigSAML describes the SAML configuration values.

type ConfigSSHSettings added in v1.23.0

type ConfigSSHSettings struct {
	KeygenAlgorithm string `json:"keygen_algorithm"`
}

ConfigSSHSettings is the site configuration for SSH.

type ConfigWorkspaces added in v1.19.0

type ConfigWorkspaces struct {
	GPUVendor              string `json:"gpu_vendor"`
	EnableContainerVMs     bool   `json:"enable_container_vms"`
	EnableWorkspacesAsCode bool   `json:"enable_workspaces_as_code"`
}

ConfigWorkspaces is the site configuration for workspace attributes.

type CordoneWorkspaceProviderReq added in v1.17.2

type CordoneWorkspaceProviderReq struct {
	Reason string `json:"reason"`
}

CordoneWorkspaceProviderReq defines the request parameters for creating a new workspace provider entity.

type CreateAPITokenReq added in v1.13.0

type CreateAPITokenReq struct {
	Name string `json:"name"`
}

CreateAPITokenReq defines the paramemters for creating a new APIToken.

type CreateDevURLReq added in v1.13.0

type CreateDevURLReq struct {
	WorkspaceID string `json:"workspace_id"`
	Port        int    `json:"port"`
	Access      string `json:"access"`
	Name        string `json:"name"`
	Scheme      string `json:"scheme"`
}

CreateDevURLReq defines the request parameters for creating a new DevURL.

type CreateImageTagReq added in v1.13.0

type CreateImageTagReq struct {
	Tag     string `json:"tag"`
	Default bool   `json:"default"`
}

CreateImageTagReq defines the request parameters for creating a new image tag.

type CreateOrganizationReq added in v1.13.0

type CreateOrganizationReq struct {
	Name                   string   `json:"name"`
	Description            string   `json:"description"`
	Default                bool     `json:"default"`
	ResourceNamespace      string   `json:"resource_namespace"`
	AutoOffThreshold       Duration `json:"auto_off_threshold"`
	CPUProvisioningRate    float32  `json:"cpu_provisioning_rate"`
	MemoryProvisioningRate float32  `json:"memory_provisioning_rate"`
}

CreateOrganizationReq describes the request parameters to create a new Organization.

type CreateSatelliteReq added in v1.21.0

type CreateSatelliteReq struct {
	Name      string `json:"name"`
	PublicKey string `json:"public_key"`
}

CreateSatelliteReq defines the request parameters for creating a new satellite entity.

type CreateUserReq added in v1.13.0

type CreateUserReq struct {
	Name              string    `json:"name"`
	Username          string    `json:"username"`
	Email             string    `json:"email"`
	Password          string    `json:"password"`
	TemporaryPassword bool      `json:"temporary_password"`
	LoginType         LoginType `json:"login_type"`
	OrganizationsIDs  []string  `json:"organizations"`
}

CreateUserReq defines the request parameters for creating a new user resource.

type CreateWorkspaceProviderReq added in v1.16.0

type CreateWorkspaceProviderReq struct {
	Name           string                `json:"name"`
	Type           WorkspaceProviderType `json:"type"`
	Hostname       string                `json:"hostname"`
	ClusterAddress string                `json:"cluster_address"`
}

CreateWorkspaceProviderReq defines the request parameters for creating a new workspace provider entity.

type CreateWorkspaceProviderRes added in v1.16.0

type CreateWorkspaceProviderRes struct {
	ID            string                  `json:"id" table:"ID"`
	Name          string                  `json:"name" table:"Name"`
	Status        WorkspaceProviderStatus `json:"status" table:"Status"`
	EnvproxyToken string                  `json:"envproxy_token" table:"Envproxy Token"`
}

CreateWorkspaceProviderRes defines the response from creating a new workspace provider entity.

type CreateWorkspaceRequest added in v1.20.0

type CreateWorkspaceRequest struct {
	Name            string  `json:"name"`
	ImageID         string  `json:"image_id"`
	OrgID           string  `json:"org_id"`
	ImageTag        string  `json:"image_tag"`
	CPUCores        float32 `json:"cpu_cores"`
	MemoryGB        float32 `json:"memory_gb"`
	DiskGB          int     `json:"disk_gb"`
	GPUs            int     `json:"gpus"`
	UseContainerVM  bool    `json:"use_container_vm"`
	ResourcePoolID  string  `json:"resource_pool_id"`
	Namespace       string  `json:"namespace"`
	EnableAutoStart bool    `json:"autostart_enabled"`

	// ForUserID is an optional param to create a workspace for another user
	// other than the requester. This only works for admins and site managers.
	ForUserID string `json:"for_user_id,omitempty"`

	// TemplateID comes from the parse template route on cemanager.
	TemplateID string `json:"template_id,omitempty"`
}

CreateWorkspaceRequest is used to configure a new workspace.

type DefaultClient added in v1.17.0

type DefaultClient struct {
	// contains filtered or unexported fields
}

DefaultClient is the default implementation of the coder.Client interface.

The empty value is meaningless and the fields are unexported; use NewClient to create an instance.

func NewClient added in v1.17.0

func NewClient(opts ClientOptions) (*DefaultClient, error)

NewClient creates a new default Coder SDK client.

func (*DefaultClient) APITokenByID added in v1.17.0

func (c *DefaultClient) APITokenByID(ctx context.Context, userID, tokenID string) (*APIToken, error)

APITokenByID fetches the metadata for a given APIToken.

func (*DefaultClient) APITokens added in v1.17.0

func (c *DefaultClient) APITokens(ctx context.Context, userID string) ([]APIToken, error)

APITokens fetches all APITokens owned by the given user.

func (*DefaultClient) APIVersion added in v1.17.0

func (c *DefaultClient) APIVersion(ctx context.Context) (string, error)

APIVersion parses the coder-version http header from an authenticated request.

func (*DefaultClient) BaseURL added in v1.17.0

func (c *DefaultClient) BaseURL() url.URL

BaseURL returns the BaseURL configured for this Client.

func (*DefaultClient) CordonWorkspaceProvider added in v1.17.2

func (c *DefaultClient) CordonWorkspaceProvider(ctx context.Context, id, reason string) error

CordonWorkspaceProvider prevents the provider from having any more workspaces placed on it.

func (*DefaultClient) CreateAPIToken added in v1.17.0

func (c *DefaultClient) CreateAPIToken(ctx context.Context, userID string, req CreateAPITokenReq) (token string, _ error)

CreateAPIToken creates a new APIToken for making authenticated requests to Coder.

func (*DefaultClient) CreateDevURL added in v1.17.0

func (c *DefaultClient) CreateDevURL(ctx context.Context, workspaceID string, req CreateDevURLReq) error

CreateDevURL inserts a new dev URL for the authenticated user.

func (*DefaultClient) CreateImageTag added in v1.17.0

func (c *DefaultClient) CreateImageTag(ctx context.Context, imageID string, req CreateImageTagReq) (*ImageTag, error)

CreateImageTag creates a new image tag resource.

func (*DefaultClient) CreateOrganization added in v1.17.0

func (c *DefaultClient) CreateOrganization(ctx context.Context, req CreateOrganizationReq) error

CreateOrganization creates a new Organization in Coder.

func (*DefaultClient) CreateSatellite added in v1.21.0

func (c *DefaultClient) CreateSatellite(ctx context.Context, req CreateSatelliteReq) (*Satellite, error)

CreateSatellite creates a new satellite entity.

func (*DefaultClient) CreateUser added in v1.17.0

func (c *DefaultClient) CreateUser(ctx context.Context, req CreateUserReq) error

CreateUser creates a new user account.

func (*DefaultClient) CreateWorkspace added in v1.20.0

func (c *DefaultClient) CreateWorkspace(ctx context.Context, req CreateWorkspaceRequest) (*Workspace, error)

CreateWorkspace sends a request to create a workspace.

func (*DefaultClient) CreateWorkspaceFromRepo added in v1.20.0

func (c *DefaultClient) CreateWorkspaceFromRepo(ctx context.Context, orgID string, req TemplateVersion) (*Workspace, error)

CreateWorkspaceFromRepo sends a request to create a workspace from a repository.

func (*DefaultClient) CreateWorkspaceProvider added in v1.17.0

CreateWorkspaceProvider creates a new WorkspaceProvider entity.

func (*DefaultClient) DeleteAPIToken added in v1.17.0

func (c *DefaultClient) DeleteAPIToken(ctx context.Context, userID, tokenID string) error

DeleteAPIToken deletes an APIToken.

func (*DefaultClient) DeleteDevURL added in v1.17.0

func (c *DefaultClient) DeleteDevURL(ctx context.Context, workspaceID, urlID string) error

DeleteDevURL deletes the specified devurl.

func (*DefaultClient) DeleteImageTag added in v1.17.0

func (c *DefaultClient) DeleteImageTag(ctx context.Context, imageID, tag string) error

DeleteImageTag deletes an image tag resource.

func (*DefaultClient) DeleteOrganization added in v1.17.0

func (c *DefaultClient) DeleteOrganization(ctx context.Context, orgID string) error

DeleteOrganization deletes an organization.

func (*DefaultClient) DeleteRegistry added in v1.17.0

func (c *DefaultClient) DeleteRegistry(ctx context.Context, registryID string) error

DeleteRegistry deletes a registry resource by its ID.

func (*DefaultClient) DeleteSatelliteByID added in v1.21.0

func (c *DefaultClient) DeleteSatelliteByID(ctx context.Context, id string) error

DeleteSatelliteByID deletes a satellite entity from the Coder control plane.

func (*DefaultClient) DeleteUser added in v1.17.0

func (c *DefaultClient) DeleteUser(ctx context.Context, userID string) error

DeleteUser deletes a user account.

func (*DefaultClient) DeleteWorkspace added in v1.20.0

func (c *DefaultClient) DeleteWorkspace(ctx context.Context, workspaceID string) error

DeleteWorkspace deletes the workspace.

func (*DefaultClient) DeleteWorkspaceProviderByID added in v1.17.0

func (c *DefaultClient) DeleteWorkspaceProviderByID(ctx context.Context, id string) error

DeleteWorkspaceProviderByID deletes a workspace provider entity from the Coder control plane.

func (*DefaultClient) DevURLs added in v1.17.0

func (c *DefaultClient) DevURLs(ctx context.Context, workspaceID string) ([]DevURL, error)

DevURLs fetches the Dev URLs for a given workspace.

func (*DefaultClient) DialExecutor added in v1.17.0

func (c *DefaultClient) DialExecutor(ctx context.Context, baseURL *url.URL, workspaceID string) (wsep.Execer, error)

DialExecutor gives a remote execution interface for performing commands inside a workspace.

func (*DefaultClient) DialIDEStatus added in v1.17.0

func (c *DefaultClient) DialIDEStatus(ctx context.Context, baseURL *url.URL, workspaceID string) (*websocket.Conn, error)

DialIDEStatus opens a websocket connection for cpu load metrics on the workspace.

func (*DefaultClient) DialResourceLoad added in v1.17.0

func (c *DefaultClient) DialResourceLoad(ctx context.Context, workspaceID string) (*websocket.Conn, error)

DialResourceLoad opens a websocket connection for cpu load metrics on the workspace.

func (*DefaultClient) DialWorkspaceBuildLog added in v1.20.0

func (c *DefaultClient) DialWorkspaceBuildLog(ctx context.Context, workspaceID string) (*websocket.Conn, error)

DialWorkspaceBuildLog opens a websocket connection for the workspace build log messages.

func (*DefaultClient) DialWorkspaceStats added in v1.20.0

func (c *DefaultClient) DialWorkspaceStats(ctx context.Context, workspaceID string) (*websocket.Conn, error)

DialWorkspaceStats opens a websocket connection for workspace stats.

func (*DefaultClient) DialWsep added in v1.17.0

func (c *DefaultClient) DialWsep(ctx context.Context, baseURL *url.URL, workspaceID string) (*websocket.Conn, error)

DialWsep dials a workspace's command execution interface See https://github.com/cdr/wsep for details.

func (*DefaultClient) EditWorkspace added in v1.20.0

func (c *DefaultClient) EditWorkspace(ctx context.Context, workspaceID string, req UpdateWorkspaceReq) error

EditWorkspace modifies the workspace specification and initiates a rebuild.

func (*DefaultClient) FollowWorkspaceBuildLog added in v1.20.0

func (c *DefaultClient) FollowWorkspaceBuildLog(ctx context.Context, workspaceID string) (<-chan BuildLogFollowMsg, error)

FollowWorkspaceBuildLog trails the build log of a Coder workspace.

func (*DefaultClient) ICEServers added in v1.22.0

func (c *DefaultClient) ICEServers(ctx context.Context) ([]webrtc.ICEServer, error)

ICEServers fetches the list of ICE servers advertised by the deployment.

func (*DefaultClient) ImageByID added in v1.17.0

func (c *DefaultClient) ImageByID(ctx context.Context, id string) (*Image, error)

ImageByID returns an image entity, fetched by its ID.

func (*DefaultClient) ImageTagByID added in v1.17.0

func (c *DefaultClient) ImageTagByID(ctx context.Context, imageID, tagID string) (*ImageTag, error)

ImageTagByID fetch an image tag by ID.

func (*DefaultClient) ImageTags added in v1.17.0

func (c *DefaultClient) ImageTags(ctx context.Context, imageID string) ([]ImageTag, error)

ImageTags fetch all image tags.

func (*DefaultClient) ImportImage added in v1.17.0

func (c *DefaultClient) ImportImage(ctx context.Context, req ImportImageReq) (*Image, error)

ImportImage creates a new image and optionally a new registry.

func (*DefaultClient) Me added in v1.17.0

func (c *DefaultClient) Me(ctx context.Context) (*User, error)

Me gets the details of the authenticated user.

func (*DefaultClient) OrganizationByID added in v1.17.0

func (c *DefaultClient) OrganizationByID(ctx context.Context, orgID string) (*Organization, error)

OrganizationByID get the Organization by its ID.

func (*DefaultClient) OrganizationImages added in v1.17.0

func (c *DefaultClient) OrganizationImages(ctx context.Context, orgID string) ([]Image, error)

OrganizationImages returns all of the images imported for orgID.

func (*DefaultClient) OrganizationMembers added in v1.17.0

func (c *DefaultClient) OrganizationMembers(ctx context.Context, orgID string) ([]OrganizationUser, error)

OrganizationMembers get all members of the given organization.

func (*DefaultClient) Organizations added in v1.17.0

func (c *DefaultClient) Organizations(ctx context.Context) ([]Organization, error)

Organizations gets all Organizations.

func (*DefaultClient) ParseTemplate added in v1.17.0

func (c *DefaultClient) ParseTemplate(ctx context.Context, req ParseTemplateRequest) (*TemplateVersion, error)

ParseTemplate parses a template config. It support both remote repositories and local files. If a local file is specified then all other values in the request are ignored.

func (*DefaultClient) PushActivity added in v1.17.0

func (c *DefaultClient) PushActivity(ctx context.Context, source, workspaceID string) error

PushActivity pushes CLI activity to Coder.

func (*DefaultClient) PutDevURL added in v1.17.0

func (c *DefaultClient) PutDevURL(ctx context.Context, workspaceID, urlID string, req PutDevURLReq) error

PutDevURL updates an existing devurl for the authenticated user.

func (*DefaultClient) PutSiteConfigAuth added in v1.17.0

func (c *DefaultClient) PutSiteConfigAuth(ctx context.Context, req ConfigAuth) error

PutSiteConfigAuth sets the sitewide authentication configuration.

func (*DefaultClient) PutSiteConfigDevURLAccess added in v1.23.0

func (c *DefaultClient) PutSiteConfigDevURLAccess(ctx context.Context, req ConfigDevURLAccess) error

PutSiteConfigDevURLAccess sets the DevURL access configuration.

func (*DefaultClient) PutSiteConfigDormancy added in v1.23.0

func (c *DefaultClient) PutSiteConfigDormancy(ctx context.Context, req ConfigDormancy) error

PutSiteConfigDormancy sets the dormancy configuration.

func (*DefaultClient) PutSiteConfigExtensionMarketplace added in v1.17.0

func (c *DefaultClient) PutSiteConfigExtensionMarketplace(ctx context.Context, req ConfigExtensionMarketplace) error

PutSiteConfigExtensionMarketplace sets the extension marketplace configuration.

func (*DefaultClient) PutSiteConfigOAuth added in v1.17.0

func (c *DefaultClient) PutSiteConfigOAuth(ctx context.Context, req ConfigOAuth) error

PutSiteConfigOAuth sets the sitewide git provider OAuth configuration.

func (*DefaultClient) PutSiteConfigSSHSettings added in v1.23.0

func (c *DefaultClient) PutSiteConfigSSHSettings(ctx context.Context, req ConfigSSHSettings) error

PutSiteConfigSSHSettings sets the SSH configuration.

func (*DefaultClient) PutSiteConfigWorkspaces added in v1.23.0

func (c *DefaultClient) PutSiteConfigWorkspaces(ctx context.Context, req ConfigWorkspaces) error

PutSiteConfigWorkspaces sets the workspace configuration.

func (*DefaultClient) RebuildWorkspace added in v1.20.0

func (c *DefaultClient) RebuildWorkspace(ctx context.Context, workspaceID string) error

RebuildWorkspace requests that the given workspaceID is rebuilt with no changes to its specification.

func (*DefaultClient) RegenerateAPIToken added in v1.17.0

func (c *DefaultClient) RegenerateAPIToken(ctx context.Context, userID, tokenID string) (token string, _ error)

RegenerateAPIToken regenerates the given APIToken and returns the new value.

func (*DefaultClient) Registries added in v1.17.0

func (c *DefaultClient) Registries(ctx context.Context, orgID string) ([]Registry, error)

Registries fetches all registries in an organization.

func (*DefaultClient) RegistryByID added in v1.17.0

func (c *DefaultClient) RegistryByID(ctx context.Context, registryID string) (*Registry, error)

RegistryByID fetches a registry resource by its ID.

func (*DefaultClient) RenameWorkspaceProvider added in v1.18.0

func (c *DefaultClient) RenameWorkspaceProvider(ctx context.Context, id string, name string) error

RenameWorkspaceProvider changes an existing cordoned providers name field.

func (*DefaultClient) SSHKey added in v1.17.0

func (c *DefaultClient) SSHKey(ctx context.Context) (*SSHKey, error)

SSHKey gets the current SSH kepair of the authenticated user.

func (*DefaultClient) Satellites added in v1.21.0

func (c *DefaultClient) Satellites(ctx context.Context) ([]Satellite, error)

Satellites fetches all satellitess known to the Coder control plane.

func (*DefaultClient) SetPolicyTemplate added in v1.21.0

func (c *DefaultClient) SetPolicyTemplate(ctx context.Context, templateID string, templateScope TemplateScope, dryRun bool) (*SetPolicyTemplateResponse, error)

func (*DefaultClient) SiteConfigAuth added in v1.17.0

func (c *DefaultClient) SiteConfigAuth(ctx context.Context) (*ConfigAuth, error)

SiteConfigAuth fetches the sitewide authentication configuration.

func (*DefaultClient) SiteConfigDevURLAccess added in v1.23.0

func (c *DefaultClient) SiteConfigDevURLAccess(ctx context.Context) (*ConfigDevURLAccess, error)

SiteConfigDevURLAccess fetches the DevURL access configuration.

func (*DefaultClient) SiteConfigDormancy added in v1.23.0

func (c *DefaultClient) SiteConfigDormancy(ctx context.Context) (*ConfigDormancy, error)

SiteConfigDormancy fetches the dormancy configuration.

func (*DefaultClient) SiteConfigExtensionMarketplace added in v1.17.0

func (c *DefaultClient) SiteConfigExtensionMarketplace(ctx context.Context) (*ConfigExtensionMarketplace, error)

SiteConfigExtensionMarketplace fetches the extension marketplace configuration.

func (*DefaultClient) SiteConfigOAuth added in v1.17.0

func (c *DefaultClient) SiteConfigOAuth(ctx context.Context) (*ConfigOAuth, error)

SiteConfigOAuth fetches the sitewide git provider OAuth configuration.

func (*DefaultClient) SiteConfigSSHSettings added in v1.23.0

func (c *DefaultClient) SiteConfigSSHSettings(ctx context.Context) (*ConfigSSHSettings, error)

SiteConfigSSHSettings fetches the SSH configuration.

func (*DefaultClient) SiteConfigWorkspaces added in v1.19.0

func (c *DefaultClient) SiteConfigWorkspaces(ctx context.Context) (*ConfigWorkspaces, error)

SiteConfigWorkspaces fetches the workspace configuration.

func (*DefaultClient) SiteSetupModeEnabled added in v1.17.0

func (c *DefaultClient) SiteSetupModeEnabled(ctx context.Context) (bool, error)

SiteSetupModeEnabled fetches the current setup_mode state of a Coder deployment.

func (*DefaultClient) StopWorkspace added in v1.20.0

func (c *DefaultClient) StopWorkspace(ctx context.Context, workspaceID string) error

StopWorkspace stops the workspace.

func (*DefaultClient) Token added in v1.17.0

func (c *DefaultClient) Token() string

Token returns the API Token used to authenticate.

func (*DefaultClient) UnCordonWorkspaceProvider added in v1.17.2

func (c *DefaultClient) UnCordonWorkspaceProvider(ctx context.Context, id string) error

UnCordonWorkspaceProvider changes an existing cordoned providers status to 'Ready'; allowing it to continue creating new workspaces and provisioning resources for them.

func (*DefaultClient) UpdateImage added in v1.17.0

func (c *DefaultClient) UpdateImage(ctx context.Context, imageID string, req UpdateImageReq) error

UpdateImage applies a partial update to an image resource.

func (*DefaultClient) UpdateImageTags added in v1.17.0

func (c *DefaultClient) UpdateImageTags(ctx context.Context, imageID string) error

UpdateImageTags refreshes the latest digests for all tags of the image.

func (*DefaultClient) UpdateLastConnectionAt added in v1.21.0

func (c *DefaultClient) UpdateLastConnectionAt(ctx context.Context, workspaceID string) error

UpdateLastConnectionAt updates the last connection at attribute of a workspace.

func (*DefaultClient) UpdateOrganization added in v1.17.0

func (c *DefaultClient) UpdateOrganization(ctx context.Context, orgID string, req UpdateOrganizationReq) error

UpdateOrganization applys a partial update of an Organization resource.

func (*DefaultClient) UpdateRegistry added in v1.17.0

func (c *DefaultClient) UpdateRegistry(ctx context.Context, registryID string, req UpdateRegistryReq) error

UpdateRegistry applies a partial update to a registry resource.

func (*DefaultClient) UpdateUXState added in v1.17.0

func (c *DefaultClient) UpdateUXState(ctx context.Context, userID string, uxsPartial map[string]interface{}) error

UpdateUXState applies a partial update of the user's UX State.

func (*DefaultClient) UpdateUser added in v1.17.0

func (c *DefaultClient) UpdateUser(ctx context.Context, userID string, req UpdateUserReq) error

UpdateUser applyes the partial update to the given user.

func (*DefaultClient) UserByEmail added in v1.17.0

func (c *DefaultClient) UserByEmail(ctx context.Context, email string) (*User, error)

UserByEmail gets a user by email.

func (*DefaultClient) UserByID added in v1.17.0

func (c *DefaultClient) UserByID(ctx context.Context, id string) (*User, error)

UserByID get the details of a user by their id.

func (*DefaultClient) UserWorkspacesByOrganization added in v1.20.0

func (c *DefaultClient) UserWorkspacesByOrganization(ctx context.Context, userID, orgID string) ([]Workspace, error)

UserWorkspacesByOrganization gets the list of workspaces owned by the given user.

func (*DefaultClient) Users added in v1.17.0

func (c *DefaultClient) Users(ctx context.Context) ([]User, error)

Users gets the list of user accounts.

func (*DefaultClient) WaitForWorkspaceReady added in v1.20.0

func (c *DefaultClient) WaitForWorkspaceReady(ctx context.Context, workspaceID string) error

WaitForWorkspaceReady will watch the build log and return when done.

func (*DefaultClient) WorkspaceByID added in v1.20.0

func (c *DefaultClient) WorkspaceByID(ctx context.Context, id string) (*Workspace, error)

WorkspaceByID get the details of a workspace by its id.

func (*DefaultClient) WorkspaceProviderByID added in v1.17.0

func (c *DefaultClient) WorkspaceProviderByID(ctx context.Context, id string) (*KubernetesProvider, error)

WorkspaceProviderByID fetches a workspace provider entity by its unique ID.

func (*DefaultClient) WorkspaceProviders added in v1.17.0

func (c *DefaultClient) WorkspaceProviders(ctx context.Context) (*WorkspaceProviders, error)

WorkspaceProviders fetches all workspace providers known to the Coder control plane.

func (*DefaultClient) Workspaces added in v1.20.0

func (c *DefaultClient) Workspaces(ctx context.Context) ([]Workspace, error)

Workspaces lists workspaces returned by the given filter. TODO: add the filter options, explore performance issue.

func (*DefaultClient) WorkspacesByWorkspaceProvider added in v1.20.0

func (c *DefaultClient) WorkspacesByWorkspaceProvider(ctx context.Context, wpID string) ([]Workspace, error)

WorkspacesByWorkspaceProvider returns all workspaces that belong to a particular workspace provider.

type DevURL

type DevURL struct {
	ID     string `json:"id"     table:"-"`
	URL    string `json:"url"    table:"URL"`
	Port   int    `json:"port"   table:"Port"`
	Access string `json:"access" table:"Access"`
	Name   string `json:"name"   table:"Name"`
	Scheme string `json:"scheme" table:"Scheme"`
}

DevURL is the parsed json response record for a devURL from cemanager.

type Duration added in v1.13.0

type Duration time.Duration

Duration is a time.Duration wrapper that marshals to millisecond precision. While it looses precision, most javascript applications expect durations to be in milliseconds.

func (Duration) MarshalJSON added in v1.13.0

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON marshals the duration to millisecond precision.

func (Duration) String added in v1.13.0

func (d Duration) String() string

func (*Duration) UnmarshalJSON added in v1.13.0

func (d *Duration) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a millisecond-precision integer to a time.Duration.

type ExtensionMarketplaceType added in v1.13.0

type ExtensionMarketplaceType string

ExtensionMarketplaceType is an enum of the valid extension marketplace configurations.

const (
	ExtensionMarketplaceInternal ExtensionMarketplaceType = "internal"
	ExtensionMarketplaceCustom   ExtensionMarketplaceType = "custom"
	ExtensionMarketplacePublic   ExtensionMarketplaceType = "public"
)

ExtensionMarketplaceType enum.

type HTTPError added in v1.12.0

type HTTPError struct {
	// contains filtered or unexported fields
}

HTTPError represents an error from the Coder API.

func NewHTTPError added in v1.20.0

func NewHTTPError(resp *http.Response) *HTTPError

NewHTTPError reads the response body and stores metadata about the response in order to be unpacked into an *APIError.

func (*HTTPError) Error added in v1.12.0

func (e *HTTPError) Error() string

func (*HTTPError) Payload added in v1.17.0

func (e *HTTPError) Payload() (*APIError, error)

Payload decode the response body into the standard error structure. The `details` section is stored as a raw json, and type depends on the `code` field.

func (*HTTPError) StatusCode added in v1.20.0

func (e *HTTPError) StatusCode() int

type Image added in v1.11.0

type Image struct {
	ID              string    `json:"id"                    table:"-"`
	OrganizationID  string    `json:"organization_id"       table:"-"`
	Repository      string    `json:"repository"            table:"Repository"`
	Description     string    `json:"description"           table:"-"`
	URL             string    `json:"url"                   table:"-"` // User-supplied URL for image.
	Registry        *Registry `json:"registry"              table:"-"`
	DefaultTag      *ImageTag `json:"default_tag"           table:"DefaultTag"`
	DefaultCPUCores float32   `json:"default_cpu_cores"     table:"DefaultCPUCores"`
	DefaultMemoryGB float32   `json:"default_memory_gb"     table:"DefaultMemoryGB"`
	DefaultDiskGB   int       `json:"default_disk_gb"       table:"DefaultDiskGB"`
	Deprecated      bool      `json:"deprecated"            table:"-"`
	CreatedAt       time.Time `json:"created_at"            table:"-"`
	UpdatedAt       time.Time `json:"updated_at"            table:"-"`
}

Image describes a Coder Image.

type ImageTag added in v1.13.0

type ImageTag struct {
	ImageID           string       `json:"image_id"             table:"-"`
	Tag               string       `json:"tag"                  table:"Tag"`
	LatestHash        string       `json:"latest_hash"          table:"-"`
	HashLastUpdatedAt time.Time    `json:"hash_last_updated_at" table:"-"`
	OSRelease         *OSRelease   `json:"os_release"           table:"OS"`
	Workspaces        []*Workspace `json:"workspaces"         table:"-"`
	UpdatedAt         time.Time    `json:"updated_at"           table:"UpdatedAt"`
	CreatedAt         time.Time    `json:"created_at"           table:"-"`
}

ImageTag is a Docker image tag.

func (ImageTag) String added in v1.13.2

func (i ImageTag) String() string

type ImportImageReq added in v1.13.0

type ImportImageReq struct {
	RegistryID      *string             `json:"registry_id"`  // Used to import images to existing registries.
	NewRegistry     *NewRegistryRequest `json:"new_registry"` // Used when adding a new registry.
	Repository      string              `json:"repository"`   // Refers to the image. Ex: "codercom/ubuntu".
	OrgID           string              `json:"org_id"`
	Tag             string              `json:"tag"`
	DefaultCPUCores float32             `json:"default_cpu_cores"`
	DefaultMemoryGB int                 `json:"default_memory_gb"`
	DefaultDiskGB   int                 `json:"default_disk_gb"`
	Description     string              `json:"description"`
	URL             string              `json:"url"`
}

ImportImageReq is used to import new images and registries into Coder.

type KubeProviderConfig added in v1.17.0

type KubeProviderConfig struct {
	ClusterAddress      string `json:"cluster_address" table:"Cluster Address"`
	DefaultNamespace    string `json:"default_namespace" table:"Namespace"`
	StorageClass        string `json:"storage_class" table:"Storage Class"`
	ClusterDomainSuffix string `json:"cluster_domain_suffix" table:"Cluster Domain Suffix"`
	SSHEnabled          bool   `json:"ssh_enabled" table:"SSH Enabled"`
}

KubeProviderConfig defines Kubernetes-specific configuration options.

type KubernetesProvider added in v1.17.0

type KubernetesProvider struct {
	ID                 string                  `json:"id"                  table:"-"`
	Name               string                  `json:"name"                table:"Name"`
	Status             WorkspaceProviderStatus `json:"status"              table:"Status"`
	BuiltIn            bool                    `json:"built_in"            table:"-"`
	EnvproxyAccessURL  string                  `json:"envproxy_access_url" table:"Access URL" validate:"required"`
	DevurlHost         string                  `json:"devurl_host"         table:"Devurl Host"`
	OrgWhitelist       []string                `json:"org_whitelist"       table:"-"`
	KubeProviderConfig `json:"config" table:"_"`
}

KubernetesProvider defines an entity capable of deploying and acting as an ingress for Coder workspaces.

type LoginRequest added in v1.17.0

type LoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

LoginRequest is a request to authenticate using email and password credentials.

This is provided for use in tests, and we recommend users authenticate using an API Token.

type LoginResponse added in v1.17.0

type LoginResponse struct {
	SessionToken string `json:"session_token"`
}

LoginResponse contains successful response data for an authentication request, including an API Token to be used for subsequent requests.

This is provided for use in tests, and we recommend users authenticate using an API Token.

func LoginWithPassword added in v1.17.0

func LoginWithPassword(ctx context.Context, client *http.Client, baseURL *url.URL, req *LoginRequest) (resp *LoginResponse, err error)

LoginWithPassword exchanges the email/password pair for a Session Token.

If client is nil, the http.DefaultClient will be used.

type LoginType added in v1.13.0

type LoginType string

LoginType defines the enum of valid user login types.

const (
	LoginTypeBuiltIn LoginType = "built-in"
	LoginTypeSAML    LoginType = "saml"
	LoginTypeOIDC    LoginType = "oidc"
)

LoginType enum options.

type NewRegistryRequest added in v1.11.0

type NewRegistryRequest struct {
	FriendlyName string `json:"friendly_name"`
	Registry     string `json:"registry"`
	Username     string `json:"username"`
	Password     string `json:"password"`
}

NewRegistryRequest describes a docker registry used in importing an image.

type OSRelease added in v1.13.0

type OSRelease struct {
	ID         string `json:"id"`
	PrettyName string `json:"pretty_name"`
	HomeURL    string `json:"home_url"`
}

OSRelease is the marshalled /etc/os-release file.

func (OSRelease) String added in v1.13.0

func (o OSRelease) String() string

type Organization added in v1.12.0

type Organization struct {
	ID                     string             `json:"id"`
	Name                   string             `json:"name"`
	Description            string             `json:"description"`
	Default                bool               `json:"default"`
	Members                []OrganizationUser `json:"members"`
	WorkspaceCount         int                `json:"workspace_count"`
	ResourceNamespace      string             `json:"resource_namespace"`
	CreatedAt              time.Time          `json:"created_at"`
	UpdatedAt              time.Time          `json:"updated_at"`
	AutoOffThreshold       Duration           `json:"auto_off_threshold"`
	CPUProvisioningRate    float32            `json:"cpu_provisioning_rate"`
	MemoryProvisioningRate float32            `json:"memory_provisioning_rate"`
}

Organization describes an Organization in Coder.

type OrganizationUser added in v1.12.0

type OrganizationUser struct {
	User
	OrganizationRoles []Role    `json:"organization_roles"`
	RolesUpdatedAt    time.Time `json:"roles_updated_at"`
}

OrganizationUser user wraps the basic User type and adds data specific to the user's membership of an organization.

type ParseTemplateRequest added in v1.16.0

type ParseTemplateRequest struct {
	RepoURL  string    `json:"repo_url"`
	Ref      string    `json:"ref"`
	Filepath string    `json:"filepath"`
	OrgID    string    `json:"-"`
	Local    io.Reader `json:"-"`
}

ParseTemplateRequest parses a template. If Local is a non-nil reader it will obviate any other fields on the request.

type PutDevURLReq added in v1.13.0

type PutDevURLReq CreateDevURLReq

PutDevURLReq defines the request parameters for overwriting a DevURL.

type RebuildMessage added in v1.11.0

type RebuildMessage struct {
	Text             string   `json:"text"`
	Required         bool     `json:"required"`
	AutoOffThreshold Duration `json:"auto_off_threshold"`
}

RebuildMessage defines the message shown when a Workspace requires a rebuild for it can be accessed.

type Registry added in v1.13.0

type Registry struct {
	ID             string    `json:"id"`
	OrganizationID string    `json:"organization_id"`
	FriendlyName   string    `json:"friendly_name"`
	Registry       string    `json:"registry"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

Registry defines an image registry configuration.

type RenameWorkspaceProviderReq added in v1.18.0

type RenameWorkspaceProviderReq struct {
	Name string `json:"name"`
}

RenameWorkspaceProviderReq defines the request parameters for changing a workspace provider name.

type Role added in v1.13.0

type Role string

Role defines a Coder permissions role group.

const (
	RoleOrgMember  Role = "organization-member"
	RoleOrgAdmin   Role = "organization-admin"
	RoleOrgManager Role = "organization-manager"
)

Organization Roles.

const (
	SiteAdmin   Role = "site-admin"
	SiteAuditor Role = "site-auditor"
	SiteManager Role = "site-manager"
	SiteMember  Role = "site-member"
)

Site Roles.

type SSHKey

type SSHKey struct {
	PublicKey  string `json:"public_key"`
	PrivateKey string `json:"private_key"`
}

SSHKey describes an SSH keypair.

type Satellite added in v1.21.0

type Satellite struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Fingerprint string `json:"fingerprint"`
}

type SetPolicyTemplateRequest added in v1.21.0

type SetPolicyTemplateRequest struct {
	TemplateID string `json:"template_id"`
	Type       string `json:"type"` // site, org
}

type SetPolicyTemplateResponse added in v1.21.0

type SetPolicyTemplateResponse struct {
	MergeConflicts []*WorkspaceTemplateMergeConflict `json:"merge_conflicts"`
}

type TemplateScope added in v1.21.0

type TemplateScope string

type TemplateVersion added in v1.17.0

type TemplateVersion struct {
	ID         string `json:"id"`
	TemplateID string `json:"template_id"`
	// FileHash is the sha256 hash of the template's file contents.
	FileHash string `json:"file_hash"`
	// Commit is the git commit from which the template was derived.
	Commit        string    `json:"commit"`
	CommitMessage string    `json:"commit_message"`
	CreatedAt     time.Time `json:"created_at"`
}

TemplateVersion is a workspace template. For now, let's not interpret it on the CLI level. We just need to forward this as part of the create workspace request.

type TplError added in v1.21.0

type TplError struct {
	// Msgs are the human facing strings to present to the user. Since there can be multiple
	// problems with a template, there might be multiple strings
	Msgs []string `json:"messages"`
}

type UpdateImageReq added in v1.13.2

type UpdateImageReq struct {
	DefaultCPUCores *float32 `json:"default_cpu_cores"`
	DefaultMemoryGB *float32 `json:"default_memory_gb"`
	DefaultDiskGB   *int     `json:"default_disk_gb"`
	Description     *string  `json:"description"`
	URL             *string  `json:"url"`
	Deprecated      *bool    `json:"deprecated"`
	DefaultTag      *string  `json:"default_tag"`
}

UpdateImageReq defines the requests parameters for a partial update of an image resource.

type UpdateOrganizationReq added in v1.13.0

type UpdateOrganizationReq struct {
	Name                   *string   `json:"name"`
	Description            *string   `json:"description"`
	Default                *bool     `json:"default"`
	AutoOffThreshold       *Duration `json:"auto_off_threshold"`
	CPUProvisioningRate    *float32  `json:"cpu_provisioning_rate"`
	MemoryProvisioningRate *float32  `json:"memory_provisioning_rate"`
}

UpdateOrganizationReq describes the patch request parameters to provide partial updates to an Organization resource.

type UpdateRegistryReq added in v1.13.0

type UpdateRegistryReq struct {
	Registry     *string `json:"registry"`
	FriendlyName *string `json:"friendly_name"`
	Username     *string `json:"username"`
	Password     *string `json:"password"`
}

UpdateRegistryReq defines the requests parameters for a partial update of a registry resource.

type UpdateUserReq added in v1.13.0

type UpdateUserReq struct {
	*UserPasswordSettings
	Revoked        *bool      `json:"revoked,omitempty"`
	Roles          *[]Role    `json:"roles,omitempty"`
	LoginType      *LoginType `json:"login_type,omitempty"`
	Name           *string    `json:"name,omitempty"`
	Username       *string    `json:"username,omitempty"`
	Email          *string    `json:"email,omitempty"`
	DotfilesGitURL *string    `json:"dotfiles_git_uri,omitempty"`
}

UpdateUserReq defines a modification to the user, updating the value of all non-nil values.

type UpdateWorkspaceReq added in v1.20.0

type UpdateWorkspaceReq struct {
	ImageID    *string  `json:"image_id"`
	ImageTag   *string  `json:"image_tag"`
	CPUCores   *float32 `json:"cpu_cores"`
	MemoryGB   *float32 `json:"memory_gb"`
	DiskGB     *int     `json:"disk_gb"`
	GPUs       *int     `json:"gpus"`
	TemplateID *string  `json:"template_id"`
}

UpdateWorkspaceReq defines the update operation, only setting nil-fields.

type User

type User struct {
	ID                string    `json:"id"                 table:"-"`
	Email             string    `json:"email"              table:"Email"`
	Username          string    `json:"username"           table:"Username"`
	Name              string    `json:"name"               table:"Name"`
	Roles             []Role    `json:"roles"              table:"-"`
	TemporaryPassword bool      `json:"temporary_password" table:"-"`
	LoginType         string    `json:"login_type"         table:"-"`
	KeyRegeneratedAt  time.Time `json:"key_regenerated_at" table:"-"`
	CreatedAt         time.Time `json:"created_at"         table:"CreatedAt"`
	UpdatedAt         time.Time `json:"updated_at"         table:"-"`
}

User describes a Coder user account.

type UserPasswordSettings added in v1.17.0

type UserPasswordSettings struct {
	// OldPassword is the account's current password.
	OldPassword string `json:"old_password,omitempty"`

	// Password is the new password, which may be a temporary password.
	Password string `json:"password,omitempty"`

	// Temporary indicates that API access should be restricted to the
	// password change API and a few other APIs. If set to true, Coder
	// will prompt the user to change their password upon their next
	// login through the web interface.
	Temporary bool `json:"temporary_password,omitempty"`
}

UserPasswordSettings allows modification of the user's password settings.

These settings are only applicable to users managed using the built-in authentication provider; users authenticating using OAuth must change their password through the identity provider instead.

type Workspace added in v1.16.0

type Workspace struct {
	ID               string           `json:"id"                 table:"-"`
	Name             string           `json:"name"               table:"Name"`
	ImageID          string           `json:"image_id"           table:"-"`
	ImageTag         string           `json:"image_tag"          table:"ImageTag"`
	OrganizationID   string           `json:"organization_id"    table:"-"`
	UserID           string           `json:"user_id"            table:"-"`
	LastBuiltAt      time.Time        `json:"last_built_at"      table:"-"`
	CPUCores         float32          `json:"cpu_cores"          table:"CPUCores"`
	MemoryGB         float32          `json:"memory_gb"          table:"MemoryGB"`
	DiskGB           int              `json:"disk_gb"            table:"DiskGB"`
	GPUs             int              `json:"gpus"               table:"-"`
	Updating         bool             `json:"updating"           table:"-"`
	LatestStat       WorkspaceStat    `json:"latest_stat"        table:"Status"`
	RebuildMessages  []RebuildMessage `json:"rebuild_messages"   table:"-"`
	CreatedAt        time.Time        `json:"created_at"         table:"-"`
	UpdatedAt        time.Time        `json:"updated_at"         table:"-"`
	LastOpenedAt     time.Time        `json:"last_opened_at"     table:"-"`
	LastConnectionAt time.Time        `json:"last_connection_at" table:"-"`
	AutoOffThreshold Duration         `json:"auto_off_threshold" table:"-"`
	UseContainerVM   bool             `json:"use_container_vm"   table:"CVM"`
	ResourcePoolID   string           `json:"resource_pool_id"   table:"-"`
}

Workspace describes a Coder workspace.

type WorkspaceProviderStatus added in v1.16.0

type WorkspaceProviderStatus string

WorkspaceProviderStatus represents the configuration state of a workspace provider.

const (
	WorkspaceProviderPending WorkspaceProviderStatus = "pending"
	WorkspaceProviderReady   WorkspaceProviderStatus = "ready"
)

Workspace Provider statuses.

type WorkspaceProviderType added in v1.17.0

type WorkspaceProviderType string

WorkspaceProviderType represents the type of workspace provider.

const (
	WorkspaceProviderKubernetes WorkspaceProviderType = "kubernetes"
)

Workspace Provider types.

type WorkspaceProviders added in v1.17.0

type WorkspaceProviders struct {
	Kubernetes []KubernetesProvider `json:"kubernetes"`
}

WorkspaceProviders defines all available Coder workspace provider targets.

type WorkspaceStat added in v1.20.0

type WorkspaceStat struct {
	Time            time.Time       `json:"time"`
	LastOnline      time.Time       `json:"last_online"`
	ContainerStatus WorkspaceStatus `json:"container_status"`
	StatError       string          `json:"stat_error"`
	CPUUsage        float32         `json:"cpu_usage"`
	MemoryTotal     int64           `json:"memory_total"`
	MemoryUsage     float32         `json:"memory_usage"`
	DiskTotal       int64           `json:"disk_total"`
	DiskUsed        int64           `json:"disk_used"`
}

WorkspaceStat represents the state of a workspace.

func (WorkspaceStat) String added in v1.20.0

func (e WorkspaceStat) String() string

type WorkspaceStatus added in v1.20.0

type WorkspaceStatus string

WorkspaceStatus refers to the states of a workspace.

const (
	WorkspaceCreating WorkspaceStatus = "CREATING"
	WorkspaceOff      WorkspaceStatus = "OFF"
	WorkspaceOn       WorkspaceStatus = "ON"
	WorkspaceFailed   WorkspaceStatus = "FAILED"
	WorkspaceUnknown  WorkspaceStatus = "UNKNOWN"
)

The following represent the possible workspace container states.

type WorkspaceTemplateMergeConflict added in v1.21.0

type WorkspaceTemplateMergeConflict struct {
	WorkspaceID             string    `json:"workspace_id"`
	CurrentTemplateWarnings []string  `json:"current_template_warnings"`
	CurrentTemplateError    *TplError `json:"current_template_errors"`
	LatestTemplateWarnings  []string  `json:"latest_template_warnings"`
	LatestTemplateError     *TplError `json:"latest_template_errors"`
	CurrentTemplateIsLatest bool      `json:"current_template_is_latest"`
	Message                 string    `json:"message"`
}

func (WorkspaceTemplateMergeConflict) String added in v1.21.0

type WorkspaceTemplateMergeConflicts added in v1.21.0

type WorkspaceTemplateMergeConflicts []*WorkspaceTemplateMergeConflict

func (WorkspaceTemplateMergeConflicts) Summary added in v1.21.0

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL