X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=osmclient%2Fsol005%2Frole.py;h=404784a71c0ef0379da2a8443027680f7362fe07;hb=404b4ea6e3fa2adf4349883488dadca4862dcaf7;hp=64e84f9eeb573f881a774bd7398f2b08b897bd9b;hpb=dd006fac5cefcff43d83bdd0ab1660d2bf2ef891;p=osm%2Fosmclient.git diff --git a/osmclient/sol005/role.py b/osmclient/sol005/role.py index 64e84f9..404784a 100644 --- a/osmclient/sol005/role.py +++ b/osmclient/sol005/role.py @@ -25,12 +25,14 @@ from osmclient.common.exceptions import ClientException from osmclient.common.exceptions import NotFound import json import yaml +import logging class Role(object): def __init__(self, http=None, client=None): self._http = http self._client = client + self._logger = logging.getLogger('osmclient') self._apiName = '/admin' self._apiVersion = '/v1' self._apiResource = '/roles' @@ -46,6 +48,8 @@ class Role(object): :raises ClientException: when receives an unexpected from the server. :raises ClientException: when fails creating a role. """ + self._logger.debug("") + self._client.get_token() role = {"name": name} if permissions: @@ -94,6 +98,8 @@ class Role(object): :raises ClientException: when receives an unexpected response from the server. :raises ClientException: when fails updating a role. """ + self._logger.debug("") + self._client.get_token() if new_name is None and permissions is None and add is None and remove is None: raise ClientException('At least one option should be provided') elif permissions and (add or remove): @@ -141,7 +147,7 @@ class Role(object): if not new_role_obj["permissions"]: del new_role_obj["permissions"] - http_code, resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase, role_obj['_id']), + http_code, resp = self._http.patch_cmd(endpoint='{}/{}'.format(self._apiBase, role_obj['_id']), postfields_dict=new_role_obj) # print('HTTP CODE: {}'.format(http_code)) # print('RESP: {}'.format(resp)) @@ -171,6 +177,8 @@ class Role(object): :param force: :raises ClientException: when fails to delete a role. """ + self._logger.debug("") + self._client.get_token() role = self.get(name) querystring = '' if force: @@ -201,6 +209,8 @@ class Role(object): :param filter: :returns: """ + self._logger.debug("") + self._client.get_token() filter_string = '' if filter: filter_string = '?{}'.format(filter) @@ -218,6 +228,8 @@ class Role(object): :raises NotFound: when the role is not found. :returns: the specified role. """ + self._logger.debug("") + self._client.get_token() if utils.validate_uuid4(name): for role in self.list(): if name == role['_id']: @@ -227,3 +239,4 @@ class Role(object): if name == role['name']: return role raise NotFound("Role {} not found".format(name)) +