photo-python/trovebox/objects/tag.py
2013-09-07 11:19:15 +01:00

40 lines
1.1 KiB
Python

"""
Representation of a Tag object
"""
try:
from urllib.parse import quote # Python3
except ImportError:
from urllib import quote # Python2
from trovebox.errors import TroveboxError
from .trovebox_object import TroveboxObject
class Tag(TroveboxObject):
""" Representation of a Tag object """
def delete(self, **kwds):
"""
Endpoint: /tag/<id>/delete.json
Deletes this tag.
Returns True if successful.
Raises a TroveboxError if not.
"""
result = self._trovebox.post("/tag/%s/delete.json" %
quote(self.id), **kwds)["result"]
if not result:
raise TroveboxError("Delete response returned False")
self._delete_fields()
return result
def update(self, **kwds):
"""
Endpoint: /tag/<id>/update.json
Updates this tag with the specified parameters.
Returns the updated tag object.
"""
result = self._trovebox.post("/tag/%s/update.json" % quote(self.id),
**kwds)["result"]
self._replace_fields(result)
# def view(self, **kwds):