Example #1
0
 def post(self):
     args = self.validate_post()
     args['tenant'] = g.tenant
     args['api_server'] = g.api_server
     args['owner'] = g.user
     actor = Actor(**args)
     actors_store[actor.db_id] = actor.to_db()
     ch = CommandChannel()
     ch.put_cmd(actor_id=actor.db_id, image=actor.image, tenant=args['tenant'])
     add_permission(g.user, actor.db_id, 'UPDATE')
     return ok(result=actor.display(), msg="Actor created successfully.", request=request)
Example #2
0
 def post(self, actor_id):
     """Add new permissions for an actor"""
     id = Actor.get_dbid(g.tenant, actor_id)
     try:
         Actor.from_db(actors_store[id])
     except KeyError:
         raise ResourceError("actor not found: {}'".format(actor_id), 404)
     args = self.validate_post()
     add_permission(args['user'], id, args['level'])
     permissions = get_permissions(id)
     return ok(result=permissions, msg="Permission added successfully.")
Example #3
0
 def post(self, actor_id):
     """Add new permissions for an actor"""
     id = Actor.get_dbid(g.tenant, actor_id)
     try:
         Actor.from_db(actors_store[id])
     except KeyError:
         raise APIException(
             "actor not found: {}'".format(actor_id), 404)
     args = self.validate_post()
     add_permission(args['user'], id, args['level'])
     permissions = get_permissions(id)
     return ok(result=permissions, msg="Permission added successfully.")
Example #4
0
 def post(self, actor_id):
     """Add new permissions for an actor"""
     logger.debug("top of POST /actors/{}/permissions.".format(actor_id))
     id = Actor.get_dbid(g.tenant, actor_id)
     try:
         Actor.from_db(actors_store[id])
     except KeyError:
         logger.debug("Did not find actor: {}.".format(actor_id))
         raise ResourceError(
             "actor not found: {}'".format(actor_id), 404)
     args = self.validate_post()
     logger.debug("POST permissions body validated for actor: {}.".format(actor_id))
     add_permission(args['user'], id, args['level'])
     logger.info("Permission added for user: {} actor: {} level: {}".format(args['user'], id, args['level']))
     permissions = get_permissions(id)
     return ok(result=permissions, msg="Permission added successfully.")
Example #5
0
 def post(self):
     logger.info("top of POST to register a new actor.")
     args = self.validate_post()
     logger.debug("validate_post() successful")
     args['tenant'] = g.tenant
     args['api_server'] = g.api_server
     args['owner'] = g.user
     actor = Actor(**args)
     actors_store[actor.db_id] = actor.to_db()
     logger.debug("new actor saved in db. id: {}. image: {}. tenant: {}".format(actor.db_id,
                                                                                actor.image,
                                                                                actor.tenant))
     actor.ensure_one_worker()
     logger.debug("ensure_one_worker() called")
     add_permission(g.user, actor.db_id, 'UPDATE')
     logger.debug("UPDATE permission added to user: {}".format(g.user))
     return ok(result=actor.display(), msg="Actor created successfully.", request=request)
Example #6
0
 def post(self):
     args = self.validate_post()
     args['tenant'] = g.tenant
     args['api_server'] = g.api_server
     args['owner'] = g.user
     actor = Actor(**args)
     actors_store[actor.db_id] = actor.to_db()
     actor.ensure_one_worker()
     # worker_id = Worker.request_worker(actor_id=actor.db_id)
     # ch = CommandChannel()
     # ch.put_cmd(actor_id=actor.db_id,
     #            worker_ids=[worker_id],
     #            image=actor.image,
     #            tenant=args['tenant'],
     #            stop_existing=False)
     add_permission(g.user, actor.db_id, 'UPDATE')
     return ok(result=actor.display(),
               msg="Actor created successfully.",
               request=request)