csc-cia-stne 0.1.10__tar.gz → 0.1.12__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.
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/PKG-INFO +1 -1
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/pyproject.toml +1 -1
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/bc_correios.py +22 -16
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/servicenow.py +10 -34
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/__init__.py +5 -1
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/functions/__init__.py +5 -0
- csc_cia_stne-0.1.12/src/csc_cia_stne/utilitarios/functions/func_delete.py +96 -0
- csc_cia_stne-0.1.12/src/csc_cia_stne/utilitarios/functions/func_validate_json.py +49 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/validations/gcp_bucket.py +19 -25
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne.egg-info/PKG-INFO +1 -1
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne.egg-info/SOURCES.txt +2 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/LICENCE +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/README.md +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/README_PYPI.md +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/setup.cfg +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/__init__.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/bc_sta.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/email.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/ftp.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/gcp_bigquery.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/gcp_bucket.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/google_drive.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/karavela.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/logger_json.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/logger_rich.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/provio.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/slack.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/stne_admin.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/functions/func_b64.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/functions/func_converters.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/functions/func_datetime.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/functions/func_get_secret.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/functions/func_recriar_pastas.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/functions/func_settings.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/functions/func_titulo.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/validations/GcpBigQueryValidator.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/validations/GoogleDriveValidator.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/validations/ServiceNowValidator.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/validations/__init__.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/validations/ftp.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/validations/waccess.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/validations/web_validator.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/web_screen/__init__.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/web_screen/web_screen_abstract.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/web_screen/web_screen_botcity.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/web_screen/web_screen_selenium.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/wacess.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/web.py +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne.egg-info/dependency_links.txt +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne.egg-info/requires.txt +0 -0
- {csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne.egg-info/top_level.txt +0 -0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "csc_cia_stne"
|
7
|
-
version = "0.1.
|
7
|
+
version = "0.1.12"
|
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"]
|
@@ -7,7 +7,7 @@ from requests.auth import HTTPBasicAuth
|
|
7
7
|
from datetime import timedelta, datetime, time
|
8
8
|
from typing import List, Tuple, Union, Optional
|
9
9
|
from pydantic import BaseModel
|
10
|
-
|
10
|
+
log = logging.getLogger(__name__)
|
11
11
|
class PastasAutorizadas(BaseModel):
|
12
12
|
MensagemErro: Optional[str] = None
|
13
13
|
OcorreuErro: bool
|
@@ -218,7 +218,7 @@ class BC_Correios:
|
|
218
218
|
break
|
219
219
|
|
220
220
|
for correio in correios:
|
221
|
-
|
221
|
+
|
222
222
|
item_de_lista_de_correios = ItemListaCorreio(
|
223
223
|
Assunto=correio.Assunto,
|
224
224
|
Data=correio.Data,
|
@@ -248,17 +248,18 @@ class BC_Correios:
|
|
248
248
|
|
249
249
|
if len(correios_filtrados) >= proxima_centena:
|
250
250
|
|
251
|
-
|
251
|
+
log.info(f"Página #{pagina_atual}: {len(correios_filtrados)} correios armazenados no total")
|
252
252
|
proxima_centena = proxima_centena + 100
|
253
253
|
|
254
254
|
# Avança para a próxima página
|
255
255
|
pagina_atual += 1
|
256
256
|
|
257
|
-
return True, correios_filtrados
|
258
|
-
|
257
|
+
#return True, correios_filtrados
|
258
|
+
return {"success": True, "data": correios_filtrados, "error": None}
|
259
|
+
|
259
260
|
except Exception as e:
|
260
|
-
|
261
|
-
return False, e
|
261
|
+
|
262
|
+
return {"success": False, "data": None, "error": str(e)}
|
262
263
|
|
263
264
|
def ler_correio(self, numero:int,data_rebimento:datetime,tipo:str,transicao:int,versao:int,pasta:str)-> Tuple[bool, Union[ItemMsgCorreio, Exception]]:
|
264
265
|
"""
|
@@ -425,7 +426,8 @@ class BC_Correios:
|
|
425
426
|
#novo end
|
426
427
|
|
427
428
|
#return True, response
|
428
|
-
return True, msg_detail
|
429
|
+
#return True, msg_detail
|
430
|
+
return {"success": True, "data": msg_detail, "error": None}
|
429
431
|
|
430
432
|
# Serializa o objeto SOAP em um dicionário Python
|
431
433
|
#serialized_response = serialize_object(response)
|
@@ -437,7 +439,8 @@ class BC_Correios:
|
|
437
439
|
|
438
440
|
except Exception as e:
|
439
441
|
|
440
|
-
return False, e
|
442
|
+
#return False, e
|
443
|
+
return {"success": False, "data": None, "error": str(e)}
|
441
444
|
|
442
445
|
def obter_anexo(self, numero:int, versao:int, transicao:int,pasta:str,anexo_id:int,file_name:str,conteudo:str)-> Tuple[bool,Union[dict, Exception]]:
|
443
446
|
"""
|
@@ -504,17 +507,20 @@ class BC_Correios:
|
|
504
507
|
conteudo_anexo = response.Anexo.Conteudo
|
505
508
|
|
506
509
|
# Retorna os dados capturados como um dicionário
|
507
|
-
return True, {
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
}
|
510
|
+
#return True, {
|
511
|
+
# 'IdAnexo': id_anexo,
|
512
|
+
# 'NomeAnexo': nome_anexo,
|
513
|
+
# 'Conteudo': conteudo_anexo
|
514
|
+
#}
|
515
|
+
return {"success": True, "error": None, "data": conteudo_anexo}
|
512
516
|
else:
|
513
|
-
return
|
517
|
+
return {"success": True, "error": "Correio não possui anexo", "data": None}
|
518
|
+
#return False, Exception("Correio não possui anexo")
|
514
519
|
|
515
520
|
except Exception as e:
|
516
521
|
|
517
|
-
return False, e
|
522
|
+
return {"success": False, "error": str(e), "data": None}
|
523
|
+
#return False, e
|
518
524
|
|
519
525
|
def encerrar(self):
|
520
526
|
"""Fecha o cliente e libera a sessão."""
|
@@ -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,
|
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=
|
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
|
-
|
298
|
+
url,
|
312
299
|
auth=self.__auth(),
|
313
300
|
headers=header,
|
314
|
-
|
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
|
-
|
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
|
]
|
{csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/functions/__init__.py
RENAMED
@@ -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
|
+
}
|
{csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/validations/gcp_bucket.py
RENAMED
@@ -1,37 +1,31 @@
|
|
1
|
-
from
|
1
|
+
from __future__ import annotations
|
2
|
+
from pydantic import BaseModel, field_validator, model_validator, ValidationError
|
3
|
+
from typing import Optional, Mapping, Any
|
4
|
+
|
2
5
|
|
3
6
|
class InitParamsValidator(BaseModel):
|
4
7
|
"""
|
5
|
-
|
6
|
-
Valida os parâmetros de inicialização para garantir que pelo menos um dos
|
7
|
-
parâmetros 'creds_dict' ou 'creds_file' seja fornecido.
|
8
|
-
Atributos:
|
9
|
-
creds_dict (dict): Um dicionário contendo as credenciais.
|
10
|
-
creds_file (str): Um caminho para o arquivo contendo as credenciais.
|
11
|
-
Métodos:
|
12
|
-
check_others_input(cls, model):
|
13
|
-
Valida se pelo menos um dos parâmetros 'creds_dict' ou 'creds_file'
|
14
|
-
foi fornecido. Levanta um ValueError caso ambos estejam ausentes ou
|
15
|
-
inválidos.
|
8
|
+
Garante que ao menos um entre `creds_dict` e `creds_file` foi informado.
|
16
9
|
"""
|
17
|
-
|
18
|
-
|
19
|
-
creds_file:str
|
10
|
+
creds_dict: Optional[Mapping[str, Any]] = None
|
11
|
+
creds_file: Optional[str] = None
|
20
12
|
|
21
13
|
@model_validator(mode="after")
|
22
|
-
def check_others_input(
|
23
|
-
|
24
|
-
|
14
|
+
def check_others_input(self):
|
15
|
+
has_dict = isinstance(self.creds_dict, Mapping) and bool(self.creds_dict)
|
16
|
+
has_file = isinstance(self.creds_file, str) and bool(self.creds_file.strip())
|
17
|
+
|
18
|
+
if not (has_dict or has_file):
|
19
|
+
raise ValueError(
|
20
|
+
"Pelo menos um dos parâmetros 'creds_dict' (dict não vazio) "
|
21
|
+
"ou 'creds_file' (caminho/string não vazia) deve ser fornecido."
|
22
|
+
)
|
23
|
+
return self
|
24
|
+
|
25
|
+
|
25
26
|
|
26
|
-
if isinstance(creds_dict, dict):
|
27
|
-
return model
|
28
27
|
|
29
|
-
elif isinstance(creds_file, str) and creds_file.strip():
|
30
|
-
return model
|
31
28
|
|
32
|
-
else:
|
33
|
-
raise ValueError("Pelo menos um dos parâmetros 'creds_dict' ou 'creds_file' deve ser fornecido.")
|
34
|
-
|
35
29
|
class ListFilesValidator(BaseModel):
|
36
30
|
"""
|
37
31
|
Classe ListFilesValidator
|
@@ -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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/functions/func_b64.py
RENAMED
File without changes
|
File without changes
|
{csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/functions/func_datetime.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/functions/func_settings.py
RENAMED
File without changes
|
{csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/functions/func_titulo.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/validations/__init__.py
RENAMED
File without changes
|
File without changes
|
{csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/validations/waccess.py
RENAMED
File without changes
|
File without changes
|
{csc_cia_stne-0.1.10 → csc_cia_stne-0.1.12}/src/csc_cia_stne/utilitarios/web_screen/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|