coder

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: GPL-3.0 Imports: 14 Imported by: 1

README

coder-sdk

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

Documentation

Overview

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

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.

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 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 Enterprise 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"`
	EnvironmentID string `db:"environment_id" json:"environment_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 environment.

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 an environment.
	// It can be thought of as a major step in the environment'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 struct {
	BaseURL *url.URL
	Token   string
}

Client wraps the Coder HTTP API.

func (Client) APITokenByID added in v1.13.0

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

APITokenByID fetches the metadata for a given APIToken.

func (Client) APITokens added in v1.13.0

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

APITokens fetches all APITokens owned by the given user.

func (Client) APIVersion added in v1.12.3

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

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

func (Client) CreateAPIToken added in v1.13.0

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

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

func (Client) CreateDevURL added in v1.13.0

func (c Client) CreateDevURL(ctx context.Context, envID string, req CreateDevURLReq) error

CreateDevURL inserts a new devurl for the authenticated user.

func (Client) CreateEnvironment added in v1.11.0

func (c Client) CreateEnvironment(ctx context.Context, orgID string, req CreateEnvironmentRequest) (*Environment, error)

CreateEnvironment sends a request to create an environment.

func (Client) CreateImageTag added in v1.13.0

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

CreateImageTag creates a new image tag resource.

func (Client) CreateOrganization added in v1.13.0

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

CreateOrganization creates a new Organization in Coder Enterprise.

func (Client) CreateUser added in v1.13.0

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

CreateUser creates a new user account.

func (Client) DeleteAPIToken added in v1.13.0

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

DeleteAPIToken deletes an APIToken.

func (Client) DeleteDevURL added in v1.13.0

func (c Client) DeleteDevURL(ctx context.Context, envID, urlID string) error

DeleteDevURL deletes the specified devurl.

func (Client) DeleteEnvironment added in v1.11.0

func (c Client) DeleteEnvironment(ctx context.Context, envID string) error

DeleteEnvironment deletes the environment.

func (Client) DeleteImageTag added in v1.13.0

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

DeleteImageTag deletes an image tag resource.

func (Client) DeleteOrganization added in v1.13.0

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

DeleteOrganization deletes an organization.

func (Client) DeleteRegistry added in v1.13.0

func (c Client) DeleteRegistry(ctx context.Context, orgID, registryID string) error

DeleteRegistry deletes a registry resource by its ID.

func (Client) DeleteSecretByName deprecated

func (c Client) DeleteSecretByName(ctx context.Context, name, userID string) error

DeleteSecretByName deletes the authenticated users secret with the given name.

Deprecated: Coder Secrets will be removed from Coder Enterprise in a future release.

func (Client) DeleteUser added in v1.13.0

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

DeleteUser deletes a user account.

func (Client) DevURLs added in v1.14.0

func (c Client) DevURLs(ctx context.Context, envID string) ([]DevURL, error)

DevURLs fetches the Dev URLs for a given environment.

func (Client) DialEnvironmentBuildLog added in v1.11.0

func (c Client) DialEnvironmentBuildLog(ctx context.Context, envID string) (*websocket.Conn, error)

DialEnvironmentBuildLog opens a websocket connection for the environment build log messages.

func (Client) DialEnvironmentStats added in v1.11.0

func (c Client) DialEnvironmentStats(ctx context.Context, envID string) (*websocket.Conn, error)

DialEnvironmentStats opens a websocket connection for environment stats.

func (Client) DialExecutor added in v1.13.0

func (c Client) DialExecutor(ctx context.Context, envID string) (wsep.Execer, error)

DialExecutor gives a remote execution interface for performing commands inside an environment.

func (Client) DialIDEStatus added in v1.11.0

func (c Client) DialIDEStatus(ctx context.Context, envID string) (*websocket.Conn, error)

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

func (Client) DialResourceLoad added in v1.11.0

func (c Client) DialResourceLoad(ctx context.Context, envID string) (*websocket.Conn, error)

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

func (Client) DialWsep

func (c Client) DialWsep(ctx context.Context, envID string) (*websocket.Conn, error)

DialWsep dials an environments command execution interface See https://github.com/cdr/wsep for details.

func (Client) EditEnvironment added in v1.12.0

func (c Client) EditEnvironment(ctx context.Context, envID string, req UpdateEnvironmentReq) error

EditEnvironment modifies the environment specification and initiates a rebuild.

func (Client) Environments added in v1.12.0

func (c Client) Environments(ctx context.Context) ([]Environment, error)

Environments lists environments returned by the given filter. TODO: add the filter options, explore performance issue.

func (Client) EnvironmentsByOrganization

func (c Client) EnvironmentsByOrganization(ctx context.Context, userID, orgID string) ([]Environment, error)

EnvironmentsByOrganization gets the list of environments owned by the given user.

func (Client) FollowEnvironmentBuildLog added in v1.12.0

func (c Client) FollowEnvironmentBuildLog(ctx context.Context, envID string) (<-chan BuildLogFollowMsg, error)

FollowEnvironmentBuildLog trails the build log of a Coder environment.

func (Client) ImageTagByID added in v1.13.0

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

ImageTagByID fetch an image tag by ID.

func (Client) ImageTags added in v1.13.0

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

ImageTags fetch all image tags.

func (Client) ImportImage added in v1.11.0

func (c Client) ImportImage(ctx context.Context, orgID string, req ImportImageReq) (*Image, error)

ImportImage creates a new image and optionally a new registry.

func (Client) InsertSecret deprecated

func (c Client) InsertSecret(ctx context.Context, userID string, req InsertSecretReq) error

InsertSecret adds a new secret for the authed user.

Deprecated: Coder Secrets will be removed from Coder Enterprise in a future release.

func (Client) Me

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

Me gets the details of the authenticated user.

func (Client) OrganizationByID added in v1.13.0

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

OrganizationByID get the Organization by its ID.

func (Client) OrganizationImages added in v1.12.3

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

OrganizationImages returns all of the images imported for orgID.

func (Client) OrganizationMembers added in v1.13.0

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

OrganizationMembers get all members of the given organization.

func (Client) Organizations added in v1.12.0

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

Organizations gets all Organizations.

func (Client) PushActivity

func (c Client) PushActivity(ctx context.Context, source, envID string) error

PushActivity pushes CLI activity to Coder.

func (Client) PutDevURL added in v1.13.0

func (c Client) PutDevURL(ctx context.Context, envID, urlID string, req PutDevURLReq) error

PutDevURL updates an existing devurl for the authenticated user.

func (Client) PutSiteConfigAuth added in v1.13.0

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

PutSiteConfigAuth sets the sitewide authentication configuration.

func (Client) PutSiteConfigExtensionMarketplace added in v1.13.0

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

PutSiteConfigExtensionMarketplace sets the extension marketplace configuration.

func (Client) PutSiteConfigOAuth added in v1.13.0

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

PutSiteConfigOAuth sets the sitewide git provider OAuth configuration.

func (Client) RebuildEnvironment added in v1.12.0

func (c Client) RebuildEnvironment(ctx context.Context, envID string) error

RebuildEnvironment requests that the given envID is rebuilt with no changes to its specification.

func (Client) RegenerateAPIToken added in v1.13.0

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

RegenerateAPIToken regenerates the given APIToken and returns the new value.

func (Client) Registries added in v1.13.0

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

Registries fetches all registries in an organization.

func (Client) RegistryByID added in v1.13.0

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

RegistryByID fetches a registry resource by its ID.

func (Client) SSHKey

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

SSHKey gets the current SSH kepair of the authenticated user.

func (Client) SecretByName deprecated

func (c Client) SecretByName(ctx context.Context, name, userID string) (*Secret, error)

SecretByName gets a secret object by name.

Deprecated: Coder Secrets will be removed from Coder Enterprise in a future release.

func (Client) SecretWithValueByID deprecated

func (c Client) SecretWithValueByID(ctx context.Context, id, userID string) (*Secret, error)

SecretWithValueByID gets the Coder secret with its value by the secret_id.

Deprecated: Coder Secrets will be removed from Coder Enterprise in a future release.

func (Client) SecretWithValueByName deprecated

func (c Client) SecretWithValueByName(ctx context.Context, name, userID string) (*Secret, error)

SecretWithValueByName gets the Coder secret with its value by its name.

Deprecated: Coder Secrets will be removed from Coder Enterprise in a future release.

func (Client) Secrets deprecated

func (c Client) Secrets(ctx context.Context, userID string) ([]Secret, error)

Secrets gets all secrets for the given user.

Deprecated: Coder Secrets will be removed from Coder Enterprise in a future release.

func (Client) SiteConfigAuth added in v1.13.0

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

SiteConfigAuth fetches the sitewide authentication configuration.

func (Client) SiteConfigExtensionMarketplace added in v1.13.0

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

SiteConfigExtensionMarketplace fetches the extension marketplace configuration.

func (Client) SiteConfigOAuth added in v1.13.0

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

SiteConfigOAuth fetches the sitewide git provider OAuth configuration.

func (Client) SiteSetupModeEnabled added in v1.13.0

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

SiteSetupModeEnabled fetches the current setup_mode state of a Coder Enterprise deployment.

func (Client) StopEnvironment added in v1.12.0

func (c Client) StopEnvironment(ctx context.Context, envID string) error

StopEnvironment stops the stops.

func (Client) UpdateImage added in v1.13.2

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

UpdateImage applies a partial update to an image resource.

func (Client) UpdateImageTags added in v1.14.0

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

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

func (Client) UpdateOrganization added in v1.13.0

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

UpdateOrganization applys a partial update of an Organization resource.

func (Client) UpdateRegistry added in v1.13.0

func (c Client) UpdateRegistry(ctx context.Context, orgID, registryID string, req UpdateRegistryReq) error

UpdateRegistry applies a partial update to a registry resource.

func (Client) UpdateUXState added in v1.14.0

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

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

func (Client) UpdateUser added in v1.13.0

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

UpdateUser applyes the partial update to the given user.

func (Client) UserByEmail

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

UserByEmail gets a user by email.

func (Client) UserByID

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

UserByID get the details of a user by their id.

func (Client) Users

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

Users gets the list of user accounts.

func (Client) WaitForEnvironmentReady added in v1.11.0

func (c Client) WaitForEnvironmentReady(ctx context.Context, envID string) error

WaitForEnvironmentReady will watch the build log and return when done.

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 Enterprise deployment.

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 Enterprise 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 Enterprise 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 Enterprise 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 Enterprise 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 Enterprise.

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 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 {
	EnvID  string `json:"environment_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 CreateEnvironmentRequest added in v1.11.0

type CreateEnvironmentRequest struct {
	Name           string   `json:"name"`
	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"`
	Services       []string `json:"services"`
	UseContainerVM bool     `json:"use_container_vm"`
}

CreateEnvironmentRequest is used to configure a new environment.

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 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 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 Environment

type Environment 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:"GPUs"`
	Updating         bool             `json:"updating"           table:"Updating"`
	LatestStat       EnvironmentStat  `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:"-"`
	SSHAvailable     bool             `json:"ssh_available"      table:"-"`
	UseContainerVM   bool             `json:"use_container_vm"   table:"CVM"`
}

Environment describes a Coder environment.

type EnvironmentStat added in v1.11.0

type EnvironmentStat struct {
	Time            time.Time         `json:"time"`
	LastOnline      time.Time         `json:"last_online"`
	ContainerStatus EnvironmentStatus `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"`
}

EnvironmentStat represents the state of an environment.

func (EnvironmentStat) String added in v1.11.0

func (e EnvironmentStat) String() string

type EnvironmentStatus added in v1.11.0

type EnvironmentStatus string

EnvironmentStatus refers to the states of an environment.

const (
	EnvironmentCreating EnvironmentStatus = "CREATING"
	EnvironmentOff      EnvironmentStatus = "OFF"
	EnvironmentOn       EnvironmentStatus = "ON"
	EnvironmentFailed   EnvironmentStatus = "FAILED"
	EnvironmentUnknown  EnvironmentStatus = "UNKNOWN"
)

The following represent the possible environment container states.

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 {
	*http.Response
}

HTTPError represents an error from the Coder API.

func (*HTTPError) Error added in v1.12.0

func (e *HTTPError) Error() string

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"`
	Environments      []*Environment `json:"environments"         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".
	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 InsertSecretReq deprecated

type InsertSecretReq struct {
	Name        string `json:"name"`
	Value       string `json:"value"`
	Description string `json:"description"`
}

InsertSecretReq describes the request body for creating a new secret.

Deprecated: Coder Secrets will be removed from Coder Enterprise in a future release.

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"`
	EnvironmentCount       int                `json:"environment_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 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 an Environment 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 Role added in v1.13.0

type Role string

Role defines a Coder Enterprise 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 Secret deprecated

type Secret struct {
	ID          string    `json:"id"              table:"-"`
	Name        string    `json:"name"            table:"Name"`
	Value       string    `json:"value,omitempty" table:"Value"`
	Description string    `json:"description"     table:"Description"`
	CreatedAt   time.Time `json:"created_at"      table:"CreatedAt"`
	UpdatedAt   time.Time `json:"updated_at"      table:"-"`
}

Secret describes a Coder secret.

Deprecated: Coder Secrets will be removed from Coder Enterprise in a future release.

type UpdateEnvironmentReq added in v1.12.0

type UpdateEnvironmentReq 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"`
	Services             *[]string `json:"services"`
	CodeServerReleaseURL *string   `json:"code_server_release_url"`
}

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

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 {
	// TODO(@cmoog) add update password option
	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 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.

Jump to

Keyboard shortcuts

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