/
graphpolicyinfo.go
74 lines (53 loc) · 1.57 KB
/
graphpolicyinfo.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
package gaia
import (
"fmt"
"github.com/mitchellh/copystructure"
"go.aporeto.io/elemental"
)
// GraphPolicyInfo represents the model of a graphpolicyinfo
type GraphPolicyInfo struct {
// Number of times the policy has been hit.
Count int `json:"count" msgpack:"count" bson:"-" mapstructure:"count,omitempty"`
// Namespace of the policy.
Namespace string `json:"namespace" msgpack:"namespace" bson:"-" mapstructure:"namespace,omitempty"`
ModelVersion int `json:"-" msgpack:"-" bson:"_modelversion"`
}
// NewGraphPolicyInfo returns a new *GraphPolicyInfo
func NewGraphPolicyInfo() *GraphPolicyInfo {
return &GraphPolicyInfo{
ModelVersion: 1,
}
}
// BleveType implements the bleve.Classifier Interface.
func (o *GraphPolicyInfo) BleveType() string {
return "graphpolicyinfo"
}
// DeepCopy returns a deep copy if the GraphPolicyInfo.
func (o *GraphPolicyInfo) DeepCopy() *GraphPolicyInfo {
if o == nil {
return nil
}
out := &GraphPolicyInfo{}
o.DeepCopyInto(out)
return out
}
// DeepCopyInto copies the receiver into the given *GraphPolicyInfo.
func (o *GraphPolicyInfo) DeepCopyInto(out *GraphPolicyInfo) {
target, err := copystructure.Copy(o)
if err != nil {
panic(fmt.Sprintf("Unable to deepcopy GraphPolicyInfo: %s", err))
}
*out = *target.(*GraphPolicyInfo)
}
// Validate valides the current information stored into the structure.
func (o *GraphPolicyInfo) Validate() error {
errors := elemental.Errors{}
requiredErrors := elemental.Errors{}
if len(requiredErrors) > 0 {
return requiredErrors
}
if len(errors) > 0 {
return errors
}
return nil
}