brynq-sdk-elastic 3.0.3__tar.gz → 3.0.4__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: 3.0.3
3
+ Version: 3.0.4
4
4
  Summary: elastic wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -111,12 +111,12 @@ class Elastic:
111
111
  "disabledFeatures": [],
112
112
  }
113
113
 
114
- response = requests.head(url=url + fr'/{space_name}', headers=self.kibana_headers, verify=self.verify)
114
+ response = requests.head(url=url + fr'/{space_name}', headers=self.kibana_headers, verify=self.verify, timeout=self.timeout)
115
115
 
116
116
  if response.status_code == 200:
117
117
  return f'Index \'{space_name}\' already exists'
118
118
  else:
119
- response = requests.post(url=url, headers=self.kibana_headers, data=json.dumps(data), verify=self.verify)
119
+ response = requests.post(url=url, headers=self.kibana_headers, data=json.dumps(data), verify=self.verify, timeout=self.timeout)
120
120
  if response.status_code == 200:
121
121
  return f'space {space_name} created'
122
122
  else:
@@ -148,12 +148,12 @@ class Elastic:
148
148
  }
149
149
  }
150
150
 
151
- response = requests.head(url=url + fr'/{view_name}', headers=self.kibana_headers, verify=self.verify)
151
+ response = requests.head(url=url + fr'/{view_name}', headers=self.kibana_headers, verify=self.verify, timeout=self.timeout)
152
152
 
153
153
  if response.status_code == 200:
154
154
  return f'Data view \'{view_name}\' already exists'
155
155
  else:
156
- response = requests.post(url=url, headers=self.kibana_headers, data=json.dumps(data), verify=self.verify)
156
+ response = requests.post(url=url, headers=self.kibana_headers, data=json.dumps(data), verify=self.verify, timeout=self.timeout)
157
157
  if response.status_code == 200:
158
158
  return f'data view {view_name} created'
159
159
  else:
@@ -175,7 +175,7 @@ class Elastic:
175
175
  size = 10000
176
176
 
177
177
  # Get all indices with the given index from the function parameter. For each day a new index.
178
- indices = requests.get(url=self.elasticsearch_host + '/' + index + '*/_settings', headers=self.elastic_headers, verify=self.verify).json()
178
+ indices = requests.get(url=self.elasticsearch_host + '/' + index + '*/_settings', headers=self.elastic_headers, verify=self.verify, timeout=self.timeout).json()
179
179
  index_list = {}
180
180
 
181
181
  for index in indices:
@@ -200,7 +200,7 @@ class Elastic:
200
200
  url = f'{self.elasticsearch_host}/_search/scroll'
201
201
 
202
202
  while loop_boolean and total > size:
203
- next_response = pd.json_normalize(requests.post(url=url, data=body, headers=self.elastic_headers, verify=self.verify).json()["hits"]["hits"])
203
+ next_response = pd.json_normalize(requests.post(url=url, data=body, headers=self.elastic_headers, verify=self.verify, timeout=self.timeout).json()["hits"]["hits"])
204
204
  next_response.drop(['_id', '_index', '_score'], axis=1, inplace=True)
205
205
  response = pd.concat([response, next_response], ignore_index=True)
206
206
  print(f'Received {len(next_response)} documents from index {index}')
@@ -219,13 +219,13 @@ class Elastic:
219
219
 
220
220
  # Check if index exists
221
221
  url = f'{self.elasticsearch_host}/{index_name}'
222
- response = requests.head(url=url, headers=self.elastic_headers, verify=self.verify)
222
+ response = requests.head(url=url, headers=self.elastic_headers, verify=self.verify, timeout=self.timeout)
223
223
 
224
224
  # Delete index if it exists
225
225
  if response.status_code == 404:
226
226
  return f'Index \'{index_name}\' does not exist'
227
227
  else:
228
- response = requests.delete(url=url, headers=self.elastic_headers, verify=self.verify)
228
+ response = requests.delete(url=url, headers=self.elastic_headers, verify=self.verify, timeout=self.timeout)
229
229
  if response.status_code == 200:
230
230
  return f'Index \'{index_name}\' deleted'
231
231
  else:
@@ -241,7 +241,7 @@ class Elastic:
241
241
  return 'Index creation disabled'
242
242
 
243
243
  url = f'{self.elasticsearch_host}/{index_name}-000001'
244
- response = requests.head(url=url, headers=self.elastic_headers, verify=self.verify)
244
+ response = requests.head(url=url, headers=self.elastic_headers, verify=self.verify, timeout=self.timeout)
245
245
  if response.status_code == 200:
246
246
  body = {
247
247
  "settings": {
@@ -249,7 +249,7 @@ class Elastic:
249
249
  "index.lifecycle.rollover_alias": f"{index_name}_rollover"
250
250
  }
251
251
  }
252
- response = requests.put(url=f"{url}/_settings", headers=self.elastic_headers, json=body, verify=self.verify)
252
+ response = requests.put(url=f"{url}/_settings", headers=self.elastic_headers, json=body, verify=self.verify, timeout=self.timeout)
253
253
  if response.status_code == 200:
254
254
  return f'Index {index_name} settings updated'
255
255
  else:
@@ -267,7 +267,7 @@ class Elastic:
267
267
  "index.lifecycle.rollover_alias": f"{index_name}_rollover"
268
268
  }
269
269
  }
270
- response = requests.put(url=url, headers=self.elastic_headers, json=body, verify=self.verify)
270
+ response = requests.put(url=url, headers=self.elastic_headers, json=body, verify=self.verify, timeout=self.timeout)
271
271
  if response.status_code == 200:
272
272
  return f'Index {index_name} created'
273
273
  else:
@@ -309,12 +309,12 @@ class Elastic:
309
309
  }
310
310
  body = json.dumps(body)
311
311
 
312
- response = requests.head(url=url, headers=self.kibana_headers, verify=self.verify)
312
+ response = requests.head(url=url, headers=self.kibana_headers, verify=self.verify, timeout=self.timeout)
313
313
 
314
314
  if response.status_code == 200:
315
315
  return f'Role \'{role_name}\' already exists'
316
316
  else:
317
- response = requests.put(url=url, data=body, headers=self.kibana_headers, verify=self.verify)
317
+ response = requests.put(url=url, data=body, headers=self.kibana_headers, verify=self.verify, timeout=self.timeout)
318
318
  if response.status_code == 204:
319
319
  return f'Role {role_name} created'
320
320
  else:
@@ -332,7 +332,7 @@ class Elastic:
332
332
  if self.disabled:
333
333
  return {}
334
334
 
335
- indices = requests.get(url=f'{self.elasticsearch_host}/_cat/indices?format=json', headers=self.elastic_headers, verify=self.verify).json()
335
+ indices = requests.get(url=f'{self.elasticsearch_host}/_cat/indices?format=json', headers=self.elastic_headers, verify=self.verify, timeout=self.timeout).json()
336
336
  return indices
337
337
 
338
338
  def create_user(self, user_name: str, password: str, user_description: str, roles: list) -> str:
@@ -355,12 +355,12 @@ class Elastic:
355
355
  }
356
356
  body = json.dumps(body)
357
357
 
358
- response = requests.head(url=url, headers=self.elastic_headers, verify=self.verify)
358
+ response = requests.head(url=url, headers=self.elastic_headers, verify=self.verify, timeout=self.timeout)
359
359
 
360
360
  if response.status_code == 200:
361
361
  return f'user {user_name} already exists'
362
362
  else:
363
- response = requests.put(url=url, data=body, headers=self.elastic_headers, verify=self.verify)
363
+ response = requests.put(url=url, data=body, headers=self.elastic_headers, verify=self.verify, timeout=self.timeout)
364
364
  if response.status_code == 200:
365
365
  return f'user {user_name}, with password: {password} has been created'
366
366
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 1.0
2
2
  Name: brynq-sdk-elastic
3
- Version: 3.0.3
3
+ Version: 3.0.4
4
4
  Summary: elastic wrapper from BrynQ
5
5
  Home-page: UNKNOWN
6
6
  Author: BrynQ
@@ -2,7 +2,7 @@ from setuptools import setup, find_namespace_packages
2
2
 
3
3
  setup(
4
4
  name='brynq_sdk_elastic',
5
- version='3.0.3',
5
+ version='3.0.4',
6
6
  description='elastic wrapper from BrynQ',
7
7
  long_description='elastic wrapper from BrynQ',
8
8
  author='BrynQ',