Target API Views¶
Warning
Check your groups!
When creating a Target via the API, one of the accepted parameters is a list of groups that will have permission
to view the Target. If you neglect to specify any groups, your Target will only be visible to the user that
created the Target. Please be sure to specify groups!!
Tip
Better API documentation
The available parameters for RESTful API calls are not available here. However, if you navigate to /api/targets/
and click the OPTIONS button, you can easily view all of the available parameters.
From the GET view, you can experiment with the available filters and see an example of the request.
- class tom_targets.api_views.TargetViewSet(**kwargs)¶
Viewset for Target objects. By default supports CRUD operations. See the docs on viewsets: https://www.django-rest-framework.org/api-guide/viewsets/
To view supported query parameters, please use the
OPTIONSendpoint, which can be accessed through the web UI.Please note that ``groups`` are an accepted query parameters for the ``CREATE`` endpoint. The ``groups`` parameter will specify which ``groups`` can view the created Target. If no ``groups`` are specified, the ``Target`` will only be visible to the user that created the ``Target``. Make sure to check your ``groups``!!
In order to create new
TargetNameorTargetExtraobjects, a dictionary with the new values must be appended to thealiasesortargetextra_setlists. Ifidis included, the API will attempt to update an existingTargetNameorTargetExtra. If noidis provided, the API will attempt to create new entries.TargetNameandTargetExtraobjects can only be deleted or specifically retrieved via the/api/targetname/or/api/targetextra/endpoints.Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- serializer_class¶
alias of
TargetSerializer
- filterset_class¶
alias of
TargetFilterSet
- handle_exception(exc)¶
Create Custom Error Message for Http404 errors because Target can have different names based on the supplied Model.
- class tom_targets.api_views.TargetNameViewSet(**kwargs)¶
Viewset for TargetName objects. Only
GETandDELETEoperations are permitted.To view available query parameters, please use the OPTIONS endpoint, which can be accessed through the web UI.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- class tom_targets.api_views.TargetExtraViewSet(**kwargs)¶
Viewset for TargetExtra objects. Only
GETandDELETEoperations are permitted.To view available query parameters, please use the OPTIONS endpoint, which can be accessed through the web UI.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- class tom_targets.api_views.TargetListViewSet(**kwargs)¶
Viewset for TargetList objects. Only
GETandDELETEoperations are permitted.To view available query parameters, please use the OPTIONS endpoint, which can be accessed through the web UI.
Constructor. Called in the URLconf; can contain helpful extra keyword arguments, and other things.
- serializer_class¶
alias of
TargetListSerializer
- Filters are available for Target objects:
type: Filter by target type (e.g., ‘SIDEREAL’, ‘NON_SIDEREAL’).
name: Filter by target name or alias.
key: Filter by a specific key in the target’s extra fields.
value: Filter by a specific value in the target’s extra fields.
cone_search: Perform a cone search around a given position (RA,Dec,Radius).
targetlist__name: Filter by the name of the target list the target belongs to.
name_fuzzy: Perform a fuzzy search on the target name or aliases.
target_cone_search: Perform a cone search on the target’s position (radius).
order: Order the results by a specific field (‘name’, ‘created’, ‘modified’)
- Access these filters via the API endpoint:
GET /api/targets/?type=<type>&cone_search=<ra,dec,radius>