brynq-sdk-newrelic 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .newrelic_interface import NewRelicAPI
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from brynq_sdk_brynq import BrynQ
|
|
2
|
+
from typing import Union, List, Literal, Optional
|
|
3
|
+
import requests
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class NewRelicAPI(BrynQ):
|
|
7
|
+
|
|
8
|
+
def __init__(self, system_type: Optional[Literal['source', 'target']] = None, debug: bool = False):
|
|
9
|
+
"""
|
|
10
|
+
For the full documentation, see: https://docs.newrelic.com/docs/apis/nerdgraph/get-started/introduction-new-relic-nerdgraph/
|
|
11
|
+
"""
|
|
12
|
+
super().__init__()
|
|
13
|
+
self.headers = self._set_credentials(system_type)
|
|
14
|
+
self.url = "https://api.newrelic.com/graphql"
|
|
15
|
+
self.timeout = 3600
|
|
16
|
+
|
|
17
|
+
def _set_credentials(self, system_type):
|
|
18
|
+
"""
|
|
19
|
+
Get the credentials from BrynQ and get the username and private key from there
|
|
20
|
+
"""
|
|
21
|
+
credentials = self.interfaces.credentials.get(system="newrelic-api", system_type=system_type)
|
|
22
|
+
credentials = credentials.get('data')
|
|
23
|
+
api_key = credentials['api_key']
|
|
24
|
+
headers = {
|
|
25
|
+
'API-Key': f'{api_key}',
|
|
26
|
+
'Content-Type': 'application/json'
|
|
27
|
+
}
|
|
28
|
+
return headers
|
|
29
|
+
|
|
30
|
+
def execute_query(self, query: dict):
|
|
31
|
+
response = requests.post(self.url, headers=self.headers, json=query, timeout=self.timeout)
|
|
32
|
+
if response.status_code == 200:
|
|
33
|
+
return response.json()
|
|
34
|
+
else:
|
|
35
|
+
response.raise_for_status()
|
|
36
|
+
|
|
37
|
+
return response
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: brynq_sdk_newrelic
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Newrelic wrapper from BrynQ
|
|
5
|
+
Author: BrynQ
|
|
6
|
+
Author-email: support@brynq.com
|
|
7
|
+
License: BrynQ License
|
|
8
|
+
Requires-Dist: brynq-sdk-brynq<5,>=4
|
|
9
|
+
Requires-Dist: pandas<3,>=2
|
|
10
|
+
Dynamic: author
|
|
11
|
+
Dynamic: author-email
|
|
12
|
+
Dynamic: description
|
|
13
|
+
Dynamic: license
|
|
14
|
+
Dynamic: requires-dist
|
|
15
|
+
Dynamic: summary
|
|
16
|
+
|
|
17
|
+
Newrelic wrapper from BrynQ
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
brynq_sdk_newrelic/__init__.py,sha256=7y7fKZPY7L8wr7rWmywa5xObQPehhbFNRvw90pxq45I,43
|
|
2
|
+
brynq_sdk_newrelic/newrelic_interface.py,sha256=z9-LJZBeL_oXV9J1s64sv961-UR9i6Y7maK7sLdUkvs,1347
|
|
3
|
+
brynq_sdk_newrelic-2.0.0.dist-info/METADATA,sha256=yefFmjgumFosB9DfjkVOpTJIcmDW1Ydu4EEYX-KMErI,378
|
|
4
|
+
brynq_sdk_newrelic-2.0.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
5
|
+
brynq_sdk_newrelic-2.0.0.dist-info/top_level.txt,sha256=HavNJRdo5tAa5bQ9hTHCpIOatUyaJpoqJn7HbcbLEx4,19
|
|
6
|
+
brynq_sdk_newrelic-2.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
brynq_sdk_newrelic
|