1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# API Reference
Complete reference for all PyVyOS classes and methods.
## VyDevice Class
Main class for interacting with VyOS devices.
### Constructor
```python
VyDevice(hostname: str, apikey: str, protocol: "http"|"https" = "https",
port: int = 443, verify: bool = True, timeout: int = 10)
```
**Parameters:** `hostname`, `apikey`, `protocol`, `port` (1-65535), `verify`, `timeout`
### Configuration Methods
- `configure_set(path)`: Set configuration values
- `configure_delete(path)`: Delete configuration values
- `configure_multiple_op(op_path)`: Execute multiple operations atomically
```python
device.configure_set(path=["interfaces", "ethernet", "eth0", "address", "192.168.1.1/24"])
device.configure_delete(path=["interfaces", "dummy", "dum1"])
device.configure_multiple_op(op_path=[
{"op": "set", "path": [...]},
{"op": "delete", "path": [...]}
])
```
### Retrieval Methods
- `retrieve_show_config(path)`: Get configuration in show format
- `retrieve_return_values(path)`: Get specific configuration values
```python
device.retrieve_show_config(path=["system"])
device.retrieve_return_values(path=["interfaces", "dummy", "dum1", "address"])
```
### Operational Methods
- `show(path)`: Execute show commands
- `generate(path)`: Generate configuration elements
- `reset(path)`: Reset configuration elements
```python
device.show(path=["system", "image"])
device.generate(path=["ssh", "client-key", "/tmp/key"])
device.reset(path=["conntrack-sync", "internal-cache"])
```
### File Operations
- `config_file_save(file)`: Save configuration to file
- `config_file_load(file)`: Load configuration from file
```python
device.config_file_save(file="/config/backup.config")
device.config_file_load(file="/config/backup.config")
```
**Note:** The `path` parameter is automatically included as `[]` for config-file operations, as required by the VyOS API.
### System Operations
- `reboot(path=["now"])`: Reboot the device
- `poweroff(path=["now"])`: Power off the device
### Image Management
- `image_add(url, file, path)`: Add VyOS system image
- `image_delete(name, url, file, path)`: Delete a system image
## ApiResponse Class
Response object: `status` (int), `request` (dict, API key removed), `result` (dict), `error` (str|bool)
```python
response = device.show(path=["system"])
if response.error:
print(f"Error {response.status}: {response.error}")
else:
print(response.result)
```
|