github.com/vmware/govmomi@v0.37.1/vapi/appliance/logging/forwarding.go (about) 1 /* 2 Copyright (c) 2019 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 logging 18 19 import ( 20 "context" 21 "net/http" 22 23 "github.com/vmware/govmomi/vapi/rest" 24 ) 25 26 const applianceLoggingForwardingPath = "/appliance/logging/forwarding" 27 28 // Manager provides convenience methods to configure appliance logging forwarding. 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 // Forwarding represents configuration for log message forwarding. 41 type Forwarding struct { 42 Hostname string `json:"hostname,omitempty"` 43 Port int `json:"port,omitempty"` 44 Protocol string `json:"protocol,omitempty"` 45 } 46 47 func (m *Manager) getManagerResource() *rest.Resource { 48 return m.Resource(applianceLoggingForwardingPath) 49 } 50 51 // Forwarding returns all logging forwarding config. 52 func (m *Manager) Forwarding(ctx context.Context) ([]Forwarding, error) { 53 r := m.getManagerResource() 54 var res []Forwarding 55 return res, m.Do(ctx, r.Request(http.MethodGet), &res) 56 }