def __get_client(self) -> ApiClient: if self.__api_client != None: return self.__api_client if self.api_key == "": self.logger.warning("Missing API Key") raise MissingAPIKeyError("Missing API Key") configuration = Configuration() configuration.api_key['authorization'] = self.api_key configuration.host = self.peacemakr_hostname + "/api/v1" self.__api_client = ApiClient(configuration=configuration) self.persister.save(PERSISTER_APIKEY_KEY, self.api_key) return self.__api_client
def setup_params(): # set up test address test_url = os.getenv("PEACEMAKR_TEST_URL", "http://localhost:8080") # need to wait until server is setup, otherwise call to server will fail time.sleep(5) # set up test api_key configuration = Configuration() configuration.api_key['authorization'] = "" configuration.host = test_url + "/api/v1" api_client = ApiClient(configuration=configuration) org_api = OrgApi(api_client=api_client) api_key = None api_key = org_api.get_test_organization_api_key() assert api_key!=None, "No testing api key was found" params = {} params["api_key"] = api_key.key params["test_url"] = test_url return params
def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client