print(table)
+@cli.command(name='project-update')
+@click.argument('project')
+@click.option('--name',
+ prompt=True,
+ help='new name for the project')
+
+@click.pass_context
+def project_update(ctx, project, name):
+ """
+ Update a project name
+
+ :param ctx:
+ :param project: id or name of the project to modify
+ :param name: new name for the project
+ :return:
+ """
+
+ project_changes = {}
+ project_changes['name'] = name
+
+ try:
+ check_client_version(ctx.obj, ctx.command.name)
+ ctx.obj.project.update(project, project_changes)
+ except ClientException as inst:
+ print(inst.message)
+
+
####################
# User mgmt operations
####################
msg = resp
raise ClientException("failed to create project {} - {}".format(name, msg))
- def update(self, name, project):
+ def update(self, project, project_changes):
"""Updates an OSM project identified by name
"""
- proj = self.get(name)
- http_code, resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase,proj['_id']),
- postfields_dict=project)
- #print('HTTP CODE: {}'.format(http_code))
- #print('RESP: {}'.format(resp))
- if http_code in (200, 201, 202, 204):
+ proj = self.get(project)
+ http_code, resp = self._http.put_cmd(endpoint='{}/{}'.format(self._apiBase, proj['_id']),
+ postfields_dict=project_changes)
+ # print('HTTP CODE: {}'.format(http_code))
+ # print('RESP: {}'.format(resp))
+ if http_code in (200, 201, 202):
if resp:
resp = json.loads(resp)
if not resp or 'id' not in resp:
raise ClientException('unexpected response from server - {}'.format(
resp))
print(resp['id'])
+ elif http_code == 204:
+ print("Updated")
else:
msg = ""
if resp:
msg = json.loads(resp)
except ValueError:
msg = resp
- raise ClientException("failed to update project {} - {}".format(name, msg))
+ raise ClientException("failed to update project {} - {}".format(project, msg))
def delete(self, name, force=False):
"""Deletes an OSM project identified by name