|
| 1 | +// This is a generated file. DO NOT EDIT manually. |
| 2 | +//go:generate goimports -w Blob.gen.go |
| 3 | + |
| 4 | +package go_xen_client |
| 5 | + |
| 6 | +import ( |
| 7 | + "reflect" |
| 8 | + "strconv" |
| 9 | + "time" |
| 10 | + |
| 11 | + "github.com/nilshell/xmlrpc" |
| 12 | +) |
| 13 | + |
| 14 | +//Blob: A placeholder for a binary blob |
| 15 | +type Blob struct { |
| 16 | + Uuid string // Unique identifier/object reference |
| 17 | + NameLabel string // a human-readable name |
| 18 | + NameDescription string // a notes field containing human-readable description |
| 19 | + Size int // Size of the binary data, in bytes |
| 20 | + Public bool // True if the blob is publicly accessible |
| 21 | + LastUpdated time.Time // Time at which the data in the blob was last updated |
| 22 | + MimeType string // The mime type associated with this object. Defaults to 'application/octet-stream' if the empty string is supplied |
| 23 | + |
| 24 | +} |
| 25 | + |
| 26 | +func FromBlobToXml(blob *Blob) (result xmlrpc.Struct) { |
| 27 | + result = make(xmlrpc.Struct) |
| 28 | + |
| 29 | + result["uuid"] = |
| 30 | + |
| 31 | + blob.Uuid |
| 32 | + |
| 33 | + result["name_label"] = |
| 34 | + |
| 35 | + blob.NameLabel |
| 36 | + |
| 37 | + result["name_description"] = |
| 38 | + |
| 39 | + blob.NameDescription |
| 40 | + |
| 41 | + result["size"] = |
| 42 | + |
| 43 | + strconv.Itoa(blob.Size) |
| 44 | + |
| 45 | + result["public"] = |
| 46 | + |
| 47 | + blob.Public |
| 48 | + |
| 49 | + result["last_updated"] = |
| 50 | + |
| 51 | + blob.LastUpdated |
| 52 | + |
| 53 | + result["mime_type"] = |
| 54 | + |
| 55 | + blob.MimeType |
| 56 | + |
| 57 | + return result |
| 58 | +} |
| 59 | + |
| 60 | +func ToBlob(obj interface{}) (resultObj *Blob) { |
| 61 | + |
| 62 | + objValue := reflect.ValueOf(obj) |
| 63 | + resultObj = &Blob{} |
| 64 | + |
| 65 | + for _, oKey := range objValue.MapKeys() { |
| 66 | + keyName := oKey.String() |
| 67 | + keyValue := objValue.MapIndex(oKey).Interface() |
| 68 | + switch keyName { |
| 69 | + case "uuid": |
| 70 | + if v, ok := keyValue.(string); ok { |
| 71 | + resultObj.Uuid = v |
| 72 | + } |
| 73 | + case "name_label": |
| 74 | + if v, ok := keyValue.(string); ok { |
| 75 | + resultObj.NameLabel = v |
| 76 | + } |
| 77 | + case "name_description": |
| 78 | + if v, ok := keyValue.(string); ok { |
| 79 | + resultObj.NameDescription = v |
| 80 | + } |
| 81 | + case "size": |
| 82 | + if v, ok := keyValue.(int); ok { |
| 83 | + resultObj.Size = v |
| 84 | + } |
| 85 | + case "public": |
| 86 | + if v, ok := keyValue.(bool); ok { |
| 87 | + resultObj.Public = v |
| 88 | + } |
| 89 | + case "last_updated": |
| 90 | + if v, ok := keyValue.(time.Time); ok { |
| 91 | + resultObj.LastUpdated = v |
| 92 | + } |
| 93 | + case "mime_type": |
| 94 | + if v, ok := keyValue.(string); ok { |
| 95 | + resultObj.MimeType = v |
| 96 | + } |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + return resultObj |
| 101 | +} |
| 102 | + |
| 103 | +/* GetAllRecords: Return a map of blob references to blob records for all blobs known to the system. */ |
| 104 | +func (client *XenClient) BlobGetAllRecords() (result map[string]Blob, err error) { |
| 105 | + obj, err := client.APICall("blob.get_all_records") |
| 106 | + if err != nil { |
| 107 | + return |
| 108 | + } |
| 109 | + |
| 110 | + interim := reflect.ValueOf(obj) |
| 111 | + result = map[string]Blob{} |
| 112 | + for _, key := range interim.MapKeys() { |
| 113 | + obj := interim.MapIndex(key) |
| 114 | + mapObj := ToBlob(obj.Interface()) |
| 115 | + result[key.String()] = *mapObj |
| 116 | + } |
| 117 | + |
| 118 | + return |
| 119 | +} |
| 120 | + |
| 121 | +/* GetAll: Return a list of all the blobs known to the system. */ |
| 122 | +func (client *XenClient) BlobGetAll() (result []string, err error) { |
| 123 | + obj, err := client.APICall("blob.get_all") |
| 124 | + if err != nil { |
| 125 | + return |
| 126 | + } |
| 127 | + |
| 128 | + result = make([]string, len(obj.([]interface{}))) |
| 129 | + for i, value := range obj.([]interface{}) { |
| 130 | + result[i] = value.(string) |
| 131 | + } |
| 132 | + |
| 133 | + return |
| 134 | +} |
| 135 | + |
| 136 | +/* Destroy: */ |
| 137 | +func (client *XenClient) BlobDestroy(self string) (err error) { |
| 138 | + _, err = client.APICall("blob.destroy", self) |
| 139 | + if err != nil { |
| 140 | + return |
| 141 | + } |
| 142 | + // no return result |
| 143 | + return |
| 144 | +} |
| 145 | + |
| 146 | +/* Create: Create a placeholder for a binary blob */ |
| 147 | +func (client *XenClient) BlobCreate(mime_type string, public bool) (result string, err error) { |
| 148 | + obj, err := client.APICall("blob.create", mime_type, public) |
| 149 | + if err != nil { |
| 150 | + return |
| 151 | + } |
| 152 | + result = obj.(string) |
| 153 | + return |
| 154 | +} |
| 155 | + |
| 156 | +/* SetPublic: Set the public field of the given blob. */ |
| 157 | +func (client *XenClient) BlobSetPublic(self string, value bool) (err error) { |
| 158 | + _, err = client.APICall("blob.set_public", self, value) |
| 159 | + if err != nil { |
| 160 | + return |
| 161 | + } |
| 162 | + // no return result |
| 163 | + return |
| 164 | +} |
| 165 | + |
| 166 | +/* SetNameDescription: Set the name/description field of the given blob. */ |
| 167 | +func (client *XenClient) BlobSetNameDescription(self string, value string) (err error) { |
| 168 | + _, err = client.APICall("blob.set_name_description", self, value) |
| 169 | + if err != nil { |
| 170 | + return |
| 171 | + } |
| 172 | + // no return result |
| 173 | + return |
| 174 | +} |
| 175 | + |
| 176 | +/* SetNameLabel: Set the name/label field of the given blob. */ |
| 177 | +func (client *XenClient) BlobSetNameLabel(self string, value string) (err error) { |
| 178 | + _, err = client.APICall("blob.set_name_label", self, value) |
| 179 | + if err != nil { |
| 180 | + return |
| 181 | + } |
| 182 | + // no return result |
| 183 | + return |
| 184 | +} |
| 185 | + |
| 186 | +/* GetMimeType: Get the mime_type field of the given blob. */ |
| 187 | +func (client *XenClient) BlobGetMimeType(self string) (result string, err error) { |
| 188 | + obj, err := client.APICall("blob.get_mime_type", self) |
| 189 | + if err != nil { |
| 190 | + return |
| 191 | + } |
| 192 | + result = obj.(string) |
| 193 | + return |
| 194 | +} |
| 195 | + |
| 196 | +/* GetLastUpdated: Get the last_updated field of the given blob. */ |
| 197 | +func (client *XenClient) BlobGetLastUpdated(self string) (result time.Time, err error) { |
| 198 | + obj, err := client.APICall("blob.get_last_updated", self) |
| 199 | + if err != nil { |
| 200 | + return |
| 201 | + } |
| 202 | + result = obj.(time.Time) |
| 203 | + return |
| 204 | +} |
| 205 | + |
| 206 | +/* GetPublic: Get the public field of the given blob. */ |
| 207 | +func (client *XenClient) BlobGetPublic(self string) (result bool, err error) { |
| 208 | + obj, err := client.APICall("blob.get_public", self) |
| 209 | + if err != nil { |
| 210 | + return |
| 211 | + } |
| 212 | + result = obj.(bool) |
| 213 | + return |
| 214 | +} |
| 215 | + |
| 216 | +/* GetSize: Get the size field of the given blob. */ |
| 217 | +func (client *XenClient) BlobGetSize(self string) (result int, err error) { |
| 218 | + obj, err := client.APICall("blob.get_size", self) |
| 219 | + if err != nil { |
| 220 | + return |
| 221 | + } |
| 222 | + result = obj.(int) |
| 223 | + return |
| 224 | +} |
| 225 | + |
| 226 | +/* GetNameDescription: Get the name/description field of the given blob. */ |
| 227 | +func (client *XenClient) BlobGetNameDescription(self string) (result string, err error) { |
| 228 | + obj, err := client.APICall("blob.get_name_description", self) |
| 229 | + if err != nil { |
| 230 | + return |
| 231 | + } |
| 232 | + result = obj.(string) |
| 233 | + return |
| 234 | +} |
| 235 | + |
| 236 | +/* GetNameLabel: Get the name/label field of the given blob. */ |
| 237 | +func (client *XenClient) BlobGetNameLabel(self string) (result string, err error) { |
| 238 | + obj, err := client.APICall("blob.get_name_label", self) |
| 239 | + if err != nil { |
| 240 | + return |
| 241 | + } |
| 242 | + result = obj.(string) |
| 243 | + return |
| 244 | +} |
| 245 | + |
| 246 | +/* GetUuid: Get the uuid field of the given blob. */ |
| 247 | +func (client *XenClient) BlobGetUuid(self string) (result string, err error) { |
| 248 | + obj, err := client.APICall("blob.get_uuid", self) |
| 249 | + if err != nil { |
| 250 | + return |
| 251 | + } |
| 252 | + result = obj.(string) |
| 253 | + return |
| 254 | +} |
| 255 | + |
| 256 | +/* GetByNameLabel: Get all the blob instances with the given label. */ |
| 257 | +func (client *XenClient) BlobGetByNameLabel(label string) (result []string, err error) { |
| 258 | + obj, err := client.APICall("blob.get_by_name_label", label) |
| 259 | + if err != nil { |
| 260 | + return |
| 261 | + } |
| 262 | + |
| 263 | + result = make([]string, len(obj.([]interface{}))) |
| 264 | + for i, value := range obj.([]interface{}) { |
| 265 | + result[i] = value.(string) |
| 266 | + } |
| 267 | + |
| 268 | + return |
| 269 | +} |
| 270 | + |
| 271 | +/* GetByUuid: Get a reference to the blob instance with the specified UUID. */ |
| 272 | +func (client *XenClient) BlobGetByUuid(uuid string) (result string, err error) { |
| 273 | + obj, err := client.APICall("blob.get_by_uuid", uuid) |
| 274 | + if err != nil { |
| 275 | + return |
| 276 | + } |
| 277 | + result = obj.(string) |
| 278 | + return |
| 279 | +} |
| 280 | + |
| 281 | +/* GetRecord: Get a record containing the current state of the given blob. */ |
| 282 | +func (client *XenClient) BlobGetRecord(self string) (result Blob, err error) { |
| 283 | + obj, err := client.APICall("blob.get_record", self) |
| 284 | + if err != nil { |
| 285 | + return |
| 286 | + } |
| 287 | + |
| 288 | + result = *ToBlob(obj.(interface{})) |
| 289 | + |
| 290 | + return |
| 291 | +} |
0 commit comments