/
bootstrap.go
162 lines (127 loc) · 6.11 KB
/
bootstrap.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
160
161
162
/*
Copyright (c) 2015, Alcatel-Lucent Inc
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package vspk
import "github.com/nuagenetworks/go-bambou/bambou"
// BootstrapIdentity represents the Identity of the object
var BootstrapIdentity = bambou.Identity{
Name: "bootstrap",
Category: "bootstraps",
}
// BootstrapsList represents a list of Bootstraps
type BootstrapsList []*Bootstrap
// BootstrapsAncestor is the interface that an ancestor of a Bootstrap must implement.
// An Ancestor is defined as an entity that has Bootstrap as a descendant.
// An Ancestor can get a list of its child Bootstraps, but not necessarily create one.
type BootstrapsAncestor interface {
Bootstraps(*bambou.FetchingInfo) (BootstrapsList, *bambou.Error)
}
// BootstrapsParent is the interface that a parent of a Bootstrap must implement.
// A Parent is defined as an entity that has Bootstrap as a child.
// A Parent is an Ancestor which can create a Bootstrap.
type BootstrapsParent interface {
BootstrapsAncestor
CreateBootstrap(*Bootstrap) *bambou.Error
}
// Bootstrap represents the model of a bootstrap
type Bootstrap struct {
ID string `json:"ID,omitempty"`
ParentID string `json:"parentID,omitempty"`
ParentType string `json:"parentType,omitempty"`
Owner string `json:"owner,omitempty"`
ZFBInfo string `json:"ZFBInfo,omitempty"`
ZFBMatchAttribute string `json:"ZFBMatchAttribute,omitempty"`
ZFBMatchValue string `json:"ZFBMatchValue,omitempty"`
LastUpdatedBy string `json:"lastUpdatedBy,omitempty"`
LastUpdatedDate string `json:"lastUpdatedDate,omitempty"`
ActivationURL string `json:"activationURL,omitempty"`
EmbeddedMetadata []interface{} `json:"embeddedMetadata,omitempty"`
InstallerID string `json:"installerID,omitempty"`
EntityScope string `json:"entityScope,omitempty"`
CreationDate string `json:"creationDate,omitempty"`
AssociatedEntityType string `json:"associatedEntityType,omitempty"`
Status string `json:"status,omitempty"`
Owner string `json:"owner,omitempty"`
ExternalID string `json:"externalID,omitempty"`
}
// NewBootstrap returns a new *Bootstrap
func NewBootstrap() *Bootstrap {
return &Bootstrap{
Status: "INACTIVE",
}
}
// Identity returns the Identity of the object.
func (o *Bootstrap) Identity() bambou.Identity {
return BootstrapIdentity
}
// Identifier returns the value of the object's unique identifier.
func (o *Bootstrap) Identifier() string {
return o.ID
}
// SetIdentifier sets the value of the object's unique identifier.
func (o *Bootstrap) SetIdentifier(ID string) {
o.ID = ID
}
// Fetch retrieves the Bootstrap from the server
func (o *Bootstrap) Fetch() *bambou.Error {
return bambou.CurrentSession().FetchEntity(o)
}
// Save saves the Bootstrap into the server
func (o *Bootstrap) Save() *bambou.Error {
return bambou.CurrentSession().SaveEntity(o)
}
// Delete deletes the Bootstrap from the server
func (o *Bootstrap) Delete() *bambou.Error {
return bambou.CurrentSession().DeleteEntity(o)
}
// Permissions retrieves the list of child Permissions of the Bootstrap
func (o *Bootstrap) Permissions(info *bambou.FetchingInfo) (PermissionsList, *bambou.Error) {
var list PermissionsList
err := bambou.CurrentSession().FetchChildren(o, PermissionIdentity, &list, info)
return list, err
}
// CreatePermission creates a new child Permission under the Bootstrap
func (o *Bootstrap) CreatePermission(child *Permission) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
}
// Metadatas retrieves the list of child Metadatas of the Bootstrap
func (o *Bootstrap) Metadatas(info *bambou.FetchingInfo) (MetadatasList, *bambou.Error) {
var list MetadatasList
err := bambou.CurrentSession().FetchChildren(o, MetadataIdentity, &list, info)
return list, err
}
// CreateMetadata creates a new child Metadata under the Bootstrap
func (o *Bootstrap) CreateMetadata(child *Metadata) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
}
// GlobalMetadatas retrieves the list of child GlobalMetadatas of the Bootstrap
func (o *Bootstrap) GlobalMetadatas(info *bambou.FetchingInfo) (GlobalMetadatasList, *bambou.Error) {
var list GlobalMetadatasList
err := bambou.CurrentSession().FetchChildren(o, GlobalMetadataIdentity, &list, info)
return list, err
}
// CreateGlobalMetadata creates a new child GlobalMetadata under the Bootstrap
func (o *Bootstrap) CreateGlobalMetadata(child *GlobalMetadata) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
}