|
1 | 1 | package types |
2 | 2 |
|
| 3 | +import ( |
| 4 | + "time" |
| 5 | + |
| 6 | + "github.com/google/uuid" |
| 7 | +) |
| 8 | + |
3 | 9 | /* |
4 | 10 | contains shared definations where compete modulation was not possible |
5 | 11 | Eg. session and transprocesser need same transaction structure and updating seperate definations |
6 | 12 | needs rewriting same code multiple times. |
7 | 13 | */ |
8 | 14 |
|
9 | | -/* Note: currently in development - just dummy fields */ |
| 15 | +/* represents the result of the transaction */ |
| 16 | +type TxnStatus string |
10 | 17 |
|
11 | | -/* transaction represents a permission management transaction */ |
12 | | -type Transaction struct { |
13 | | - ID string |
14 | | - UserID string |
15 | | - Action string |
16 | | - Resource string |
17 | | - Permissions string |
18 | | - Status string |
19 | | - Timestamp string |
| 18 | +/* defining transactions status types */ |
| 19 | +const ( |
| 20 | + StatusPending TxnStatus = "pending" |
| 21 | + StatusSuccess TxnStatus = "success" |
| 22 | + StatusFailed TxnStatus = "failed" |
| 23 | +) |
| 24 | + |
| 25 | +/* represents what kind of ACL operation was performed */ |
| 26 | +type OperationType string |
| 27 | + |
| 28 | +/* defining operating types */ |
| 29 | +const ( |
| 30 | + OperationGetACL OperationType = "getfacl" |
| 31 | + OperationSetACL OperationType = "setfacl" |
| 32 | +) |
| 33 | + |
| 34 | +/* represents an individual ACL rule attempted to be changed */ |
| 35 | +type ACLEntry struct { |
| 36 | + /* e.g., "user", "group", "mask", "other" */ |
| 37 | + EntityType string `json:"entityType"` |
| 38 | + |
| 39 | + /* username, group name, or blank for "other"/"mask" */ |
| 40 | + Entity string `json:"entity"` |
| 41 | + |
| 42 | + /* e.g., "rwx", "rw-", etc. */ |
| 43 | + Permissions string `json:"permissions"` |
| 44 | + |
| 45 | + /* e.g., "add", "modify", "remove" */ |
| 46 | + Action string `json:"action"` |
| 47 | + |
| 48 | + /* only set if failed */ |
| 49 | + Error string `json:"error,omitempty"` |
| 50 | + Success bool `json:"success"` |
20 | 51 | } |
21 | 52 |
|
22 | | -/* represents the result of a processed transaction */ |
23 | | -type TransactionResult struct { |
24 | | - Transaction Transaction |
25 | | - Success bool |
26 | | - Error string |
27 | | - Timestamp string |
| 53 | +/* holds the full state of a permission change operation */ |
| 54 | +type Transaction struct { |
| 55 | + ID uuid.UUID `json:"id"` |
| 56 | + SessionID uuid.UUID `json:"sessionId"` |
| 57 | + Timestamp time.Time `json:"timestamp"` |
| 58 | + |
| 59 | + /* getfacl/setfacl */ |
| 60 | + Operation OperationType `json:"operation"` |
| 61 | + |
| 62 | + /* File/directory affected */ |
| 63 | + TargetPath string `json:"targetPath"` |
| 64 | + |
| 65 | + /* ACL entries involved */ |
| 66 | + Entries []ACLEntry `json:"entries"` |
| 67 | + |
| 68 | + /* success/failure/pending */ |
| 69 | + Status TxnStatus `json:"status"` |
| 70 | + |
| 71 | + /* set if failed */ |
| 72 | + ErrorMsg string `json:"errorMsg,omitempty"` |
| 73 | + |
| 74 | + /* stdout or stderr captured */ |
| 75 | + Output string `json:"output"` |
| 76 | + |
| 77 | + /* user who triggered this */ |
| 78 | + ExecutedBy string `json:"executedBy"` |
| 79 | + |
| 80 | + /* execution duration in ms */ |
| 81 | + DurationMs int64 `json:"durationMs"` |
28 | 82 | } |
0 commit comments