-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathaddon.go
More file actions
74 lines (63 loc) · 2.43 KB
/
Copy pathaddon.go
File metadata and controls
74 lines (63 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Package addon holds primitives and logic for the Uploadcare Addons API.
//
// Addons allow executing various processing tasks on uploaded files,
// such as background removal, virus scanning, and image recognition.
package addon
import "encoding/json"
// Addon name constants used in URL paths
const (
AddonRemoveBG = "remove_bg"
AddonClamAV = "uc_clamav_virus_scan"
AddonRekognitionLabels = "aws_rekognition_detect_labels"
AddonRekognitionModeration = "aws_rekognition_detect_moderation_labels"
)
// Execution status constants
const (
StatusInProgress = "in_progress"
StatusDone = "done"
StatusError = "error"
StatusUnknown = "unknown"
)
// ExecuteParams holds parameters for executing an addon
type ExecuteParams struct {
// Target is the file UUID to process
Target string `json:"target"`
// Params holds addon-specific parameters.
// Use RemoveBGParams, ClamAVParams, or nil depending on the addon.
Params interface{} `json:"params,omitempty"`
}
// ExecuteResult holds the response from an addon execution request
type ExecuteResult struct {
// RequestID is the unique identifier for this execution request
RequestID string `json:"request_id"`
}
// StatusParams holds parameters for checking addon execution status
type StatusParams struct {
// RequestID is the execution request ID returned by Execute
RequestID string `json:"request_id"`
}
// StatusResult holds the response from an addon status check
type StatusResult struct {
// Status is the current execution status
Status string `json:"status"`
// Result holds addon-specific result data.
// The structure varies per addon.
Result json.RawMessage `json:"result"`
}
// RemoveBGParams holds parameters for the remove.bg addon
type RemoveBGParams struct {
Crop *bool `json:"crop,omitempty"`
CropMargin *string `json:"crop_margin,omitempty"`
Scale *string `json:"scale,omitempty"`
AddShadow *bool `json:"add_shadow,omitempty"`
TypeLevel *string `json:"type_level,omitempty"`
Type *string `json:"type,omitempty"`
Semitransparency *bool `json:"semitransparency,omitempty"`
Channels *string `json:"channels,omitempty"`
ROI *string `json:"roi,omitempty"`
Position *string `json:"position,omitempty"`
}
// ClamAVParams holds parameters for the ClamAV virus scan addon
type ClamAVParams struct {
PurgeInfected *bool `json:"purge_infected,omitempty"`
}