def update_supported_app_data_by_agentid_and_appid(agent_id, app_id, app_data): """Update the supported_apps_per_agent collection by agent_id and app_id. This function should not be called directly. Args: agent_id (str): 36 character UUID of the agent. app_id (str): 64 character ID of the application. app_data(dict): Dictionary of the application data that is being updated for the agent. Basic Usage: >>> from vFense.plugins.patching.patching import update_supported_app_data_by_agentid_and_appid >>> agent_id = '7f242ab8-a9d7-418f-9ce2-7bcba6c2d9dc' >>> app_id = '15fa819554aca425d7f699e81a2097898b06f00a0f2dd6e8d51a18405360a6eb' >>> app_data = {'status': 'pending'} >>> update_supported_app_data_by_agentid_and_appid(agent_id, app_id, app_data) Return: Tuple (status_code, count, error, generated ids) >>> (2001, 1, None, []) """ collection = AppCollections.SupportedAppsPerAgent data = update_app_data_by_agentid_and_appid( agent_id, app_id, app_data, collection=collection ) return data
def update_app_status_by_agentid_and_appid( agent_id, app_id, status, collection=AppCollections.AppsPerAgent ): """Update the application status for an agent Args: agent_id (str): 36 character UUID of the agent. app_id (str): 64 character ID of the application. status (str): The new status for the application. Kwargs: collection (str): Collection where the status update is done. Basic Usage: >>> from vFense.plugins.patching.patching import update_app_status_by_agentid_and_appid >>> agent_id = '7f242ab8-a9d7-418f-9ce2-7bcba6c2d9dc' >>> app_id = '15fa819554aca425d7f699e81a2097898b06f00a0f2dd6e8d51a18405360a6eb' >>> status = 'pending' >>> update_app_status_by_agentid_and_appid(agent_id, app_id, status) Returns: Boolean """ updated = False if status in CommonAppKeys.ValidPackageStatuses: app_status = {DbCommonAppPerAgentKeys.Status: status} status_code, _, _, _ = update_app_data_by_agentid_and_appid( agent_id, app_id, app_status, collection ) if status_code == DbCodes.Replaced: updated = True return updated