github.com/vmware/govmomi@v0.51.0/vapi/appliance/access/consolecli/consolecli.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 consolecli 6 7 import ( 8 "context" 9 "net/http" 10 11 "github.com/vmware/govmomi/vapi/rest" 12 ) 13 14 const Path = "/api/appliance/access/consolecli" 15 16 // Manager provides convenience methods to get/set enabled state of CLI. 17 type Manager struct { 18 *rest.Client 19 } 20 21 // NewManager creates a new Manager with the given client 22 func NewManager(client *rest.Client) *Manager { 23 return &Manager{ 24 Client: client, 25 } 26 } 27 28 // Get returns enabled state of the console-based controlled CLI (TTY1). 29 func (m *Manager) Get(ctx context.Context) (bool, error) { 30 r := m.Resource(Path) 31 32 var status bool 33 return status, m.Do(ctx, r.Request(http.MethodGet), &status) 34 } 35 36 // Access represents the value to be set for ConsoleCLI 37 type Access struct { 38 Enabled bool `json:"enabled"` 39 } 40 41 // Set enables state of the console-based controlled CLI (TTY1). 42 func (m *Manager) Set(ctx context.Context, inp Access) error { 43 r := m.Resource(Path) 44 45 return m.Do(ctx, r.Request(http.MethodPut, inp), nil) 46 }