summaryrefslogtreecommitdiff
path: root/docs/getting-started.md
blob: 3cf4891302f6f81911edf5772c96ca077b7d431a (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
# Getting Started

This guide will help you set up PyVyOS and make your first API call to a VyOS device.

## Prerequisites

- VyOS device with REST API enabled
- API key generated on your VyOS device
- Network access to your VyOS device

## Step 1: Install PyVyOS

See [Installation](installation.md) for detailed instructions.

## Step 2: Configure Environment Variables

Create a `.env` file in your project directory:

```bash
VYDEVICE_HOSTNAME=192.168.1.1
VYDEVICE_APIKEY=your-api-key-here
VYDEVICE_PORT=443
VYDEVICE_PROTOCOL=https
VYDEVICE_VERIFY_SSL=true
```

## Step 3: Create Your First Script

```python
import os
from dotenv import load_dotenv
from pyvyos import VyDevice

load_dotenv()

device = VyDevice(
    hostname=os.getenv('VYDEVICE_HOSTNAME'),
    apikey=os.getenv('VYDEVICE_APIKEY'),
    port=os.getenv('VYDEVICE_PORT'),
    protocol=os.getenv('VYDEVICE_PROTOCOL'),
    verify=os.getenv('VYDEVICE_VERIFY_SSL', 'True').lower() == 'true'
)

response = device.show(path=["system", "image"])
if not response.error:
    print(response.result)
else:
    print(f"Error: {response.error}")
```

## Step 4: Disable SSL Warnings (Optional)

If using `verify=False`, disable urllib3 warnings:

```python
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
```

## Understanding API Responses

All methods return an `ApiResponse` object with:
- `status`: HTTP status code
- `request`: Request payload (API key sanitized)
- `result`: Response data dictionary
- `error`: Error message (False if successful)

## Common Operations

See [Examples](examples.md) for more detailed usage patterns.

## Next Steps

- Read [API Reference](api-reference.md) for complete method documentation
- Explore [Configuration](configuration.md) for advanced setup
- Check [Concepts](concepts.md) to understand PyVyOS architecture