Add headers for ChatopsProxyAPIClient (#3789)
# What this PR does Add necessary headers to ChatopsProxyAPIClient for dev environment testing. ## Which issue(s) this PR fixes ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
This commit is contained in:
parent
06933a696a
commit
84a92cc9d3
1 changed files with 14 additions and 5 deletions
|
|
@ -4,6 +4,7 @@ from typing import List
|
|||
from urllib.parse import urljoin
|
||||
|
||||
import requests
|
||||
from django.conf import settings
|
||||
|
||||
SERVICE_TYPE_ONCALL = "oncall"
|
||||
|
||||
|
|
@ -64,7 +65,7 @@ class ChatopsProxyAPIClient:
|
|||
"service_type": service_type,
|
||||
}
|
||||
}
|
||||
response = requests.post(url=url, json=d)
|
||||
response = requests.post(url=url, json=d, headers=self._headers)
|
||||
self._check_response(response)
|
||||
|
||||
return Tenant(**response.json()["tenant"]), response
|
||||
|
|
@ -81,7 +82,7 @@ class ChatopsProxyAPIClient:
|
|||
}
|
||||
}
|
||||
|
||||
response = requests.post(url=url, json=d)
|
||||
response = requests.post(url=url, json=d, headers=self._headers)
|
||||
self._check_response(response)
|
||||
|
||||
return response.json()["removed"], response
|
||||
|
|
@ -96,7 +97,7 @@ class ChatopsProxyAPIClient:
|
|||
"cluster_slug": cluster_slug,
|
||||
"slack_team_id": slack_team_id,
|
||||
}
|
||||
response = requests.post(url=url, json=d)
|
||||
response = requests.post(url=url, json=d, headers=self._headers)
|
||||
self._check_response(response)
|
||||
return response
|
||||
|
||||
|
|
@ -111,7 +112,7 @@ class ChatopsProxyAPIClient:
|
|||
"slack_team_id": slack_team_id,
|
||||
}
|
||||
}
|
||||
response = requests.post(url=url, json=d)
|
||||
response = requests.post(url=url, json=d, headers=self._headers)
|
||||
self._check_response(response)
|
||||
return SlackLink(**response.json()["slack_link"]), response
|
||||
|
||||
|
|
@ -126,7 +127,7 @@ class ChatopsProxyAPIClient:
|
|||
"slack_team_id": slack_team_id,
|
||||
}
|
||||
}
|
||||
response = requests.post(url=url, json=d)
|
||||
response = requests.post(url=url, json=d, headers=self._headers)
|
||||
self._check_response(response)
|
||||
return response.json()["removed"], response
|
||||
|
||||
|
|
@ -152,3 +153,11 @@ class ChatopsProxyAPIClient:
|
|||
msg=message,
|
||||
method=response.request.method,
|
||||
)
|
||||
|
||||
@property
|
||||
def _headers(self) -> dict:
|
||||
return {
|
||||
"User-Agent": settings.GRAFANA_COM_USER_AGENT,
|
||||
"Authorization": f"Bearer {self.api_token}",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue