Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit 828f9ef

Browse files
committed
add :meth:atomx.Atomx.delete to send a HTTP DELETE request to the api
1 parent 9f0e246 commit 828f9ef

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

CHANGES.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
1.3 (unreleased)
2+
----------------
3+
4+
- add :meth:`atomx.Atomx.delete` to send a ``HTTP DELETE`` request to the api
5+
6+
17
1.2
28
---
39

atomx/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,17 @@ def put(self, resource, id, json, **kwargs):
346346
raise APIError(r_json['error'])
347347
return r_json[r_json['resource']]
348348

349-
def delete(self, resource, id, json, **kwargs):
350-
"""Delete is currently not supported by the api.
351-
Set the resources `state` to `INACTIVE` to deactivate it.
349+
def delete(self, resource, **kwargs):
350+
"""Send HTTP DELETE to ``resource``.
351+
352+
:param resource: Name of the resource to `DELETE`.
353+
:return: message or resource returned by the api.
352354
"""
353-
pass
355+
r = self.session.delete(self.api_endpoint + resource.strip('/'), params=kwargs)
356+
r_json = r.json()
357+
if not r.ok:
358+
raise APIError(r_json['error'])
359+
return r_json[r_json['resource']]
354360

355361
def save(self, model):
356362
"""Alias for :meth:`.models.AtomxModel.save` with `session` argument."""

atomx/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
VERSION = '1.2'
1+
VERSION = '1.3b'
22
API_VERSION = 'v1'

0 commit comments

Comments
 (0)