opsrampcli 1.9.0__tar.gz → 1.11.0__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.
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/PKG-INFO +1 -1
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/opsrampenv.py +28 -18
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/resources.py +1 -1
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/pyproject.toml +1 -1
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/README.md +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/DataSource.py +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/JSONDataSource.py +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/ServiceNowDataSource.py +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/URLDataSource.py +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/__init.py__ +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/alerts.py +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/argparsing.py +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/customattrs.py +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/discovery.py +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/escalationpolicies.py +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/incidents.py +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/integrations.py +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/monitoring.py +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/opsrampcli.py +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/servicemaps.py +0 -0
- {opsrampcli-1.9.0 → opsrampcli-1.11.0}/opsrampcli/test.py +0 -0
|
@@ -256,24 +256,33 @@ class OpsRampEnv:
|
|
|
256
256
|
params['pageSize'] = page_size
|
|
257
257
|
params['pageNo'] = page_no
|
|
258
258
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
259
|
+
max_retries = 20
|
|
260
|
+
sleep_interval = 5
|
|
261
|
+
attempt = 0
|
|
262
262
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
263
|
+
for attempt in range(max_retries):
|
|
264
|
+
try:
|
|
265
|
+
response = requests.request("GET", url, headers=headers, params=params, verify=self.isSecure)
|
|
266
|
+
logger.debug(f'OpsRampEnv.get_with_pagination GET response - response:{response} response.text:{response.text} response.headers:{response.headers}')
|
|
267
|
+
|
|
268
|
+
if 'x-ratelimit-remaining' in response.headers and int(response.headers['x-ratelimit-remaining']) < 2 :
|
|
269
|
+
sleeptime = abs(int(response.headers['x-ratelimit-reset']) - int(datetime.now().timestamp()) + 3)
|
|
270
|
+
if sleeptime > 60:
|
|
271
|
+
sleeptime = sleeptime % 60
|
|
272
|
+
logger.warning(f'Sleeping for {str(sleeptime)} sec to wait for API throttling limit to reset..')
|
|
273
|
+
time.sleep(sleeptime)
|
|
274
|
+
bodydict = response.json()
|
|
275
|
+
results = []
|
|
276
|
+
if result_array_key in bodydict:
|
|
277
|
+
results = bodydict[result_array_key]
|
|
278
|
+
if 'nextPage' in bodydict and bodydict['nextPage']:
|
|
279
|
+
return results + self.get_with_pagination(path=path, result_array_key=result_array_key, params=params, page_no=page_no+1, page_size=page_size)
|
|
280
|
+
else:
|
|
281
|
+
return results
|
|
282
|
+
except Exception as exc:
|
|
283
|
+
logger.warning(f'OpsRampEnv.get_with_pagination Exception on attempt {attempt + 1}. Retry in {sleep_interval} sec...', exc_info=exc)
|
|
284
|
+
time.sleep(sleep_interval)
|
|
285
|
+
attempt = attempt + 1
|
|
277
286
|
|
|
278
287
|
def get_without_pagination(self, path:str):
|
|
279
288
|
logger.debug(f'OpsRampEnv.get_without_pagination called - path:{path}')
|
|
@@ -351,7 +360,8 @@ class OpsRampEnv:
|
|
|
351
360
|
results = []
|
|
352
361
|
if 'results' in bodydict:
|
|
353
362
|
results = bodydict['results']
|
|
354
|
-
|
|
363
|
+
logger.info(f'Got {len(results)} records for page {page_no}.')
|
|
364
|
+
if len(results) > 0:
|
|
355
365
|
results = results + self.do_opsql_query(object_type, fields, filter_criteria, aggregate, group_by, sort_by, page_no+1, page_size)
|
|
356
366
|
return results
|
|
357
367
|
|
|
@@ -518,7 +518,7 @@ async def import_resources_from_dataframe(ops:OpsRampEnv, args, df:pd.DataFrame,
|
|
|
518
518
|
opsql['sortBy'] = "name"
|
|
519
519
|
|
|
520
520
|
logger.info(f'Using opsql resource search, opsql filter is \'{opsql["filter"]}\'')
|
|
521
|
-
resources =
|
|
521
|
+
resources = ops.do_opsql_query('resource',opsql['fields'], opsql['filter'],page_size=opsql['pageSize'], sort_by=opsql['sortBy'])
|
|
522
522
|
else:
|
|
523
523
|
old_query_type = True
|
|
524
524
|
queryString = None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|