The API reference is generated from Swagger comments and struct tags, and several `enums:"..."` tags narrowed a named enum type, so the docs omitted values the server returns. For example, `User.status` listed only `active` and `suspended`, not `dormant`, and `TemplateVersion.warnings` listed `DEPRECATED_PARAMETERS`, which is not a value of the type. Remove 34 `enums` tags that narrow or duplicate a named type so the referenced type's full value list is used. Tags that describe an intentional subset stay: ACL role fields (which omit the `""` deleted sentinel used only in update requests), `APIKey.scope`, and plain-string fields. `Template.provisioner` keeps its tag because `.swaggo` replaces `ProvisionerType` with `string`. Also fix enum defects that break code generators: - The provisioner jobs and daemons `status` query parameters listed their enum twice (Swagger 2.0 requires unique `enum` items) or with the wrong type. Both are now `[]codersdk.ProvisionerJobStatus` and `[]codersdk.ProvisionerDaemonStatus`, matching what each handler parses, including comma-separated values. The daemons route previously documented job statuses, which the handler rejects with a 500. - Replace the `_` zero placeholder of `WatchErrorCode` with `iota + 1`, so the spec no longer lists 0 or `x-enum-varnames: ["_", ...]`. Wire values are unchanged. Where the narrowed tag hid values the server returns, the SDK type now includes them: `LoginTypeOAuth2ProviderApp`, `BuildReasonAutodelete`, and `MissingTemplateParameter` widen the generated TypeScript unions. The dashboard attributes `autodelete` builds to Coder like other system builds. `APIKey.login_type` and `AuthorizationCheck.action` set explicit examples so the generated samples stay representative. `TestSwaggerEnumsNotNarrowed` fails when a property's enum list drops values of its named type (other than the 15 allowlisted intentional subsets), lists a value the type lacks, or repeats a value. Part of DOCS-1122, split from #30121. --- 🤖 Built with AI assistance.
129 lines
4.9 KiB
Go
129 lines
4.9 KiB
Go
package codersdk
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type WorkspaceAppHealth string
|
|
|
|
const (
|
|
WorkspaceAppHealthDisabled WorkspaceAppHealth = "disabled"
|
|
WorkspaceAppHealthInitializing WorkspaceAppHealth = "initializing"
|
|
WorkspaceAppHealthHealthy WorkspaceAppHealth = "healthy"
|
|
WorkspaceAppHealthUnhealthy WorkspaceAppHealth = "unhealthy"
|
|
)
|
|
|
|
type WorkspaceAppStatusState string
|
|
|
|
const (
|
|
WorkspaceAppStatusStateWorking WorkspaceAppStatusState = "working"
|
|
WorkspaceAppStatusStateIdle WorkspaceAppStatusState = "idle"
|
|
WorkspaceAppStatusStateComplete WorkspaceAppStatusState = "complete"
|
|
WorkspaceAppStatusStateFailure WorkspaceAppStatusState = "failure"
|
|
)
|
|
|
|
var MapWorkspaceAppHealths = map[WorkspaceAppHealth]struct{}{
|
|
WorkspaceAppHealthDisabled: {},
|
|
WorkspaceAppHealthInitializing: {},
|
|
WorkspaceAppHealthHealthy: {},
|
|
WorkspaceAppHealthUnhealthy: {},
|
|
}
|
|
|
|
type WorkspaceAppSharingLevel string
|
|
|
|
const (
|
|
WorkspaceAppSharingLevelOwner WorkspaceAppSharingLevel = "owner"
|
|
WorkspaceAppSharingLevelAuthenticated WorkspaceAppSharingLevel = "authenticated"
|
|
WorkspaceAppSharingLevelOrganization WorkspaceAppSharingLevel = "organization"
|
|
WorkspaceAppSharingLevelPublic WorkspaceAppSharingLevel = "public"
|
|
)
|
|
|
|
var MapWorkspaceAppSharingLevels = map[WorkspaceAppSharingLevel]struct{}{
|
|
WorkspaceAppSharingLevelOwner: {},
|
|
WorkspaceAppSharingLevelAuthenticated: {},
|
|
WorkspaceAppSharingLevelOrganization: {},
|
|
WorkspaceAppSharingLevelPublic: {},
|
|
}
|
|
|
|
type WorkspaceAppOpenIn string
|
|
|
|
const (
|
|
WorkspaceAppOpenInSlimWindow WorkspaceAppOpenIn = "slim-window"
|
|
WorkspaceAppOpenInTab WorkspaceAppOpenIn = "tab"
|
|
)
|
|
|
|
var MapWorkspaceAppOpenIns = map[WorkspaceAppOpenIn]struct{}{
|
|
WorkspaceAppOpenInSlimWindow: {},
|
|
WorkspaceAppOpenInTab: {},
|
|
}
|
|
|
|
type WorkspaceApp struct {
|
|
ID uuid.UUID `json:"id" format:"uuid"`
|
|
// URL is the address being proxied to inside the workspace.
|
|
// If external is specified, this will be opened on the client.
|
|
URL string `json:"url,omitempty"`
|
|
// External specifies whether the URL should be opened externally on
|
|
// the client or not.
|
|
External bool `json:"external"`
|
|
// Slug is a unique identifier within the agent.
|
|
Slug string `json:"slug"`
|
|
// DisplayName is a friendly name for the app.
|
|
DisplayName string `json:"display_name,omitempty"`
|
|
Command string `json:"command,omitempty"`
|
|
// Icon is a relative path or external URL that specifies
|
|
// an icon to be displayed in the dashboard.
|
|
Icon string `json:"icon,omitempty"`
|
|
// Subdomain denotes whether the app should be accessed via a path on the
|
|
// `coder server` or via a hostname-based dev URL. If this is set to true
|
|
// and there is no app wildcard configured on the server, the app will not
|
|
// be accessible in the UI.
|
|
Subdomain bool `json:"subdomain"`
|
|
// SubdomainName is the application domain exposed on the `coder server`.
|
|
SubdomainName string `json:"subdomain_name,omitempty"`
|
|
SharingLevel WorkspaceAppSharingLevel `json:"sharing_level"`
|
|
// Healthcheck specifies the configuration for checking app health.
|
|
Healthcheck Healthcheck `json:"healthcheck,omitempty"`
|
|
Health WorkspaceAppHealth `json:"health"`
|
|
Group string `json:"group,omitempty"`
|
|
Hidden bool `json:"hidden"`
|
|
OpenIn WorkspaceAppOpenIn `json:"open_in"`
|
|
// Tooltip is an optional markdown supported field that is displayed
|
|
// when hovering over workspace apps in the UI.
|
|
Tooltip string `json:"tooltip,omitempty"`
|
|
|
|
// Statuses is a list of statuses for the app.
|
|
Statuses []WorkspaceAppStatus `json:"statuses"`
|
|
}
|
|
|
|
type Healthcheck struct {
|
|
// URL specifies the endpoint to check for the app health.
|
|
URL string `json:"url"`
|
|
// Interval specifies the seconds between each health check.
|
|
Interval int32 `json:"interval"`
|
|
// Threshold specifies the number of consecutive failed health checks before returning "unhealthy".
|
|
Threshold int32 `json:"threshold"`
|
|
}
|
|
|
|
type WorkspaceAppStatus struct {
|
|
ID uuid.UUID `json:"id" format:"uuid"`
|
|
CreatedAt time.Time `json:"created_at" format:"date-time"`
|
|
WorkspaceID uuid.UUID `json:"workspace_id" format:"uuid"`
|
|
AgentID uuid.UUID `json:"agent_id" format:"uuid"`
|
|
AppID uuid.UUID `json:"app_id" format:"uuid"`
|
|
State WorkspaceAppStatusState `json:"state"`
|
|
Message string `json:"message"`
|
|
// URI is the URI of the resource that the status is for.
|
|
// e.g. https://github.com/org/repo/pull/123
|
|
// e.g. file:///path/to/file
|
|
URI string `json:"uri"`
|
|
|
|
// Deprecated: This field is unused and will be removed in a future version.
|
|
// Icon is an external URL to an icon that will be rendered in the UI.
|
|
Icon string `json:"icon"`
|
|
// Deprecated: This field is unused and will be removed in a future version.
|
|
// NeedsUserAttention specifies whether the status needs user attention.
|
|
NeedsUserAttention bool `json:"needs_user_attention"`
|
|
}
|