Agent: Replace fields in configuration using pydantic syntax in PBA file upload resource

This commit is contained in:
Shreya Malviya 2022-08-30 12:30:10 +05:30
parent 163c54a8c3
commit a9a006a9fd
1 changed files with 7 additions and 4 deletions

View File

@ -1,5 +1,4 @@
import logging import logging
from dataclasses import replace
from http import HTTPStatus from http import HTTPStatus
from flask import Response, make_response, request, send_file from flask import Response, make_response, request, send_file
@ -102,11 +101,15 @@ class PBAFileUpload(AbstractResource):
agent_configuration = self._agent_configuration_repository.get_configuration() agent_configuration = self._agent_configuration_repository.get_configuration()
if target_os == LINUX_PBA_TYPE: if target_os == LINUX_PBA_TYPE:
custom_pbas = replace(agent_configuration.custom_pbas, linux_filename=safe_filename) custom_pbas = agent_configuration.custom_pbas.copy(
update={"linux_filename": safe_filename}
)
else: else:
custom_pbas = replace(agent_configuration.custom_pbas, windows_filename=safe_filename) custom_pbas = agent_configuration.custom_pbas.copy(
update={"windows_filename": safe_filename}
)
updated_agent_configuration = replace(agent_configuration, custom_pbas=custom_pbas) updated_agent_configuration = agent_configuration.copy(update={"custom_pbas": custom_pbas})
self._agent_configuration_repository.store_configuration(updated_agent_configuration) self._agent_configuration_repository.store_configuration(updated_agent_configuration)
@jwt_required @jwt_required