github.com/vmware/govmomi@v0.51.0/vapi/appliance/access/shell/shell.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 shell 6 7 import ( 8 "context" 9 "net/http" 10 11 "github.com/vmware/govmomi/vapi/rest" 12 ) 13 14 const Path = "/api/appliance/access/shell" 15 16 // Manager provides convenience methods to get/set enabled state of BASH. 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 BASH, that is, access to BASH from within the controlled CLI. 29 func (m *Manager) Get(ctx context.Context) (Access, error) { 30 r := m.Resource(Path) 31 32 var status Access 33 return status, m.Do(ctx, r.Request(http.MethodGet), &status) 34 } 35 36 // Access represents shell configuration. 37 type Access struct { 38 Enabled bool `json:"enabled"` 39 Timeout int `json:"timeout"` 40 } 41 42 // Set enables state of BASH, that is access to BASH from within the controlled CLI. 43 func (m *Manager) Set(ctx context.Context, inp Access) error { 44 r := m.Resource(Path) 45 46 return m.Do(ctx, r.Request(http.MethodPut, inp), nil) 47 }