Skip to content

Commit b759e28

Browse files
committed
Fix _req method
1 parent d17187a commit b759e28

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ Create a new ssh key from key string
9393

9494
```python
9595
sshkey = vultr.create_key("key-name", "ssh-rsa AAAA...")
96+
vultr.delete_key(sshkey['id'])
9697
```
9798

9899
Create a new instance
@@ -112,15 +113,15 @@ Arbitrary Methods `get`, `post`, `patch`, `put`, `delete`
112113
```python
113114
plans = vultr.get("/plans", {"type": "vc2"})
114115
sshkey = vultr.post("/ssh-keys", name="key-name", ssh_key="ssh-rsa AAAA...")
115-
instance = vultr.patch("/instances", plan=plans[1]["id"])
116+
instance = vultr.patch("/instances/{instance-id}", plan=plans[1]["id"])
116117
database = vultr.put("/databases/{database-id}", tag="new tag")
117118
vultr.delete("/snapshots/{snapshot-id}")
118119
```
119120

120121
Error Handling
121122

122123
```python
123-
>>> instance = vultr.create_instance("atl", "vc2-1c-0.5gb-v6", **data)
124+
>>> instance = vultr.create_instance("atl", "vc2-1c-0.5gb-v6", os_id=2284)
124125
Traceback (most recent call last):
125126
vultr.vultr.VultrException: Error 400: Server add failed: Ubuntu 24.04 LTS x64 requires a plan with at least 1000 MB memory.
126127
```

docs/index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Create a new ssh key from key string
7171

7272
```python
7373
sshkey = vultr.create_key("key-name", "ssh-rsa AAAA...")
74+
vultr.delete_key(sshkey['id'])
7475
```
7576

7677
Create a new instance
@@ -90,15 +91,15 @@ Arbitrary Methods [get](#Vultr.get), [post](#Vultr.post), [patch](#Vultr.patch),
9091
```python
9192
plans = vultr.get("/plans", {"type": "vc2"})
9293
sshkey = vultr.post("/ssh-keys", name="key-name", ssh_key="ssh-rsa AAAA...")
93-
instance = vultr.patch("/instances", plan=plans[1]["id"])
94+
instance = vultr.patch("/instances/{instance-id}", plan=plans[1]["id"])
9495
database = vultr.put("/databases/{database-id}", tag="new tag")
9596
vultr.delete("/snapshots/{snapshot-id}")
9697
```
9798

9899
Error Handling
99100

100101
```python
101-
>>> instance = vultr.create_instance("atl", "vc2-1c-0.5gb-v6", **data)
102+
>>> instance = vultr.create_instance("atl", "vc2-1c-0.5gb-v6", os_id=2284)
102103
Traceback (most recent call last):
103104
vultr.vultr.VultrException: Error 400: Server add failed: Ubuntu 24.04 LTS x64 requires a plan with at least 1000 MB memory.
104105
```

src/vultr/vultr.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def get(self, url: str, params: Optional[dict] = None) -> Any:
2424
:return: Response Data
2525
:raises: `VultrException`
2626
"""
27-
return self._req("get", f"{self.url}/{url.lstrip('/')}", params)
27+
return self._req("get", f"{self.url}/{url.lstrip('/')}", params=params)
2828

2929
def post(self, url: str, **kwargs) -> Any:
3030
"""
@@ -209,8 +209,8 @@ def filter_scripts(scripts: list, name: str) -> dict:
209209
except StopIteration:
210210
return {}
211211

212-
def _req(self, method, url, params: Optional[dict] = None) -> Any:
213-
r = self._session.request(method, url, params=params, timeout=10)
212+
def _req(self, method, url, data: Any = None, params: Optional[dict] = None) -> Any:
213+
r = self._session.request(method, url, params=params, json=data, timeout=10)
214214
if not r.ok:
215215
raise VultrException(r)
216216
if r.status_code == 204:

0 commit comments

Comments
 (0)