/
vmresync.go
156 lines (121 loc) · 5.81 KB
/
vmresync.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
/*
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"
// VMResyncIdentity represents the Identity of the object
var VMResyncIdentity = bambou.Identity{
Name: "resync",
Category: "resync",
}
// VMResyncsList represents a list of VMResyncs
type VMResyncsList []*VMResync
// VMResyncsAncestor is the interface that an ancestor of a VMResync must implement.
// An Ancestor is defined as an entity that has VMResync as a descendant.
// An Ancestor can get a list of its child VMResyncs, but not necessarily create one.
type VMResyncsAncestor interface {
VMResyncs(*bambou.FetchingInfo) (VMResyncsList, *bambou.Error)
}
// VMResyncsParent is the interface that a parent of a VMResync must implement.
// A Parent is defined as an entity that has VMResync as a child.
// A Parent is an Ancestor which can create a VMResync.
type VMResyncsParent interface {
VMResyncsAncestor
CreateVMResync(*VMResync) *bambou.Error
}
// VMResync represents the model of a resync
type VMResync struct {
ID string `json:"ID,omitempty"`
ParentID string `json:"parentID,omitempty"`
ParentType string `json:"parentType,omitempty"`
Owner string `json:"owner,omitempty"`
LastRequestTimestamp int `json:"lastRequestTimestamp,omitempty"`
LastTimeResyncInitiated int `json:"lastTimeResyncInitiated,omitempty"`
LastUpdatedBy string `json:"lastUpdatedBy,omitempty"`
LastUpdatedDate string `json:"lastUpdatedDate,omitempty"`
EmbeddedMetadata []interface{} `json:"embeddedMetadata,omitempty"`
EntityScope string `json:"entityScope,omitempty"`
CreationDate string `json:"creationDate,omitempty"`
Status string `json:"status,omitempty"`
Owner string `json:"owner,omitempty"`
ExternalID string `json:"externalID,omitempty"`
}
// NewVMResync returns a new *VMResync
func NewVMResync() *VMResync {
return &VMResync{}
}
// Identity returns the Identity of the object.
func (o *VMResync) Identity() bambou.Identity {
return VMResyncIdentity
}
// Identifier returns the value of the object's unique identifier.
func (o *VMResync) Identifier() string {
return o.ID
}
// SetIdentifier sets the value of the object's unique identifier.
func (o *VMResync) SetIdentifier(ID string) {
o.ID = ID
}
// Fetch retrieves the VMResync from the server
func (o *VMResync) Fetch() *bambou.Error {
return bambou.CurrentSession().FetchEntity(o)
}
// Save saves the VMResync into the server
func (o *VMResync) Save() *bambou.Error {
return bambou.CurrentSession().SaveEntity(o)
}
// Delete deletes the VMResync from the server
func (o *VMResync) Delete() *bambou.Error {
return bambou.CurrentSession().DeleteEntity(o)
}
// Permissions retrieves the list of child Permissions of the VMResync
func (o *VMResync) 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 VMResync
func (o *VMResync) CreatePermission(child *Permission) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
}
// Metadatas retrieves the list of child Metadatas of the VMResync
func (o *VMResync) 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 VMResync
func (o *VMResync) CreateMetadata(child *Metadata) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
}
// GlobalMetadatas retrieves the list of child GlobalMetadatas of the VMResync
func (o *VMResync) 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 VMResync
func (o *VMResync) CreateGlobalMetadata(child *GlobalMetadata) *bambou.Error {
return bambou.CurrentSession().CreateChild(o, child)
}