-
Notifications
You must be signed in to change notification settings - Fork 7
/
special-properties.go
142 lines (129 loc) · 4.83 KB
/
special-properties.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
package special
import (
"github.com/apibrew/apibrew/pkg/model"
"github.com/apibrew/apibrew/pkg/service/annotations"
"google.golang.org/protobuf/types/known/structpb"
"time"
)
var IdProperty = &model.ResourceProperty{
Name: "id",
Type: model.ResourceProperty_UUID,
Primary: true,
Required: true,
Immutable: true,
Description: Pointer("The unique identifier of the resource. It is randomly generated and immutable."),
Annotations: map[string]string{
annotations.SpecialProperty: "true",
},
ExampleValue: structpb.NewStringValue("a39621a4-6d48-11ee-b962-0242ac120002"),
}
var VersionProperty = &model.ResourceProperty{
Name: "version",
Title: Pointer("Version"),
Description: Pointer("The version of the resource/record. It is incremented on every update."),
Type: model.ResourceProperty_INT32,
Required: true,
DefaultValue: structpb.NewNumberValue(1),
ExampleValue: structpb.NewNumberValue(1),
Annotations: map[string]string{
annotations.SpecialProperty: annotations.Enabled,
annotations.AllowEmptyPrimitive: annotations.Enabled,
},
}
var AuditPropertyCreatedBy = &model.ResourceProperty{
Name: "createdBy",
Title: Pointer("Created By"),
Description: Pointer("The user who created the resource/record."),
Type: model.ResourceProperty_STRING,
Length: 256,
Immutable: true,
ExampleValue: structpb.NewStringValue("admin"),
Annotations: map[string]string{
annotations.SpecialProperty: "true",
},
}
var AuditPropertyUpdatedBy = &model.ResourceProperty{
Name: "updatedBy",
Title: Pointer("Updated By"),
Description: Pointer("The user who last updated the resource/record."),
Type: model.ResourceProperty_STRING,
Length: 256,
Required: false,
ExampleValue: structpb.NewStringValue("admin"),
Annotations: map[string]string{
annotations.SpecialProperty: "true",
},
}
var AuditPropertyCreatedOn = &model.ResourceProperty{
Name: "createdOn",
Title: Pointer("Created On"),
Description: Pointer("The timestamp when the resource/record was created."),
Type: model.ResourceProperty_TIMESTAMP,
Immutable: true,
ExampleValue: structpb.NewStringValue(time.Now().Format(time.RFC3339)),
Annotations: map[string]string{
annotations.SpecialProperty: "true",
},
}
var AuditPropertyUpdatedOn = &model.ResourceProperty{
Name: "updatedOn",
Title: Pointer("Updated On"),
Description: Pointer("The timestamp when the resource/record was last updated."),
Type: model.ResourceProperty_TIMESTAMP,
Required: false,
ExampleValue: structpb.NewStringValue(time.Now().Format(time.RFC3339)),
Annotations: map[string]string{
annotations.SpecialProperty: "true",
},
}
var AuditDataSubType = &model.ResourceSubType{
Name: "AuditData",
Title: "Audit Data",
Description: "Audit Data is a type that represents the audit data of a resource/record. ",
Properties: []*model.ResourceProperty{
AuditPropertyCreatedBy,
AuditPropertyUpdatedBy,
AuditPropertyCreatedOn,
AuditPropertyUpdatedOn,
},
}
var AuditProperty = &model.ResourceProperty{
Name: "auditData",
Title: Pointer("Audit Data"),
Description: Pointer("The audit data of the resource/record. \nIt contains information about who created the resource/record, when it was created, who last updated the resource/record and when it was last updated."),
Type: model.ResourceProperty_STRUCT,
ExampleValue: structpb.NewStructValue(&structpb.Struct{Fields: map[string]*structpb.Value{
"createdBy": structpb.NewStringValue("admin"),
"updatedBy": structpb.NewStringValue("admin"),
"createdOn": structpb.NewStringValue(time.Now().Format(time.RFC3339)),
"updatedOn": structpb.NewStringValue(time.Now().Format(time.RFC3339)),
}}),
TypeRef: Pointer("AuditData"),
Annotations: map[string]string{
annotations.SpecialProperty: "true",
},
}
var AnnotationsProperty = &model.ResourceProperty{
Name: "annotations",
Title: Pointer("Annotations"),
Description: Pointer("The annotations of the resource/record. It contains information about the resource/record. For example, it can contain information about the UI representation of the resource/record."),
Type: model.ResourceProperty_MAP,
Required: false,
Immutable: false,
Item: &model.ResourceProperty{
Type: model.ResourceProperty_STRING,
},
ExampleValue: structpb.NewStructValue(&structpb.Struct{Fields: map[string]*structpb.Value{
annotations.CheckVersion: structpb.NewStringValue(annotations.Enabled),
annotations.IgnoreIfExists: structpb.NewStringValue(annotations.Enabled),
annotations.CommonType: structpb.NewStringValue("testType"),
}}),
Annotations: map[string]string{
annotations.SpecialProperty: annotations.Enabled,
},
}
func Pointer[T interface{}](val T) *T {
var pointer = new(T)
*pointer = val
return pointer
}