github.com/vmware/govmomi@v0.51.0/vslm/client.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 vslm 6 7 import ( 8 "context" 9 10 "github.com/vmware/govmomi/vim25" 11 "github.com/vmware/govmomi/vim25/soap" 12 vim "github.com/vmware/govmomi/vim25/types" 13 "github.com/vmware/govmomi/vslm/methods" 14 "github.com/vmware/govmomi/vslm/types" 15 ) 16 17 const ( 18 Namespace = "vslm" 19 Path = "/vslm/sdk" 20 ) 21 22 var ( 23 ServiceInstance = vim.ManagedObjectReference{ 24 Type: "VslmServiceInstance", 25 Value: "ServiceInstance", 26 } 27 ) 28 29 type Client struct { 30 *soap.Client 31 32 ServiceContent types.VslmServiceInstanceContent 33 } 34 35 func NewClient(ctx context.Context, c *vim25.Client) (*Client, error) { 36 sc := c.Client.NewServiceClient(Path, Namespace) 37 sc.Cookie = c.SessionCookie // vcSessionCookie soap.Header, value must be from vim25.Client 38 39 req := types.RetrieveContent{ 40 This: ServiceInstance, 41 } 42 43 res, err := methods.RetrieveContent(ctx, sc, &req) 44 if err != nil { 45 return nil, err 46 } 47 48 return &Client{sc, res.Returnval}, nil 49 }