def updateResource(self, resource_id, resource_name=None, status=None, description=None, external_system=None, location=None, department=None, owner=None, **add_params): """ Update resource information Find resource in database by ID and update all non-None passed attributes """ self.db_conn.connect() raw_resource = self.db_conn.get_entity(CommonDatabaseAPI.ET_RESOURCE, resource_id) resource = Resource(raw_resource) if resource_name is not None: resource.set_resource_name(resource_name) if status is not None: resource.set_resource_status(status) if description is not None: resource.set_description(description) if external_system is not None: resource.set_external_system(external_system) if location is not None: resource.set_location(location) if department is not None: resource.set_department(department) if owner is not None: resource.set_owner(owner) for param_name, param_value in add_params.iteritems(): resource.set_attribute(param_name, param_value) resource.validate() self.db_conn.save_entity(CommonDatabaseAPI.ET_RESOURCE, resource.to_dict()) self.db_conn.close() return resource