github.com/vmware/govmomi@v0.51.0/vapi/appliance/logging/forwarding.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 logging
     6  
     7  import (
     8  	"context"
     9  	"net/http"
    10  
    11  	"github.com/vmware/govmomi/vapi/rest"
    12  )
    13  
    14  const applianceLoggingForwardingPath = "/appliance/logging/forwarding"
    15  
    16  // Manager provides convenience methods to configure appliance logging forwarding.
    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  // Forwarding represents configuration for log message forwarding.
    29  type Forwarding struct {
    30  	Hostname string `json:"hostname,omitempty"`
    31  	Port     int    `json:"port,omitempty"`
    32  	Protocol string `json:"protocol,omitempty"`
    33  }
    34  
    35  func (m *Manager) getManagerResource() *rest.Resource {
    36  	return m.Resource(applianceLoggingForwardingPath)
    37  }
    38  
    39  // Forwarding returns all logging forwarding config.
    40  func (m *Manager) Forwarding(ctx context.Context) ([]Forwarding, error) {
    41  	r := m.getManagerResource()
    42  	var res []Forwarding
    43  	return res, m.Do(ctx, r.Request(http.MethodGet), &res)
    44  }