1/* 2Copyright (c) 2015 VMware, Inc. All Rights Reserved. 3 4Licensed under the Apache License, Version 2.0 (the "License"); 5you may not use this file except in compliance with the License. 6You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10Unless required by applicable law or agreed to in writing, software 11distributed under the License is distributed on an "AS IS" BASIS, 12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13See the License for the specific language governing permissions and 14limitations under the License. 15*/ 16 17package object 18 19import ( 20 "context" 21 22 "github.com/vmware/govmomi/vim25" 23 "github.com/vmware/govmomi/vim25/methods" 24 "github.com/vmware/govmomi/vim25/types" 25) 26 27type HostDatastoreBrowser struct { 28 Common 29} 30 31func NewHostDatastoreBrowser(c *vim25.Client, ref types.ManagedObjectReference) *HostDatastoreBrowser { 32 return &HostDatastoreBrowser{ 33 Common: NewCommon(c, ref), 34 } 35} 36 37func (b HostDatastoreBrowser) SearchDatastore(ctx context.Context, datastorePath string, searchSpec *types.HostDatastoreBrowserSearchSpec) (*Task, error) { 38 req := types.SearchDatastore_Task{ 39 This: b.Reference(), 40 DatastorePath: datastorePath, 41 SearchSpec: searchSpec, 42 } 43 44 res, err := methods.SearchDatastore_Task(ctx, b.c, &req) 45 if err != nil { 46 return nil, err 47 } 48 49 return NewTask(b.c, res.Returnval), nil 50} 51 52func (b HostDatastoreBrowser) SearchDatastoreSubFolders(ctx context.Context, datastorePath string, searchSpec *types.HostDatastoreBrowserSearchSpec) (*Task, error) { 53 req := types.SearchDatastoreSubFolders_Task{ 54 This: b.Reference(), 55 DatastorePath: datastorePath, 56 SearchSpec: searchSpec, 57 } 58 59 res, err := methods.SearchDatastoreSubFolders_Task(ctx, b.c, &req) 60 if err != nil { 61 return nil, err 62 } 63 64 return NewTask(b.c, res.Returnval), nil 65} 66