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