github.com/vmware/govmomi@v0.51.0/object/host_datastore_browser.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 object 6 7 import ( 8 "context" 9 10 "github.com/vmware/govmomi/vim25" 11 "github.com/vmware/govmomi/vim25/methods" 12 "github.com/vmware/govmomi/vim25/types" 13 ) 14 15 type HostDatastoreBrowser struct { 16 Common 17 } 18 19 func NewHostDatastoreBrowser(c *vim25.Client, ref types.ManagedObjectReference) *HostDatastoreBrowser { 20 return &HostDatastoreBrowser{ 21 Common: NewCommon(c, ref), 22 } 23 } 24 25 func (b HostDatastoreBrowser) SearchDatastore(ctx context.Context, datastorePath string, searchSpec *types.HostDatastoreBrowserSearchSpec) (*Task, error) { 26 req := types.SearchDatastore_Task{ 27 This: b.Reference(), 28 DatastorePath: datastorePath, 29 SearchSpec: searchSpec, 30 } 31 32 res, err := methods.SearchDatastore_Task(ctx, b.c, &req) 33 if err != nil { 34 return nil, err 35 } 36 37 return NewTask(b.c, res.Returnval), nil 38 } 39 40 func (b HostDatastoreBrowser) SearchDatastoreSubFolders(ctx context.Context, datastorePath string, searchSpec *types.HostDatastoreBrowserSearchSpec) (*Task, error) { 41 req := types.SearchDatastoreSubFolders_Task{ 42 This: b.Reference(), 43 DatastorePath: datastorePath, 44 SearchSpec: searchSpec, 45 } 46 47 res, err := methods.SearchDatastoreSubFolders_Task(ctx, b.c, &req) 48 if err != nil { 49 return nil, err 50 } 51 52 return NewTask(b.c, res.Returnval), nil 53 }