facilapp-sql-sdk 1.0.127__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.
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.4
2
+ Name: facilapp-sql-sdk
3
+ Version: 1.0.127
4
+ Summary: SDK oficial em Python para a FacilApp SQL API
5
+ Author: FacilApp
6
+ Keywords: facilapp,sql,api,oauth2
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: Other/Proprietary License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+
13
+ # FacilApp SQL SDK para Python
14
+
15
+ ```python
16
+ from facilapp_sql import FacilAppSqlClient
17
+ api = FacilAppSqlClient()
18
+ login = api.login_client_secret("CLIENT_ID", "CLIENT_SECRET")
19
+ resultado = api.executar({"funcao": "consultar_sqlserver", "banco": "BANCO", "tabela": "TABELA"})
20
+ ```
21
+
22
+ SDK oficial para Python 3.9+, sem dependências externas. Documentação: https://sql.facilapp.com.br/docs/.
@@ -0,0 +1,10 @@
1
+ # FacilApp SQL SDK para Python
2
+
3
+ ```python
4
+ from facilapp_sql import FacilAppSqlClient
5
+ api = FacilAppSqlClient()
6
+ login = api.login_client_secret("CLIENT_ID", "CLIENT_SECRET")
7
+ resultado = api.executar({"funcao": "consultar_sqlserver", "banco": "BANCO", "tabela": "TABELA"})
8
+ ```
9
+
10
+ SDK oficial para Python 3.9+, sem dependências externas. Documentação: https://sql.facilapp.com.br/docs/.
@@ -0,0 +1,16 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "facilapp-sql-sdk"
7
+ version = "1.0.127"
8
+ description = "SDK oficial em Python para a FacilApp SQL API"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ authors = [{name = "FacilApp"}]
12
+ keywords = ["facilapp", "sql", "api", "oauth2"]
13
+ classifiers = ["Programming Language :: Python :: 3", "License :: Other/Proprietary License", "Operating System :: OS Independent"]
14
+
15
+ [tool.setuptools.packages.find]
16
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ from .client import FacilAppApiError, FacilAppSqlClient
2
+
3
+ __all__ = ["FacilAppSqlClient", "FacilAppApiError"]
4
+ __version__ = "1.0.127"
@@ -0,0 +1,51 @@
1
+ """Cliente oficial, sem dependências externas, para a FacilApp SQL API."""
2
+ from __future__ import annotations
3
+ import json
4
+ from typing import Any
5
+ from urllib.error import HTTPError, URLError
6
+ from urllib.parse import urlencode
7
+ from urllib.request import Request, urlopen
8
+
9
+ class FacilAppApiError(RuntimeError):
10
+ def __init__(self, status_code: int, response_body: str):
11
+ self.status_code, self.response_body = status_code, response_body
12
+ super().__init__(f"FacilApp SQL API retornou HTTP {status_code}: {response_body}")
13
+
14
+ class FacilAppSqlClient:
15
+ def __init__(self, base_url: str = "https://sql.facilapp.com.br", timeout: float = 30.0):
16
+ self.base_url, self.timeout, self.access_token = base_url.rstrip("/"), timeout, None
17
+
18
+ def status(self) -> dict[str, Any]: return self.request("GET", "/status", authenticated=False)
19
+ def openapi(self) -> dict[str, Any]: return self.request("GET", "/swagger/v1/swagger.json", authenticated=False)
20
+
21
+ def login_client_secret(self, client_id: str, client_secret: str, scope: str | None = None) -> dict[str, Any]:
22
+ result = self.request("POST", "/oauth/login-simples", json_body={"client_id": client_id, "client_secret": client_secret, "scope": scope}, authenticated=False)
23
+ self.access_token = result.get("access_token")
24
+ return result
25
+
26
+ def oauth_token(self, client_id: str, client_secret: str, scope: str | None = None) -> dict[str, Any]:
27
+ form = urlencode({"grant_type": "client_credentials", "client_id": client_id, "client_secret": client_secret, "scope": scope or ""}).encode()
28
+ result = self.request("POST", "/oauth/token", data=form, content_type="application/x-www-form-urlencoded", authenticated=False)
29
+ self.access_token = result.get("access_token")
30
+ return result
31
+
32
+ def executar(self, pedido: dict[str, Any]) -> dict[str, Any]: return self.request("POST", "/executar", json_body=pedido)
33
+
34
+ def request(self, method: str, path: str, *, json_body: Any = None, data: bytes | None = None,
35
+ content_type: str = "application/json", authenticated: bool = True) -> Any:
36
+ headers = {"Accept": "application/json"}
37
+ if json_body is not None: data = json.dumps(json_body, ensure_ascii=False).encode("utf-8")
38
+ if data is not None: headers["Content-Type"] = content_type
39
+ if authenticated:
40
+ if not self.access_token: raise RuntimeError("Faça o login ou informe access_token antes da chamada autenticada.")
41
+ headers["Authorization"] = f"Bearer {self.access_token}"
42
+ req = Request(f"{self.base_url}/{path.lstrip('/')}", data=data, headers=headers, method=method.upper())
43
+ try:
44
+ with urlopen(req, timeout=self.timeout) as response:
45
+ raw = response.read().decode("utf-8")
46
+ return json.loads(raw) if raw else None
47
+ except HTTPError as error:
48
+ body = error.read().decode("utf-8", errors="replace")
49
+ raise FacilAppApiError(error.code, body) from error
50
+ except URLError as error:
51
+ raise ConnectionError(f"Não foi possível acessar {self.base_url}: {error.reason}") from error
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.4
2
+ Name: facilapp-sql-sdk
3
+ Version: 1.0.127
4
+ Summary: SDK oficial em Python para a FacilApp SQL API
5
+ Author: FacilApp
6
+ Keywords: facilapp,sql,api,oauth2
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: Other/Proprietary License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.9
11
+ Description-Content-Type: text/markdown
12
+
13
+ # FacilApp SQL SDK para Python
14
+
15
+ ```python
16
+ from facilapp_sql import FacilAppSqlClient
17
+ api = FacilAppSqlClient()
18
+ login = api.login_client_secret("CLIENT_ID", "CLIENT_SECRET")
19
+ resultado = api.executar({"funcao": "consultar_sqlserver", "banco": "BANCO", "tabela": "TABELA"})
20
+ ```
21
+
22
+ SDK oficial para Python 3.9+, sem dependências externas. Documentação: https://sql.facilapp.com.br/docs/.
@@ -0,0 +1,8 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/facilapp_sql/__init__.py
4
+ src/facilapp_sql/client.py
5
+ src/facilapp_sql_sdk.egg-info/PKG-INFO
6
+ src/facilapp_sql_sdk.egg-info/SOURCES.txt
7
+ src/facilapp_sql_sdk.egg-info/dependency_links.txt
8
+ src/facilapp_sql_sdk.egg-info/top_level.txt