Documentation ¶
Index ¶
- func GetEnv(key, fallback string) string
- func IsTimeoutError(err error) bool
- type Client
- func (device *Client) FactoryReset(keepNetworkSettings bool) error
- func (device *Client) Get(pointers []string) (Config, error)
- func (device *Client) GetDiagnosticClient() *DiagnosisClient
- func (device *Client) GetInit() (Config, error)
- func (device *Client) GetSchema(pointers []string) (string, error)
- func (d *Client) IsAvailable(timeout time.Duration, opts ...WaitForOption) (bool, error)
- func (device *Client) Reboot() error
- func (device *Client) RebootToSWUpdate() error
- func (device *Client) Remove(pointer string) error
- func (device *Client) SaveInit(pointers []string) error
- func (device *Client) Set(conf Config) error
- type ClientOption
- type Config
- type ConfigOption
- type DiagnosisClient
- type WaitForConfig
- type WaitForOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTimeoutError ¶ added in v2.4.0
IsTimeoutError checks if the given error is a network timeout error. It returns true if the error is a network error and the timeout flag is set, otherwise it returns false.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(opts ...ClientOption) *Client
NewClient creates a new OVP8xx client with the provided options. The opts parameter is a variadic parameter that allows specifying multiple client options. Example usage:
client := NewClient(WithHost("192.168.47.11")) // ...
func (*Client) FactoryReset ¶
FactoryReset performs a factory reset on the OVP8xx device. If keepNetworkSettings is set to true, the network settings will be preserved after the reset. Returns an error if the factory reset fails or if there is an issue with the XML-RPC client.
func (*Client) Get ¶
Get retrieves the configuration for the specified pointers from the OVP8xx device. The pointers parameter is a slice of strings that contains the pointers to retrieve the configuration for. The function returns the retrieved configuration as a Config struct and an error if any occurred. Example usage:
config, err := device.Get([]string{"/device", "/ports"}) // ...
func (*Client) GetDiagnosticClient ¶
func (device *Client) GetDiagnosticClient() *DiagnosisClient
GetDiagnosticClient returns a new instance of DiagnosisClient that can be used to perform diagnostic operations on the OVP8xx device.
func (*Client) GetInit ¶
GetInit retrieves the initial configuration from the OVP8xx device. It returns a Config struct representing the device configuration and an error if any.
func (*Client) GetSchema ¶
GetSchema retrieves the schema for the specified pointers from the OVP8xx device. It returns the schema in JSON format as a string. If an error occurs during the retrieval process, it returns an empty string and the error.
func (*Client) IsAvailable ¶ added in v2.4.0
IsAvailable checks if the client is available by making a XML-RPC get request to query the "/device" object. This is useful to wait until a device is ready for communication. It returns a boolean indicating the availability status and an error if any. The function uses a timeout duration to limit the execution time of the request. Example usage:
ok, err := device.IsAvailable(time.Duration(timeout) * time.Second, ovp8xx.AndPortsAreOnline()) // ...
func (*Client) Reboot ¶
Reboot sends a reboot command to the OVP8xx device. If an error occurs during the connection or the method call, it is returned.
func (*Client) RebootToSWUpdate ¶
RebootToSWUpdate reboots the OVP8xx device into software update mode. It establishes a connection with the device using XML-RPC and calls the "rebootToRecovery" method. This method is typically used to initiate a firmware update on the device. Returns an error if there was a problem establishing the connection or calling the method.
func (*Client) Remove ¶ added in v2.8.0
Remove does remove an element from the device temporary configuration. The scope of this method is limited to the following regular expressions: - ^\/applications\/instances\/app\d+$ - ^\/device\/log\/components\/[a-zA-Z0-9\-_]+$ - ^\/applications\/instances\/app\d+/presets/\d+$
If an error occurs during the connection or the method call, it is returned.
type ClientOption ¶
type ClientOption func(c *Client)
func WithHost ¶
func WithHost(host string) ClientOption
WithHost sets the host for the OVP8xx client. It returns a ClientOption function that can be used to configure the client.
type Config ¶
type Config struct {
JSON string
}
func NewConfig ¶
func NewConfig(opts ...ConfigOption) *Config
type ConfigOption ¶
type ConfigOption func(c *Config)
func WitJSONString ¶
func WitJSONString(json string) ConfigOption
type DiagnosisClient ¶
type DiagnosisClient struct {
// contains filtered or unexported fields
}
func (*DiagnosisClient) GetFilterSchema ¶
func (device *DiagnosisClient) GetFilterSchema() (Config, error)
GetFilterSchema retrieves the filter schema from the DiagnosisClient. It returns a Config object representing the filter schema and an error if any.
func (*DiagnosisClient) GetFiltered ¶
func (device *DiagnosisClient) GetFiltered(conf Config) (Config, error)
GetFiltered retrieves a filtered configuration from the DiagnosisClient. It takes a Config object as input and returns a Config object and an error.
type WaitForConfig ¶ added in v2.4.1
type WaitForConfig struct {
// contains filtered or unexported fields
}
WaitForConfig represents the configuration for waiting for a specific stage.
type WaitForOption ¶ added in v2.4.1
type WaitForOption func(c *WaitForConfig)
WaitForOption is a function type that is used as an option for configuring the behavior of the WaitFor function. It takes a pointer to a WaitForConfig struct as a parameter and can be used to modify its properties.
func AndAppsAreOnline ¶ added in v2.4.1
func AndAppsAreOnline() WaitForOption
AndAppsAreOnline returns a WaitForOption function that sets the stage to "applications".
func AndPortsAreOnline ¶ added in v2.4.1
func AndPortsAreOnline() WaitForOption
AndPortsAreOnline returns a WaitForOption function that sets the stage to "ports".