csc-cia-stne 0.1.8__py3-none-any.whl → 0.1.10__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.
- csc_cia_stne/email.py +7 -5
- csc_cia_stne/servicenow.py +57 -0
- {csc_cia_stne-0.1.8.dist-info → csc_cia_stne-0.1.10.dist-info}/METADATA +1 -1
- {csc_cia_stne-0.1.8.dist-info → csc_cia_stne-0.1.10.dist-info}/RECORD +7 -7
- {csc_cia_stne-0.1.8.dist-info → csc_cia_stne-0.1.10.dist-info}/WHEEL +0 -0
- {csc_cia_stne-0.1.8.dist-info → csc_cia_stne-0.1.10.dist-info}/licenses/LICENCE +0 -0
- {csc_cia_stne-0.1.8.dist-info → csc_cia_stne-0.1.10.dist-info}/top_level.txt +0 -0
csc_cia_stne/email.py
CHANGED
@@ -150,7 +150,7 @@ class Email():
|
|
150
150
|
}
|
151
151
|
|
152
152
|
|
153
|
-
def send_email( self, to : list , message : str , title : str , reply_to: str, attachments : list = [] , cc : list = [] , cco : list = [], from_mask: str = "" ) -> dict:
|
153
|
+
def send_email( self, to : list , message : str , title : str , reply_to: str, attachments : list = [] , cc : list = [] , cco : list = [], from_mask: str = "", block_by_attachments:bool=False) -> dict:
|
154
154
|
"""
|
155
155
|
Envia um email com os parâmetros fornecidos.
|
156
156
|
Args:
|
@@ -227,10 +227,12 @@ class Email():
|
|
227
227
|
|
228
228
|
except Exception as e:
|
229
229
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
230
|
+
if block_by_attachments:
|
231
|
+
|
232
|
+
return {
|
233
|
+
'status':False,
|
234
|
+
'error':str(e)
|
235
|
+
}
|
234
236
|
|
235
237
|
msg.attach(MIMEText(message, 'html'))
|
236
238
|
|
csc_cia_stne/servicenow.py
CHANGED
@@ -807,3 +807,60 @@ class ServiceNow:
|
|
807
807
|
except Exception as e:
|
808
808
|
logging.debug("Erro ao obter anexos.")
|
809
809
|
return {"success": False, "error": str(e)}
|
810
|
+
|
811
|
+
def criar_task(self, payload: dict, header_content_type: dict = None, timeout: int = 15):
|
812
|
+
"""
|
813
|
+
Cria uma nova task no ServiceNow utilizando os dados fornecidos no payload.
|
814
|
+
Args:
|
815
|
+
payload (dict): Dicionário contendo os dados necessários para criação da task.
|
816
|
+
header_content_type (dict, opcional): Cabeçalho HTTP personalizado para a requisição. Se não informado, utiliza o cabeçalho padrão da instância.
|
817
|
+
timeout (int, opcional): Tempo limite (em segundos) para a requisição HTTP. Padrão é 15 segundos.
|
818
|
+
Returns:
|
819
|
+
dict: Dicionário contendo o resultado da operação.
|
820
|
+
- Se sucesso: {"success": True, "result": <dados da task criada>}
|
821
|
+
- Se falha: {"success": False, "error": <mensagem de erro>, "result": None}
|
822
|
+
Raises:
|
823
|
+
TypeError: Se o payload não for um dicionário.
|
824
|
+
Observações:
|
825
|
+
- Realiza tratamento de erros HTTP, de requisição e erros inesperados, registrando logs para depuração.
|
826
|
+
"""
|
827
|
+
if not isinstance(payload, dict):
|
828
|
+
raise TypeError("Payload deve ser um dicionário.")
|
829
|
+
if not isinstance(timeout, int):
|
830
|
+
raise TypeError("Timeout deve ser um inteiro.")
|
831
|
+
|
832
|
+
if header_content_type:
|
833
|
+
header = header_content_type
|
834
|
+
else:
|
835
|
+
header = self.api_header
|
836
|
+
data = json.dumps(payload)
|
837
|
+
url = f"{self.api_url}/now/table/sc_task"
|
838
|
+
try:
|
839
|
+
response = requests.post(
|
840
|
+
f"{url}",
|
841
|
+
auth=self.__auth(),
|
842
|
+
headers=header,
|
843
|
+
data=data,
|
844
|
+
timeout=timeout,
|
845
|
+
)
|
846
|
+
response.raise_for_status()
|
847
|
+
|
848
|
+
result = response.json()
|
849
|
+
|
850
|
+
return {"success": True, "result": result["result"]} if "result" in result else {"success": False, "result": result}
|
851
|
+
|
852
|
+
# TRATAMENTOS DE ERRO
|
853
|
+
except requests.exceptions.HTTPError as http_err:
|
854
|
+
|
855
|
+
logging.debug(
|
856
|
+
f"Erro HTTP ao tentar registrar o ticket: {http_err} \n Reposta da solicitação: {response.json().get('error').get('message')}"
|
857
|
+
)
|
858
|
+
return {"success": False, "error": str(http_err), "result": None}
|
859
|
+
|
860
|
+
except requests.exceptions.RequestException as req_err:
|
861
|
+
logging.debug(f"Erro ao tentar registrar o ticket: \n {req_err}")
|
862
|
+
return {"success": False, "error": str(req_err), "result": None}
|
863
|
+
|
864
|
+
except Exception as e:
|
865
|
+
logging.debug(f"Erro inesperado: \n {e}")
|
866
|
+
return {"success": False, "error": str(e), "result": None}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
csc_cia_stne/__init__.py,sha256=jwLhGpOwFCow_6cqzwLn31WcIrMzutMZtEQpLL4bQtM,2638
|
2
2
|
csc_cia_stne/bc_correios.py,sha256=pQAnRrcXEMrx3N1MWydZVIhEQLerh3x8-0B045zZIzk,24174
|
3
3
|
csc_cia_stne/bc_sta.py,sha256=sE-aU-ZVSAqryQrT1-nor9eAFM5npNAKF1QSm-ChhGU,28945
|
4
|
-
csc_cia_stne/email.py,sha256=
|
4
|
+
csc_cia_stne/email.py,sha256=y4xyPAe6_Mga5Wf6qAsDzYgn0f-zf2KshfItlWe58z8,8481
|
5
5
|
csc_cia_stne/ftp.py,sha256=M9WCaq2hm56jGyszNaPinliFaZS0BNrT7VrVPMjkMg4,10988
|
6
6
|
csc_cia_stne/gcp_bigquery.py,sha256=foq8azvvv_f7uikMDslX9RcUIrx7RAS-Sn0AGW0QFQc,7231
|
7
7
|
csc_cia_stne/gcp_bucket.py,sha256=nP77BtagZ7jQq6lS88ZEa1qshzBza6e_LvhgS3_JJJk,10268
|
@@ -10,7 +10,7 @@ csc_cia_stne/karavela.py,sha256=jJCYX43D49gGuzmwwK6bN9XVnv2dXdp9iHnnV5H1LMQ,4794
|
|
10
10
|
csc_cia_stne/logger_json.py,sha256=CXxSCOFGMymDi8XE9SKnPKjW4D0wJLqDLnxqePS26i8,3187
|
11
11
|
csc_cia_stne/logger_rich.py,sha256=fklgkBb4rblKQd7YZ3q-eWfhGg9eflO2k2-z4pGh_yo,5201
|
12
12
|
csc_cia_stne/provio.py,sha256=G-pDnHYLSp97joc7S7dvwjNvl3omnTmvdi3rOPQf5GA,3987
|
13
|
-
csc_cia_stne/servicenow.py,sha256=
|
13
|
+
csc_cia_stne/servicenow.py,sha256=QNiK5yyz5Pr8xYvgr0AsDQvlJH0UlPBpWLnfiVVPAHc,36379
|
14
14
|
csc_cia_stne/slack.py,sha256=sPLeaQh_JewLcrBDjjwUgbjtC7d1Np03OTy06JimMV4,8117
|
15
15
|
csc_cia_stne/stne_admin.py,sha256=4v_BVQAwZeWmxvjDOkwFAl9yIxJ3r54BY7pRgAgSXEM,24220
|
16
16
|
csc_cia_stne/wacess.py,sha256=g-bWZNpm_tU7UsW1G_rqh_2fW2KShvxZHGOerX8DuQw,26768
|
@@ -36,8 +36,8 @@ csc_cia_stne/utilitarios/web_screen/__init__.py,sha256=5QcOPXKd95SvP2DoZiHS0gaU6
|
|
36
36
|
csc_cia_stne/utilitarios/web_screen/web_screen_abstract.py,sha256=PjL8Vgfj_JdKidia7RFyCkro3avYLQu4RZRos41sh3w,3241
|
37
37
|
csc_cia_stne/utilitarios/web_screen/web_screen_botcity.py,sha256=Xi5YJjl2pcxlX3OimqcBWRNXZEpAE7asyUjDJ4Oho5U,12297
|
38
38
|
csc_cia_stne/utilitarios/web_screen/web_screen_selenium.py,sha256=JLIcPJE9ZX3Pd6zG6oTRMqqUAY063UzLY3ReRlxmiSM,15581
|
39
|
-
csc_cia_stne-0.1.
|
40
|
-
csc_cia_stne-0.1.
|
41
|
-
csc_cia_stne-0.1.
|
42
|
-
csc_cia_stne-0.1.
|
43
|
-
csc_cia_stne-0.1.
|
39
|
+
csc_cia_stne-0.1.10.dist-info/licenses/LICENCE,sha256=LPGMtgKki2C3KEZP7hDhA1HBrlq5JCHkIeStUCLEMx4,1073
|
40
|
+
csc_cia_stne-0.1.10.dist-info/METADATA,sha256=UtlOaLEo2hxXI6rlOZ3NHr0TAotyIEz5tL0oW7mPFH4,1464
|
41
|
+
csc_cia_stne-0.1.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
42
|
+
csc_cia_stne-0.1.10.dist-info/top_level.txt,sha256=ldo7GVv3tQx5KJvwBzdZzzQmjPys2NDVVn1rv0BOF2Q,13
|
43
|
+
csc_cia_stne-0.1.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|