photo-python/openphoto/api_tag.py
sneakypete81 b56e690d33 Frontend issue 927 is now fixed, so the tag.create endpoint can be used.
The tag.create endpoint doesn't return the newly created tag - it is invisible, since it has no photos.
2013-03-24 12:18:32 +00:00

32 lines
987 B
Python

from errors import *
from objects import Tag
class ApiTags:
def __init__(self, client):
self._client = client
def list(self, **kwds):
""" Returns a list of Tag objects """
results = self._client.get("/tags/list.json", **kwds)["result"]
return [Tag(self._client, tag) for tag in results]
class ApiTag:
def __init__(self, client):
self._client = client
def create(self, tag, **kwds):
""" Create a new tag. The API returns true if the tag was sucessfully created """
return self._client.post("/tag/create.json", tag=tag, **kwds)["result"]
def delete(self, tag, **kwds):
""" Delete a tag """
if not isinstance(tag, Tag):
tag = Tag(self._client, {"id": tag})
tag.delete(**kwds)
def update(self, tag, **kwds):
""" Update a tag """
if not isinstance(tag, Tag):
tag = Tag(self._client, {"id": tag})
tag.update(**kwds)
return tag