Updating function docs
This commit is contained in:
parent
82c8a5bb4a
commit
69b520e97c
@ -62,6 +62,7 @@ class fortraEFC:
|
|||||||
|
|
||||||
def pushPayload(self):
|
def pushPayload(self):
|
||||||
fortraEFC.readToken(self)
|
fortraEFC.readToken(self)
|
||||||
|
print(self.tokenData)
|
||||||
try:
|
try:
|
||||||
url = f'{self.platformConfig["efc_url"]}/api/v1/unity/data/{self.platformConfig["tenant_id"]}/machine_event'
|
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"]}'},\
|
pushPayloadResponse = self.r.post(url, headers={'Authorization': f'bearer {self.tokenData["access_token"]}'},\
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
def processData(data, template, **kwargs):
|
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 = []
|
processedData = []
|
||||||
transactionLoginid = []
|
transactionLoginid = []
|
||||||
|
|
||||||
for row in data:
|
for row in data:
|
||||||
# print(f'Row: {row}')
|
# print(f'Row: {row}')
|
||||||
|
if identifyUtype(row.get('Command')) == "other":
|
||||||
|
continue
|
||||||
|
|
||||||
if row.get('Command') == None:
|
if row.get('Command') == None:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
@ -75,6 +80,7 @@ def processData(data, template, **kwargs):
|
|||||||
return processedData
|
return processedData
|
||||||
|
|
||||||
def identifyUserType(obj):
|
def identifyUserType(obj):
|
||||||
|
"""Check string if it has Admin-> return Administrator else return User."""
|
||||||
if obj:
|
if obj:
|
||||||
if "Admin" in obj:
|
if "Admin" in obj:
|
||||||
return "Administrator"
|
return "Administrator"
|
||||||
@ -83,6 +89,8 @@ def identifyUserType(obj):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
def identifyUtype(obj):
|
def identifyUtype(obj):
|
||||||
|
"""Process Type of transaction based on string that passed in.
|
||||||
|
Return transaction type."""
|
||||||
user_logged_on = ['AUTH']
|
user_logged_on = ['AUTH']
|
||||||
file_deleted = ["dele"]
|
file_deleted = ["dele"]
|
||||||
file_uploaded = ["created"]
|
file_uploaded = ["created"]
|
||||||
|
@ -3,6 +3,8 @@ import decimal
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
class Encoder(json.JSONEncoder):
|
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):
|
def default(self, o):
|
||||||
if isinstance(o, decimal.Decimal):
|
if isinstance(o, decimal.Decimal):
|
||||||
return int(o)
|
return int(o)
|
||||||
|
19
test.py
19
test.py
@ -18,4 +18,21 @@ def builddict(keys,*args,**kwargs):
|
|||||||
testfolder = '/Usr/a/asdf/asf'
|
testfolder = '/Usr/a/asdf/asf'
|
||||||
user = 'a'
|
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"
|
Loading…
x
Reference in New Issue
Block a user