From 9e1d2568ac215ad8c8d694aa6d70002d3f5697ae Mon Sep 17 00:00:00 2001 From: Benoit Perigaud <8754100+b-per@users.noreply.github.com> Date: Tue, 21 May 2024 18:40:47 +0200 Subject: [PATCH] Add specific user agent --- src/client/__init__.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/client/__init__.py b/src/client/__init__.py index f986ce8..d7bc94e 100644 --- a/src/client/__init__.py +++ b/src/client/__init__.py @@ -10,7 +10,7 @@ ) from src.schemas.job import JobDefinition - +VERSION = "0.3.2" class DBTCloud: """A minimalistic API client for fetching dbt Cloud data.""" @@ -31,6 +31,7 @@ def __init__( self._headers = { "Authorization": f"Bearer {self._api_key}", "Content-Type": "application/json", + "User-Agent": f"dbt-jobs-as-code/v{VERSION}", } self._verify = not disable_ssl_verification if not self._verify: @@ -159,10 +160,7 @@ def get_job(self, job_id: int) -> JobDefinition: response = requests.get( url=(f"{self.base_url}/api/v2/accounts/" f"{self.account_id}/jobs/{job_id}"), - headers={ - "Authorization": f"Bearer {self._api_key}", - "Content-Type": "application/json", - }, + headers=self._headers, verify=self._verify, ) return JobDefinition(**response.json()["data"]) @@ -287,10 +285,7 @@ def get_environments(self) -> Dict: response = requests.get( url=(f"{self.base_url}/api/v3/accounts/" f"{self.account_id}/environments/"), - headers={ - "Authorization": f"Bearer {self._api_key}", - "Content-Type": "application/json", - }, + headers=self._headers, verify=self._verify, )