github.com/vmware/govmomi@v0.51.0/vapi/library/library_item_storage.go (about) 1 // © Broadcom. All Rights Reserved. 2 // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 3 // SPDX-License-Identifier: Apache-2.0 4 5 package library 6 7 import ( 8 "context" 9 "net/http" 10 11 "github.com/vmware/govmomi/vapi/internal" 12 ) 13 14 // Storage is an expanded form of library.File that includes details about the 15 // storage backing for a file in a library item 16 type Storage struct { 17 Checksum Checksum `json:"checksum_info,omitempty"` 18 StorageBacking StorageBacking `json:"storage_backing"` 19 StorageURIs []string `json:"storage_uris"` 20 Name string `json:"name"` 21 Size int64 `json:"size"` 22 Cached bool `json:"cached"` 23 Version string `json:"version"` 24 } 25 26 // ListLibraryItemStorage returns a list of all the storage for a library item. 27 func (c *Manager) ListLibraryItemStorage(ctx context.Context, id string) ([]Storage, error) { 28 url := c.Resource(internal.LibraryItemStoragePath).WithParam("library_item_id", id) 29 var res []Storage 30 return res, c.Do(ctx, url.Request(http.MethodGet), &res) 31 } 32 33 // GetLibraryItemStorage returns the storage for a specific file in a library item. 34 func (c *Manager) GetLibraryItemStorage(ctx context.Context, id, fileName string) ([]Storage, error) { 35 url := c.Resource(internal.LibraryItemStoragePath).WithID(id).WithAction("get") 36 spec := struct { 37 Name string `json:"file_name"` 38 }{fileName} 39 var res []Storage 40 return res, c.Do(ctx, url.Request(http.MethodPost, spec), &res) 41 }