csc-cia-stne 0.1.10__tar.gz → 0.1.11__tar.gz

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.
Files changed (51) hide show
  1. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/PKG-INFO +1 -1
  2. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/pyproject.toml +1 -1
  3. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/servicenow.py +10 -34
  4. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/__init__.py +5 -1
  5. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/functions/__init__.py +5 -0
  6. csc_cia_stne-0.1.11/src/csc_cia_stne/utilitarios/functions/func_delete.py +96 -0
  7. csc_cia_stne-0.1.11/src/csc_cia_stne/utilitarios/functions/func_validate_json.py +49 -0
  8. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne.egg-info/PKG-INFO +1 -1
  9. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne.egg-info/SOURCES.txt +2 -0
  10. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/LICENCE +0 -0
  11. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/README.md +0 -0
  12. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/README_PYPI.md +0 -0
  13. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/setup.cfg +0 -0
  14. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/__init__.py +0 -0
  15. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/bc_correios.py +0 -0
  16. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/bc_sta.py +0 -0
  17. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/email.py +0 -0
  18. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/ftp.py +0 -0
  19. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/gcp_bigquery.py +0 -0
  20. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/gcp_bucket.py +0 -0
  21. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/google_drive.py +0 -0
  22. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/karavela.py +0 -0
  23. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/logger_json.py +0 -0
  24. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/logger_rich.py +0 -0
  25. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/provio.py +0 -0
  26. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/slack.py +0 -0
  27. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/stne_admin.py +0 -0
  28. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/functions/func_b64.py +0 -0
  29. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/functions/func_converters.py +0 -0
  30. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/functions/func_datetime.py +0 -0
  31. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/functions/func_get_secret.py +0 -0
  32. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/functions/func_recriar_pastas.py +0 -0
  33. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/functions/func_settings.py +0 -0
  34. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/functions/func_titulo.py +0 -0
  35. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/validations/GcpBigQueryValidator.py +0 -0
  36. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/validations/GoogleDriveValidator.py +0 -0
  37. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/validations/ServiceNowValidator.py +0 -0
  38. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/validations/__init__.py +0 -0
  39. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/validations/ftp.py +0 -0
  40. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/validations/gcp_bucket.py +0 -0
  41. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/validations/waccess.py +0 -0
  42. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/validations/web_validator.py +0 -0
  43. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/web_screen/__init__.py +0 -0
  44. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/web_screen/web_screen_abstract.py +0 -0
  45. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/web_screen/web_screen_botcity.py +0 -0
  46. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/utilitarios/web_screen/web_screen_selenium.py +0 -0
  47. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/wacess.py +0 -0
  48. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne/web.py +0 -0
  49. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne.egg-info/dependency_links.txt +0 -0
  50. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne.egg-info/requires.txt +0 -0
  51. {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.11}/src/csc_cia_stne.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: csc_cia_stne
3
- Version: 0.1.10
3
+ Version: 0.1.11
4
4
  Summary: Biblioteca do time CSC-CIA utilizada no desenvolvimento de RPAs
5
5
  License: MIT
6
6
  Keywords: karavela,csc,cia,stone,rpa,botcity,stne
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "csc_cia_stne"
7
- version = "0.1.10"
7
+ version = "0.1.11"
8
8
  license = { text = "MIT" }
9
9
  description = "Biblioteca do time CSC-CIA utilizada no desenvolvimento de RPAs"
10
10
  keywords = ["karavela", "csc", "cia", "stone", "rpa", "botcity", "stne"]
@@ -139,7 +139,7 @@ class ServiceNow:
139
139
  logging.debug(f"Erro inesperado: {e}")
140
140
  return {"success": False, "result": None, "error": str(e)}
141
141
 
142
- def __request_download(self, url, params="", timeout=15):
142
+ def __request_download(self, url: str, params: str="", timeout: int=15):
143
143
  """
144
144
  Realiza uma requisição GET para a URL especificada.
145
145
 
@@ -199,7 +199,7 @@ class ServiceNow:
199
199
  logging.debug(f"Erro inesperado: {e}")
200
200
  return {"success": False, "error": str(e), "result": None}
201
201
 
202
- def put(self, url, payload, timeout=15):
202
+ def put(self, url: str, payload: dict, timeout: int = 15):
203
203
  """
204
204
  Realiza uma requisição PUT para a URL especificada.
205
205
 
@@ -251,17 +251,7 @@ class ServiceNow:
251
251
 
252
252
  # POSSUINDO 'RESULT', TEREMOS O RETORNO DO TICKET ABERTO.
253
253
  result = response.json()
254
- if "result" in result:
255
- update = result["result"]
256
- logging.debug(
257
- f"Atualização concluída com sucesso. Registro atualizado: {update['sys_id']} | Alterações: {payload}"
258
- )
259
- return {"success": True, "result": update}
260
- else:
261
- logging.debug(
262
- f"A Resposta da sua requisição não contém o campo 'Result'. Segue o retorno: \n {result} | Alterações: {payload}"
263
- )
264
- return {"success": False, "result": result}
254
+ return {"success": True, "result": result["result"], "error": None} if "result" in result else {"success": False, "result": result, "error": None}
265
255
 
266
256
  # TRATAMENTOS DE ERRO
267
257
  except requests.exceptions.HTTPError as http_err:
@@ -279,7 +269,7 @@ class ServiceNow:
279
269
  return {"success": False, "error": str(e), "result": None}
280
270
 
281
271
  def post(
282
- self, url: str, variables: dict, header_content_type="", timeout: int = 15
272
+ self, url: str, payload: dict, header_content_type="", timeout: int = 15
283
273
  ):
284
274
  """
285
275
  Função para criar um novo ticket no servicenow usando o API REST.
@@ -293,7 +283,7 @@ class ServiceNow:
293
283
 
294
284
  """
295
285
  try:
296
- PostValidator(url=url, variables=variables)
286
+ PostValidator(url=url, variables=payload)
297
287
  except ValidationError as e:
298
288
  raise ValueError(
299
289
  "Erro na validação dos dados de input do método:", e.errors()
@@ -303,15 +293,12 @@ class ServiceNow:
303
293
  header = header_content_type
304
294
  else:
305
295
  header = self.api_header
306
-
307
- # Ajustar o Payload para a abertura do ticket
308
- payload = {"sysparm_quantity": "1", "variables": json.dumps(variables)}
309
296
  try:
310
297
  response = requests.post(
311
- f"{url}",
298
+ url,
312
299
  auth=self.__auth(),
313
300
  headers=header,
314
- data=f"{payload}",
301
+ json=payload,
315
302
  timeout=timeout,
316
303
  )
317
304
 
@@ -320,18 +307,8 @@ class ServiceNow:
320
307
 
321
308
  # POSSUINDO 'RESULT', TEREMOS O RETORNO DO TICKET ABERTO.
322
309
  result = response.json()
323
- if "result" in result:
324
- ticket_number = result["result"].get("number")
325
- ticket_sys_id = result["result"].get("sys_id")
326
- logging.debug(
327
- f"Ticket registrado com sucesso. Número: {ticket_number} | SYS_ID: {ticket_sys_id}"
328
- )
329
- return {"success": True, "result": result["result"]}
330
- else:
331
- logging.debug(
332
- f"A Resposta da sua requisição não contém o campo 'Result'. Segue o retorno: \n {result}"
333
- )
334
- return {"success": False, "result": result}
310
+ return {"success": True, "result": result["result"], "error" : None} if "result" in result else {"success": False, "result": result, "error" : None}
311
+
335
312
 
336
313
  # TRATAMENTOS DE ERRO
337
314
  except requests.exceptions.HTTPError as http_err:
@@ -502,7 +479,7 @@ class ServiceNow:
502
479
  )
503
480
 
504
481
  logging.debug("Arquivo adicionado no ticket")
505
- return {"success": True, "result": response}
482
+ return {"success": True, "result": response.json()}
506
483
 
507
484
  except Exception as e:
508
485
  return {"success": False, "result": None, "error": str(e)}
@@ -617,7 +594,6 @@ class ServiceNow:
617
594
  try:
618
595
  if not os.path.exists(file_path):
619
596
  diretorio = os.path.dirname(file_path)
620
- print(diretorio)
621
597
  os.makedirs(diretorio, exist_ok=True)
622
598
  logging.debug(f"Diretorio criado: {diretorio}")
623
599
  with open(file_path, "wb") as f:
@@ -1,4 +1,5 @@
1
- from .functions import titulo, recriar_pasta, b64encode, b64decode, convert_bquery_result_to_json,get_config, get_secret, now_sp
1
+ from .functions import titulo, recriar_pasta, b64encode, b64decode, convert_bquery_result_to_json,get_config, get_secret, now_sp, validate_json, delete_file, delete_folder
2
+
2
3
  __all__ = [
3
4
  "titulo",
4
5
  "recriar_pasta",
@@ -8,4 +9,7 @@ __all__ = [
8
9
  "get_config",
9
10
  "get_secret",
10
11
  "now_sp",
12
+ "delete_file",
13
+ "delete_folder",
14
+ "validate_json"
11
15
  ]
@@ -5,6 +5,8 @@ from .func_converters import convert_bquery_result_to_json
5
5
  from .func_settings import get_config
6
6
  from .func_get_secret import get_secret
7
7
  from .func_datetime import now_sp
8
+ from .func_delete import delete_file, delete_folder
9
+ from .func_validate_json import validate_json
8
10
 
9
11
  __all__ = [
10
12
  "titulo",
@@ -15,4 +17,7 @@ __all__ = [
15
17
  "get_config",
16
18
  "get_secret",
17
19
  "now_sp",
20
+ "delete_file",
21
+ "delete_folder",
22
+ "validate_json"
18
23
  ]
@@ -0,0 +1,96 @@
1
+ import os
2
+ import shutil
3
+
4
+
5
+ def delete_file(filename:str) -> bool:
6
+ """
7
+ Exclui um arquivo no diretório atual com o nome especificado.
8
+ Parâmetros:
9
+ filename (str): O nome do arquivo a ser excluído.
10
+ Retorna:
11
+ dict: Um dicionário indicando o sucesso da operação.
12
+ - Se bem-sucedido: {"success": True}
13
+ - Se falhar: {"success": False, "error": <mensagem de erro>}
14
+ Possíveis mensagens de erro incluem:
15
+ - "Permissão negada."
16
+ - "Arquivo não encontrado."
17
+ - Mensagem de exceção genérica.
18
+ """
19
+
20
+ filepath = os.path.join(os.getcwd(), filename)
21
+
22
+ if os.path.exists(filepath):
23
+
24
+ try:
25
+ os.remove(filepath)
26
+
27
+ return {
28
+ "success": True,
29
+ }
30
+
31
+ except PermissionError as e:
32
+
33
+ return {
34
+ "success": False,
35
+ "error": "Permissão negada.",
36
+ }
37
+
38
+ except Exception as e:
39
+
40
+ return {
41
+ "success": False,
42
+ "error": str(e),
43
+ }
44
+
45
+ else:
46
+
47
+ return {
48
+ "success": False,
49
+ "error": "Arquivo não encontrado."
50
+ }
51
+
52
+ def delete_folder(foldername:str):
53
+ """
54
+ Exclui uma pasta especificada pelo nome.
55
+ Parâmetros:
56
+ foldername (str): O nome da pasta a ser excluída.
57
+ Retorna:
58
+ dict: Um dicionário indicando se a exclusão foi bem-sucedida.
59
+ - Se bem-sucedido: {"success": True}
60
+ - Se a pasta não for encontrada: {"success": False, "error": "Pasta não encontrada."}
61
+ - Se houver permissão negada: {"success": False, "error": "Permissão negada."}
62
+ - Para outros erros: {"success": False, "error": <mensagem do erro>}
63
+ """
64
+
65
+ filepath = os.path.join(os.getcwd(), foldername)
66
+
67
+ if os.path.exists(filepath):
68
+
69
+ try:
70
+
71
+ shutil.rmtree(filepath)
72
+
73
+ return {
74
+ "success": True
75
+ }
76
+
77
+ except PermissionError as e:
78
+
79
+ return {
80
+ "success": False,
81
+ "error": "Permissão negada.",
82
+ }
83
+
84
+ except Exception as e:
85
+
86
+ return {
87
+ "success": False,
88
+ "error": str(e),
89
+ }
90
+
91
+ else:
92
+
93
+ return {
94
+ "success": False,
95
+ "error": "Pasta não encontrada."
96
+ }
@@ -0,0 +1,49 @@
1
+ import json
2
+
3
+
4
+ def validate_json(token):
5
+ """
6
+ Valida e converte uma string JSON em um objeto Python (dict ou list).
7
+ Parâmetros:
8
+ token (str, dict ou list): O JSON a ser validado, podendo ser uma string ou já um objeto Python.
9
+ Retorna:
10
+ dict: Um dicionário contendo:
11
+ - "success" (bool): Indica se a validação/conversão foi bem-sucedida.
12
+ - "data" (dict ou list, opcional): O objeto Python resultante, presente se o sucesso for True.
13
+ - "error" (Exception, opcional): A exceção capturada, presente se o sucesso for False.
14
+ Exemplo:
15
+ >>> validate_json('{"chave": "valor"}')
16
+ {'success': True, 'data': {'chave': 'valor'}}
17
+ """
18
+
19
+ if not isinstance(token,dict) and not isinstance(token,list):
20
+
21
+ try:
22
+
23
+ token = json.loads(token)
24
+
25
+ return {
26
+ "success":True,
27
+ "data":token
28
+ }
29
+
30
+ except json.JSONDecodeError as e:
31
+
32
+ return {
33
+ "success":False,
34
+ "error":e
35
+ }
36
+
37
+ except Exception as e:
38
+
39
+ return {
40
+ "success":False,
41
+ "error":e
42
+ }
43
+
44
+ else:
45
+
46
+ return {
47
+ "success":True,
48
+ "data":token
49
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: csc_cia_stne
3
- Version: 0.1.10
3
+ Version: 0.1.11
4
4
  Summary: Biblioteca do time CSC-CIA utilizada no desenvolvimento de RPAs
5
5
  License: MIT
6
6
  Keywords: karavela,csc,cia,stone,rpa,botcity,stne
@@ -29,10 +29,12 @@ src/csc_cia_stne/utilitarios/functions/__init__.py
29
29
  src/csc_cia_stne/utilitarios/functions/func_b64.py
30
30
  src/csc_cia_stne/utilitarios/functions/func_converters.py
31
31
  src/csc_cia_stne/utilitarios/functions/func_datetime.py
32
+ src/csc_cia_stne/utilitarios/functions/func_delete.py
32
33
  src/csc_cia_stne/utilitarios/functions/func_get_secret.py
33
34
  src/csc_cia_stne/utilitarios/functions/func_recriar_pastas.py
34
35
  src/csc_cia_stne/utilitarios/functions/func_settings.py
35
36
  src/csc_cia_stne/utilitarios/functions/func_titulo.py
37
+ src/csc_cia_stne/utilitarios/functions/func_validate_json.py
36
38
  src/csc_cia_stne/utilitarios/validations/GcpBigQueryValidator.py
37
39
  src/csc_cia_stne/utilitarios/validations/GoogleDriveValidator.py
38
40
  src/csc_cia_stne/utilitarios/validations/ServiceNowValidator.py
File without changes
File without changes
File without changes