Skip to content

Commit

Permalink
Validate mandatory parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
vduseev committed Dec 13, 2024
1 parent 205b9fe commit d49351c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
14 changes: 7 additions & 7 deletions dynatrace/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ def __init__(
base_url = base_url[:-1]
self.base_url = base_url

# Persistent session
self.session = requests.Session()

# Mount the adapter once during initialization
self.session.mount("https://", HTTPAdapter(max_retries=self.retries))
self.session.mount("http://", HTTPAdapter(max_retries=self.retries))

# Custom headers
self.headers = headers.copy() if headers else {}

Expand Down Expand Up @@ -101,6 +94,13 @@ def __init__(
raise_on_status=False,
)

# Persistent session
self.session = requests.Session()

# Mount the adapter once during initialization
self.session.mount("https://", HTTPAdapter(max_retries=self.retries))
self.session.mount("http://", HTTPAdapter(max_retries=self.retries))

# This is for internal dynatrace usage
self.mc_jsession_id = mc_jsession_id
self.mc_b925d32c = mc_b925d32c
Expand Down
5 changes: 5 additions & 0 deletions dynatrace/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ def __init__(
timeout: Optional[int] = None,
headers: Optional[Dict] = None,
):
if not base_url:
raise ValueError("base_url is required")
if not token:
raise ValueError("token is required")

self.__http_client = HttpClient(
base_url,
token,
Expand Down

0 comments on commit d49351c

Please sign in to comment.