github.com/vmware/govmomi@v0.51.0/vapi/library/library_file.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 // Checksum provides checksum information on library item files. 15 type Checksum struct { 16 Algorithm string `json:"algorithm,omitempty"` 17 Checksum string `json:"checksum"` 18 } 19 20 // File provides methods to get information on library item files. 21 type File struct { 22 Cached *bool `json:"cached,omitempty"` 23 Checksum *Checksum `json:"checksum_info,omitempty"` 24 Name string `json:"name,omitempty"` 25 Size *int64 `json:"size,omitempty"` 26 Version string `json:"version,omitempty"` 27 DownloadEndpoint string `json:"file_download_endpoint,omitempty"` 28 } 29 30 // ListLibraryItemFiles returns a list of all the files for a library item. 31 func (c *Manager) ListLibraryItemFiles(ctx context.Context, id string) ([]File, error) { 32 url := c.Resource(internal.LibraryItemFilePath).WithParam("library_item_id", id) 33 var res []File 34 return res, c.Do(ctx, url.Request(http.MethodGet), &res) 35 } 36 37 // GetLibraryItemFile returns a file with the provided name for a library item. 38 func (c *Manager) GetLibraryItemFile(ctx context.Context, id, fileName string) (*File, error) { 39 url := c.Resource(internal.LibraryItemFilePath).WithID(id).WithAction("get") 40 spec := struct { 41 Name string `json:"name"` 42 }{fileName} 43 var res File 44 return &res, c.Do(ctx, url.Request(http.MethodPost, spec), &res) 45 }