@@ -6505,6 +6505,70 @@ def execute_bigquery_query(data_set):
65056505 except :
65066506 return CommonUtil .Exception_Handler (sys .exc_info ())
65076507
6508+ @logger
6509+ def connect_to_google_service_account (data_set ):
6510+ """
6511+ data_set:
6512+ credentials path | input parameter | path to credentails json file
6513+ connect to google service client | common action | client variable name
6514+ """
6515+
6516+ sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
6517+ CommonUtil .ExecLog (sModuleInfo , "Actions involving the Google service account may not function correctly without a virtual environment." , 2 )
6518+ cred_path = None
6519+ client_var_name = None
6520+ for left , _ , right in data_set :
6521+ if left .strip ().lower () == 'credentials path' :
6522+ cred_path = right .strip ()
6523+ if left .strip ().lower () == 'connect to google service client' :
6524+ client_var_name = right .strip ()
6525+
6526+ try :
6527+ from google .cloud import storage
6528+ client = storage .Client .from_service_account_json (json_credentials_path = cred_path )
6529+ sr .Set_Shared_Variables (client_var_name , client )
6530+ return "passed"
6531+ except :
6532+ CommonUtil .ExecLog (sModuleInfo , "Incorrect Credentails" , 3 )
6533+ return "zeuz_failed"
6534+
6535+ @logger
6536+ def upload_to_google_storage_bucket (data_set ):
6537+ """
6538+ data_set:
6539+ filepath | input parameter | filepath
6540+ bucket | input parameter | bucket name
6541+ upload to google storage bucket | common action | client variable name
6542+ """
6543+
6544+ sModuleInfo = inspect .currentframe ().f_code .co_name + " : " + MODULE_NAME
6545+ CommonUtil .ExecLog (sModuleInfo , "Actions involving the Google service account may not function correctly without a virtual environment." , 2 )
6546+ filepath = None
6547+ client_var_name = None
6548+ bucket = None
6549+
6550+ for left , _ , right in data_set :
6551+ if left .strip ().lower () == 'filepath' :
6552+ filepath = right .strip ()
6553+ if left .strip ().lower () == 'upload to google storage bucket' :
6554+ client_var_name = right .strip ()
6555+ if left .strip ().lower () == 'bucket' :
6556+ bucket = right .strip ()
6557+
6558+ if None in (filepath ,client_var_name ,bucket ):
6559+ CommonUtil .ExecLog (sModuleInfo , "Incorrect Dataset" , 3 )
6560+ return "zeuz_failed"
6561+
6562+ try :
6563+ client = sr .Get_Shared_Variables (client_var_name )
6564+ bucket = client .get_bucket (bucket )
6565+ blob = bucket .blob (os .path .basename (filepath ))
6566+ blob .upload_from_filename (filepath )
6567+ CommonUtil .ExecLog (sModuleInfo , f'File { filepath } uploaded to { bucket } .' )
6568+ return "passed"
6569+ except :
6570+ return CommonUtil .Exception_Handler (sys .exc_info ())
6571+
65086572@logger
65096573def text_to_speech (data_set ):
65106574 """
0 commit comments