github.com/vmware/govmomi@v0.37.1/vapi/appliance/access/dcui/dcui.go (about) 1 /* 2 Copyright (c) 2022 VMware, Inc. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0. 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 dcui 18 19 import ( 20 "context" 21 "net/http" 22 23 "github.com/vmware/govmomi/vapi/rest" 24 ) 25 26 const Path = "/api/appliance/access/dcui" 27 28 // Manager provides convenience methods to get/set enabled state of DCUI. 29 type Manager struct { 30 *rest.Client 31 } 32 33 // NewManager creates a new Manager with the given client 34 func NewManager(client *rest.Client) *Manager { 35 return &Manager{ 36 Client: client, 37 } 38 } 39 40 // Get returns enabled state of Direct Console User Interface (DCUI TTY2). 41 func (m *Manager) Get(ctx context.Context) (bool, error) { 42 r := m.Resource(Path) 43 44 var state bool 45 err := m.Do(ctx, r.Request(http.MethodGet), &state) 46 47 return state, err 48 } 49 50 // Access represents the value to be set for DCUI 51 type Access struct { 52 Enabled bool `json:"enabled"` 53 } 54 55 // Set enables state of Direct Console User Interface (DCUI TTY2). 56 func (m *Manager) Set(ctx context.Context, inp Access) error { 57 r := m.Resource(Path) 58 59 return m.Do(ctx, r.Request(http.MethodPut, inp), nil) 60 }