brynq-sdk-elastic 2.2.1__tar.gz → 2.2.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq_sdk_elastic
3
- Version: 2.2.1
3
+ Version: 2.2.2
4
4
  Summary: elastic wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -17,6 +17,7 @@ class Elastic:
17
17
  try:
18
18
  self.verify = False
19
19
  self.disabled = disabled
20
+ self.timeout = 60 # seconds before request to elastic fails
20
21
  elasticsearch_host = os.getenv("ELASTIC_HOST")
21
22
  elasticsearch_port = os.getenv("ELASTIC_PORT")
22
23
  kibana_port = os.getenv("KIBANA_PORT")
@@ -75,7 +76,7 @@ class Elastic:
75
76
  return 'Healthy connection established with elasticsearch!'
76
77
 
77
78
  try:
78
- health = requests.get(url=f'{self.elasticsearch_host}/_cat/health?', headers=self.elastic_headers, verify=self.verify).status_code
79
+ health = requests.get(url=f'{self.elasticsearch_host}/_cat/health?', headers=self.elastic_headers, verify=self.verify, timeout=self.timeout).status_code
79
80
  if health != 200:
80
81
  raise ConnectionError(f"Elasticsearch cluster health check failed with status code: {health}")
81
82
  else:
@@ -185,7 +186,7 @@ class Elastic:
185
186
 
186
187
  # initial request
187
188
  params = {"size": size, "scroll": "10m"}
188
- response = requests.get(url=url, headers=self.elastic_headers, params=params, verify=self.verify).json()
189
+ response = requests.get(url=url, headers=self.elastic_headers, params=params, verify=self.verify, timeout=self.timeout).json()
189
190
 
190
191
  # next requests until finished
191
192
  scroll_id = response['_scroll_id']
@@ -356,7 +357,7 @@ class Elastic:
356
357
 
357
358
  url = f'{self.elasticsearch_host}/{index_name}/_doc/'
358
359
  body = json.dumps(document)
359
- response = requests.post(url=url, data=body, headers=self.elastic_headers, verify=self.verify)
360
+ response = requests.post(url=url, data=body, headers=self.elastic_headers, verify=self.verify, timeout=self.timeout)
360
361
  return response
361
362
 
362
363
  def get_document(self, index_name: str, document_id: str) -> requests.Response:
@@ -370,7 +371,7 @@ class Elastic:
370
371
  return None
371
372
 
372
373
  url = f'{self.elasticsearch_host}/{index_name}/_doc/{document_id}'
373
- response = requests.get(url=url, headers=self.elastic_headers, verify=self.verify)
374
+ response = requests.get(url=url, headers=self.elastic_headers, verify=self.verify, timeout=self.timeout)
374
375
  return response
375
376
 
376
377
  def delete_document(self, index_name: str, document_id: str) -> requests.Response:
@@ -384,7 +385,7 @@ class Elastic:
384
385
  return None
385
386
 
386
387
  url = f'{self.elasticsearch_host}/{index_name}/_doc/{document_id}'
387
- response = requests.delete(url=url, headers=self.elastic_headers, verify=self.verify)
388
+ response = requests.delete(url=url, headers=self.elastic_headers, verify=self.verify, timeout=self.timeout)
388
389
  return response
389
390
 
390
391
  def task_execution_log(self, information: dict) -> requests.Response:
@@ -399,7 +400,7 @@ class Elastic:
399
400
  # Add new document
400
401
  url = f'{self.elasticsearch_host}/task_execution_log_{self.client_user}/_doc/'
401
402
  body = json.dumps(information)
402
- response = requests.post(url=url, data=body, headers=self.elastic_headers, verify=self.verify)
403
+ response = requests.post(url=url, data=body, headers=self.elastic_headers, verify=self.verify, timeout=self.timeout)
403
404
  return response
404
405
 
405
406
  @staticmethod
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq-sdk-elastic
3
- Version: 2.2.1
3
+ Version: 2.2.2
4
4
  Summary: elastic wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -3,7 +3,7 @@ from setuptools import setup
3
3
 
4
4
  setup(
5
5
  name='brynq_sdk_elastic',
6
- version='2.2.1',
6
+ version='2.2.2',
7
7
  description='elastic wrapper from BrynQ',
8
8
  long_description='elastic wrapper from BrynQ',
9
9
  author='BrynQ',