-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataTypes.go
More file actions
97 lines (80 loc) · 1.99 KB
/
dataTypes.go
File metadata and controls
97 lines (80 loc) · 1.99 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package main
import (
"encoding/json"
"fmt"
)
type Str struct {
string
}
type RunQueryParams struct {
UserId string `form:"uid" binding:"required"`
UserAddress string `form:"adr" binding:"required"`
UserAddressPort int `form:"prt" binding:"required"`
Assignment string `form:"asnmt" binding:"required"`
Force bool `form:"frc"`
}
type PostData struct {
PythonScript []byte `form:"pyscript" binding:"required"`
}
type RunNotebookRequest struct {
*RunQueryParams
*PostData
RequestId string
PostHash string
}
type RunNotebookResponse struct {
RequestId string `json:"requestId"`
PyscriptHash string `json:"pyscriptHash"`
Status *ResponseStatus `json:"status,omitempty"`
Error *string `json:"error,omitempty"`
Result *string `json:"result,omitempty"`
}
type TemplateData struct {
JobName string
Image string
PyScriptHash string
UserId string
RequestId string
}
type ResultResponse struct {
Result *string `json:"result,omitempty"`
Error *string `json:"error,omitempty"`
Status ResponseStatus `json:"status,omitempty"`
}
type ResultRequest struct {
RequestId string `uri:"requestId"`
}
type ResponseStatus string
const (
ErrorStatus ResponseStatus = "ERROR"
RunningStatus ResponseStatus = "RUNNING"
FinishedStatus ResponseStatus = "FINISHED"
)
func (r ResponseStatus) pointer() *ResponseStatus {
return &r
}
func (r *RunNotebookResponse) String() string {
return fmt.Sprintf("{RequestId:%s, PyscriptHash:%s, Status:%s, Result:%s, Error:%s}", r.RequestId, r.PyscriptHash, r.Status, String(r.Result), String(r.Error))
}
func (r *RunNotebookRequest) String() string {
s, _ := json.Marshal(*r)
return string(s)
}
func String(s *string) string {
if s == nil {
return ""
}
return *s
}
func (s *Str) String() string {
if s == nil {
return "nil"
}
return s.string
}
func (r *ResponseStatus) String() string {
if r == nil {
return ""
}
return string(*r)
}