Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
feat: send "x-organizationid" header
Browse files Browse the repository at this point in the history
  • Loading branch information
miwurster committed Dec 6, 2023
1 parent 7ee49f4 commit 0ceb1a0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion planqk/qiskit/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import requests
from requests import Response, HTTPError

from planqk.context import ContextResolver
from planqk.credentials import DefaultCredentialsProvider
from planqk.exceptions import InvalidAccessTokenError, PlanqkClientError
from planqk.qiskit.client.backend_dtos import BackendDto, PROVIDER, BackendStateInfosDto
Expand All @@ -32,14 +33,15 @@ def _dict_values_to_string(obj_values_dict: dict):

class _PlanqkClient(object):
_credentials = None
_context_resolver: ContextResolver = None

@classmethod
def set_credentials(cls, credentials: DefaultCredentialsProvider):
cls._credentials = credentials

@classmethod
def get_credentials(cls):
return cls._credentials;
return cls._credentials

@classmethod
def perform_request(cls, request_func: Callable[..., Response], url: str, params=None, data=None, headers=None):
Expand Down Expand Up @@ -125,6 +127,13 @@ def _get_default_headers(cls):
if service_execution_id() is not None:
headers["x-planqk-service-execution-id"] = service_execution_id()

if cls._context_resolver is None:
cls._context_resolver = ContextResolver()

context = cls._context_resolver.get_context()
if context is not None and context.is_organization:
headers["x-organizationid"] = context.get_organization_id()

return headers

@classmethod
Expand Down

0 comments on commit 0ceb1a0

Please sign in to comment.