github.com/vmware/govmomi@v0.43.0/object/environment_browser.go (about) 1 /* 2 Copyright (c) 2023-2023 VMware, Inc. All Rights Reserved. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package object 18 19 import ( 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 27 type EnvironmentBrowser struct { 28 Common 29 } 30 31 func NewEnvironmentBrowser(c *vim25.Client, ref types.ManagedObjectReference) *EnvironmentBrowser { 32 return &EnvironmentBrowser{ 33 Common: NewCommon(c, ref), 34 } 35 } 36 37 func (b EnvironmentBrowser) QueryConfigTarget(ctx context.Context, host *HostSystem) (*types.ConfigTarget, error) { 38 req := types.QueryConfigTarget{ 39 This: b.Reference(), 40 } 41 42 if host != nil { 43 ref := host.Reference() 44 req.Host = &ref 45 } 46 47 res, err := methods.QueryConfigTarget(ctx, b.Client(), &req) 48 if err != nil { 49 return nil, err 50 } 51 52 return res.Returnval, nil 53 } 54 55 func (b EnvironmentBrowser) QueryTargetCapabilities(ctx context.Context, host *HostSystem) (*types.HostCapability, error) { 56 req := types.QueryTargetCapabilities{ 57 This: b.Reference(), 58 } 59 60 if host != nil { 61 ref := host.Reference() 62 req.Host = &ref 63 } 64 65 res, err := methods.QueryTargetCapabilities(ctx, b.Client(), &req) 66 if err != nil { 67 return nil, err 68 } 69 70 return res.Returnval, nil 71 } 72 73 func (b EnvironmentBrowser) QueryConfigOption(ctx context.Context, spec *types.EnvironmentBrowserConfigOptionQuerySpec) (*types.VirtualMachineConfigOption, error) { 74 req := types.QueryConfigOptionEx{ 75 This: b.Reference(), 76 Spec: spec, 77 } 78 79 res, err := methods.QueryConfigOptionEx(ctx, b.Client(), &req) 80 if err != nil { 81 return nil, err 82 } 83 84 return res.Returnval, nil 85 } 86 87 func (b EnvironmentBrowser) QueryConfigOptionDescriptor(ctx context.Context) ([]types.VirtualMachineConfigOptionDescriptor, error) { 88 req := types.QueryConfigOptionDescriptor{ 89 This: b.Reference(), 90 } 91 92 res, err := methods.QueryConfigOptionDescriptor(ctx, b.Client(), &req) 93 if err != nil { 94 return nil, err 95 } 96 97 return res.Returnval, nil 98 }