Updating function docs

This commit is contained in:
Jonathan Branan 2024-08-15 13:23:25 -05:00
parent 82c8a5bb4a
commit 69b520e97c
4 changed files with 30 additions and 2 deletions

View File

@ -62,6 +62,7 @@ class fortraEFC:
def pushPayload(self):
fortraEFC.readToken(self)
print(self.tokenData)
try:
url = f'{self.platformConfig["efc_url"]}/api/v1/unity/data/{self.platformConfig["tenant_id"]}/machine_event'
pushPayloadResponse = self.r.post(url, headers={'Authorization': f'bearer {self.tokenData["access_token"]}'},\

View File

@ -1,10 +1,15 @@
def processData(data, template, **kwargs):
"""Translates data from sql query to the appropriate place in the respective template.
Accepts data, which is the sql query output, the template function, and finally
additional data to insert into the template."""
processedData = []
transactionLoginid = []
for row in data:
# print(f'Row: {row}')
if identifyUtype(row.get('Command')) == "other":
continue
if row.get('Command') == None:
continue
try:
@ -75,6 +80,7 @@ def processData(data, template, **kwargs):
return processedData
def identifyUserType(obj):
"""Check string if it has Admin-> return Administrator else return User."""
if obj:
if "Admin" in obj:
return "Administrator"
@ -83,6 +89,8 @@ def identifyUserType(obj):
else:
return None
def identifyUtype(obj):
"""Process Type of transaction based on string that passed in.
Return transaction type."""
user_logged_on = ['AUTH']
file_deleted = ["dele"]
file_uploaded = ["created"]

View File

@ -3,6 +3,8 @@ import decimal
import datetime
class Encoder(json.JSONEncoder):
"""Encoder uses json.JSONEncoder and checks for instances of decimal and datetime.
Changes decimal.Decimal to int and datetime.datetime to unix timestamp with miliseconds."""
def default(self, o):
if isinstance(o, decimal.Decimal):
return int(o)

19
test.py
View File

@ -18,4 +18,21 @@ def builddict(keys,*args,**kwargs):
testfolder = '/Usr/a/asdf/asf'
user = 'a'
print(testfolder.split(f"/{user}/"))
def identifyUtype(obj):
"""Process Type of transaction based on string that passed in.
Return transaction type."""
user_logged_on = ['AUTH']
file_deleted = ["dele"]
file_uploaded = ["created"]
file_downloaded = ["sent"]
if obj in user_logged_on:
return "user_logged_on"
if obj in file_deleted:
return "file_deleted"
if obj in file_uploaded:
return "file_uploaded"
if obj in file_downloaded:
return "file_downloaded"
else:
return "other"