-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtypes.go
220 lines (193 loc) · 6.89 KB
/
types.go
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
package gofaas
import (
"time"
)
// QueryParams is for HTTP Request
type QueryParams map[string]string
// FaasRequestDefinition is for faas request
type FaasRequestDefinition struct {
// Method can be GET/PUT/POST/PATCH/DELETE
Method string
// This is the address of OpenFaas gateway you get e.g. http://127.0.0.1:8080
GatewayAddress string
// Path of the API being called e.g. /system/functions (Trailing slash must be specified)
Path string
// URL is the full path of the API being called which is basically gateway address + path (E.g. http://127.0.0.1:8080/system/functions)
URL string
// http headers
Headers map[string]string
// query params
QueryParams QueryParams
// request body to send. Must be byte array
Body []byte
// Cluster Type e.g. swarm/kubernetes
ClusterType string
}
// HTTPResponse will holds the response from an API call.
type HTTPResponse struct {
StatusCode int // e.g. 200
Body string // e.g. {"result: success"}
Headers map[string][]string // e.g. Authorization:"Basic qwertyuiop"
}
// OpenFaasClient is a client
type OpenFaasClient struct {
FaasRequestDefinition
}
// FaasGatewayCredentials is for faas gateway credentials
type FaasGatewayCredentials struct {
Username string `json:"username"`
Password string `json:"password"`
GatewayAddress string `json:"gatewayAddress"`
ClusterType string `json:"clusterType"`
}
// FunctionListEntry functions list entry
type FunctionListEntry []struct {
Name string `json:"name"`
Image string `json:"image"`
InvocationCount int64 `json:"invocationCount"`
Replicas int64 `json:"replicas"`
AvailableReplicas int64 `json:"availableReplicas"`
EnvProcess string `json:"envProcess"`
Labels map[string]string `json:"labels"`
Annotations map[string]string `json:"annotations"`
}
// Annotations struct for annotations
type Annotations struct {
Topics string `json:"topics"`
Foo string `json:"foo"`
}
// EnvVars for environment variables
type EnvVars struct {
AdditionalProp1 string `json:"additionalProp1"`
AdditionalProp2 string `json:"additionalProp2"`
AdditionalProp3 string `json:"additionalProp3"`
}
// Limits struct for hardware limits
type Limits struct {
Memory string `json:"memory"`
CPU string `json:"cpu"`
}
// Requests struct for hardware request
type Requests struct {
Memory string `json:"memory"`
CPU string `json:"cpu"`
}
// SyncInvocationOpts defines synchronous invocation options
type SyncInvocationOpts struct {
Body interface{}
FunctionName string
}
// AsyncInvocationOpts defines asynchronous invocation options
type AsyncInvocationOpts struct {
Body interface{}
FunctionName string
CallbackURL string
}
// FunctionDefintion defines a function
type FunctionDefintion struct {
Service string `json:"service"`
Network string `json:"network"`
Image string `json:"image"`
EnvProcess string `json:"envProcess"`
EnvVars EnvVars `json:"envVars"`
Constraints []string `json:"constraints"`
Labels map[string]string `json:"labels"`
Annotations Annotations `json:"annotations"`
Secrets []string `json:"secrets"`
RegistryAuth string `json:"registryAuth"`
Limits Limits `json:"limits"`
Requests Requests `json:"requests"`
ReadOnlyRootFilesystem bool `json:"readOnlyRootFilesystem"`
}
// DeleteFunctionBodyOpts is for deleting funtion body options
type DeleteFunctionBodyOpts struct {
FunctionName string `json:"functionName"`
}
// SystemAlertLables defines system alert lables
type SystemAlertLables struct {
Alertname string `json:"alertname"`
Code string `json:"code"`
FunctionName string `json:"function_name"`
Instance string `json:"instance"`
Job string `json:"job"`
Monitor string `json:"monitor"`
Service string `json:"service"`
Severity string `json:"severity"`
Value string `json:"value"`
}
// SystemAlertAnnotations defines system alert annotations
type SystemAlertAnnotations struct {
Description string `json:"description"`
Summary string `json:"summary"`
}
// SystemAlertsStruct defines system alerts
type SystemAlertsStruct struct {
Status string `json:"status"`
Labels SystemAlertLables `json:"labels"`
Annotations SystemAlertAnnotations `json:"annotations"`
StartsAt time.Time `json:"startsAt"`
EndsAt time.Time `json:"endsAt"`
GeneratorURL string `json:"generatorURL"`
}
// GroupLabels defines group labels
type GroupLabels struct {
Alertname string `json:"alertname"`
Service string `json:"service"`
}
// CommonLabels defines common labels
type CommonLabels struct {
Alertname string `json:"alertname"`
Code string `json:"code"`
FunctionName string `json:"function_name"`
Instance string `json:"instance"`
Job string `json:"job"`
Monitor string `json:"monitor"`
Service string `json:"service"`
Severity string `json:"severity"`
Value string `json:"value"`
}
// CommonAnnotations defines common annotations
type CommonAnnotations struct {
Description string `json:"description"`
Summary string `json:"summary"`
}
// SystemAlertBodyOpts defines system alert body options
type SystemAlertBodyOpts struct {
Receiver string `json:"receiver"`
Status string `json:"status"`
Alerts []SystemAlertsStruct `json:"alerts"`
GroupLabels GroupLabels `json:"groupLabels"`
CommonLabels CommonLabels `json:"commonLabels"`
CommonAnnotations CommonAnnotations `json:"commonAnnotations"`
ExternalURL string `json:"externalURL"`
Version string `json:"version"`
GroupKey int64 `json:"groupKey"`
}
// ScaleFunctionBodyOpts defines scale function body options
type ScaleFunctionBodyOpts struct {
Service string `json:"service"`
Replicas int `json:"replicas"`
}
// SecretBodyOpts defines secret body options
type SecretBodyOpts struct {
Name string `json:"name"`
Value string `json:"value"`
}
// LogEntry defines log entry
type LogEntry struct {
Name string `json:"name"`
Instance string `json:"instance"`
Timestamp time.Time `json:"timestamp"`
Text string `json:"text"`
}
// SecretNameBodyOpts defines secret name body options
type SecretNameBodyOpts struct {
Name string `json:"name"`
}
// SystemLogsQueryOpts defines system logs query opts
type SystemLogsQueryOpts struct {
Name string `json:"name"`
Since string `json:"since"`
Tail int `json:"tail"`
Follow bool `json:"follow"`
}