else "any"
)
if parameters["data_source"] not in ["celestrak", "spacetrack", "any"]:
raise ValidationError(500, error_messages.INVALID_SOURCE)
if "tle" in parameters.keys():
parameters["tle"] = parse_tle(parameters["tle"])
# TODO: used for tools endpoints, might not be needed here (move to tools service?)
if "name" in parameters.keys() and len(parameters) == 1:
parameters["name"] = parameters["name"].upper()
if "id_type" in parameters.keys():
if parameters["id_type"] not in ["catalog", "name"]:
raise ValidationError(400, error_messages.INVALID_PARAMETER)
if "end_date_jd" in parameters.keys() and parameters["end_date_jd"] is not None:
try:
parameters["end_date_jd"] = (
Time(parameters["end_date_jd"], format="jd", scale="ut1")
.to_datetime()
.replace(tzinfo=timezone.utc)
)
except Exception as e:
raise ValidationError(500, error_messages.INVALID_JD, e) from e
if "start_date_jd" in parameters.keys() and parameters["start_date_jd"] is not None:
try:
parameters["start_date_jd"] = (
Time(parameters["start_date_jd"], format="jd", scale="ut1")
.to_datetime()
.replace(tzinfo=timezone.utc)
)
except Exception as e:
raise ValidationError(500, error_messages.INVALID_JD, e) from e
return parameters
https://github.com/iausathub/satchecker/blob/95c45e06d5f1ba459f92ec182b12d89de49df146/src/api/services/validation_service.py#L153