Commit e9727ba0 authored by jens.kleineheismann's avatar jens.kleineheismann

Implemented delete/remove operations.

parent bf0d103b
......@@ -28,10 +28,13 @@ USAGE
print g.name
iism.create_group('IISM-EM-newgroup', 'Neue Gruppe')
staff = gv.getGroup('IISM-EM-OU-Staff')
for u in staff.get_users(effective=True):
newgroup = gv.getGroup('IISM-EM-newgroup')
newgroup.add_user('zy8373')
newgroup.add_group('IISM-EM-Alle')
for u in newgroup.get_users(effective=True):
print "{fn} {ln} ({un})".format(fn=u.firstname, ln=u.lastname, un=u.samaccount)
for g in staff.get_groups():
for g in newgroup.get_groups():
print "{gn} ({desc})".format(gn=g.name, desc=g.description)
me = gv.getUser('zy8373')
......
......@@ -4,7 +4,7 @@ Library for accessing the KIT Gruppenverwaltung REST API
The object, you are looking for is kitgvapi.ObjectInterface.
"""
__version__ = '1.2'
__version__ = '1.3'
__author__ = 'Jens Kleineheismann'
__email__ = 'kleineheismann@kit.edu'
__license__ = """
......
......@@ -106,7 +106,10 @@ class RestClient(object):
"""Send DELETE request."""
if not self.config.enable_delete:
raise NotAllowedError("DELETE operations are disabled by configuration")
raise NotImplementedError("Not ready")
url = self.config.url_schema + self.config.server + self.config.base_uri + path
r = requests.delete(url, verify=True, auth=self.config.credentials)
r.raise_for_status()
return r
def get_oes(self, pk_only=False):
path = '/oe/list'
......@@ -175,7 +178,9 @@ class RestClient(object):
self.post(path)
def remove_group_user(self, group_pk, user_pk):
raise NotImplementedError("Not ready")
oe_pk = group_pk.partition('-')[0]
path = '/groups/{oe}/{group}/members/{user}'.format(oe=oe_pk, group=group_pk, user=user_pk)
self.delete(path)
def add_group_group(self, super_pk, sub_pk):
oe_pk = super_pk.partition('-')[0]
......@@ -183,7 +188,9 @@ class RestClient(object):
self.post(path)
def remove_group_group(self, super_pk, sub_pk):
raise NotImplementedError("Not ready")
oe_pk = super_pk.partition('-')[0]
path = '/groups/{oe}/{superg}/subgroups/{subg}'.format(oe=oe_pk, superg=super_pk, subg=sub_pk)
self.delete(path)
def create_group(self, name, description):
oe_pk = name.partition('-')[0]
......@@ -192,4 +199,6 @@ class RestClient(object):
self.post(path, data=data)
def delete_group(self, pk):
raise NotImplementedError("Not ready")
oe_pk = pk.partition('-')[0]
path = '/groups/{oe}/{group}'.format(oe=oe_pk, group=pk)
self.delete(path)
......@@ -77,7 +77,7 @@ class Group(Model):
self.client.add_group_user(group_pk=self.pk, user_pk=pk)
def remove_user(self, pk):
raise NotImplementedError('Not yet')
self.client.remove_group_user(group_pk=self.pk, user_pk=pk)
def get_groups(self):
self.load()
......@@ -90,7 +90,7 @@ class Group(Model):
self.client.add_group_group(super_pk=self.pk, sub_pk=pk)
def remove_group(self, pk):
raise NotImplementedError('Not yet')
self.client.remove_group_group(super_pk=self.pk, sub_pk=pk)
class Oe(Model):
......@@ -123,7 +123,7 @@ class Oe(Model):
self.client.create_group(name, description)
def delete_group(self, pk):
raise NotImplementedError('Not yet')
self.client.delete_group(pk)
class User(Model):
......
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