/
model.go
85 lines (72 loc) · 1.99 KB
/
model.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
/*
* © 2018 SAP SE or an SAP affiliate company.
* All rights reserved.
* Please see http://www.sap.com/corporate-en/legal/copyright/index.epx for additional trademark information and
* notices.
*/
package testkit
import (
"bytes"
"encoding/json"
)
var (
ApiRawSpec = compact([]byte("{\"name\":\"api\"}"))
EventsRawSpec = compact([]byte("{\"name\":\"events\"}"))
)
type Service struct {
ID string `json:"id"`
Provider string `json:"provider"`
Name string `json:"name"`
Description string `json:"description"`
}
type ServiceDetails struct {
Provider string `json:"provider"`
Name string `json:"name"`
Description string `json:"description"`
Api *API `json:"api,omitempty"`
Events *Events `json:"events,omitempty"`
Documentation *Documentation `json:"documentation,omitempty"`
}
type PostServiceResponse struct {
ID string `json:"id"`
}
type ErrorResponse struct {
Code int `json:"code"`
Error string `json:"error"`
}
type API struct {
TargetUrl string `json:"targetUrl"`
Credentials *Credentials `json:"credentials,omitempty"`
Spec json.RawMessage `json:"spec,omitempty"`
}
type Credentials struct {
Oauth Oauth `json:"oauth"`
}
type Oauth struct {
URL string `json:"url"`
ClientID string `json:"clientId"`
ClientSecret string `json:"clientSecret"`
}
type Events struct {
Spec json.RawMessage `json:"spec,omitempty"`
}
type Documentation struct {
DisplayName string `json:"displayName"`
Description string `json:"description"`
Type string `json:"type"`
Tags []string `json:"tags,omitempty"`
Docs []DocsObject `json:"docs,omitempty"`
}
type DocsObject struct {
Title string `json:"title"`
Type string `json:"type"`
Source string `json:"source"`
}
func compact(src []byte) []byte {
buffer := new(bytes.Buffer)
err := json.Compact(buffer, src)
if err != nil {
return src
}
return buffer.Bytes()
}