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