algosec-appviz 0.0.13__py3-none-any.whl → 0.1.1__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.
algosec_appviz/main.py CHANGED
@@ -1,3 +1,4 @@
1
+ import json
1
2
  import requests
2
3
  from algosec_appviz import environment
3
4
  from datetime import datetime, timedelta
@@ -86,7 +87,7 @@ class AppViz:
86
87
  raise ValueError("Application revision ID is mandatory")
87
88
 
88
89
  if not tag_list:
89
- print("Nothing to udpate")
90
+ print("Nothing to update")
90
91
 
91
92
  if operation.lower() == 'add':
92
93
  body = {'addLabels': tag_list}
@@ -143,12 +144,59 @@ class AppViz:
143
144
  result = self._make_api_call('DELETE',
144
145
  f'/BusinessFlow/rest/v1/network_objects/{obj_id}')
145
146
 
146
- if result['httpStatusCode'] != 200:
147
+ if not result['success']:
147
148
  print(f"Error deleting object: {result['message']}")
148
149
  return ""
149
150
 
150
151
  return result
151
152
 
153
+ def get_log_entries(self, categories=None, text_filter=None, entity_type='All', start_epoch=None, end_epoch=None):
154
+ if not categories:
155
+ raise ValueError("Categories is a mandatory parameter")
156
+ if not text_filter:
157
+ raise ValueError("text_filter is a mandatory parameter")
158
+ log_entries = []
159
+ page = 1
160
+
161
+ headers = {
162
+ 'Accept': 'application/json',
163
+ 'Authorization': f'{self._token_type} {self._token}'
164
+ }
165
+
166
+ query_json = {
167
+ "categories": categories,
168
+ "sort": {"column": "Date", "direction": "DESC"},
169
+ "freeTextFilters": text_filter
170
+ }
171
+
172
+ if start_epoch:
173
+ query_json["startDate"] = start_epoch
174
+
175
+ if end_epoch:
176
+ query_json["endDate"] = end_epoch
177
+
178
+ while True:
179
+ print(f"Getting AppViz log entries, page {page}...")
180
+ response = requests.get(url=self.url + '/BusinessFlow/rest/v2/activity_logs/search',
181
+ headers=headers,
182
+ params={
183
+ "identifier": 0,
184
+ "page_number": page,
185
+ "type": "All",
186
+ "entityType": entity_type,
187
+ "query": json.dumps(query_json)
188
+ })
189
+
190
+ content = json.loads(response.text)
191
+ log_entries.extend([x for x in content['content']])
192
+
193
+ page = page + 1
194
+
195
+ if page > content['totalPages']:
196
+ break
197
+
198
+ return log_entries
199
+
152
200
  def get_object_by_id(self, obj_id):
153
201
  response = self._make_api_call('GET',
154
202
  f'/BusinessFlow/rest/v1/network_objects/{obj_id}')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: algosec_appviz
3
- Version: 0.0.13
3
+ Version: 0.1.1
4
4
  Summary: AlgoSec AppViz Library
5
5
  License: LICENSE
6
6
  License-File: LICENSE
@@ -0,0 +1,7 @@
1
+ algosec_appviz/__init__.py,sha256=epwLWpezNwfYP0Zuqk32rWEvNeloAKzbrRFi9tzlsXo,46
2
+ algosec_appviz/environment.py,sha256=ycrVSpR6oLpj9p54SvDdy0nqwS9IwHAh-1x-zOaTQ5I,1775
3
+ algosec_appviz/main.py,sha256=T0H4ObHS4x8KfcEL_IouhdZumSdEipiplLVdjLEGSQI,10576
4
+ algosec_appviz-0.1.1.dist-info/METADATA,sha256=YgRgy21uQNu5ms4BtJztCOgah3qnP_jcDjAuFjlxXBc,1765
5
+ algosec_appviz-0.1.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
6
+ algosec_appviz-0.1.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
7
+ algosec_appviz-0.1.1.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- algosec_appviz/__init__.py,sha256=epwLWpezNwfYP0Zuqk32rWEvNeloAKzbrRFi9tzlsXo,46
2
- algosec_appviz/environment.py,sha256=ycrVSpR6oLpj9p54SvDdy0nqwS9IwHAh-1x-zOaTQ5I,1775
3
- algosec_appviz/main.py,sha256=ON-6oXux1ZpDjanNCTwb3Z2gatMNpxfm27pG8Shq7pw,8892
4
- algosec_appviz-0.0.13.dist-info/METADATA,sha256=Iwl54-omswJGvXd6vYsc0PCww_vgfWXrT9Lx3Cl_1SM,1766
5
- algosec_appviz-0.0.13.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
6
- algosec_appviz-0.0.13.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
7
- algosec_appviz-0.0.13.dist-info/RECORD,,