-
Notifications
You must be signed in to change notification settings - Fork 0
/
rest_type_subresource.go
105 lines (86 loc) · 2.37 KB
/
rest_type_subresource.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
// Copyright (c) Topicus Security B.V.
// SPDX-License-Identifier: APSL-2.0
package model
type restSubresourceClassType struct {
reachable bool
name string
prefix string
nestedType RestType
dsType *restSubresourceClassType
}
func NewRestSubresourceClassType(name string, prefix string, nestedType RestType) RestType {
return &restSubresourceClassType{
name: name,
prefix: prefix,
nestedType: nestedType,
}
}
func (t *restSubresourceClassType) Reachable() bool {
return t.reachable
}
func (t *restSubresourceClassType) MarkReachable() {
if t.reachable {
return
}
t.reachable = true
t.nestedType.MarkReachable()
}
func (t *restSubresourceClassType) Extends(typeName string) bool {
return t.nestedType.Extends(typeName)
}
func (t *restSubresourceClassType) IsObject() bool {
return t.nestedType.IsObject()
}
func (t *restSubresourceClassType) ObjectAttrTypesName() string {
return FirstCharToLower(t.name) + "AttrTypes"
}
func (t *restSubresourceClassType) DataStructName() string {
return FirstCharToLower(t.name) + "Data"
}
func (t *restSubresourceClassType) APITypeName() string {
return t.nestedType.APITypeName()
}
func (t *restSubresourceClassType) APIDiscriminator() string {
return t.nestedType.APIDiscriminator()
}
func (t *restSubresourceClassType) GoTypeName() string {
return FirstCharToUpper(t.name)
}
func (t *restSubresourceClassType) SDKTypeName() string {
return t.nestedType.SDKTypeName()
}
func (t *restSubresourceClassType) SDKTypeConstructor() string {
return t.nestedType.SDKTypeConstructor()
}
func (t *restSubresourceClassType) AllProperties() []*RestProperty {
ret := make([]*RestProperty, 0)
parent := &RestProperty{
Parent: t,
Name: t.prefix + "Uuid",
Required: true,
WriteOnly: false,
Deprecated: false,
}
parent.Type = NewFindParentByUUIDObjectType()
ret = append(ret, parent)
ret = append(ret, t.nestedType.AllProperties()...)
return ret
}
func (t *restSubresourceClassType) HasDirectUUIDProperty() bool {
return t.nestedType.HasDirectUUIDProperty()
}
func (t *restSubresourceClassType) Suffix() string {
return t.nestedType.Suffix()
}
func (t *restSubresourceClassType) DS() RestType {
if t.dsType != nil {
// break recursion
return t.dsType
}
t.dsType = &restSubresourceClassType{
name: t.name,
prefix: t.prefix,
nestedType: t.nestedType.DS(),
}
return t.dsType
}