Commit cb69a058 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Update comment docs for image client

parent f5eac743
......@@ -30,7 +30,8 @@
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from kamaki.clients import Client
from kamaki.clients import Client, ClientError
from kamaki.clients.utils import path4url
......@@ -46,7 +47,8 @@ class ImageClient(Client):
:param filters: (dict) request filters
:param order: (str) sort_dir|desc
:param order: (str) order listing by field (default is ascending, - for
descending)
:returns: (list) id,name + full image info if detail
"""
......@@ -65,6 +67,11 @@ class ImageClient(Client):
return r.json
def get_meta(self, image_id):
"""
:param image_id: (string)
:returns: (list) image metadata (key:val)
"""
path = path4url('images', image_id)
r = self.head(path, success=200)
......@@ -87,6 +94,17 @@ class ImageClient(Client):
return reply
def register(self, name, location, params={}, properties={}):
"""Register image put at location
:param name: (str)
:param location: (str) pithos://<account>/<container>/<path>
:param params: (dict) image metadata (X-Image-Meta) can be id, store,
disc_format, container_format, size, checksum, is_public, owner
:param properties: (dict) image properties (X-Image-Meta-Property)
"""
path = path4url('images/')
self.set_header('X-Image-Meta-Name', name)
self.set_header('X-Image-Meta-Location', location)
......@@ -104,6 +122,17 @@ class ImageClient(Client):
r.release()
def reregister(self, location, name=None, params={}, properties={}):
"""Update existing image (key: location)
:param location: (str) pithos://<account>/<container>/<path>
:param name: (str)
:param params: (dict) image metadata (X-Image-Meta) can be id, store,
disc_format, container_format, size, checksum, is_public, owner
:param properties: (dict) image properties (X-Image-Meta-Property)
"""
path = path4url('images', 'detail')
r = self.get(path, success=200)
imgs = [img for img in r.json if img['location'] == location]
......@@ -116,27 +145,52 @@ class ImageClient(Client):
r.release()
def list_members(self, image_id):
"""
:param image_id: (str)
:returns: (list) users who can use current user's images
"""
path = path4url('images', image_id, 'members')
r = self.get(path, success=200)
return r.json['members']
def list_shared(self, member):
"""
:param member: (str) sharers account
:returns: (list) images shared by member
"""
path = path4url('shared-images', member)
#self.set_param('format', 'json')
r = self.get(path, success=200)
return r.json['shared_images']
def add_member(self, image_id, member):
"""
:param image_id: (str)
:param member: (str) user to allow access to current user's images
"""
path = path4url('images', image_id, 'members', member)
r = self.put(path, success=204)
r.release()
def remove_member(self, image_id, member):
"""
:param image_id: (str)
:param member: (str) user to deprive from current user's images
"""
path = path4url('images', image_id, 'members', member)
r = self.delete(path, success=204)
r.release()
def set_members(self, image_id, members):
"""
:param image_id: (str)
:param members: (list) user to deprive from current user's images
"""
path = path4url('images', image_id, 'members')
req = {'memberships': [{'member_id': member} for member in members]}
r = self.put(path, json=req, success=204)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment