summaryrefslogtreecommitdiff
path: root/docs/vyos-api.md
blob: 33a443f981cb5f5274d595a511333160d4bf618d (plain)
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
# VyOS API Command Reference

The JSON definitions for each VyOS REST API command supported by PyVyOS are located in `docs/development/vyos_api/`.

## Location

All JSON specification files are stored in: **`docs/development/vyos_api/`**

These JSONs are reference documentation and are:
- Used for API documentation generation
- Available for validation and testing
- Not packaged with the library (reference only)

## Files

- `schema.json` - JSON Schema definition for all API commands
- Individual command files:
  - `configure-set.json` - Set configuration values
  - `configure-delete.json` - Delete configuration values
  - `configure-multiple-op.json` - Execute multiple operations atomically
  - `retrieve-show-config.json` - Retrieve configuration in show format
  - `retrieve-return-values.json` - Retrieve specific configuration values
  - `show.json` - Execute show commands
  - `generate.json` - Generate configuration elements (SSH keys, etc.)
  - `reset.json` - Reset configuration elements
  - `config-file-save.json` - Save configuration to file
  - `config-file-load.json` - Load configuration from file
  - `reboot.json` - Reboot the device
  - `poweroff.json` - Power off the device
  - `image-add.json` - Add VyOS system image
  - `image-delete.json` - Delete VyOS system image

## Structure

Each JSON file follows this structure:

```json
{
  "command": "command-name",
  "operation": "operation-name",
  "description": "Description of what the command does",
  "endpoint": "/endpoint-path",
  "method": "HTTP_METHOD",
  "request": {
    "payload": { ... },
    "example": { ... }
  },
  "response": {
    "success": { ... },
    "error": { ... }
  },
  "parameters": { ... },
  "python_usage": "device.method_name(...)"
}
```

## Usage

These JSON files can be used for:
- API documentation generation
- Request validation
- Response schema validation
- Client library code generation
- Testing and mocking

## JSON Schema

The `schema.json` file defines the complete structure for all API commands and can be used with JSON Schema validators.

## Path Parameter Handling

**Important:** The `path` parameter handling varies by command:

- **config-file commands** (`save`, `load`): The VyOS API requires `path` to be present in the payload, even if empty (`[]`). PyVyOS handles this automatically.
- **Other commands**: When `path` is empty or not provided, it may be omitted from the payload for cleaner requests.

See individual JSON files in `docs/development/vyos_api/` for specific parameter requirements.