github.com/vmware/govmomi@v0.51.0/simulator/sim25/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 sim25
     6  
     7  import (
     8  	"context"
     9  	"time"
    10  
    11  	"github.com/vmware/govmomi/vim25"
    12  	"github.com/vmware/govmomi/vim25/methods"
    13  	"github.com/vmware/govmomi/vim25/types"
    14  )
    15  
    16  // SetSessionTimeout changes the default session timeout.
    17  func SetSessionTimeout(ctx context.Context, c *vim25.Client, timeout time.Duration) error {
    18  	// Note that real vCenter supports the same OptionValue Key, but only with a Value of whole seconds.
    19  	req := types.UpdateOptions{
    20  		This: *c.ServiceContent.Setting,
    21  		ChangedValue: []types.BaseOptionValue{
    22  			&types.OptionValue{
    23  				Key:   "config.vmacore.soap.sessionTimeout",
    24  				Value: timeout.String(),
    25  			},
    26  		},
    27  	}
    28  
    29  	_, err := methods.UpdateOptions(ctx, c, &req)
    30  	return err
    31  }