-
Notifications
You must be signed in to change notification settings - Fork 69
/
common.go
99 lines (80 loc) · 2.95 KB
/
common.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
package gtm
import (
"fmt"
"net/http"
)
// default schema version
var schemaVersion = "1.6"
// internal method to set version. passed in as string
func setVersionHeader(req *http.Request, version string) {
req.Header.Set("Accept", fmt.Sprintf("application/vnd.config-gtm.v%s+json", version))
if req.Method != "GET" {
req.Header.Set("Content-Type", fmt.Sprintf("application/vnd.config-gtm.v%s+json", version))
}
return
}
// ResponseStatus is returned on Create, Update or Delete operations for all entity types
type ResponseStatus struct {
ChangeID string `json:"changeId,omitempty"`
Links *[]Link `json:"links,omitempty"`
Message string `json:"message,omitempty"`
PassingValidation bool `json:"passingValidation,omitempty"`
PropagationStatus string `json:"propagationStatus,omitempty"`
PropagationStatusDate string `json:"propagationStatusDate,omitempty"`
}
// ResponseBody is a generic response struct
type ResponseBody struct {
Resource interface{} `json:"resource"`
Status *ResponseStatus `json:"status"`
}
// DomainResponse contains a response after creating or updating Domain
type DomainResponse struct {
Resource *Domain `json:"resource"`
Status *ResponseStatus `json:"status"`
}
// DatacenterResponse contains a response after creating or updating Datacenter
type DatacenterResponse struct {
Status *ResponseStatus `json:"status"`
Resource *Datacenter `json:"resource"`
}
// PropertyResponse contains a response after creating or updating Property
type PropertyResponse struct {
Resource *Property `json:"resource"`
Status *ResponseStatus `json:"status"`
}
// ResourceResponse contains a response after creating or updating Resource
type ResourceResponse struct {
Resource *Resource `json:"resource"`
Status *ResponseStatus `json:"status"`
}
// CIDRMapResponse contains a response after creating or updating CIDRMap
type CIDRMapResponse struct {
Resource *CIDRMap `json:"resource"`
Status *ResponseStatus `json:"status"`
}
// GeoMapResponse contains a response after creating or updating GeoMap
type GeoMapResponse struct {
Resource *GeoMap `json:"resource"`
Status *ResponseStatus `json:"status"`
}
// ASMapResponse contains a response after creating or updating ASMap
type ASMapResponse struct {
Resource *ASMap `json:"resource"`
Status *ResponseStatus `json:"status"`
}
// Link is Probably THE most common type
type Link struct {
Rel string `json:"rel"`
Href string `json:"href"`
}
// LoadObject contains information about the load reporting interface
type LoadObject struct {
LoadObject string `json:"loadObject,omitempty"`
LoadObjectPort int `json:"loadObjectPort,omitempty"`
LoadServers []string `json:"loadServers,omitempty"`
}
// DatacenterBase is a placeholder for default Datacenter
type DatacenterBase struct {
Nickname string `json:"nickname,omitempty"`
DatacenterID int `json:"datacenterId"`
}