@@ -132,7 +132,7 @@ def _login(self, username, password):
132132 return True
133133
134134 @class_or_instance
135- def query_region (self , coordinates , * , radius = 0.3 * units .deg ):
135+ def query_region (self , coordinates , * , radius = 0.3 * units .deg , get_query_payload = False ):
136136 """
137137 search for Gemini observations by target on the sky.
138138
@@ -148,15 +148,20 @@ def query_region(self, coordinates, *, radius=0.3*units.deg):
148148 The string must be parsable by `~astropy.coordinates.Angle`. The
149149 appropriate `~astropy.units.Quantity` object from
150150 `~astropy.units` may also be used. Defaults to 0.3 deg.
151+ get_query_payload : bool, optional
152+ If set to `True` then returns the URL and method that would be used for the
153+ request. Defaults to `False`.
151154
152155 Returns
153156 -------
154- response : `~astropy.table.Table`
157+ response : `~astropy.table.Table` or dict
158+ The response from the query as an `~astropy.table.Table`, or if get_query_payload
159+ is True, a dictionary containing the URL and HTTP method that would be used.
155160 """
156- return self .query_criteria (coordinates = coordinates , radius = radius )
161+ return self .query_criteria (coordinates = coordinates , radius = radius , get_query_payload = get_query_payload )
157162
158163 @class_or_instance
159- def query_object (self , objectname , * , radius = 0.3 * units .deg ):
164+ def query_object (self , objectname , * , radius = 0.3 * units .deg , get_query_payload = False ):
160165 """
161166 search for Gemini observations by target on the sky.
162167
@@ -173,18 +178,23 @@ def query_object(self, objectname, *, radius=0.3*units.deg):
173178 The string must be parsable by `~astropy.coordinates.Angle`. The
174179 appropriate `~astropy.units.Quantity` object from
175180 `~astropy.units` may also be used. Defaults to 0.3 deg.
181+ get_query_payload : bool, optional
182+ If set to `True` then returns the URL and method that would be used for the
183+ request. Defaults to `False`.
176184
177185 Returns
178186 -------
179- response : `~astropy.table.Table`
187+ response : `~astropy.table.Table` or dict
188+ The response from the query as an `~astropy.table.Table`, or if get_query_payload
189+ is True, a dictionary containing the URL and HTTP method that would be used.
180190 """
181- return self .query_criteria (objectname = objectname , radius = radius )
191+ return self .query_criteria (objectname = objectname , radius = radius , get_query_payload = get_query_payload )
182192
183193 @class_or_instance
184194 def query_criteria (self , * rawqueryargs , coordinates = None , radius = None , pi_name = None , program_id = None , utc_date = None ,
185- instrument = None , observation_class = None , observation_type = None , mode = None ,
186- adaptive_optics = None , program_text = None , objectname = None , raw_reduced = None ,
187- orderby = None , ** rawquerykwargs ):
195+ instrument = None , observation_class = None , observation_type = None , mode = None ,
196+ adaptive_optics = None , program_text = None , objectname = None , raw_reduced = None ,
197+ orderby = None , get_query_payload = False , ** rawquerykwargs ):
188198 """
189199 search a variety of known parameters against the Gemini observations.
190200
@@ -294,7 +304,9 @@ def query_criteria(self, *rawqueryargs, coordinates=None, radius=None, pi_name=N
294304
295305 Returns
296306 -------
297- response : `~astropy.table.Table`
307+ response : `~astropy.table.Table` or dict
308+ The response from the query as an `~astropy.table.Table`, or if get_query_payload
309+ is True, a dictionary containing the URL and HTTP method that would be used.
298310
299311 Raises
300312 ------
@@ -316,7 +328,8 @@ def query_criteria(self, *rawqueryargs, coordinates=None, radius=None, pi_name=N
316328 args .append (arg )
317329 if rawquerykwargs :
318330 for (k , v ) in rawquerykwargs .items ():
319- kwargs [k ] = v
331+ if k != 'get_query_payload' :
332+ kwargs [k ] = v
320333
321334 # If coordinates is set but we have no radius, set a default
322335 if (coordinates or objectname ) and radius is None :
@@ -370,6 +383,8 @@ def query_criteria(self, *rawqueryargs, coordinates=None, radius=None, pi_name=N
370383 if orderby is not None :
371384 kwargs ["orderby" ] = orderby
372385
386+ if get_query_payload :
387+ kwargs ['get_query_payload' ] = get_query_payload
373388 return self .query_raw (* args , ** kwargs )
374389
375390 @class_or_instance
@@ -380,7 +395,7 @@ def query_raw(self, *args, **kwargs):
380395 This is a more flexible query method. This method will do special handling for
381396 coordinates and radius if present in kwargs. However, for the remaining arguments
382397 it assumes all of args are useable as query path elements. For kwargs, it assumes
383- all of the elements can be passed as name=value within the query path to Gemini .
398+ all of the elements can be passed as name=value within the query path to the webserver .
384399
385400 This method does not do any validation checking or attempt to interperet the
386401 values being passed, aside from coordinates and radius.
@@ -406,11 +421,24 @@ def query_raw(self, *args, **kwargs):
406421 path to the webserver. The ``orderby`` key value pair has a special
407422 intepretation and is appended as a query parameter like the one used
408423 in the archive website for sorting results.
424+ get_query_payload : bool, optional
425+ If set to `True` then returns the URL and method that would be used for the
426+ request. Defaults to `False`.
409427
410428 Returns
411429 -------
412- response : `~astropy.table.Table`
430+ response : `~astropy.table.Table` or dict
431+ The response from the query as an `~astropy.table.Table`, or if get_query_payload
432+ is True, a dictionary containing the URL and HTTP method that would be used.
413433 """
434+ if kwargs .pop ('get_query_payload' , False ):
435+ url = self .url_helper .build_url (* args , ** kwargs )
436+ return {
437+ 'url' : url ,
438+ 'method' : 'GET' ,
439+ 'data' : {}
440+ }
441+
414442 url = self .url_helper .build_url (* args , ** kwargs )
415443
416444 response = self ._request (method = "GET" , url = url , data = {}, timeout = 180 , cache = False )
0 commit comments