handlers

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeListFailed      = "ERR_LIST_FAILED"
	ErrCodeGetFailed       = "ERR_GET_FAILED"
	ErrAppNotRunning       = "ERR_APP_NOT_RUNNING"
	ErrCodeInstallFailed   = "ERR_INSTALL_FAILED"
	ErrCodeUninstallFailed = "ERR_UNINSTALL_FAILED"
	ErrCodeStartFailed     = "ERR_START_FAILED"
	ErrCodeStopFailed      = "ERR_STOP_FAILED"
	ErrAlreadyStopped      = "ERR_ALREADY_STOPPED"
	ErrAlreadyRunning      = "ERR_ALREADY_RUNNING"
)
View Source
const (
	ErrCodeProvisionFailed = "ERR_DATASITE_PROVISION_FAILED"
	ErrRequestEmailCode    = "ERR_REQUEST_EMAIL_CODE"
	ErrCodeVerifyEmailCode = "ERR_VERIFY_EMAIL_CODE"
)
View Source
const (
	CodeOk                  string = "OK"
	ErrCodeBadRequest       string = "ERR_BAD_REQUEST"
	ErrCodeUnknownError     string = "ERR_UNKNOWN_ERROR"
	ErrCodeDatasiteNotReady string = "ERR_DATASITE_NOT_READY"
)
View Source
const (
	ErrCodeListWorkspaceItemsFailed  = "ERR_LIST_WORKSPACE_ITEMS_FAILED"
	ErrCodeCreateWorkspaceItemFailed = "ERR_CREATE_WORKSPACE_ITEM_FAILED"
	ErrCodeDeleteWorkspaceItemFailed = "ERR_DELETE_WORKSPACE_ITEM_FAILED"
	ErrCodeMoveWorkspaceItemsFailed  = "ERR_MOVE_WORKSPACE_ITEMS_FAILED"
	ErrCodeCopyWorkspaceItemsFailed  = "ERR_COPY_WORKSPACE_ITEMS_FAILED"
	ErrCodeGetWorkspaceContentFailed = "ERR_GET_WORKSPACE_CONTENT_FAILED"
)
View Source
const ErrCodeLogsRetrievalFailed = "ERR_LOGS_RETRIEVAL_FAILED"

ErrCodeLogsRetrievalFailed is the error code for when logs cannot be retrieved

Variables

This section is empty.

Functions

func AbortWithError

func AbortWithError(c *gin.Context, status int, code string, err error)

Types

type AppHandler

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

func NewAppHandler

func NewAppHandler(mgr *datasitemgr.DatasiteManager) *AppHandler

func (*AppHandler) Get

func (h *AppHandler) Get(c *gin.Context)

Get an app

@Summary		Get app
@Description	Get an app
@Tags			Apps
@Produce		json
@Param			appId			path		string	true	"App ID"
@Param			processStats	query		bool	false	"Whether to include process statistics"
@Success		200				{object}	AppResponse
@Failure		400				{object}	ControlPlaneError
@Failure		401				{object}	ControlPlaneError
@Failure		403				{object}	ControlPlaneError
@Failure		409				{object}	ControlPlaneError
@Failure		429				{object}	ControlPlaneError
@Failure		500				{object}	ControlPlaneError
@Failure		503				{object}	ControlPlaneError
@Router			/v1/apps/{appId} [get]

func (*AppHandler) Install

func (h *AppHandler) Install(c *gin.Context)

Install an app

@Summary		Install app
@Description	Install an app
@Tags			Apps
@Accept			json
@Produce		json
@Param			request	body		AppInstallRequest	true	"Install request"
@Success		200		{object}	AppResponse
@Failure		400		{object}	ControlPlaneError
@Failure		401		{object}	ControlPlaneError
@Failure		403		{object}	ControlPlaneError
@Failure		409		{object}	ControlPlaneError
@Failure		429		{object}	ControlPlaneError
@Failure		500		{object}	ControlPlaneError
@Failure		503		{object}	ControlPlaneError
@Router			/v1/apps/ [post]

func (*AppHandler) List

func (h *AppHandler) List(c *gin.Context)

List all installed apps

@Summary		List apps
@Description	List all installed apps
@Tags			Apps
@Produce		json
@Success		200	{object}	AppListResponse
@Failure		400	{object}	ControlPlaneError
@Failure		401	{object}	ControlPlaneError
@Failure		403	{object}	ControlPlaneError
@Failure		409	{object}	ControlPlaneError
@Failure		429	{object}	ControlPlaneError
@Failure		500	{object}	ControlPlaneError
@Failure		503	{object}	ControlPlaneError
@Router			/v1/apps/ [get]

func (*AppHandler) Start

func (h *AppHandler) Start(c *gin.Context)

Start an app

@Summary		Start app
@Description	Start an app
@Tags			Apps
@Produce		json
@Param			appId	path		string	true	"App ID"
@Success		200		{object}	AppResponse
@Failure		400		{object}	ControlPlaneError
@Failure		401		{object}	ControlPlaneError
@Failure		403		{object}	ControlPlaneError
@Failure		409		{object}	ControlPlaneError
@Failure		429		{object}	ControlPlaneError
@Failure		500		{object}	ControlPlaneError
@Failure		503		{object}	ControlPlaneError
@Router			/v1/apps/{appId}/start [post]

func (*AppHandler) Stop

func (h *AppHandler) Stop(c *gin.Context)

Stop an app

@Summary		Stop app
@Description	Stop an app
@Tags			Apps
@Produce		json
@Param			appId	path		string	true	"App ID"
@Success		200		{object}	AppResponse
@Failure		400		{object}	ControlPlaneError
@Failure		401		{object}	ControlPlaneError
@Failure		403		{object}	ControlPlaneError
@Failure		409		{object}	ControlPlaneError
@Failure		429		{object}	ControlPlaneError
@Failure		500		{object}	ControlPlaneError
@Failure		503		{object}	ControlPlaneError
@Router			/v1/apps/{appId}/stop [post]

func (*AppHandler) Uninstall

func (h *AppHandler) Uninstall(c *gin.Context)

Uninstall an app

@Summary		Uninstall app
@Description	Uninstall an app
@Tags			Apps
@Produce		json
@Param			appId	path	string	true	"App ID"
@Success		204
@Failure		400	{object}	ControlPlaneError
@Failure		401	{object}	ControlPlaneError
@Failure		403	{object}	ControlPlaneError
@Failure		409	{object}	ControlPlaneError
@Failure		429	{object}	ControlPlaneError
@Failure		500	{object}	ControlPlaneError
@Failure		503	{object}	ControlPlaneError
@Router			/v1/apps/{appId} [delete]

type AppInstallRequest

type AppInstallRequest struct {
	RepoURL string `json:"repoURL" binding:"required"` // url of the github repo to install
	Branch  string `json:"branch"`                     // branch of the repo to install
	Tag     string `json:"tag"`                        // tag of the repo to install
	Commit  string `json:"commit"`                     // commit of the repo to install
	Force   bool   `json:"force"`                      // force install
}

AppInstallRequest represents the request to install an app.

type AppListResponse

type AppListResponse struct {
	Apps []*AppResponse `json:"apps"` // list of installed apps
}

AppListResponse represents the response to list all installed apps.

type AppResponse

type AppResponse struct {
	// Unique ID of the app [deprecated]
	ID string `json:"id"`
	// name of the app [deprecated]
	Name string `json:"name"`
	// Absolute path to the app from the workspace root [deprecated]
	Path string `json:"path"`
	// Info about the app
	Info *apps.AppInfo `json:"info"`
	// Status of the app
	Status apps.AppProcessStatus `json:"status"`
	// Process ID of the app's run.sh
	PID int32 `json:"pid,omitempty"`
	// List of ports this app is listening on
	Ports []uint32 `json:"ports,omitempty"`
	// Extended process statistics (optional)
	ProcessStats *apps.ProcessStats `json:"processStats,omitempty"`
}

func NewAppResponse

func NewAppResponse(app *apps.App, processStats bool) (*AppResponse, error)

func (AppResponse) MarshalJSON

func (a AppResponse) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface for AppResponse

func (*AppResponse) UnmarshalJSON

func (a *AppResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface for AppResponse

type ControlPlaneError

type ControlPlaneError struct {
	ErrorCode string `json:"code"`
	Error     string `json:"error"`
}

type ControlPlaneResponse

type ControlPlaneResponse struct {
	Code string `json:"code"`
}

type DatasiteConfig

type DatasiteConfig struct {
	DataDir   string `json:"data_dir"`
	Email     string `json:"email"`
	ServerURL string `json:"server_url"`
}

type DatasiteInfo

type DatasiteInfo struct {
	Status string          `json:"status"`           // status of the datasite.
	Error  string          `json:"error,omitempty"`  // error message if the datasite is not ready.
	Config *DatasiteConfig `json:"config,omitempty"` // config of the datasite.
}

type GetTokenRequest

type GetTokenRequest struct {
	Email     string `form:"email" binding:"required"`      // email of the user
	ServerURL string `form:"server_url" binding:"required"` // syftbox server url from where the token is requested
}

GetTokenRequest represents the request to get a token from the syftbox server.

type InitDatasiteRequest

type InitDatasiteRequest struct {
	Email      string `json:"email" binding:"required"`     // email of the user
	DataDir    string `json:"dataDir" binding:"required"`   // datasite directory
	ServerURL  string `json:"serverUrl" binding:"required"` // syftbox server url
	EmailToken string `json:"token" binding:"required"`     // email token of the user
}

InitDatasiteRequest represents the request to initialize a datasite.

type InitHandler

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

func NewInitHandler

func NewInitHandler(mgr *datasitemgr.DatasiteManager, controlPlaneURL string) *InitHandler

func (*InitHandler) GetToken

func (h *InitHandler) GetToken(c *gin.Context)

GetToken requests an email validation token from the syftbox server

@Summary		Get token
@Description	Request an email validation token from the syftbox server
@Tags			Init
@Produce		json
@Param			email		query		string	true	"Email"			Format(email)
@Param			server_url	query		string	true	"Server URL"	Format(url)
@Success		200			{object}	ControlPlaneResponse
@Failure		400			{object}	ControlPlaneError
@Router			/v1/init/token [get]

func (*InitHandler) InitDatasite

func (h *InitHandler) InitDatasite(c *gin.Context)

InitDatasite provisions a datasite with the given configuration

@Summary		Initialize the client
@Description	Initialize the client with the given configuration
@Tags			Init
@Accept			json
@Produce		json
@Param			request	body		InitDatasiteRequest	true	"Initialize request"
@Success		200		{object}	ControlPlaneResponse
@Failure		400		{object}	ControlPlaneError
@Failure		500		{object}	ControlPlaneError
@Router			/v1/init/datasite [post]

type LogEntry

type LogEntry struct {
	LineNumber int64  `json:"lineNumber"`
	Timestamp  string `json:"timestamp"`
	Message    string `json:"message"`
}

LogEntry represents a single log message

type LogsHandler

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

LogsHandler handles log-related requests

func NewLogsHandler

func NewLogsHandler(mgr *datasitemgr.DatasiteManager) *LogsHandler

NewLogsHandler creates a new handler for logs

func (*LogsHandler) DownloadLogs

func (h *LogsHandler) DownloadLogs(c *gin.Context)

DownloadLogs handles GET requests to download all logs as a zip file

@Summary		Download logs
@Description	Download all logs as a zip file
@Tags			Logs
@Produce		application/zip
@Success		200	{file}		file	"Zip file containing all logs"
@Failure		400	{object}	ControlPlaneError
@Failure		401	{object}	ControlPlaneError
@Failure		403	{object}	ControlPlaneError
@Failure		429	{object}	ControlPlaneError
@Failure		500	{object}	ControlPlaneError
@Failure		503	{object}	ControlPlaneError
@Router			/v1/logs/download [get]

func (*LogsHandler) GetLogs

func (h *LogsHandler) GetLogs(c *gin.Context)

GetLogs handles GET requests to retrieve logs

@Summary		Get logs
@Description	Get system logs with pagination support
@Tags			Logs
@Produce		json
@Param			appId			query		string	false	"The ID of the app to retrieve logs for"										default(system)
@Param			startingToken	query		int		false	"Pagination token from a previous request to retrieve the next page of results"	default(1)		minimum(1)
@Param			maxResults		query		int		false	"Maximum number of lines to read"												default(100)	minimum(1)	maximum(1000)
@Success		200				{object}	LogsResponse
@Failure		400				{object}	ControlPlaneError
@Failure		401				{object}	ControlPlaneError
@Failure		403				{object}	ControlPlaneError
@Failure		404				{object}	ControlPlaneError
@Failure		429				{object}	ControlPlaneError
@Failure		500				{object}	ControlPlaneError
@Failure		503				{object}	ControlPlaneError
@Router			/v1/logs [get]

type LogsRequest

type LogsRequest struct {
	// The name of the app to retrieve logs for.
	AppId string `form:"appId" binding:"required" default:"system"`
	// Specify the pagination token from a previous request to retrieve the next page of results.
	StartingToken int64 `form:"startingToken" binding:"min=1" default:"1"`
	// The maximum number of logs to return in one page of results.
	MaxResults int `form:"maxResults" binding:"gte=1,lte=1000" default:"100"`
}

LogsRequest represents the request parameters for retrieving logs

type LogsResponse

type LogsResponse struct {
	// A list of log items.
	Logs []LogEntry `json:"logs"`
	// A pagination token to retrieve the next page of logs.
	NextToken int64 `json:"nextToken"`
	// Whether there are more logs to retrieve.
	HasMore bool `json:"hasMore"`
}

LogsResponse represents the response for retrieving logs

type Permission

type Permission struct {
	ID     string `json:"id"`
	UserID string `json:"userId"`
	Name   string `json:"name"`
	Email  string `json:"email"`
	Type   string `json:"type"` // "read", "write", or "admin"
	Avatar string `json:"avatar"`
}

Permission represents a user's permission for a workspace item

type StatusHandler

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

StatusHandler handles status-related endpoints

func NewStatusHandler

func NewStatusHandler(mgr *datasitemgr.DatasiteManager) *StatusHandler

NewStatusHandler creates a new status handler

func (*StatusHandler) Status

func (h *StatusHandler) Status(c *gin.Context)

GetStatus returns the status of the service

@Summary		Get status
@Description	Returns the status of the service
@Tags			Status
@Produce		json
@Success		200	{object}	StatusResponse
@Failure		503	{object}	ControlPlaneError
@Router			/v1/status [get]

type StatusResponse

type StatusResponse struct {
	Status    string        `json:"status"`    // health status ("ok").
	Timestamp string        `json:"ts"`        // timestamp when health check was performed.
	Version   string        `json:"version"`   // version of the client.
	Revision  string        `json:"revision"`  // revision of the client.
	BuildDate string        `json:"buildDate"` // build date of the client.
	Datasite  *DatasiteInfo `json:"datasite"`  // datasite status.
}

StatusResponse represents the health status of the service.

type SyncStatus

type SyncStatus string

SyncStatus represents the synchronization status of a workspace item

const (
	SyncStatusSynced   SyncStatus = "synced"
	SyncStatusSyncing  SyncStatus = "syncing"
	SyncStatusPending  SyncStatus = "pending"
	SyncStatusRejected SyncStatus = "rejected"
	SyncStatusError    SyncStatus = "error"
	SyncStatusIgnored  SyncStatus = "ignored"
	SyncStatusHidden   SyncStatus = "hidden"
)

type UpdateMode

type UpdateMode string

UpdateMode represents how the content should be updated

const (
	UpdateModeOverwrite UpdateMode = "overwrite" // Replace entire file content
	UpdateModeAppend    UpdateMode = "append"    // Add content to end of file
	UpdateModePrepend   UpdateMode = "prepend"   // Add content to start of file
)

type WorkspaceConflictError

type WorkspaceConflictError struct {
	ErrorCode    string        `json:"errorCode"`
	Error        string        `json:"error"`
	ExistingItem WorkspaceItem `json:"existingItem"`
}

WorkspaceConflictError represents an error response when there is a conflict with an existing item

type WorkspaceContentRequest

type WorkspaceContentRequest struct {
	Path string `form:"path" binding:"required"`
}

WorkspaceContentRequest represents the request parameters for getting file content

type WorkspaceContentUpdateRequest

type WorkspaceContentUpdateRequest struct {
	Path    string     `json:"path" binding:"required"`
	Content string     `json:"content" binding:"required"`
	Mode    UpdateMode `json:"mode" binding:"required,oneof=overwrite append prepend" default:"overwrite"`
	Create  bool       `json:"create" default:"false"` // Create file if it doesn't exist
}

WorkspaceContentUpdateRequest represents the request for updating file content

type WorkspaceHandler

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

func NewWorkspaceHandler

func NewWorkspaceHandler(mgr *datasitemgr.DatasiteManager) *WorkspaceHandler

func (*WorkspaceHandler) CopyItems

func (h *WorkspaceHandler) CopyItems(c *gin.Context)

CopyItems copies a file or folder to a new location. Can also be used for renaming a file or folder.

@Summary		Copy a file or folder
@Description	Create a copy of a file or folder
@Tags			Workspace
@Accept			json
@Produce		json
@Param			request	body		WorkspaceItemCopyRequest	true	"Request body"
@Success		200		{object}	WorkspaceItemCopyResponse
@Failure		400		{object}	ControlPlaneError
@Failure		401		{object}	ControlPlaneError
@Failure		403		{object}	ControlPlaneError
@Failure		404		{object}	ControlPlaneError
@Failure		409		{object}	ControlPlaneError
@Failure		429		{object}	ControlPlaneError
@Failure		500		{object}	ControlPlaneError
@Router			/v1/workspace/items/copy [post]

func (*WorkspaceHandler) CreateItem

func (h *WorkspaceHandler) CreateItem(c *gin.Context)

Create workspace item

@Summary		Create workspace item
@Description	Create a new file or folder in the workspace
@Tags			Workspace
@Accept			json
@Produce		json
@Param			request	body		WorkspaceItemCreateRequest	true	"Request body"
@Success		201		{object}	WorkspaceItemCreateResponse
@Failure		400		{object}	ControlPlaneError
@Failure		401		{object}	ControlPlaneError
@Failure		403		{object}	ControlPlaneError
@Failure		409		{object}	ControlPlaneError
@Failure		429		{object}	ControlPlaneError
@Failure		500		{object}	ControlPlaneError
@Failure		503		{object}	ControlPlaneError
@Router			/v1/workspace/items [post]

func (*WorkspaceHandler) DeleteItems

func (h *WorkspaceHandler) DeleteItems(c *gin.Context)

Delete workspace items

@Summary		Delete workspace items
@Description	Delete multiple files or folders. The operation is similar to the Unix `rm -rf` command.
@Description	- If the path is a file, the file will be deleted.
@Description	- If the path is a folder, all its contents will also be deleted.
@Description	- If the path is a symlink, the symlink will be deleted without deleting the target.
@Description	- If the path does not exist, the operation will be a no-op.
@Tags			Workspace
@Accept			json
@Param			request	body		WorkspaceItemDeleteRequest	true	"Request body"
@Success		204		{object}	nil
@Failure		400		{object}	ControlPlaneError
@Failure		401		{object}	ControlPlaneError
@Failure		403		{object}	ControlPlaneError
@Failure		409		{object}	ControlPlaneError
@Failure		429		{object}	ControlPlaneError
@Failure		500		{object}	ControlPlaneError
@Failure		503		{object}	ControlPlaneError
@Router			/v1/workspace/items [delete]

func (*WorkspaceHandler) GetContent

func (h *WorkspaceHandler) GetContent(c *gin.Context)

Get file content

@Summary		Get file content
@Description	Get the content of a file at the specified path. Supports range requests for efficient streaming of large files.
@Tags			Workspace
@Produce		text/plain
@Produce		application/octet-stream
@Produce		*/*
@Param			path	query		string	true	"Path to the file"
@Success		200		{file}		file	"File content"
@Success		206		{file}		file	"Partial file content for range requests"
@Failure		400		{object}	ControlPlaneError
@Failure		401		{object}	ControlPlaneError
@Failure		403		{object}	ControlPlaneError
@Failure		404		{object}	ControlPlaneError
@Failure		429		{object}	ControlPlaneError
@Failure		500		{object}	ControlPlaneError
@Failure		503		{object}	ControlPlaneError
@Router			/v1/workspace/content [get]

func (*WorkspaceHandler) GetItems

func (h *WorkspaceHandler) GetItems(c *gin.Context)

GetItems gets workspace at a specified path

@Summary		Get workspace items
@Description	Get files and folders at a specified path
@Tags			Workspace
@Produce		json
@Param			path	query		string	false	"Path to the directory (default is root)"
@Param			depth	query		integer	false	"Maximum depth for retrieving children (0 = no children, 1 = immediate children only, etc.)"	minimum(0)	default(1)
@Success		200		{object}	WorkspaceItemsResponse
@Failure		400		{object}	ControlPlaneError
@Failure		401		{object}	ControlPlaneError
@Failure		403		{object}	ControlPlaneError
@Failure		409		{object}	ControlPlaneError
@Failure		429		{object}	ControlPlaneError
@Failure		500		{object}	ControlPlaneError
@Failure		503		{object}	ControlPlaneError
@Router			/v1/workspace/items [get]

func (*WorkspaceHandler) MoveItems

func (h *WorkspaceHandler) MoveItems(c *gin.Context)

MoveItems moves an item to a new location. Can also be used for renaming an item.

@Summary		Move item
@Description	Move an item to a new location. Can also be used for renaming an item.
@Tags			Workspace
@Accept			json
@Produce		json
@Param			request	body		WorkspaceItemMoveRequest	true	"Request body"
@Success		200		{object}	WorkspaceItemMoveResponse
@Failure		400		{object}	ControlPlaneError
@Failure		401		{object}	ControlPlaneError
@Failure		403		{object}	ControlPlaneError
@Failure		404		{object}	ControlPlaneError
@Failure		409		{object}	ControlPlaneError
@Failure		429		{object}	ControlPlaneError
@Failure		500		{object}	ControlPlaneError
@Router			/v1/workspace/items/move [post]

func (*WorkspaceHandler) UpdateContent

func (h *WorkspaceHandler) UpdateContent(c *gin.Context)

UpdateContent handles PUT requests to update file content

@Summary		Update file content
@Description	Update the content of a file at the specified path. Supports overwrite, append, and prepend modes. Can create the file if it doesn't exist.
@Tags			Workspace
@Accept			json
@Produce		json
@Param			request	body		WorkspaceContentUpdateRequest	true	"Request body"
@Success		200		{object}	WorkspaceItem
@Failure		400		{object}	ControlPlaneError
@Failure		401		{object}	ControlPlaneError
@Failure		403		{object}	ControlPlaneError
@Failure		404		{object}	ControlPlaneError
@Failure		429		{object}	ControlPlaneError
@Failure		500		{object}	ControlPlaneError
@Failure		503		{object}	ControlPlaneError
@Router			/v1/workspace/content [put]

type WorkspaceItem

type WorkspaceItem struct {
	Id           string            `json:"id"`
	Name         string            `json:"name"`
	Type         WorkspaceItemType `json:"type"`
	Path         string            `json:"path"`
	AbsolutePath string            `json:"absolutePath"`
	CreatedAt    time.Time         `json:"createdAt"`
	ModifiedAt   time.Time         `json:"modifiedAt"`
	Size         int64             `json:"size"`
	SyncStatus   SyncStatus        `json:"syncStatus"`
	Permissions  []Permission      `json:"permissions"`
	Children     []WorkspaceItem   `json:"children"`
}

WorkspaceItem represents a file or folder in the workspace

func (WorkspaceItem) MarshalJSON

func (w WorkspaceItem) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface for WorkspaceItem

func (*WorkspaceItem) UnmarshalJSON

func (w *WorkspaceItem) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface for WorkspaceItem

type WorkspaceItemCopyRequest

type WorkspaceItemCopyRequest struct {
	// Full path of the item to copy
	SourcePath string `json:"sourcePath" binding:"required"`
	// Full path of the new item location, including the item name
	NewPath string `json:"newPath" binding:"required"`
	// Overwrite the destination item if it exists
	Overwrite bool `json:"overwrite,omitempty" default:"false"`
}

WorkspaceItemCopyRequest represents the request for copying a workspace item

type WorkspaceItemCopyResponse

type WorkspaceItemCopyResponse struct {
	Item WorkspaceItem `json:"item"`
}

WorkspaceItemCopyResponse represents the response for copying a workspace item

type WorkspaceItemCreateRequest

type WorkspaceItemCreateRequest struct {
	Path      string            `json:"path" binding:"required"`
	Type      WorkspaceItemType `json:"type" binding:"required,oneof=file folder"`
	Overwrite bool              `json:"overwrite,omitempty" default:"false"`
}

WorkspaceItemCreateRequest represents the request for creating a workspace item

type WorkspaceItemCreateResponse

type WorkspaceItemCreateResponse struct {
	Item WorkspaceItem `json:"item"`
}

WorkspaceItemCreateResponse represents the response for creating a workspace item

type WorkspaceItemDeleteRequest

type WorkspaceItemDeleteRequest struct {
	Paths []string `json:"paths" binding:"required"`
}

WorkspaceItemDeleteRequest represents the request for deleting workspace items

type WorkspaceItemMoveRequest

type WorkspaceItemMoveRequest struct {
	// Full path to the source item
	SourcePath string `json:"sourcePath" binding:"required"`
	// Full path to the new item location, including the item name
	NewPath string `json:"newPath" binding:"required"`
	// Overwrite the destination item if it exists
	Overwrite bool `json:"overwrite,omitempty" default:"false"`
}

WorkspaceItemMoveRequest represents the request for moving a workspace item

type WorkspaceItemMoveResponse

type WorkspaceItemMoveResponse struct {
	Item WorkspaceItem `json:"item"`
}

WorkspaceItemMoveResponse represents the response for moving a workspace item

type WorkspaceItemType

type WorkspaceItemType string
const (
	WorkspaceItemTypeFile   WorkspaceItemType = "file"
	WorkspaceItemTypeFolder WorkspaceItemType = "folder"
)

type WorkspaceItemsRequest

type WorkspaceItemsRequest struct {
	Path  string `form:"path"`
	Depth int    `form:"depth" binding:"min=0"`
}

WorkspaceItemsRequest represents the request parameters for listing workspace items

type WorkspaceItemsResponse

type WorkspaceItemsResponse struct {
	Items []WorkspaceItem `json:"items"`
}

WorkspaceItemsResponse represents the response for listing workspace items

Jump to

Keyboard shortcuts

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