common.application_layer.rest_api.views package

Submodules

common.application_layer.rest_api.views.auth module

common.application_layer.rest_api.views.auth.issue_user_jwt(request: Request) → Response

Get a JWT for the provided user id URL: auth

Parameters:

request –

POST request, expecting JSON object like: {

”userId”, <int>

}

Returns:

a JWT string or 400 response (HTTPBadRequest) if expected parameters not given or 404 response (HTTPNotFound) if no user was found with user id

common.application_layer.rest_api.views.auth.options_response(request: Request) → Response

For CORS preflight requests, return an empty dict URL: auth/*

Parameters:

request – OPTIONS request

Returns:

an empty dict

common.application_layer.rest_api.views.auth.search_users(request: Request) → Response

Return a list of users matching a search term (by name or user id) URL: auth/{searchterm}

Parameters:

request – GET request

Returns:

Response with JSON-formatted list of matching users (may be empty)

common.application_layer.rest_api.views.byid module

common.application_layer.rest_api.views.gbo_calculator module

common.application_layer.rest_api.views.gbo_calculator.calculate_from_resource(request: Request) → Response

Calculate observing time by calling the gbo_calculator_service with a resource_id and set of inputs for calculation. Required inputs can change depending on other inputs and hardware.

URL: gbo_calculator/calculate_from_resource

Parameters:

request – POST request with JSON body defining inputs, where an example superset of inputs looks like

{

“resourceId”: “244-49”, “rSigRef”: 1, “noAvgRef”: 1, “smoothing”: “velocity_resolution_topo”, “smoothing_resolution”: 1, “conversion”: “Sensitivity to Time”, “units”: “flux”, “sensitivity”: 1, “time”: 1, “frame”: “Rest Frame”, “restFreq”: 1440, “doppler”: “Optical”, “redshift”: 0, “sourceVelocity”: 0.0, “sourceDiameterSlider”: 0, “effectiveBw”: 12, “galactic”: “estimated”, “rightAscension”: 0, “estimatedContinuum”: 0, “declination”: 0, “minElevation”: 5, “diffSignal”: True, “avgPol”: True, “topocentricFreq”: 1440, “dutyCycle”: 10,

}

Returns:

Response object containing the calulation response, where resp[“e”] contains the results, resp[“messages”] contains warnings, and the other keys contain inputs and other metadata or 400 (HTTPBadRequest) if any required params are missing or 404 (HTTPNotFound) if the requested resource_id does not exist in the GBO Sensitivity Calculator database

common.application_layer.rest_api.views.gbo_calculator.calculate_from_target(request: Request) → Response

Request sensitivity->time calculation from the GBO Sensitivity Calculator given a Science|Reference Target :param request: POST request with JSON containing either {scienceTargetId: <int>} or {referenceTargetId: <int>} :return: JSON payload containing the calculated time on source, and metadata describing the equations/values used or 400 (HTTPBadRequest) if computation with given params cannot proceed or 404 (HTTPNotFound) if target or ResourceID is not found

common.application_layer.rest_api.views.gbo_calculator.get_hardware_from_resource(request: Request) → Response

Get the hardware saved for a given resource by calling the gbo_calculator_service URL: gbo_calculator/get_hardware_from_resource/{resource_id}

Parameters:

request – GET request

Raises:
  • ValueError – if resource_id is not given

  • ResourceNotFound – if requested resource_id does not exist in the GBO Calculator database

Returns:

Response with JSON containing the hardware, and any warnings e.g. if the resource was saved for a different version or 400 (HTTPBadRequest) if resource_id is not given or 404 (HTTPNotFound) if the requested resource does not exist in the GBO Calculator database

common.application_layer.rest_api.views.gbo_calculator.get_hardware_options(request: Request) → Response

Get valid options for hardware based on other selections, where at least backend, mode, & receiver are selected

Parameters:

request – POST request with JSON containing hardware inputs with at least backend, mode, & receiver defined, e.g:

{

“backend”: “VErsatile GB Astronomical Spectrometer”, “mode”: “Spectral Line”, “receiver”: “L (1.15 - 1.73 GHz)”,

} :return: Response object with JSON containing all HW keys not originally specified, each of which stores a list of valid options, e.g.: {

‘beams’: [1], ‘polarization’: [‘Dual’, ‘Full’], ‘bandwidth’: [11.72, 16.9, 23.44, 100.0, 187.5, 850.0, 1250.0], ‘windows’: [1, 2, 3, 4, 5, 6, 7, 8], ‘switching’: [‘In-Band Frequency Switching’, ‘Out-of-Band Frequency Switching’, ‘Position Switching’], ‘success’: ‘ok’

} or 400 (HTTPBadRequest) if backend, mode, or receiver are missing from the JSON

common.application_layer.rest_api.views.gbo_calculator.get_resource_id(request: Request) → Response

Get a resource ID for the specified hardware by calling the gbo_calculator_service URL: gbo_calculator/get_resource_id

Parameters:

request – POST request with JSON body defining hardware like

{

“backend”: “Caltech Continuum Backend”, “mode”: “Continuum”, “receiver”: “Ka (26.0 - 39.8 GHz)”, “beams”: 2, “polarization”: “Single”, “bandwidth”: 3500.0, “windows”: 4, “switching”: “Beam Switching - Nodding between beams”

} :return: 200 Response object with resourceId if resource was successfully fetched

or 201 Response object with resourceId if resource was just created or 400 (HTTPBadRequest) if the resource is not valid

Module contents