Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make target_save.php POST request available via API, (to update redshift and ztfid). #117

Open
emirkmo opened this issue Sep 20, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@emirkmo
Copy link
Member

emirkmo commented Sep 20, 2022

Currently, editing the target is possible via the website. The endpoint is /target_save.php

It takes a referrer with some targetid:
https://flows.phys.au.dk/target_edit.php?target=114

It also requires cookie and a sessionID to be set, so a logged in client. It would be great if this endpoint was also available via making a POST request to api/target.php?target=114 or something like api/target_save.php?target=114, with the data containing the updated target info. Obviously, the targetid/name should not be updatable, but everything else should be. So that it can be used from within the API without having to make a logged-in client and spoof headers etc.

just for reference, these are the fields (minus targetid/targetname).
{'target_name': '2020wtp',
'targetid': 114,
'ra': 124.99880293333,
'decl': 7.79367375,
'catalog_downloaded': True,
'discovery_mag': 19.22,
'inserted': '2020-10-26 09:52:06.485412',
'redshift': 0.07,
'redshift_error': None,
'discovery_date': '2020-10-13 11:25:26.4',
'project': 'ztf-ia',
'host_galaxy': 'api_edited',
'ztf_id': 'ZTF20aciugdl',
'target_status': 'target',
'sntype': 'Ia'}

@rhandberg
Could you add this endpoint, and also, could you please provide a list of API endpoints to me as well, so that I have access to them?

Currently, these are the known ones:
https://github.com/SNflows/tendrils/blob/da578e1eb56b9e75b3e0fd09d9de52fb13748994/tendrils/utils/urls.py#L13-L26

class RemoteUrls:
    base_url: str = 'https://flows.phys.au.dk/api/'
    datafiles_url: str = 'datafiles.php'
    targets_url: str = 'targets.php'
    sites_url: str = 'sites.php'
    set_photometry_status_url: str = 'set_photometry_status.php'
    photometry_url: str = 'download_photometry.php'
    photometry_upload_url: str = 'upload_photometry.php'
    cleanup_photometry_status_url: str = 'cleanup_photometry_status.php'
    catalogs_url: str = 'reference_stars.php'
    catalogs_missing_url: str = 'catalog_missing.php'
    filters_url: str = 'filters.php'
    lightcurves_url: str = 'lightcurve.php'
    targets_post_url: str = 'targets_add.php'
@emirkmo emirkmo added the enhancement New feature or request label Sep 20, 2022
@rhandberg
Copy link
Contributor

It should actually be possible to modify a target using the exact same API endpoint as for adding a target. Only thing is that you have to add the targetid to the POST request. Only problem is that you have to add all the information about the target. I.e. you have to provide the full dict. It should be easy to make the Python API pull down the current target information, modify what needs to be modified in the dict, and post it back to the web-API.

@emirkmo
Copy link
Member Author

emirkmo commented Sep 26, 2022

I did try this but it returns with the error that target already exists. Are you sure? I tried pulling a random target, modifying only the host, and passing in the targetid. But it's possible I did something wrong.

@rhandberg
Copy link
Contributor

It should work... What is the exact error message that you get?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants