mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: rename locked to dormant (#9290)
* chore: rename locked to dormant - The following columns have been updated: - workspace.locked_at -> dormant_at - template.inactivity_ttl -> time_til_dormant - template.locked_ttl -> time_til_dormant_autodelete This change has also been reflected in the SDK. A route has also been updated from /workspaces/<id>/lock to /workspaces/<id>/dormant
This commit is contained in:
@@ -108,12 +108,12 @@ type CreateTemplateRequest struct {
|
||||
// FailureTTLMillis allows optionally specifying the max lifetime before Coder
|
||||
// stops all resources for failed workspaces created from this template.
|
||||
FailureTTLMillis *int64 `json:"failure_ttl_ms,omitempty"`
|
||||
// InactivityTTLMillis allows optionally specifying the max lifetime before Coder
|
||||
// TimeTilDormantMillis allows optionally specifying the max lifetime before Coder
|
||||
// locks inactive workspaces created from this template.
|
||||
InactivityTTLMillis *int64 `json:"inactivity_ttl_ms,omitempty"`
|
||||
// LockedTTLMillis allows optionally specifying the max lifetime before Coder
|
||||
// permanently deletes locked workspaces created from this template.
|
||||
LockedTTLMillis *int64 `json:"locked_ttl_ms,omitempty"`
|
||||
TimeTilDormantMillis *int64 `json:"dormant_ttl_ms,omitempty"`
|
||||
// TimeTilDormantAutoDeleteMillis allows optionally specifying the max lifetime before Coder
|
||||
// permanently deletes dormant workspaces created from this template.
|
||||
TimeTilDormantAutoDeleteMillis *int64 `json:"delete_ttl_ms,omitempty"`
|
||||
|
||||
// DisableEveryoneGroupAccess allows optionally disabling the default
|
||||
// behavior of granting the 'everyone' group access to use the template.
|
||||
|
||||
+15
-15
@@ -44,12 +44,12 @@ type Template struct {
|
||||
AllowUserAutostop bool `json:"allow_user_autostop"`
|
||||
AllowUserCancelWorkspaceJobs bool `json:"allow_user_cancel_workspace_jobs"`
|
||||
|
||||
// FailureTTLMillis, InactivityTTLMillis, and LockedTTLMillis are enterprise-only. Their
|
||||
// FailureTTLMillis, TimeTilDormantMillis, and TimeTilDormantAutoDeleteMillis are enterprise-only. Their
|
||||
// values are used if your license is entitled to use the advanced
|
||||
// template scheduling feature.
|
||||
FailureTTLMillis int64 `json:"failure_ttl_ms"`
|
||||
InactivityTTLMillis int64 `json:"inactivity_ttl_ms"`
|
||||
LockedTTLMillis int64 `json:"locked_ttl_ms"`
|
||||
FailureTTLMillis int64 `json:"failure_ttl_ms"`
|
||||
TimeTilDormantMillis int64 `json:"time_til_dormant_ms"`
|
||||
TimeTilDormantAutoDeleteMillis int64 `json:"time_til_dormant_autodelete_ms"`
|
||||
}
|
||||
|
||||
// WeekdaysToBitmap converts a list of weekdays to a bitmap in accordance with
|
||||
@@ -185,22 +185,22 @@ type UpdateTemplateMeta struct {
|
||||
// RestartRequirement can only be set if your license includes the advanced
|
||||
// template scheduling feature. If you attempt to set this value while
|
||||
// unlicensed, it will be ignored.
|
||||
RestartRequirement *TemplateRestartRequirement `json:"restart_requirement,omitempty"`
|
||||
AllowUserAutostart bool `json:"allow_user_autostart,omitempty"`
|
||||
AllowUserAutostop bool `json:"allow_user_autostop,omitempty"`
|
||||
AllowUserCancelWorkspaceJobs bool `json:"allow_user_cancel_workspace_jobs,omitempty"`
|
||||
FailureTTLMillis int64 `json:"failure_ttl_ms,omitempty"`
|
||||
InactivityTTLMillis int64 `json:"inactivity_ttl_ms,omitempty"`
|
||||
LockedTTLMillis int64 `json:"locked_ttl_ms,omitempty"`
|
||||
RestartRequirement *TemplateRestartRequirement `json:"restart_requirement,omitempty"`
|
||||
AllowUserAutostart bool `json:"allow_user_autostart,omitempty"`
|
||||
AllowUserAutostop bool `json:"allow_user_autostop,omitempty"`
|
||||
AllowUserCancelWorkspaceJobs bool `json:"allow_user_cancel_workspace_jobs,omitempty"`
|
||||
FailureTTLMillis int64 `json:"failure_ttl_ms,omitempty"`
|
||||
TimeTilDormantMillis int64 `json:"time_til_dormant_ms,omitempty"`
|
||||
TimeTilDormantAutoDeleteMillis int64 `json:"time_til_dormant_autodelete_ms,omitempty"`
|
||||
// UpdateWorkspaceLastUsedAt updates the last_used_at field of workspaces
|
||||
// spawned from the template. This is useful for preventing workspaces being
|
||||
// immediately locked when updating the inactivity_ttl field to a new, shorter
|
||||
// value.
|
||||
UpdateWorkspaceLastUsedAt bool `json:"update_workspace_last_used_at"`
|
||||
// UpdateWorkspaceLockedAt updates the locked_at field of workspaces spawned
|
||||
// from the template. This is useful for preventing locked workspaces being immediately
|
||||
// deleted when updating the locked_ttl field to a new, shorter value.
|
||||
UpdateWorkspaceLockedAt bool `json:"update_workspace_locked_at"`
|
||||
// UpdateWorkspaceDormant updates the dormant_at field of workspaces spawned
|
||||
// from the template. This is useful for preventing dormant workspaces being immediately
|
||||
// deleted when updating the dormant_ttl field to a new, shorter value.
|
||||
UpdateWorkspaceDormantAt bool `json:"update_workspace_dormant_at"`
|
||||
}
|
||||
|
||||
type TemplateExample struct {
|
||||
|
||||
+16
-13
@@ -35,14 +35,15 @@ type Workspace struct {
|
||||
TTLMillis *int64 `json:"ttl_ms,omitempty"`
|
||||
LastUsedAt time.Time `json:"last_used_at" format:"date-time"`
|
||||
|
||||
// DeletingAt indicates the time of the upcoming workspace deletion, if applicable; otherwise it is nil.
|
||||
// Workspaces may have impending deletions if Template.InactivityTTL feature is turned on and the workspace is inactive.
|
||||
// DeletingAt indicates the time at which the workspace will be permanently deleted.
|
||||
// A workspace is eligible for deletion if it is dormant (a non-nil dormant_at value)
|
||||
// and a value has been specified for time_til_dormant_autodelete on its template.
|
||||
DeletingAt *time.Time `json:"deleting_at" format:"date-time"`
|
||||
// LockedAt being non-nil indicates a workspace that has been locked.
|
||||
// A locked workspace is no longer accessible by a user and must be
|
||||
// unlocked by an admin. It is subject to deletion if it breaches
|
||||
// the duration of the locked_ttl field on its template.
|
||||
LockedAt *time.Time `json:"locked_at" format:"date-time"`
|
||||
// DormantAt being non-nil indicates a workspace that is dormant.
|
||||
// A dormant workspace is no longer accessible must be activated.
|
||||
// It is subject to deletion if it breaches
|
||||
// the duration of the time_til_ field on its template.
|
||||
DormantAt *time.Time `json:"dormant_at" format:"date-time"`
|
||||
// Health shows the health of the workspace and information about
|
||||
// what is causing an unhealthy status.
|
||||
Health WorkspaceHealth `json:"health"`
|
||||
@@ -293,14 +294,16 @@ func (c *Client) PutExtendWorkspace(ctx context.Context, id uuid.UUID, req PutEx
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateWorkspaceLock is a request to lock or unlock a workspace.
|
||||
type UpdateWorkspaceLock struct {
|
||||
Lock bool `json:"lock"`
|
||||
// UpdateWorkspaceDormancy is a request to activate or make a workspace dormant.
|
||||
// A value of false will activate a dormant workspace.
|
||||
type UpdateWorkspaceDormancy struct {
|
||||
Dormant bool `json:"dormant"`
|
||||
}
|
||||
|
||||
// UpdateWorkspaceLock locks or unlocks a workspace.
|
||||
func (c *Client) UpdateWorkspaceLock(ctx context.Context, id uuid.UUID, req UpdateWorkspaceLock) error {
|
||||
path := fmt.Sprintf("/api/v2/workspaces/%s/lock", id.String())
|
||||
// UpdateWorkspaceDormancy sets a workspace as dormant if dormant=true and activates a dormant workspace
|
||||
// if dormant=false.
|
||||
func (c *Client) UpdateWorkspaceDormancy(ctx context.Context, id uuid.UUID, req UpdateWorkspaceDormancy) error {
|
||||
path := fmt.Sprintf("/api/v2/workspaces/%s/dormant", id.String())
|
||||
res, err := c.Request(ctx, http.MethodPut, path, req)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("update workspace lock: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user