Add server file manager workflow
This commit is contained in:
@@ -1000,6 +1000,7 @@ type ServerConfigWriteDispatch struct {
|
||||
type FileOperationKind string
|
||||
|
||||
const (
|
||||
FileOperationList FileOperationKind = "list"
|
||||
FileOperationRead FileOperationKind = "read"
|
||||
FileOperationWrite FileOperationKind = "write"
|
||||
)
|
||||
@@ -1042,6 +1043,151 @@ type DeclaredFileReadSnapshot struct {
|
||||
Reason string
|
||||
}
|
||||
|
||||
type ServerFileEntryKind string
|
||||
|
||||
const (
|
||||
ServerFileEntryDirectory ServerFileEntryKind = "directory"
|
||||
ServerFileEntryFile ServerFileEntryKind = "file"
|
||||
)
|
||||
|
||||
type ServerFileTransferPolicy struct {
|
||||
Channel string
|
||||
UploadChunkSizeBytes int
|
||||
DownloadChunkSizeBytes int
|
||||
MaxInlineEditBytes int
|
||||
MaxBrowserUploadBytes int64
|
||||
Notes []string
|
||||
}
|
||||
|
||||
type ServerFileWorkspaceView struct {
|
||||
ServerInstanceID string
|
||||
PluginID string
|
||||
DefaultDirectoryKey string
|
||||
Directories []PluginLogicalDirectory
|
||||
Files []PluginLogicalFile
|
||||
ConfigFields []PluginConfigField
|
||||
Transfer ServerFileTransferPolicy
|
||||
DeclaredOnly bool
|
||||
RuntimeWorkspaceScope string
|
||||
}
|
||||
|
||||
type ServerFileEntry struct {
|
||||
Name string
|
||||
Kind ServerFileEntryKind
|
||||
DirectoryKey string
|
||||
RelativePath string
|
||||
LogicalKey string
|
||||
Scope string
|
||||
SizeBytes int64
|
||||
ModifiedAt time.Time
|
||||
Checksum string
|
||||
Editable bool
|
||||
Downloadable bool
|
||||
Remark string
|
||||
}
|
||||
|
||||
type ServerFileListRequest struct {
|
||||
ServerInstanceID string
|
||||
DirectoryKey string
|
||||
Path string
|
||||
Query string
|
||||
Recursive bool
|
||||
IdempotencyKey string
|
||||
}
|
||||
|
||||
type ServerFileListResult struct {
|
||||
ServerInstanceID string
|
||||
PluginID string
|
||||
DirectoryKey string
|
||||
Path string
|
||||
State string
|
||||
Entries []ServerFileEntry
|
||||
Job Job
|
||||
RefreshedAt time.Time
|
||||
Reason string
|
||||
}
|
||||
|
||||
type ServerFileReadRequest struct {
|
||||
ServerInstanceID string
|
||||
PluginID string
|
||||
Key string
|
||||
IdempotencyKey string
|
||||
}
|
||||
|
||||
type ServerFileWriteRequest struct {
|
||||
ServerInstanceID string
|
||||
PluginID string
|
||||
Key string
|
||||
Content string
|
||||
InputRef string
|
||||
ExpectedVersion int
|
||||
ExpectedChecksum string
|
||||
IdempotencyKey string
|
||||
}
|
||||
|
||||
type ServerFileUploadRequest struct {
|
||||
ServerInstanceID string
|
||||
DirectoryKey string
|
||||
RelativePath string
|
||||
Filename string
|
||||
Payload []byte
|
||||
Checksum string
|
||||
IdempotencyKey string
|
||||
}
|
||||
|
||||
type ServerFileUploadDispatch struct {
|
||||
Status string
|
||||
ServerInstanceID string
|
||||
DirectoryKey string
|
||||
RelativePath string
|
||||
ArtifactID string
|
||||
InputRef string
|
||||
SizeBytes int64
|
||||
Checksum string
|
||||
Job Job
|
||||
}
|
||||
|
||||
type ServerFileDownloadRequest struct {
|
||||
ServerInstanceID string
|
||||
Key string
|
||||
IdempotencyKey string
|
||||
}
|
||||
|
||||
type ServerFileDownloadResult struct {
|
||||
Status string
|
||||
ServerInstanceID string
|
||||
Key string
|
||||
Filename string
|
||||
ContentType string
|
||||
Content string
|
||||
Checksum string
|
||||
SizeBytes int64
|
||||
Artifact *ArtifactDownloadReference
|
||||
Job Job
|
||||
ReadAt time.Time
|
||||
Reason string
|
||||
}
|
||||
|
||||
type RunFileInputChunkRequest struct {
|
||||
RunEndpointID string
|
||||
SessionToken string
|
||||
JobID string
|
||||
LeaseToken string
|
||||
Attempt int
|
||||
Offset int64
|
||||
Length int
|
||||
}
|
||||
|
||||
type RunFileInputChunk struct {
|
||||
JobID string
|
||||
ArtifactID string
|
||||
Offset int64
|
||||
TotalBytes int64
|
||||
Checksum string
|
||||
Payload []byte
|
||||
Complete bool
|
||||
}
|
||||
|
||||
type RunCapacity struct {
|
||||
MaxJobs int
|
||||
RunningJobs int
|
||||
@@ -1054,6 +1200,7 @@ type RunCapacity struct {
|
||||
|
||||
const (
|
||||
JobCapabilityConfigWrite = "config.write"
|
||||
JobCapabilityFilesList = "files.list"
|
||||
JobCapabilityFilesRead = "files.read"
|
||||
JobCapabilityFilesWrite = "files.write"
|
||||
JobCapabilityRemoteFTPRead = "remote.ftp.read"
|
||||
@@ -1963,6 +2110,66 @@ func CopyFileOperationDispatchResult(result FileOperationDispatchResult) FileOpe
|
||||
return result
|
||||
}
|
||||
|
||||
func CopyServerFileTransferPolicy(policy ServerFileTransferPolicy) ServerFileTransferPolicy {
|
||||
policy.Notes = CopyStringSlice(policy.Notes)
|
||||
return policy
|
||||
}
|
||||
|
||||
func CopyServerFileWorkspaceView(view ServerFileWorkspaceView) ServerFileWorkspaceView {
|
||||
view.Directories = append([]PluginLogicalDirectory(nil), view.Directories...)
|
||||
view.Files = append([]PluginLogicalFile(nil), view.Files...)
|
||||
view.ConfigFields = append([]PluginConfigField(nil), view.ConfigFields...)
|
||||
view.Transfer = CopyServerFileTransferPolicy(view.Transfer)
|
||||
return view
|
||||
}
|
||||
|
||||
func CopyServerFileEntry(entry ServerFileEntry) ServerFileEntry {
|
||||
return entry
|
||||
}
|
||||
|
||||
func CopyServerFileEntries(entries []ServerFileEntry) []ServerFileEntry {
|
||||
if entries == nil {
|
||||
return nil
|
||||
}
|
||||
out := make([]ServerFileEntry, len(entries))
|
||||
copy(out, entries)
|
||||
return out
|
||||
}
|
||||
|
||||
func CopyServerFileListResult(result ServerFileListResult) ServerFileListResult {
|
||||
result.Entries = CopyServerFileEntries(result.Entries)
|
||||
result.Job = CopyJob(result.Job)
|
||||
return result
|
||||
}
|
||||
|
||||
func CopyServerFileUploadRequest(request ServerFileUploadRequest) ServerFileUploadRequest {
|
||||
request.Payload = CopyBytes(request.Payload)
|
||||
return request
|
||||
}
|
||||
|
||||
func CopyServerFileUploadDispatch(dispatch ServerFileUploadDispatch) ServerFileUploadDispatch {
|
||||
dispatch.Job = CopyJob(dispatch.Job)
|
||||
return dispatch
|
||||
}
|
||||
|
||||
func CopyServerFileDownloadResult(result ServerFileDownloadResult) ServerFileDownloadResult {
|
||||
if result.Artifact != nil {
|
||||
artifact := CopyArtifactDownloadReference(*result.Artifact)
|
||||
result.Artifact = &artifact
|
||||
}
|
||||
result.Job = CopyJob(result.Job)
|
||||
return result
|
||||
}
|
||||
|
||||
func CopyRunFileInputChunkRequest(request RunFileInputChunkRequest) RunFileInputChunkRequest {
|
||||
return request
|
||||
}
|
||||
|
||||
func CopyRunFileInputChunk(chunk RunFileInputChunk) RunFileInputChunk {
|
||||
chunk.Payload = CopyBytes(chunk.Payload)
|
||||
return chunk
|
||||
}
|
||||
|
||||
func CopyRunEndpoint(endpoint RunEndpoint) RunEndpoint {
|
||||
endpoint.Capabilities = CopyStringSlice(endpoint.Capabilities)
|
||||
endpoint.Capacity.PressureCodes = CopyStringSlice(endpoint.Capacity.PressureCodes)
|
||||
|
||||
Reference in New Issue
Block a user