Source code for academic_observatory_api.server.api

# Copyright 2022 Curtin University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Author: Aniek Roelofs


from typing import Any, Tuple
from academic_observatory_api.server.elastic import (
    get_pit_id,
    query_elasticsearch
)

[docs]Response = Tuple[Any, int]
[docs]session_ = None # Global session
[docs]def pit_id_agg(agg: str): return get_pit_id(agg=agg, subagg=None)
[docs]def pit_id_subagg(agg: str, subagg: str): return get_pit_id(agg=agg, subagg=subagg)
[docs]def query_agg(agg: str): return query_elasticsearch(agg=agg, subagg=None)
[docs]def query_subagg(agg: str, subagg: str): return query_elasticsearch(agg=agg, subagg=subagg)