-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresourcemodel.go
159 lines (143 loc) · 4.99 KB
/
resourcemodel.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
package icp
import (
"bytes"
"fmt"
"time"
)
// Version type
//
// https://icp-api.itrsgroup.com/v2.0/Help/ResourceModel?modelName=PropertiesEntity
type Version struct {
Major int `json:"Major,omitempty"`
Minor int `json:"Minor,omitempty"`
Build int `json:"Build,omitempty"`
Revision int `json:"Revision,omitempty"`
MajorRevision int `json:"MajorRevision,omitempty"`
MinorRevision int `json:"MinorRevision,omitempty"`
}
// EntityPerformance type
//
// https://icp-api.itrsgroup.com/v2.0/Help/ResourceModel?modelName=EntityPerformance
type EntityPerformance struct {
DataSourceName string `json:"DataSourceName"`
DataDateTime *Time `json:"DataDateTime"`
SourceKey1 string `json:"SourceKey1"`
SourceKey2 string `json:"SourceKey2"`
SourceKey3 string `json:"SourceKey3"`
SourceKey4 string `json:"SourceKey4"`
SourceKey5 string `json:"SourceKey5"`
MetricName string `json:"MetricName"`
MetricValue string `json:"MetricValue"`
}
// EntityRelation type
//
// https://icp-api.itrsgroup.com/v2.0/Help/ResourceModel?modelName=EntityRelation
type EntityRelation struct {
DataSourceName string `json:"DataSourceName"`
Entity1SourceKey1 string `json:"Entity1SourceKey1"`
Entity1SourceKey2 string `json:"Entity1SourceKey2"`
Entity1SourceKey3 string `json:"Entity1SourceKey3"`
Entity1SourceKey4 string `json:"Entity1SourceKey4"`
Entity1SourceKey5 string `json:"Entity1SourceKey5"`
Entity2SourceKey1 string `json:"Entity2SourceKey1"`
Entity2SourceKey2 string `json:"Entity2SourceKey2"`
Entity2SourceKey3 string `json:"Entity2SourceKey3"`
Entity2SourceKey4 string `json:"Entity2SourceKey4"`
Entity2SourceKey5 string `json:"Entity2SourceKey5"`
RelationName string `json:"RelationName"`
EffectiveFrom *Time `json:"EffectiveFrom"`
}
// PropertiesEntity type
//
// https://icp-api.itrsgroup.com/v2.0/Help/ResourceModel?modelName=PropertiesEntity
type PropertiesEntity struct {
DataSourceName string `json:"DataSourceName"`
SourceKey1 string `json:"SourceKey1"`
SourceKey2 string `json:"SourceKey2"`
SourceKey3 string `json:"SourceKey3"`
SourceKey4 string `json:"SourceKey4"`
SourceKey5 string `json:"SourceKey5"`
PropertyName string `json:"PropertyName"`
PropertyValue string `json:"PropertyValue"`
EffectiveFrom *Time `json:"EffectiveFrom"`
}
// Metrics type
//
// https://icp-api.itrsgroup.com/v2.0/Help/ResourceModel?modelName=Metrics
type Metrics struct {
MetricName string `json:"MetricName"`
MetricValue string `json:"MetricValue"`
DataDateTime *Time `json:"DataDateTime"`
}
// MetricTimeSeries type
//
// https://icp-api.itrsgroup.com/v2.0/Help/ResourceModel?modelName=MetricTimeseries
type MetricTimeSeries struct {
MetricValue string `json:"MetricValue"`
DataDateTime *Time `json:"DataDateTime"`
}
// EntityProperties type
//
// https://icp-api.itrsgroup.com/v2.0/Help/ResourceModel?modelName=EntityProperties
type EntityProperties struct {
PropertyName string `json:"PropertyName"`
PropertyValue string `json:"PropertyValue"`
EffectiveFrom *Time `json:"EffectiveFrom"`
}
// MetricCapacities type
//
// https://icp-api.itrsgroup.com/v2.0/Help/ResourceModel?modelName=MetricCapacities
type MetricCapacities struct {
CapacityValue string `json:"CapacityValue"`
EffectiveFrom *Time `json:"EffectiveFrom"`
}
// PredictedEvent type
//
// https://icp-api.itrsgroup.com/v2.0/Help/ResourceModel?modelName=PredictedEvent
type PredictedEvent struct {
ID int `json:"Id,omitempty"`
Priority string `json:"Priority,omitempty"`
Confidence float64 `json:"Confidence,omitempty"`
EventTime *Time `json:"EventTime,omitempty"`
Metric string `json:"Metric,omitempty"`
Description string `json:"Description,omitempty"`
Entity string `json:"Entity,omitempty"`
EntityType string `json:"EntityType,omitempty"`
Element string `json:"Element,omitempty"`
InternalID string `json:"InternalId,omitempty"`
SourceServer string `json:"SourceServer,omitempty"`
IsClusterEvent bool `json:"IsClusterEvent,omitempty"`
Critical string `json:"Critical,omitempty"`
Major string `json:"Major,omitempty"`
Warning string `json:"Warning,omitempty"`
}
// Grouping type
//
// https://icp-api.itrsgroup.com/v2.0/Help/ResourceModel?modelName=Grouping
type Grouping struct {
Key string `json:"Key"`
Value string `json:"Value"`
}
// ICP date times may not have a timezone, work around it
type Time struct {
time.Time
}
func (t *Time) UnmarshalJSON(data []byte) (err error) {
if bytes.Equal(data, []byte("null")) || bytes.Contains(data, []byte("0001-01-01T00:00:00")) {
return
}
if bytes.Contains(data, []byte("Z")) {
t.Time, err = time.Parse(`"2006-01-02T15:04:05Z"`, string(data))
} else {
t.Time, err = time.Parse(`"2006-01-02T15:04:05"`, string(data))
}
if err == nil {
return
}
// try default
return t.Time.UnmarshalJSON(data)
}
func (t *Time) MarshalJSON() ([]byte, error) {
ts := fmt.Sprintf("%q", t.UTC().Format(time.RFC3339))
return []byte(ts), nil
}