Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) Client() *http.Client
- func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)
- func (c *Client) Insecure() *Client
- func (c *Client) NewRequest(urlStr string, request interface{}) (*http.Request, error)
- func (s *Client) PowerOff(ctx context.Context) (*PowerResponse, *Response, error)
- func (s *Client) Reboot(ctx context.Context) (*PowerResponse, *Response, error)
- func (c *Client) Save(ctx context.Context)
- func (c *Client) WithToken(token string) *Client
- func (c *Client) WithURL(url string) *Client
- type ConfigRequest
- type ConfigResponse
- type ConfigService
- func (s *ConfigService) Comment(ctx context.Context, path string) (*ConfigResponse, *Response, error)
- func (s *ConfigService) Delete(ctx context.Context, path string) (*ConfigResponse, *Response, error)
- func (s *ConfigService) Exists(ctx context.Context, path string) (*ConfigResponse, *Response, error)
- func (s *ConfigService) Get(ctx context.Context, path string, options *RetrieveOptions) (*ConfigResponse, *Response, error)
- func (s *ConfigService) Load(ctx context.Context, file string) (*ConfigResponse, *Response, error)
- func (s *ConfigService) Save(ctx context.Context, file string) (*ConfigResponse, *Response, error)
- func (s *ConfigService) Set(ctx context.Context, path ...string) (*ConfigResponse, *Response, error)
- type GenerateResponse
- type GenerateService
- type ImageAddRequest
- type ImageDeleteRequest
- type ImageResponse
- type ImageService
- type OPMode
- type Path
- type PowerResponse
- type PowerService
- type RawResponse
- type Request
- type ResetResponse
- type ResetService
- type Response
- type RetrieveOptions
- type ShowResponse
- type ShowService
Constants ¶
This section is empty.
Variables ¶
var ( ErrMethodNotSupported = errors.New("method not supported") ErrContextNil = errors.New("context must be non-nil") ErrInterfaceNil = errors.New("can not unmarshal into nil interface") ErrEmptyPath = errors.New("path cannot be empty") )
var (
ErrMustLoadFromFile = errors.New("file must not be empty or nil")
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { BaseURL string // Base URL for API requests. UserAgent string // User agent used when communicating with the API. Token string // Token used for authentication. // Services used for talking to different parts of the VyOS API. Show *ShowService Conf *ConfigService Gen *GenerateService Reset *ResetService Power *PowerService Image *ImageService ConfigFile *ConfigService // contains filtered or unexported fields }
Vyos represents a VyOS API client.
func NewClient ¶
NewClient creates a new VyOS API client. If no HTTP client is provided, a new one is created.
func (*Client) Insecure ¶
Insecure sets the InsecureSkipVerify field of the TLS configuration to true.
func (*Client) NewRequest ¶
NewRequest creates a new HTTP request for the VyOS API.
func (*Client) PowerOff ¶
PowerOff is a helper function to power off the VyOS instance from the client struct.
func (*Client) Reboot ¶
Reboot is a helper function to reboot the VyOS instance from the client struct.
type ConfigRequest ¶
type ConfigResponse ¶
type ConfigResponse struct {
*RawResponse
}
ShowResponse represents a response from the VyOS API.
type ConfigService ¶
type ConfigService service
Response represents a response from the VyOS API.
func (*ConfigService) Comment ¶
func (s *ConfigService) Comment(ctx context.Context, path string) (*ConfigResponse, *Response, error)
func (*ConfigService) Delete ¶
func (s *ConfigService) Delete(ctx context.Context, path string) (*ConfigResponse, *Response, error)
Delete deletes a configuration path in the VyOS API.
func (*ConfigService) Exists ¶
func (s *ConfigService) Exists(ctx context.Context, path string) (*ConfigResponse, *Response, error)
Exists checks if a configuration path exists in the VyOS API. Handles: - op: exists, path: []string{}
func (*ConfigService) Get ¶
func (s *ConfigService) Get(ctx context.Context, path string, options *RetrieveOptions) (*ConfigResponse, *Response, error)
Get retrives the configuration from the VyOS API. If path is empty, it will return the entire configuration. Handles: - op: showConfig, path: "" - op: showConfig, path: []string{} - op: returnValues, path: []string{} &ShowOptions{multivalue: true}
func (*ConfigService) Load ¶
func (s *ConfigService) Load(ctx context.Context, file string) (*ConfigResponse, *Response, error)
Add adds a new image from a url
func (*ConfigService) Save ¶
func (s *ConfigService) Save(ctx context.Context, file string) (*ConfigResponse, *Response, error)
Add adds a new image from a url
func (*ConfigService) Set ¶
func (s *ConfigService) Set(ctx context.Context, path ...string) (*ConfigResponse, *Response, error)
Set sets a configuration path in the VyOS API. NOTE: This does not send multiple requests to the API. It sends a single request with multiple paths.
type GenerateResponse ¶
type GenerateResponse struct {
*RawResponse
}
type GenerateService ¶
type GenerateService service
func (*GenerateService) Do ¶
func (s *GenerateService) Do(ctx context.Context, path string) (*GenerateResponse, *Response, error)
Do sends a request to the VyOS API and returns the response.
type ImageAddRequest ¶
type ImageDeleteRequest ¶
type ImageResponse ¶
type ImageResponse struct {
*RawResponse
}
ShowResponse represents a response from the VyOS API.
type ImageService ¶
type ImageService service
Response represents a response from the VyOS API.
func (*ImageService) Add ¶
func (s *ImageService) Add(ctx context.Context, url string) (*ImageResponse, *Response, error)
Add adds a new image from a url
func (*ImageService) Delete ¶
func (s *ImageService) Delete(ctx context.Context, name string) (*ImageResponse, *Response, error)
Delete deletes an existing image
type OPMode ¶
type OPMode string // OPMode is a type for the different operational modes of the VyOS API.
const ( // OPMode constants OPModeShow OPMode = "show" // OPModeShow is the show operational mode. OPModeSet OPMode = "set" // OPModeSet is the set operational mode. OPModeComment OPMode = "comment" // OPModeComment is the comment operational mode. OPModeGenerate OPMode = "generate" // OPModeGenerate is the generate operational mode. OPModeConfigure OPMode = "configure" // OPModeConfigure is the configure operational mode. )
type PowerResponse ¶
type PowerResponse struct {
*RawResponse
}
ShowResponse represents a response from the VyOS API.
type PowerService ¶
type PowerService service
Response represents a response from the VyOS API.
func (*PowerService) PowerOff ¶
func (s *PowerService) PowerOff(ctx context.Context) (*PowerResponse, *Response, error)
PowerOff sends a request to the VyOS API to power off the system.
func (*PowerService) Reboot ¶
func (s *PowerService) Reboot(ctx context.Context) (*PowerResponse, *Response, error)
Reboot sends a request to the VyOS API to reboot the system.
type RawResponse ¶
type RawResponse struct { Success bool `json:"success,omitempty"` Data interface{} `json:"data,omitempty"` Error string `json:"error,omitempty"` }
RawResponse represents a raw response from the VyOS API.
type ResetResponse ¶
type ResetResponse struct {
*RawResponse
}
type ResetService ¶
type ResetService service
func (*ResetService) Do ¶
func (s *ResetService) Do(ctx context.Context, path string) (*ResetResponse, *Response, error)
Do sends a request to the VyOS API and returns the response.
type RetrieveOptions ¶
type RetrieveOptions struct {
MultiValue bool
}
type ShowResponse ¶
type ShowResponse struct {
*RawResponse
}
ShowResponse represents a response from the VyOS API.
type ShowService ¶
type ShowService service
Response represents a response from the VyOS API.
func (*ShowService) Do ¶
func (s *ShowService) Do(ctx context.Context, path string) (*ShowResponse, *Response, error)
Do sends a request to the VyOS API and returns the response.