github.com/vmware/govmomi@v0.51.0/object/host_date_time_system.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  	"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  type HostDateTimeSystem struct {
    17  	Common
    18  }
    19  
    20  func NewHostDateTimeSystem(c *vim25.Client, ref types.ManagedObjectReference) *HostDateTimeSystem {
    21  	return &HostDateTimeSystem{
    22  		Common: NewCommon(c, ref),
    23  	}
    24  }
    25  
    26  func (s HostDateTimeSystem) UpdateConfig(ctx context.Context, config types.HostDateTimeConfig) error {
    27  	req := types.UpdateDateTimeConfig{
    28  		This:   s.Reference(),
    29  		Config: config,
    30  	}
    31  
    32  	_, err := methods.UpdateDateTimeConfig(ctx, s.c, &req)
    33  	return err
    34  }
    35  
    36  func (s HostDateTimeSystem) Update(ctx context.Context, date time.Time) error {
    37  	req := types.UpdateDateTime{
    38  		This:     s.Reference(),
    39  		DateTime: date,
    40  	}
    41  
    42  	_, err := methods.UpdateDateTime(ctx, s.c, &req)
    43  	return err
    44  }
    45  
    46  func (s HostDateTimeSystem) Query(ctx context.Context) (*time.Time, error) {
    47  	req := types.QueryDateTime{
    48  		This: s.Reference(),
    49  	}
    50  
    51  	res, err := methods.QueryDateTime(ctx, s.c, &req)
    52  	if err != nil {
    53  		return nil, err
    54  	}
    55  
    56  	return &res.Returnval, nil
    57  }