B
    |d                 @   s*   d Z dd ZdddZdd Zd	d
 ZdS )z#API URL implementation for DQSEGDB
c              K   s   d dd t|  D S )z=Return a URL query string based on some key, value pairs
    &c             s   s   | ]\}}d  ||V  qdS )z{0}={1}N)format).0keyvalue r   Y/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/dqsegdb2/api.py	<genexpr>   s   z_query.<locals>.<genexpr>)joinsorteditems)kwargsr   r   r   _query   s    
r   Nmetadata,known,activec          
   C   s   dj | |||t|||ddS )a  Returns the URL to use in querying for segments

    Parameters
    ----------
    host : `str`
        the URL of the target DQSEGDB2 host

    ifo : `str`
        the interferometer prefix

    name : `str`
        the name of the flag

    version : `int`
        the version of the flag

    start : `int`
        the start GPS time of the query

    end : `int`
        the end GPS time of the query

    include : `str`, optional
        the data to return, should be a comma-separated list of keys

    Returns
    -------
    url : `str`
        the full REST URL to query for information

    Examples
    --------
    >>> from dqsegdb2.api import segment_query_url
    >>> print(segment_query_url('https://segments.ligo.org', 'G1',
    ...                         'GEO-SCIENCE', 1, 1000000000, 11000000000))
    'https://segments.ligo.org/dq/G1/GEO-SCIENCE/1?s=1000000000&e=11000000000&include=metadata,known,active'
    z({host}/dq/{ifo}/{name}/{version}?{query})seinclude)hostifonameversionquery)r   r   )r   r   r   r   startendr   r   r   r   segment_query_url   s    'r   c             C   s   dj | ||dS )aF  Returns the URL to use in querying for flag versions

    Parameters
    ----------
    host : `str`
        the URL of the target DQSEGDB2 host

    ifo : `str`
        the interferometer prefix

    name : `str`
        the name of the flag

    Returns
    -------
    url : `str`
        the full REST URL to query for information

    Examples
    --------
    >>> from dqsegdb2.api import version_query_url
    >>> print(version_query_url('https://segments.ligo.org', 'G1',
    ...                         'GEO-SCIENCE'))
    'https://segments.ligo.org/dq/G1/GEO-SCIENCE'
    z{host}/dq/{ifo}/{name})r   r   r   )r   )r   r   r   r   r   r   version_query_urlI   s    r   c             C   s   dj | |dS )a  Returns the URL to use in querying for flag names

    Parameters
    ----------
    host : `str`
        the URL of the target DQSEGDB2 host

    ifo : `str`
        the interferometer prefix

    Returns
    -------
    url : `str`
        the full REST URL to query for information

    Examples
    --------
    >>> from dqsegdb2.api import name_query_url
    >>> print(name_query_url('https://segments.ligo.org', 'G1'))
    'https://segments.ligo.org/dq/G1'
    z{host}/dq/{ifo})r   r   )r   )r   r   r   r   r   name_query_urlf   s    r   )NNr   )__doc__r   r   r   r   r   r   r   r   <module>   s
    
+