예제 #1
0
 def __init__(
         self,
         token=None,
         nexus_endpoint="https://nexus.humanbrainproject.org/v0",
         kg_query_endpoint="https://kg.humanbrainproject.eu/query",
         release_endpoint="https://kg.humanbrainproject.eu/api/releases",
         idm_endpoint="https://services.humanbrainproject.eu/idm/v1/api"):
     if token is None:
         if oauth_token_handler:
             token = oauth_token_handler.get_token()
         else:
             try:
                 token = os.environ["HBP_AUTH_TOKEN"]
             except KeyError:
                 raise AuthenticationError("No token provided.")
     ep = urlparse(nexus_endpoint)
     self.nexus_endpoint = nexus_endpoint
     auth_client = AccessTokenClient(token)
     self._nexus_client = NexusClient(scheme=ep.scheme,
                                      host=ep.netloc,
                                      prefix=ep.path[1:],
                                      alternative_namespace=nexus_endpoint,
                                      auth_client=auth_client)
     self._kg_query_client = HttpClient(kg_query_endpoint,
                                        "",
                                        auth_client=auth_client)
     self._release_client = HttpClient(release_endpoint,
                                       "",
                                       auth_client=auth_client,
                                       raw=True)
     self._idm_client = HttpClient(idm_endpoint,
                                   "",
                                   auth_client=auth_client)
     self._instance_repo = self._nexus_client.instances
     self.cache = {}  # todo: use combined uri and rev as cache keys
예제 #2
0
 def __init__(self,
              token,
              nexus_endpoint="https://nexus.humanbrainproject.org/v0"):
     ep = urlparse(nexus_endpoint)
     self._nexus_client = NexusClient(scheme=ep.scheme,
                                      host=ep.netloc,
                                      prefix=ep.path[1:],
                                      alternative_namespace=nexus_endpoint,
                                      auth_client=AccessTokenClient(token))
     self._instance_repo = self._nexus_client.instances
     self.cache = {}  # todo: use combined uri and rev as cache keys
예제 #3
0
def init_client(token: str, deployment: str) -> NexusClient:
    auth_client = AccessTokenClient(token)
    parsed = urlparse(deployment)
    alt_namespace = f"{parsed.scheme}://{parsed.netloc}"
    return NexusClient(parsed.scheme, parsed.netloc, parsed.path,
                       alt_namespace, auth_client)
예제 #4
0
 def by_single_token(access_token: str, endpoint: str):
     auth_client = AccessTokenClient(access_token)
     return KGClient(auth_client, endpoint)