Skip to content

Commit

Permalink
Merge pull request #3 from arangodb/parameters_update
Browse files Browse the repository at this point in the history
Parameters update
  • Loading branch information
cw00dw0rd authored Jul 22, 2022
2 parents 779fe8a + abba8f1 commit cce0a78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions adb_cloud_connector/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import time
from json.decoder import JSONDecodeError
from typing import Any, Dict
from typing import Any, Dict, Optional

import requests
from requests.exceptions import HTTPError
Expand All @@ -11,7 +11,10 @@
dir_path = os.path.dirname(os.path.realpath(__file__))


def get_temp_credentials() -> Json:
def get_temp_credentials(
tutorialName: Optional[str] = None,
credentialProvider: str = "https://tutorials.arangodb.cloud:8529/_db/_system/tutorialDB/tutorialDB",
) -> Json:
creds_file = f"{dir_path}/data/creds.json"

try:
Expand All @@ -26,8 +29,9 @@ def get_temp_credentials() -> Json:

except (JSONDecodeError, HTTPError):
print("Log: requesting new credentials...")
url = "https://tutorials.arangodb.cloud:8529/_db/_system/tutorialDB/tutorialDB"
response = requests.post(url, data=json.dumps({}))
url = credentialProvider
body = {"tutorialName": tutorialName} if tutorialName else "{}"
response = requests.post(url, data=json.dumps(body))
response.raise_for_status()

data: Json = response.json()
Expand Down
1 change: 1 addition & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

def test_get_temp_credentials() -> None:
new_creds = get_temp_credentials()
print(new_creds)
assert new_creds.keys() == {
"url",
"hostname",
Expand Down

0 comments on commit cce0a78

Please sign in to comment.