Extended API to add pythonic classes/methods. See the updated README.markdown for examples
This commit is contained in:
parent
ccc6e6ba1c
commit
b418cf7e78
9 changed files with 457 additions and 60 deletions
25
openphoto/api_tag.py
Normal file
25
openphoto/api_tag.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
from openphoto_http import OpenPhotoHttp, OpenPhotoError
|
||||
from objects import Tag
|
||||
|
||||
class ApiTag(OpenPhotoHttp):
|
||||
def tag_create(self, tag_id, **kwds):
|
||||
""" Create a new tag and return it """
|
||||
result = self.post("/tag/create.json", tag=tag_id, **kwds)["result"]
|
||||
return Tag(self, result)
|
||||
|
||||
def tag_delete(self, tag_id, **kwds):
|
||||
""" Delete a tag """
|
||||
tag = Tag(self, {"id": tag_id})
|
||||
tag.delete(**kwds)
|
||||
|
||||
def tag_update(self, tag_id, **kwds):
|
||||
""" Update a tag """
|
||||
tag = Tag(self, {"id": tag_id})
|
||||
tag.update(**kwds)
|
||||
return tag
|
||||
|
||||
def tags_list(self, **kwds):
|
||||
""" Returns a list of Tag objects """
|
||||
results = self.get("/tags/list.json", **kwds)["result"]
|
||||
return [Tag(self, tag) for tag in results]
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue