def update_resource_member(resource_id, res_type, member_id, values, session=None): # Only member who is not the owner of the resource can update the # membership status. if member_id != security.get_project_id(): raise exc.DBEntityNotFoundException( "Resource member not found [resource_id=%s, member_id=%s]" % (resource_id, member_id) ) query = _secure_query(models.ResourceMember).filter_by( resource_type=res_type ) res_member = query.filter( _get_criterion(resource_id, member_id, is_owner=False) ).first() if not res_member: raise exc.DBEntityNotFoundException( "Resource member not found [resource_id=%s, member_id=%s]" % (resource_id, member_id) ) res_member.update(values.copy()) return res_member
def update_cron_trigger(name, values, session=None, query_filter=None): cron_trigger = _get_cron_trigger(name) if not cron_trigger: raise exc.DBEntityNotFoundException( "Cron trigger not found [name=%s]" % name ) if query_filter: try: # Execute the UPDATE statement with the query_filter as the WHERE. specimen = models.CronTrigger(id=cron_trigger.id, **query_filter) query = b.model_query(models.CronTrigger) cron_trigger = query.update_on_match( specimen=specimen, surrogate_key='id', values=values ) return cron_trigger, 1 except oslo_sqlalchemy.update_match.NoRowsMatched: LOG.debug( "No rows matched for cron update call" "[id=%s, values=%s, query_filter=%s", id, values, query_filter ) return cron_trigger, 0 else: cron_trigger.update(values.copy()) return cron_trigger, len(session.dirty)
def test_nf_with_no_message(self): exc = exceptions.DBEntityNotFoundException() self.assertIn("Object not found", six.text_type(exc)) self.assertEqual( 404, exc.http_code, )
def get_environment(name): env = _get_environment(name) if not env: raise exc.DBEntityNotFoundException( "Environment not found [name=%s]" % name ) return env
def get_delayed_call(id, session=None): delayed_call = _get_delayed_call(id=id, session=session) if not delayed_call: raise exc.DBEntityNotFoundException( "Delayed Call not found [id=%s]" % id ) return delayed_call
def get_workbook(name): wb = _get_workbook(name) if not wb: raise exc.DBEntityNotFoundException( "Workbook not found [workbook_name=%s]" % name ) return wb
def delete_delayed_call(id, session=None): delayed_call = _get_delayed_call(id) if not delayed_call: raise exc.DBEntityNotFoundException( "DelayedCall not found [id=%s]" % id ) session.delete(delayed_call)
def get_execution(id): ex = _get_execution(id) if not ex: raise exc.DBEntityNotFoundException( "Execution not found [execution_id=%s]" % id ) return ex
def delete_action_definition(name, session=None): a_def = _get_action_definition(name) if not a_def: raise exc.DBEntityNotFoundException( "Action definition not found [action_name=%s]" % name ) session.delete(a_def)
def delete_workflow_execution(id, session=None): wf_ex = _get_workflow_execution(id) if not wf_ex: raise exc.DBEntityNotFoundException( "WorkflowExecution not found [id=%s]" % id ) session.delete(wf_ex)
def get_workflow_execution(id): wf_ex = _get_workflow_execution(id) if not wf_ex: raise exc.DBEntityNotFoundException( "WorkflowExecution not found [id=%s]" % id ) return wf_ex
def delete_workbook(name, session=None): wb = _get_workbook(name) if not wb: raise exc.DBEntityNotFoundException( "Workbook not found [workbook_name=%s]" % name ) session.delete(wb)
def delete_action_execution(id, session=None): a_ex = _get_action_execution(id) if not a_ex: raise exc.DBEntityNotFoundException( "ActionExecution not found [id=%s]" % id ) session.delete(a_ex)
def get_action_execution(id): a_ex = _get_action_execution(id) if not a_ex: raise exc.DBEntityNotFoundException( "ActionExecution not found [id=%s]" % id ) return a_ex
def delete_task_execution(id, session=None): task_ex = _get_task_execution(id) if not task_ex: raise exc.DBEntityNotFoundException( "TaskExecution not found [id=%s]" % id ) session.delete(task_ex)
def delete_environment(name, session=None): env = _get_environment(name) if not env: raise exc.DBEntityNotFoundException( "Environment not found [name=%s]" % name ) session.delete(env)
def get_action_definition(name): a_def = _get_action_definition(name) if not a_def: raise exc.DBEntityNotFoundException( "Action definition not found [action_name=%s]" % name ) return a_def
def get_cron_trigger(name): cron_trigger = _get_cron_trigger(name) if not cron_trigger: raise exc.DBEntityNotFoundException( "Cron trigger not found [name=%s]" % name ) return cron_trigger
def get_action_definition_by_id(id): action_def = _get_db_object_by_id(models.ActionDefinition, id) if not action_def: raise exc.DBEntityNotFoundException( "Action not found [action_id=%s]" % id ) return action_def
def get_workflow_definition_by_id(id): wf_def = _get_workflow_definition_by_id(id) if not wf_def: raise exc.DBEntityNotFoundException( "Workflow not found [workflow_id=%s]" % id ) return wf_def
def get_task_execution(id): task_ex = _get_task_execution(id) if not task_ex: raise exc.DBEntityNotFoundException( "Task execution not found [id=%s]" % id ) return task_ex
def delete_execution(id, session=None): ex = _get_execution(id) if not ex: raise exc.DBEntityNotFoundException( "Execution not found [execution_id=%s]" % id ) session.delete(ex)
def update_workflow_execution(id, values, session=None): wf_ex = _get_workflow_execution(id) if not wf_ex: raise exc.DBEntityNotFoundException( "WorkflowExecution not found [id=%s]" % id ) wf_ex.update(values.copy()) return wf_ex
def update_action_execution(id, values, session=None): a_ex = _get_action_execution(id) if not a_ex: raise exc.DBEntityNotFoundException( "ActionExecution not found [id=%s]" % id ) a_ex.update(values.copy()) return a_ex
def update_action_definition(name, values, session=None): a_def = _get_action_definition(name) if not a_def: raise exc.DBEntityNotFoundException( "Action definition not found [action_name=%s]" % name ) a_def.update(values.copy()) return a_def
def update_task_execution(id, values, session=None): task_ex = _get_task_execution(id) if not task_ex: raise exc.DBEntityNotFoundException( "TaskExecution not found [id=%s]" % id ) task_ex.update(values.copy()) return task_ex
def update_workbook(name, values, session=None): wb = _get_workbook(name) if not wb: raise exc.DBEntityNotFoundException( "Workbook not found [workbook_name=%s]" % name ) wb.update(values.copy()) return wb
def update_execution(id, values, session=None): ex = _get_execution(id) if not ex: raise exc.DBEntityNotFoundException( "Execution not found [execution_id=%s]" % id ) ex.update(values.copy()) return ex
def update_environment(name, values, session=None): env = _get_environment(name) if not env: raise exc.DBEntityNotFoundException( "Environment not found [name=%s]" % name ) env.update(values) return env
def delete_cron_trigger(name, session=None): cron_trigger = _get_cron_trigger(name) if not cron_trigger: raise exc.DBEntityNotFoundException( "Cron trigger not found [name=%s]" % name ) # Delete the cron trigger by ID and get the affected row count. table = models.CronTrigger.__table__ result = session.execute( table.delete().where(table.c.id == cron_trigger.id) ) return result.rowcount