csc-cia-stne 0.0.38__py3-none-any.whl → 0.0.40__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/__init__.py +5 -1
- csc_cia_stne/google_drive.py +50 -47
- csc_cia_stne/servicenow.py +1 -2
- csc_cia_stne/slack.py +227 -0
- csc_cia_stne/utilitarios/validations/GoogleDriveValidator.py +30 -5
- {csc_cia_stne-0.0.38.dist-info → csc_cia_stne-0.0.40.dist-info}/METADATA +4 -1
- {csc_cia_stne-0.0.38.dist-info → csc_cia_stne-0.0.40.dist-info}/RECORD +10 -9
- {csc_cia_stne-0.0.38.dist-info → csc_cia_stne-0.0.40.dist-info}/WHEEL +1 -1
- {csc_cia_stne-0.0.38.dist-info → csc_cia_stne-0.0.40.dist-info}/LICENCE +0 -0
- {csc_cia_stne-0.0.38.dist-info → csc_cia_stne-0.0.40.dist-info}/top_level.txt +0 -0
csc_cia_stne/__init__.py
CHANGED
@@ -10,6 +10,8 @@ from .bc_correios import BC_Correios
|
|
10
10
|
from .gcp_bigquery import BigQuery
|
11
11
|
from .email import Email
|
12
12
|
from .provio import Provio
|
13
|
+
from .google_drive import GoogleDrive
|
14
|
+
from .slack import Slack
|
13
15
|
|
14
16
|
# Define os itens disponíveis para importação
|
15
17
|
__all__ = [
|
@@ -22,7 +24,9 @@ __all__ = [
|
|
22
24
|
"Util",
|
23
25
|
"logger",
|
24
26
|
"Provio",
|
25
|
-
"Email"
|
27
|
+
"Email",
|
28
|
+
"GoogleDrive",
|
29
|
+
"Slack"
|
26
30
|
]
|
27
31
|
|
28
32
|
_diretorio_inicial = os.getcwd()
|
csc_cia_stne/google_drive.py
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
-
import os,
|
2
|
-
from .karavela import Karavela
|
1
|
+
import os, logging
|
3
2
|
from googleapiclient.discovery import build
|
4
3
|
from googleapiclient.http import MediaFileUpload
|
5
4
|
from googleapiclient.errors import HttpError
|
6
5
|
from io import BytesIO
|
7
|
-
from googleapiclient.discovery import build
|
8
6
|
from google.oauth2 import service_account
|
9
|
-
from .utilitarios.validations.GoogleDriveValidator import InitParamsValidator, CreateFolderValidator, ListFolderValidator
|
7
|
+
from .utilitarios.validations.GoogleDriveValidator import InitParamsValidator, CreateFolderValidator, ListFolderValidator, UploadValidator
|
10
8
|
from pydantic import ValidationError
|
11
9
|
|
12
10
|
|
13
|
-
|
14
11
|
class GoogleDrive():
|
15
12
|
|
16
13
|
"""
|
@@ -20,8 +17,16 @@ class GoogleDrive():
|
|
20
17
|
Args:
|
21
18
|
key (str): Chave de autenticação para acessar a API do Google Drive.
|
22
19
|
"""
|
20
|
+
_instance = None # Atributo de classe para armazenar a única instância.
|
21
|
+
|
22
|
+
def __new__(cls, *args, **kwargs):
|
23
|
+
# Verifica se já existe uma instância da classe.
|
24
|
+
if cls._instance is None:
|
25
|
+
# Cria e armazena a instância na primeira chamada.
|
26
|
+
cls._instance = super().__new__(cls)
|
27
|
+
return cls._instance
|
23
28
|
|
24
|
-
def __init__(self,
|
29
|
+
def __init__(self, token : dict, with_subject : str, scopes : list = ["https://www.googleapis.com/auth/drive"], version : str = "v3"):
|
25
30
|
"""
|
26
31
|
Inicializa uma instância da classe GoogleDrive.
|
27
32
|
Parâmetros:
|
@@ -36,43 +41,20 @@ class GoogleDrive():
|
|
36
41
|
google_drive = GoogleDrive(key="chave_secreta", with_subject="assunto", scopes=["https://www.googleapis.com/auth/drive"], version="v3")
|
37
42
|
```
|
38
43
|
"""
|
39
|
-
# código de inicialização da instância
|
40
44
|
|
41
45
|
try:
|
42
|
-
InitParamsValidator(
|
46
|
+
InitParamsValidator(token=token, with_subject=with_subject, scopes=scopes, version=version)
|
43
47
|
except ValidationError as e:
|
44
48
|
raise ValueError("Erro na validação dos dados de input da inicialização da instância:", e.errors())
|
45
|
-
|
46
|
-
self.__token = json.loads(Karavela.get_secret(key))
|
49
|
+
self.__token = token
|
47
50
|
self.version = version
|
48
51
|
self.scopes = scopes
|
49
|
-
self.
|
52
|
+
self.with_subject = with_subject
|
50
53
|
self.page_size = 1000
|
51
|
-
self.service = self.
|
54
|
+
self.service = self.__create_service()
|
52
55
|
|
53
|
-
|
54
|
-
|
55
|
-
Decorator que calcula o tempo de execução de uma função.
|
56
|
-
Args:
|
57
|
-
func: A função a ser decorada.
|
58
|
-
Returns:
|
59
|
-
A função decorada.
|
60
|
-
Exemplo de uso:
|
61
|
-
@timer_decorator
|
62
|
-
def minha_funcao():
|
63
|
-
# código da função
|
64
|
-
minha_funcao()
|
65
|
-
"""
|
66
|
-
|
67
|
-
def wrapper(*args, **kwargs):
|
68
|
-
inicio = time.time()
|
69
|
-
resultado = func(*args, **kwargs)
|
70
|
-
fim = time.time()
|
71
|
-
logging.debug(f"Tempo de execução de {func.__name__}: {fim - inicio:.2f} segundos")
|
72
|
-
return resultado
|
73
|
-
return wrapper
|
74
|
-
|
75
|
-
def create_service(self):
|
56
|
+
|
57
|
+
def __create_service(self):
|
76
58
|
"""
|
77
59
|
Cria um serviço do Google Drive.
|
78
60
|
Returns:
|
@@ -89,14 +71,15 @@ class GoogleDrive():
|
|
89
71
|
"""
|
90
72
|
|
91
73
|
try:
|
92
|
-
|
93
|
-
|
94
|
-
logging.
|
95
|
-
return
|
74
|
+
auth = self.__autentica(self.with_subject)
|
75
|
+
service = build(f"drive", f"{self.version}", credentials=auth)
|
76
|
+
logging.info(f"Serviço do Google drive criado")
|
77
|
+
return service
|
96
78
|
except Exception as e:
|
97
|
-
logging.
|
79
|
+
logging.info(f"Erro ao criar o serviço do Google drive: Error: {e}")
|
98
80
|
return False
|
99
|
-
|
81
|
+
|
82
|
+
|
100
83
|
def __autentica(self, with_subject : str):
|
101
84
|
"""
|
102
85
|
Autentica o usuário com as credenciais fornecidas e retorna as credenciais delegadas para o assunto especificado.
|
@@ -121,7 +104,7 @@ class GoogleDrive():
|
|
121
104
|
logging.debug(f"Erro ao tentar autenticar. Verifique o erro: {e}")
|
122
105
|
return False
|
123
106
|
|
124
|
-
|
107
|
+
|
125
108
|
def upload(self, folder_id: str, name: str, file_path: str, mimetype: str):
|
126
109
|
"""
|
127
110
|
Faz o upload de um arquivo para o Google Drive em uma pasta especificada.
|
@@ -131,11 +114,27 @@ class GoogleDrive():
|
|
131
114
|
name (str): Nome do arquivo que será carregado.
|
132
115
|
file_path (str): Caminho completo do arquivo no sistema local.
|
133
116
|
mimetype (str): Tipo MIME do arquivo a ser carregado.
|
117
|
+
exemplos: text/plain
|
118
|
+
text/html
|
119
|
+
image/jpeg
|
120
|
+
image/png
|
121
|
+
audio/mpeg
|
122
|
+
audio/ogg
|
123
|
+
audio/*
|
124
|
+
video/mp4
|
125
|
+
application/octet-stream
|
134
126
|
|
135
127
|
Returns:
|
136
128
|
dict: Informações sobre o arquivo carregado, incluindo o ID do arquivo.
|
137
129
|
None: Caso o caminho do arquivo não seja encontrado.
|
138
130
|
"""
|
131
|
+
try:
|
132
|
+
UploadValidator(folder_id=folder_id, name=name, file_path=file_path, mimetype=mimetype)
|
133
|
+
except ValidationError as e:
|
134
|
+
raise ValueError("Erro na validação dos dados para realizar o upload do arquivo", e.errors())
|
135
|
+
|
136
|
+
|
137
|
+
|
139
138
|
file_metadata = {"name": name, "parents": [folder_id]}
|
140
139
|
if not os.path.exists(file_path):
|
141
140
|
logging.debug(f"Pasta {file_path} não encontrada")
|
@@ -156,6 +155,7 @@ class GoogleDrive():
|
|
156
155
|
logging.debug(f"Erro ao realizar o upload do arquivo {name} no google drive. Erro: {e}")
|
157
156
|
return {"success" : False, "result" : None, "error" : str(e)}
|
158
157
|
|
158
|
+
|
159
159
|
def create_folder(self, name: str, parent_folder_id: str):
|
160
160
|
"""
|
161
161
|
Cria uma pasta no Google Drive dentro de uma pasta existente.
|
@@ -185,8 +185,9 @@ class GoogleDrive():
|
|
185
185
|
except Exception as e:
|
186
186
|
logging.debug(f"Não foi possível criar a pasta {name}")
|
187
187
|
return {"success" : False, "result": None, "error" : str(e)}
|
188
|
-
|
189
|
-
|
188
|
+
|
189
|
+
|
190
|
+
def list_items_folder(self, query: str = "", spaces: str = "drive", fields: str = "nextPageToken, files(id, name)"):
|
190
191
|
"""
|
191
192
|
Lista os arquivos e pastas no Google Drive com base nos critérios fornecidos.
|
192
193
|
|
@@ -194,6 +195,7 @@ class GoogleDrive():
|
|
194
195
|
query (str, optional): Critério de busca para os arquivos ou pastas no Google Drive.
|
195
196
|
Consulte https://developers.google.com/drive/api/v3/ref-search-terms.
|
196
197
|
Defaults to "".
|
198
|
+
exemplo: query = 'ID_DA_PASTA_NO_GOOGLE_DRIVE' in parents and trashed=false"
|
197
199
|
spaces (str, optional): Especifica os locais de armazenamento a serem consultados. Pode ser 'drive',
|
198
200
|
'appDataFolder', ou 'photos'. Defaults to 'drive'.
|
199
201
|
fields (str, optional): Campos a serem retornados na resposta. Consulte a documentação para os campos disponíveis.
|
@@ -221,8 +223,10 @@ class GoogleDrive():
|
|
221
223
|
except HttpError as hr:
|
222
224
|
logging.debug(f"Ocorreu um de http. Erro: {hr}")
|
223
225
|
return {"success" : False, "result" : None, "error" : str(hr)}
|
226
|
+
except Exception as e:
|
227
|
+
logging.error(f"Ocorreu um erro ao fazer a requisição. Error: {e}")
|
224
228
|
|
225
|
-
|
229
|
+
|
226
230
|
def get_file(self, file : str, ):
|
227
231
|
"""
|
228
232
|
Obtém o conteúdo de um arquivo armazenado no Google Drive.
|
@@ -249,8 +253,7 @@ class GoogleDrive():
|
|
249
253
|
- A função assume a existência de um atributo `self.service` configurado para interagir com a API do Google Drive.
|
250
254
|
"""
|
251
255
|
try:
|
252
|
-
|
253
|
-
logging.debug(f"Lendo o arquivo {file.get("name")}")
|
256
|
+
logging.debug(f"Lendo o arquivo {file.get('name')}")
|
254
257
|
request = self.service.files().get_media(fileId=file.get("id"))
|
255
258
|
file_data = BytesIO(request.execute())
|
256
259
|
logging.debug("Leitura do arquivo finalizada")
|
csc_cia_stne/servicenow.py
CHANGED
@@ -382,8 +382,7 @@ class ServiceNow:
|
|
382
382
|
except ValidationError as e:
|
383
383
|
raise ValueError("Erro na validação dos dados de input do método:", e.errors())
|
384
384
|
|
385
|
-
|
386
|
-
payload["assigned_to"] = self.__username
|
385
|
+
payload["assigned_to"] = self.__username
|
387
386
|
|
388
387
|
try:
|
389
388
|
|
csc_cia_stne/slack.py
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
import base64
|
2
|
+
from slack_sdk import WebClient
|
3
|
+
from pydantic import BaseModel, ValidationError, field_validator
|
4
|
+
from typing import Union
|
5
|
+
|
6
|
+
|
7
|
+
class InitParamsValidator(BaseModel):
|
8
|
+
"""
|
9
|
+
Classe para validar os parâmetros de inicialização.
|
10
|
+
Atributos:
|
11
|
+
- token_slack: Union[str, dict] - O token do Slack, que pode ser uma string ou um dicionário.
|
12
|
+
- channel_id: str - O ID do canal do Slack.
|
13
|
+
- on_base64: bool - Indica se o token do Slack está em base64.
|
14
|
+
Métodos:
|
15
|
+
- validate_token_slack(value, info): Valida o token do Slack.
|
16
|
+
- validate_token_slack_dict(value, info): Valida o token do Slack quando é um dicionário.
|
17
|
+
- validate_token_slack(value, info): Valida o valor de on_base64.
|
18
|
+
"""
|
19
|
+
|
20
|
+
token_slack: Union[str, dict]
|
21
|
+
channel_id:str
|
22
|
+
on_base64:bool
|
23
|
+
|
24
|
+
"""
|
25
|
+
Valida o token do Slack.
|
26
|
+
Parâmetros:
|
27
|
+
- value: str - O valor do token do Slack.
|
28
|
+
- info: dict - Informações adicionais sobre o campo.
|
29
|
+
Retorna:
|
30
|
+
- str: O valor do token do Slack, se for válido.
|
31
|
+
Lança:
|
32
|
+
- ValueError: Se o valor não for uma string ou estiver vazio.
|
33
|
+
"""
|
34
|
+
@field_validator('channel_id')
|
35
|
+
def validate_token_slack(cls, value, info):
|
36
|
+
if not isinstance(value, str) or not value.strip():
|
37
|
+
raise ValueError(f"O campo '{info.field_name}' deve ser strings e não {type(value)}")
|
38
|
+
return value
|
39
|
+
|
40
|
+
"""
|
41
|
+
Valida o token do Slack quando é um dicionário.
|
42
|
+
Parâmetros:
|
43
|
+
- value: dict - O valor do token do Slack.
|
44
|
+
- info: dict - Informações adicionais sobre o campo.
|
45
|
+
Retorna:
|
46
|
+
- dict: O valor do token do Slack, se for válido.
|
47
|
+
Lança:
|
48
|
+
- ValueError: Se o valor não for um dicionário ou uma string vazia.
|
49
|
+
"""
|
50
|
+
@field_validator('token_slack')
|
51
|
+
def validate_token_slack_dict(cls, value, info):
|
52
|
+
if not isinstance(value, dict) or (not isinstance(value, str) or not value.strip()):
|
53
|
+
raise ValueError(f"O campo '{info.field_name}' deve ser strings e não {type(value)}")
|
54
|
+
return value
|
55
|
+
|
56
|
+
"""
|
57
|
+
Valida o valor de on_base64.
|
58
|
+
Parâmetros:
|
59
|
+
- value: bool - O valor de on_base64.
|
60
|
+
- info: dict - Informações adicionais sobre o campo.
|
61
|
+
Retorna:
|
62
|
+
- bool: O valor de on_base64, se for válido.
|
63
|
+
Lança:
|
64
|
+
- ValueError: Se o valor não for um booleano.
|
65
|
+
"""
|
66
|
+
@field_validator('on_base64')
|
67
|
+
def validate_token_slack(cls, value, info):
|
68
|
+
if not isinstance(value, bool):
|
69
|
+
raise ValueError(f"O campo '{info.field_name}' deve ser strings e não {type(value)}")
|
70
|
+
return value
|
71
|
+
|
72
|
+
|
73
|
+
class SendSlackMessageParamsValidator(BaseModel):
|
74
|
+
"""
|
75
|
+
Valida os parâmetros para enviar uma mensagem no Slack.
|
76
|
+
Atributos:
|
77
|
+
- message (str): A mensagem a ser enviada.
|
78
|
+
- highlights (list): Uma lista de destaques.
|
79
|
+
- files (list): Uma lista de arquivos.
|
80
|
+
Métodos:
|
81
|
+
- validate_message(value, info): Valida o campo 'message' para garantir que seja uma string não vazia.
|
82
|
+
- validate_list(value, info): Valida os campos 'highlights' e 'files' para garantir que sejam listas.
|
83
|
+
"""
|
84
|
+
|
85
|
+
message:str
|
86
|
+
highlights:list
|
87
|
+
files:list
|
88
|
+
|
89
|
+
@field_validator('message')
|
90
|
+
def validate_message(cls, value, info):
|
91
|
+
if not isinstance(value, str) or not value.strip():
|
92
|
+
raise ValueError(f"O campo '{info.field_name}' deve ser strings e não {type(value)}")
|
93
|
+
return value
|
94
|
+
|
95
|
+
@field_validator('highlights','files')
|
96
|
+
def validate_list(cls, value, info):
|
97
|
+
if not isinstance(value, list):
|
98
|
+
raise ValueError(f"O campo '{info.field_name}' deve ser strings e não {type(value)}")
|
99
|
+
return value
|
100
|
+
|
101
|
+
|
102
|
+
class Slack():
|
103
|
+
|
104
|
+
|
105
|
+
def __init__(self, token_slack:Union[str, dict], channel_id, on_base64:bool=False):
|
106
|
+
"""
|
107
|
+
Inicializa a classe Slack.
|
108
|
+
Parâmetros:
|
109
|
+
- token_slack (str): O token de autenticação do Slack.
|
110
|
+
- base64 (bool, opcional): Indica se o token_slack está codificado em base64. O padrão é False.
|
111
|
+
"""
|
112
|
+
|
113
|
+
self.token_slack = token_slack
|
114
|
+
self.on_base64 = on_base64
|
115
|
+
self.channel_id = channel_id
|
116
|
+
|
117
|
+
try:
|
118
|
+
|
119
|
+
InitParamsValidator(token_slack=token_slack, on_base64=on_base64,channel_id=channel_id)
|
120
|
+
|
121
|
+
except ValidationError as e:
|
122
|
+
|
123
|
+
raise ValueError("Erro na validação dos dados de input da inicialização da instância:", e.errors())
|
124
|
+
|
125
|
+
if self.on_base64:
|
126
|
+
|
127
|
+
self.token_slack = base64.b64decode(self.token_slack).decode('utf-8')
|
128
|
+
|
129
|
+
self.client = WebClient(self.token_slack)
|
130
|
+
|
131
|
+
|
132
|
+
def send_message(self, message:str, highlights:list=[] , files:list=[]):
|
133
|
+
"""
|
134
|
+
Envia uma mensagem para o canal do Slack.
|
135
|
+
Parâmetros:
|
136
|
+
- message: str - A mensagem a ser enviada.
|
137
|
+
- highlights: list - Uma lista de destaques (attachments) a serem exibidos junto com a mensagem.
|
138
|
+
- files: list (opcional) - Uma lista de arquivos a serem anexados à mensagem.
|
139
|
+
Retorna:
|
140
|
+
Um dicionário com as seguintes chaves:
|
141
|
+
- status: bool - Indica se o envio da mensagem foi bem-sucedido.
|
142
|
+
- message: dict - A resposta da API do Slack contendo informações sobre a mensagem enviada.
|
143
|
+
- success_attachments: list - Uma lista dos anexos que foram enviados com sucesso.
|
144
|
+
- failed_success_attachments: list - Uma lista dos anexos que falharam ao serem enviados.
|
145
|
+
Caso ocorra algum erro durante o envio da mensagem, o dicionário terá a seguinte estrutura:
|
146
|
+
- status: bool - Indica se ocorreu um erro durante o envio da mensagem.
|
147
|
+
- error: dict - A resposta da API do Slack contendo informações sobre o erro ocorrido.
|
148
|
+
- success_attachments: list - Uma lista dos anexos que foram enviados com sucesso.
|
149
|
+
- failed_attachments: list - Uma lista dos anexos que falharam ao serem enviados.
|
150
|
+
"""
|
151
|
+
|
152
|
+
try:
|
153
|
+
|
154
|
+
SendSlackMessageParamsValidator(message=message, highlights=highlights, files=files)
|
155
|
+
|
156
|
+
except ValidationError as e:
|
157
|
+
|
158
|
+
raise ValueError("Erro na validação dos dados de input da inicialização da instância:", e.errors())
|
159
|
+
|
160
|
+
|
161
|
+
failed_attachments = []
|
162
|
+
|
163
|
+
success_attachments = []
|
164
|
+
|
165
|
+
result_message = self.client.chat_postMessage(
|
166
|
+
channel=self.channel_id,
|
167
|
+
text=message,
|
168
|
+
blocks=[
|
169
|
+
{
|
170
|
+
"type": "section",
|
171
|
+
"text": {
|
172
|
+
"type": "mrkdwn",
|
173
|
+
"text": message
|
174
|
+
}
|
175
|
+
},
|
176
|
+
],
|
177
|
+
attachments=highlights
|
178
|
+
)
|
179
|
+
|
180
|
+
if files is not None and len(files) > 0:
|
181
|
+
|
182
|
+
# validar os arquivos anexados
|
183
|
+
|
184
|
+
for file in files:
|
185
|
+
|
186
|
+
if 'title' in file and 'file' in file:
|
187
|
+
|
188
|
+
if file['title'] is not None and len(str(file['title']).replace(" ","")) > 0 and file['file'] is not None and len(str(files['file']).replace(" ","")) > 0:
|
189
|
+
|
190
|
+
success_attachments.append(file)
|
191
|
+
|
192
|
+
else:
|
193
|
+
|
194
|
+
failed_attachments.append(file)
|
195
|
+
|
196
|
+
else:
|
197
|
+
|
198
|
+
failed_attachments.append(file)
|
199
|
+
|
200
|
+
if len(success_attachments) > 0:
|
201
|
+
|
202
|
+
# Enviar mensagem com anexos
|
203
|
+
|
204
|
+
result_message = self.client.files_upload_v2(
|
205
|
+
channel=self.channel_id,
|
206
|
+
initial_comment="anexos",
|
207
|
+
file_uploads=success_attachments
|
208
|
+
)
|
209
|
+
|
210
|
+
if result_message.get('ok', True):
|
211
|
+
|
212
|
+
return {
|
213
|
+
'status':True,
|
214
|
+
'message':result_message,
|
215
|
+
'success_attachments':success_attachments,
|
216
|
+
'failed_success_attachments':failed_attachments
|
217
|
+
}
|
218
|
+
|
219
|
+
else:
|
220
|
+
|
221
|
+
return {
|
222
|
+
'status':False,
|
223
|
+
'error':result_message,
|
224
|
+
'success_attachments':success_attachments,
|
225
|
+
'failed_attachments':failed_attachments
|
226
|
+
}
|
227
|
+
|
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
from pydantic import BaseModel, field_validator
|
2
|
+
from pydantic import BaseModel, field_validator, EmailStr
|
3
3
|
|
4
4
|
class InitParamsValidator(BaseModel):
|
5
5
|
"""
|
@@ -14,8 +14,8 @@ class InitParamsValidator(BaseModel):
|
|
14
14
|
- check_list_input(cls, value, info): Valida se o valor é uma lista.
|
15
15
|
"""
|
16
16
|
|
17
|
-
|
18
|
-
with_subject:
|
17
|
+
token: dict
|
18
|
+
with_subject: EmailStr
|
19
19
|
scopes : list
|
20
20
|
version : str
|
21
21
|
|
@@ -29,11 +29,17 @@ class InitParamsValidator(BaseModel):
|
|
29
29
|
Lança:
|
30
30
|
- ValueError: Se o valor não for uma string ou estiver vazio.
|
31
31
|
"""
|
32
|
-
@field_validator(
|
32
|
+
@field_validator("version")
|
33
33
|
def check_str_input(cls, value, info):
|
34
34
|
if not isinstance(value, str) or not value.strip():
|
35
35
|
raise ValueError(f"O campo '{info.field_name}' deve ser strings e não {type(value)}")
|
36
36
|
return value
|
37
|
+
|
38
|
+
@field_validator('token')
|
39
|
+
def check_dict_input(cls, value, info):
|
40
|
+
if not isinstance(value, dict):
|
41
|
+
raise ValueError(f"O campo '{info.field_name}' deve ser um dicionário e não {type(value)}")
|
42
|
+
return value
|
37
43
|
|
38
44
|
"""
|
39
45
|
Valida se o valor é uma lista.
|
@@ -116,4 +122,23 @@ class ListFolderValidator(BaseModel):
|
|
116
122
|
def check_str_input(cls, value, info):
|
117
123
|
if not isinstance(value, str) or not value.strip():
|
118
124
|
raise ValueError(f"O campo '{info.field_name}' deve ser strings e não {type(value)}")
|
119
|
-
return value
|
125
|
+
return value
|
126
|
+
|
127
|
+
class UploadValidator(BaseModel):
|
128
|
+
"""
|
129
|
+
Validador para upload de arquivo no Google Drive.
|
130
|
+
|
131
|
+
Atributos:
|
132
|
+
- file_path (str): Caminho do arquivo a ser enviado.
|
133
|
+
|
134
|
+
"""
|
135
|
+
folder_id: str
|
136
|
+
name: str
|
137
|
+
file_path: str
|
138
|
+
mimetype: str
|
139
|
+
|
140
|
+
@field_validator('folder_id','name','file_path', 'mimetype')
|
141
|
+
def check_str_input(cls, value, info):
|
142
|
+
if not isinstance(value, str) or not value.strip():
|
143
|
+
raise ValueError(f"O campo '{info.field_name}' deve ser strings e não {type(value)}")
|
144
|
+
return value
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: csc_cia_stne
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.40
|
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
|
@@ -16,9 +16,12 @@ Requires-Dist: google-cloud-bigquery
|
|
16
16
|
Requires-Dist: google-cloud-storage
|
17
17
|
Requires-Dist: google-auth-oauthlib
|
18
18
|
Requires-Dist: google-auth-httplib2
|
19
|
+
Requires-Dist: google-api-python-client
|
19
20
|
Requires-Dist: pyjwt
|
20
21
|
Requires-Dist: PyYAML
|
21
22
|
Requires-Dist: python-dotenv
|
23
|
+
Requires-Dist: slack_sdk
|
24
|
+
Requires-Dist: email-validator
|
22
25
|
|
23
26
|
Essa biblioteca é desenvolvida e atualizada pelo time **CSC-CIA** da **Stone**
|
24
27
|
|
@@ -1,14 +1,15 @@
|
|
1
|
-
csc_cia_stne/__init__.py,sha256=
|
1
|
+
csc_cia_stne/__init__.py,sha256=EpmmGz66fgGCdY2HoZtkNG9TRaqhOtjVFkXXI1lLGSk,2435
|
2
2
|
csc_cia_stne/bc_correios.py,sha256=pQAnRrcXEMrx3N1MWydZVIhEQLerh3x8-0B045zZIzk,24174
|
3
3
|
csc_cia_stne/bc_sta.py,sha256=f75HJ7FLIDSJFLDTvvSvCYo9z0HchzP7rDY5WIdiKXY,16830
|
4
4
|
csc_cia_stne/email.py,sha256=RK_TzWBVnUfpP-s5NvjTJJjzhICy8e2fME9EuaiySMY,8162
|
5
5
|
csc_cia_stne/gcp_bigquery.py,sha256=yNCx0yD1peoxOKEiu2Ml6FfDtXUTzcJGcypjWPH8QqE,7449
|
6
|
-
csc_cia_stne/google_drive.py,sha256=
|
6
|
+
csc_cia_stne/google_drive.py,sha256=JcXKlRBSxf5CKM-alT4ZpqWVWLZQfIYIX42_nENoTgU,11896
|
7
7
|
csc_cia_stne/karavela.py,sha256=LlpFiDu0ww7eh8F-oREWSQo2mVoQMibx0EGiHR6tznI,4231
|
8
8
|
csc_cia_stne/logger_json.py,sha256=W6Fj0G1-TWXHdHoLLX5SbVV7BSpVvjHm1fkKI5Q69YQ,3129
|
9
9
|
csc_cia_stne/logger_rich.py,sha256=FYO9tG-tEJJDP2EDYFTQYS8GayvbRMgRbKI9FcXvRCs,7812
|
10
10
|
csc_cia_stne/provio.py,sha256=yTRX4YJ6RdNc2ZCVPgsIEgsxe3wQgwnXns4bPX4plAI,3955
|
11
|
-
csc_cia_stne/servicenow.py,sha256=
|
11
|
+
csc_cia_stne/servicenow.py,sha256=3eifPWOIGv2udGpI3cr2SkMMKcQR4xHlA_fiOdw_fmg,32136
|
12
|
+
csc_cia_stne/slack.py,sha256=QtF3zsHldDbsqJKT206jQ2EWTdvVg9FcZ1EhM_YVJWw,8071
|
12
13
|
csc_cia_stne/stne_admin.py,sha256=vnGSEzcmqWE42vg71oEuoRg6ENaGsZsXFOjxduSH4KU,23561
|
13
14
|
csc_cia_stne/utilitarios/__init__.py,sha256=oWxCOFL2wxjs8KBgxoeA6-gVe4ulicVGDgdaw8jzvsY,253
|
14
15
|
csc_cia_stne/utilitarios/functions/__init__.py,sha256=iSLKxM8lgPM1lJ51WZ1mwy36IW5iitfMRc_AnEtzpxg,364
|
@@ -18,11 +19,11 @@ csc_cia_stne/utilitarios/functions/func_recriar_pastas.py,sha256=4whZpB3aJQaCPJ3
|
|
18
19
|
csc_cia_stne/utilitarios/functions/func_settings.py,sha256=rlu4Ec5M-7UzrreiR92L_KLrpBSXv8Hlj4uuRYcPMUc,1709
|
19
20
|
csc_cia_stne/utilitarios/functions/func_titulo.py,sha256=bH4tYxovTARF-g2kWUK_GIzzXt8egbVdp6mWD6fc_3I,5345
|
20
21
|
csc_cia_stne/utilitarios/validations/GcpBigQueryValidator.py,sha256=PfCeeQquheZkrm07HTIjobleh3QQOjljRFGdxbQ1amQ,4630
|
21
|
-
csc_cia_stne/utilitarios/validations/GoogleDriveValidator.py,sha256=
|
22
|
+
csc_cia_stne/utilitarios/validations/GoogleDriveValidator.py,sha256=PBo-AV2bjR__4o9jYxuXO-UyxjAZvVwYgMbtsrFK2sI,4537
|
22
23
|
csc_cia_stne/utilitarios/validations/ServiceNowValidator.py,sha256=yleKUIo1ZfyloP9fDPNjv3JJXdLcocT81WIgRSYmqEA,14423
|
23
24
|
csc_cia_stne/utilitarios/validations/__init__.py,sha256=O_qyEU2ji3u6LHUXZCXvUFsMpoMWL625qqHTXyXivTA,106
|
24
|
-
csc_cia_stne-0.0.
|
25
|
-
csc_cia_stne-0.0.
|
26
|
-
csc_cia_stne-0.0.
|
27
|
-
csc_cia_stne-0.0.
|
28
|
-
csc_cia_stne-0.0.
|
25
|
+
csc_cia_stne-0.0.40.dist-info/LICENCE,sha256=LPGMtgKki2C3KEZP7hDhA1HBrlq5JCHkIeStUCLEMx4,1073
|
26
|
+
csc_cia_stne-0.0.40.dist-info/METADATA,sha256=sV3O3cEAhjbK2E3R9EDfwrFPq8Zyzf8j-taaIwc2rtE,1121
|
27
|
+
csc_cia_stne-0.0.40.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
|
28
|
+
csc_cia_stne-0.0.40.dist-info/top_level.txt,sha256=ldo7GVv3tQx5KJvwBzdZzzQmjPys2NDVVn1rv0BOF2Q,13
|
29
|
+
csc_cia_stne-0.0.40.dist-info/RECORD,,
|
File without changes
|
File without changes
|