docges-api-py 0.1.7__tar.gz → 0.1.8__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.
- {docges_api_py-0.1.7/src/docges_api_py.egg-info → docges_api_py-0.1.8}/PKG-INFO +1 -1
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/README.md +208 -208
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/pyproject.toml +56 -56
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/src/docges_api_py/client.py +481 -480
- {docges_api_py-0.1.7 → docges_api_py-0.1.8/src/docges_api_py.egg-info}/PKG-INFO +1 -1
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/tests/test_check_dir_struct.py +171 -171
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/LICENSE +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/setup.cfg +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/src/docges_api_py/__init__.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/src/docges_api_py/models/__init__.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/src/docges_api_py/models/auth.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/src/docges_api_py/models/document.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/src/docges_api_py/models/requests.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/src/docges_api_py/models/responses.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/src/docges_api_py.egg-info/SOURCES.txt +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/src/docges_api_py.egg-info/dependency_links.txt +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/src/docges_api_py.egg-info/requires.txt +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/src/docges_api_py.egg-info/top_level.txt +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/tests/test_client_auth.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/tests/test_content_methods.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/tests/test_endpoints.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/tests/test_examples.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/tests/test_get_document.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/tests/test_initial_cats.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/tests/test_models_auth.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/tests/test_models_init.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/tests/test_models_requests.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/tests/test_models_responses.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/tests/test_remaining_methods.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/tests/test_retry.py +0 -0
- {docges_api_py-0.1.7 → docges_api_py-0.1.8}/tests/test_token_refresh.py +0 -0
|
@@ -1,209 +1,209 @@
|
|
|
1
|
-
# docges-api-py
|
|
2
|
-
|
|
3
|
-
Async, typed Python client for the DocGes REST API bridge (`docges-ctg-api`).
|
|
4
|
-
|
|
5
|
-
> **Production-ready** — bootstrapped via SDD (Spec-Driven Development).
|
|
6
|
-
> All core endpoints implemented with full test coverage (pytest + respx).
|
|
7
|
-
|
|
8
|
-
## Installation
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
pip install docges-api-py
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
For development with testing tools:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
pip install -e ".[dev]"
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Features
|
|
21
|
-
|
|
22
|
-
- ✅ Async HTTP client using `httpx`
|
|
23
|
-
- ✅ Typed request/response models with Pydantic v2
|
|
24
|
-
- ✅ Configurable retries (exponential backoff) and timeouts
|
|
25
|
-
- ✅ Session-based auth: stores `loginResponse` from `/Auth/Login` and auto-injects it
|
|
26
|
-
for all Content endpoints
|
|
27
|
-
- ✅ Full test coverage (pytest + respx)
|
|
28
|
-
- ✅ Complete DocGes API client: categories, documents, search, CRUD operations
|
|
29
|
-
|
|
30
|
-
## Implemented endpoints
|
|
31
|
-
|
|
32
|
-
### Auth
|
|
33
|
-
| Method | Endpoint | Description |
|
|
34
|
-
|--------|----------|-------------|
|
|
35
|
-
| `auth()` | `POST /Auth/Login` | Authenticate and store session |
|
|
36
|
-
|
|
37
|
-
### Content Tree
|
|
38
|
-
| Method | Endpoint | Description |
|
|
39
|
-
|--------|----------|-------------|
|
|
40
|
-
| `get_initial_cats()` | `POST /Content/LoadIniCats` | Load root categories for user's warehouse |
|
|
41
|
-
| `get_cat_info(sid)` | `POST /Content/LoadChilds` | Load subcategories and documents for a given category SID |
|
|
42
|
-
|
|
43
|
-
### Document Operations
|
|
44
|
-
| Method | Endpoint | Description |
|
|
45
|
-
|--------|----------|-------------|
|
|
46
|
-
| `upload_file(category_sid, file_path)` | `POST /Content/UploadExtended` | Upload a file to a category |
|
|
47
|
-
| `download_content(sid)` | `POST /Content/Download` | Download a document (returns base64 data) |
|
|
48
|
-
| `get_document(sid)` | — | Deprecated wrapper for `download_content()` |
|
|
49
|
-
|
|
50
|
-
### Search
|
|
51
|
-
| Method | Endpoint | Description |
|
|
52
|
-
|--------|----------|-------------|
|
|
53
|
-
| `search_content(field_values, date_values)` | `POST /Content/SearchContent` | Search documents by field or date criteria |
|
|
54
|
-
|
|
55
|
-
### Category Management
|
|
56
|
-
| Method | Endpoint | Description |
|
|
57
|
-
|--------|----------|-------------|
|
|
58
|
-
| `create_category(parent_sid, name)` | `POST /Content/CreateCategory` | Create a subcategory |
|
|
59
|
-
| `rename_category(sid, new_name)` | `POST /Content/RenameCategory` | Rename a category |
|
|
60
|
-
| `delete_category(sid)` | `POST /Content/DeleteCategory` | Delete a category |
|
|
61
|
-
| `check_dir_struct(root_sid, path_names, create_if_not_exist, full_info)` | — | Check or create nested directory structure (full_info=False returns only last dir) |
|
|
62
|
-
|
|
63
|
-
### Document Management
|
|
64
|
-
| Method | Endpoint | Description |
|
|
65
|
-
|--------|----------|-------------|
|
|
66
|
-
| `remove_document(sid)` | `POST /Content/RemoveDocument` | Remove a single document |
|
|
67
|
-
| `move_content(content_sid, destination_sid)` | `POST /Content/Move` | Move a document to another category |
|
|
68
|
-
| `update_content(sid, erp_relation, erp_property)` | `POST /Content/Update` | Update document ERP metadata |
|
|
69
|
-
|
|
70
|
-
## Quick start
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
pip install -e ".[dev]"
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
```python
|
|
77
|
-
import asyncio
|
|
78
|
-
import os
|
|
79
|
-
from docges_api_py import AsyncDocGes
|
|
80
|
-
|
|
81
|
-
async def main():
|
|
82
|
-
base_url = os.getenv("DOCGES_API_BASE_URL")
|
|
83
|
-
user = os.getenv("DOCGES_USER")
|
|
84
|
-
pwd = os.getenv("DOCGES_PASSWORD")
|
|
85
|
-
appid = os.getenv("DOCGES_APP_ID")
|
|
86
|
-
|
|
87
|
-
async with AsyncDocGes(base_url, user, pwd, appid) as client:
|
|
88
|
-
auth_resp = await client.auth()
|
|
89
|
-
print(f"User: {auth_resp.user_info['Nombre']}")
|
|
90
|
-
|
|
91
|
-
# Browse root categories
|
|
92
|
-
cats = await client.get_initial_cats()
|
|
93
|
-
for cat in cats.CategoriasHijas or []:
|
|
94
|
-
print(f" {cat.Nombre} [SID: {cat.SID}]")
|
|
95
|
-
|
|
96
|
-
# Search documents
|
|
97
|
-
results = await client.search_content(
|
|
98
|
-
field_values=[{"field": "name", "mode": "contains", "text": "factura"}]
|
|
99
|
-
)
|
|
100
|
-
print(f"Search results: {len(results.results)}")
|
|
101
|
-
|
|
102
|
-
asyncio.run(main())
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Environment variables
|
|
106
|
-
|
|
107
|
-
| Variable | Description | Example |
|
|
108
|
-
|----------|-------------|---------|
|
|
109
|
-
| `DOCGES_API_BASE_URL` | Bridge base URL | `http://192.168.0.90:49375` |
|
|
110
|
-
| `DOCGES_USER` | Username | `administrador` |
|
|
111
|
-
| `DOCGES_PASSWORD` | Password | `12345` |
|
|
112
|
-
| `DOCGES_APP_ID` | App ID (maps to server config in `clients.xml`) | `local-dev` |
|
|
113
|
-
| `DOCGES_ROOT_SID` | Root category SID for directory operations | `1ddbfd1b-5d33-44af-b392-...` |
|
|
114
|
-
|
|
115
|
-
**Known appIDs:**
|
|
116
|
-
- `local-dev` — local development
|
|
117
|
-
- `pre-dev` — pre-production
|
|
118
|
-
- `pro-*` — production servers
|
|
119
|
-
|
|
120
|
-
## Examples
|
|
121
|
-
|
|
122
|
-
All examples read credentials from environment variables. Run them with:
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
export DOCGES_API_BASE_URL=http://192.168.0.90:49375
|
|
126
|
-
export DOCGES_USER=administrador
|
|
127
|
-
export DOCGES_PASSWORD=12345
|
|
128
|
-
export DOCGES_APP_ID=local-dev
|
|
129
|
-
python examples/<number>_<name>.py
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
| # | File | What it does |
|
|
133
|
-
|---|------|-------------|
|
|
134
|
-
| 01 | `examples/01_auth.py` | Login and inspect session context |
|
|
135
|
-
| 02 | `examples/02_initial_cats.py` | Load and list root categories |
|
|
136
|
-
| 03 | `examples/03_browse_category.py` | Browse a category by SID (subcats + docs) |
|
|
137
|
-
| 04 | `examples/04_search.py` | Search documents by name |
|
|
138
|
-
| 05 | `examples/05_upload.py` | Upload a file to a category |
|
|
139
|
-
| 06 | `examples/06_download.py` | Download a document by SID |
|
|
140
|
-
| 07 | `examples/07_category_crud.py` | Create, rename, and delete a category |
|
|
141
|
-
| 08 | `examples/08_document_operations.py` | Update ERP metadata, move, and remove a document |
|
|
142
|
-
| 09 | `examples/09_dir_structure.py` | Check or create nested directory structure |
|
|
143
|
-
|
|
144
|
-
## Development
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
pip install -e ".[dev]"
|
|
148
|
-
ruff check src/ tests/
|
|
149
|
-
mypy src/
|
|
150
|
-
pytest --cov=docges_api_py
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
## Architecture notes
|
|
154
|
-
|
|
155
|
-
- The DocGes REST API is a thin bridge in front of DocGes WCF services. It uses session-based auth: `/Auth/Login` returns a `loginResponse` (containing `userInfo` and `wareHouseInfo`) that must be passed back on every Content request via `requestModel.loginResponse`.
|
|
156
|
-
- Content endpoints expect `contenidoModel`, `fileModel`, etc. as **top-level fields** alongside `requestModel`, not nested inside it. The client builds the correct payload shape automatically.
|
|
157
|
-
- For DocGes Web (bridge) compatibility, the client also includes `loginDocGesData` (username/password/appID) in `requestModel` — this is needed by some bridge deployments that reconstruct the DocGes login model server-side.
|
|
158
|
-
- All file content is base64-encoded in transit (handled automatically by the client).
|
|
159
|
-
|
|
160
|
-
## Project structure
|
|
161
|
-
|
|
162
|
-
```
|
|
163
|
-
docges-api-py/
|
|
164
|
-
├── src/docges_api_py/
|
|
165
|
-
│ ├── __init__.py # Exports AsyncDocGes, models
|
|
166
|
-
│ ├── client.py # AsyncDocGes client (all endpoints)
|
|
167
|
-
│ └── models/
|
|
168
|
-
│ ├── __init__.py # Re-exports all models
|
|
169
|
-
│ ├── auth.py # AuthRequest, AuthResponse
|
|
170
|
-
│ ├── document.py # Document
|
|
171
|
-
│ ├── requests.py # Request models (Pydantic v2)
|
|
172
|
-
│ └── responses.py # Response models (ResCat, ResFileDownload, etc.)
|
|
173
|
-
├── tests/
|
|
174
|
-
│ ├── conftest.py
|
|
175
|
-
│ ├── test_client_auth.py
|
|
176
|
-
│ ├── test_initial_cats.py
|
|
177
|
-
│ ├── test_content_methods.py
|
|
178
|
-
│ ├── test_remaining_methods.py
|
|
179
|
-
│ ├── test_check_dir_struct.py
|
|
180
|
-
│ ├── test_models_requests.py
|
|
181
|
-
│ ├── test_models_responses.py
|
|
182
|
-
│ ├── test_models_init.py
|
|
183
|
-
│ ├── test_endpoints.py
|
|
184
|
-
│ ├── test_retry.py
|
|
185
|
-
│ ├── test_token_refresh.py
|
|
186
|
-
│ └── test_examples.py
|
|
187
|
-
├── examples/
|
|
188
|
-
│ ├── 01_auth.py
|
|
189
|
-
│ ├── 02_initial_cats.py
|
|
190
|
-
│ ├── 03_browse_category.py
|
|
191
|
-
│ ├── 04_search.py
|
|
192
|
-
│ ├── 05_upload.py
|
|
193
|
-
│ ├── 06_download.py
|
|
194
|
-
│ ├── 07_category_crud.py
|
|
195
|
-
│ ├── 08_document_operations.py
|
|
196
|
-
│ └── 09_dir_structure.py
|
|
197
|
-
├── docs/
|
|
198
|
-
│ └── MIGRATION.md
|
|
199
|
-
├── scripts/
|
|
200
|
-
│ └── docges_debug/ # Debug helpers for payload investigation
|
|
201
|
-
├── pyproject.toml
|
|
202
|
-
├── ruff.toml
|
|
203
|
-
├── mypy.ini
|
|
204
|
-
└── README.md
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
## Contributing
|
|
208
|
-
|
|
1
|
+
# docges-api-py
|
|
2
|
+
|
|
3
|
+
Async, typed Python client for the DocGes REST API bridge (`docges-ctg-api`).
|
|
4
|
+
|
|
5
|
+
> **Production-ready** — bootstrapped via SDD (Spec-Driven Development).
|
|
6
|
+
> All core endpoints implemented with full test coverage (pytest + respx).
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install docges-api-py
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
For development with testing tools:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install -e ".[dev]"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- ✅ Async HTTP client using `httpx`
|
|
23
|
+
- ✅ Typed request/response models with Pydantic v2
|
|
24
|
+
- ✅ Configurable retries (exponential backoff) and timeouts
|
|
25
|
+
- ✅ Session-based auth: stores `loginResponse` from `/Auth/Login` and auto-injects it
|
|
26
|
+
for all Content endpoints
|
|
27
|
+
- ✅ Full test coverage (pytest + respx)
|
|
28
|
+
- ✅ Complete DocGes API client: categories, documents, search, CRUD operations
|
|
29
|
+
|
|
30
|
+
## Implemented endpoints
|
|
31
|
+
|
|
32
|
+
### Auth
|
|
33
|
+
| Method | Endpoint | Description |
|
|
34
|
+
|--------|----------|-------------|
|
|
35
|
+
| `auth()` | `POST /Auth/Login` | Authenticate and store session |
|
|
36
|
+
|
|
37
|
+
### Content Tree
|
|
38
|
+
| Method | Endpoint | Description |
|
|
39
|
+
|--------|----------|-------------|
|
|
40
|
+
| `get_initial_cats()` | `POST /Content/LoadIniCats` | Load root categories for user's warehouse |
|
|
41
|
+
| `get_cat_info(sid)` | `POST /Content/LoadChilds` | Load subcategories and documents for a given category SID |
|
|
42
|
+
|
|
43
|
+
### Document Operations
|
|
44
|
+
| Method | Endpoint | Description |
|
|
45
|
+
|--------|----------|-------------|
|
|
46
|
+
| `upload_file(category_sid, file_path)` | `POST /Content/UploadExtended` | Upload a file to a category |
|
|
47
|
+
| `download_content(sid)` | `POST /Content/Download` | Download a document (returns base64 data) |
|
|
48
|
+
| `get_document(sid)` | — | Deprecated wrapper for `download_content()` |
|
|
49
|
+
|
|
50
|
+
### Search
|
|
51
|
+
| Method | Endpoint | Description |
|
|
52
|
+
|--------|----------|-------------|
|
|
53
|
+
| `search_content(field_values, date_values)` | `POST /Content/SearchContent` | Search documents by field or date criteria |
|
|
54
|
+
|
|
55
|
+
### Category Management
|
|
56
|
+
| Method | Endpoint | Description |
|
|
57
|
+
|--------|----------|-------------|
|
|
58
|
+
| `create_category(parent_sid, name)` | `POST /Content/CreateCategory` | Create a subcategory |
|
|
59
|
+
| `rename_category(sid, new_name)` | `POST /Content/RenameCategory` | Rename a category |
|
|
60
|
+
| `delete_category(sid)` | `POST /Content/DeleteCategory` | Delete a category |
|
|
61
|
+
| `check_dir_struct(root_sid, path_names, create_if_not_exist, full_info)` | — | Check or create nested directory structure (full_info=False returns only last dir) |
|
|
62
|
+
|
|
63
|
+
### Document Management
|
|
64
|
+
| Method | Endpoint | Description |
|
|
65
|
+
|--------|----------|-------------|
|
|
66
|
+
| `remove_document(sid)` | `POST /Content/RemoveDocument` | Remove a single document |
|
|
67
|
+
| `move_content(content_sid, destination_sid)` | `POST /Content/Move` | Move a document to another category |
|
|
68
|
+
| `update_content(sid, erp_relation, erp_property)` | `POST /Content/Update` | Update document ERP metadata |
|
|
69
|
+
|
|
70
|
+
## Quick start
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install -e ".[dev]"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
import asyncio
|
|
78
|
+
import os
|
|
79
|
+
from docges_api_py import AsyncDocGes
|
|
80
|
+
|
|
81
|
+
async def main():
|
|
82
|
+
base_url = os.getenv("DOCGES_API_BASE_URL")
|
|
83
|
+
user = os.getenv("DOCGES_USER")
|
|
84
|
+
pwd = os.getenv("DOCGES_PASSWORD")
|
|
85
|
+
appid = os.getenv("DOCGES_APP_ID")
|
|
86
|
+
|
|
87
|
+
async with AsyncDocGes(base_url, user, pwd, appid) as client:
|
|
88
|
+
auth_resp = await client.auth()
|
|
89
|
+
print(f"User: {auth_resp.user_info['Nombre']}")
|
|
90
|
+
|
|
91
|
+
# Browse root categories
|
|
92
|
+
cats = await client.get_initial_cats()
|
|
93
|
+
for cat in cats.CategoriasHijas or []:
|
|
94
|
+
print(f" {cat.Nombre} [SID: {cat.SID}]")
|
|
95
|
+
|
|
96
|
+
# Search documents
|
|
97
|
+
results = await client.search_content(
|
|
98
|
+
field_values=[{"field": "name", "mode": "contains", "text": "factura"}]
|
|
99
|
+
)
|
|
100
|
+
print(f"Search results: {len(results.results)}")
|
|
101
|
+
|
|
102
|
+
asyncio.run(main())
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Environment variables
|
|
106
|
+
|
|
107
|
+
| Variable | Description | Example |
|
|
108
|
+
|----------|-------------|---------|
|
|
109
|
+
| `DOCGES_API_BASE_URL` | Bridge base URL | `http://192.168.0.90:49375` |
|
|
110
|
+
| `DOCGES_USER` | Username | `administrador` |
|
|
111
|
+
| `DOCGES_PASSWORD` | Password | `12345` |
|
|
112
|
+
| `DOCGES_APP_ID` | App ID (maps to server config in `clients.xml`) | `local-dev` |
|
|
113
|
+
| `DOCGES_ROOT_SID` | Root category SID for directory operations | `1ddbfd1b-5d33-44af-b392-...` |
|
|
114
|
+
|
|
115
|
+
**Known appIDs:**
|
|
116
|
+
- `local-dev` — local development
|
|
117
|
+
- `pre-dev` — pre-production
|
|
118
|
+
- `pro-*` — production servers
|
|
119
|
+
|
|
120
|
+
## Examples
|
|
121
|
+
|
|
122
|
+
All examples read credentials from environment variables. Run them with:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
export DOCGES_API_BASE_URL=http://192.168.0.90:49375
|
|
126
|
+
export DOCGES_USER=administrador
|
|
127
|
+
export DOCGES_PASSWORD=12345
|
|
128
|
+
export DOCGES_APP_ID=local-dev
|
|
129
|
+
python examples/<number>_<name>.py
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
| # | File | What it does |
|
|
133
|
+
|---|------|-------------|
|
|
134
|
+
| 01 | `examples/01_auth.py` | Login and inspect session context |
|
|
135
|
+
| 02 | `examples/02_initial_cats.py` | Load and list root categories |
|
|
136
|
+
| 03 | `examples/03_browse_category.py` | Browse a category by SID (subcats + docs) |
|
|
137
|
+
| 04 | `examples/04_search.py` | Search documents by name |
|
|
138
|
+
| 05 | `examples/05_upload.py` | Upload a file to a category |
|
|
139
|
+
| 06 | `examples/06_download.py` | Download a document by SID |
|
|
140
|
+
| 07 | `examples/07_category_crud.py` | Create, rename, and delete a category |
|
|
141
|
+
| 08 | `examples/08_document_operations.py` | Update ERP metadata, move, and remove a document |
|
|
142
|
+
| 09 | `examples/09_dir_structure.py` | Check or create nested directory structure |
|
|
143
|
+
|
|
144
|
+
## Development
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
pip install -e ".[dev]"
|
|
148
|
+
ruff check src/ tests/
|
|
149
|
+
mypy src/
|
|
150
|
+
pytest --cov=docges_api_py
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Architecture notes
|
|
154
|
+
|
|
155
|
+
- The DocGes REST API is a thin bridge in front of DocGes WCF services. It uses session-based auth: `/Auth/Login` returns a `loginResponse` (containing `userInfo` and `wareHouseInfo`) that must be passed back on every Content request via `requestModel.loginResponse`.
|
|
156
|
+
- Content endpoints expect `contenidoModel`, `fileModel`, etc. as **top-level fields** alongside `requestModel`, not nested inside it. The client builds the correct payload shape automatically.
|
|
157
|
+
- For DocGes Web (bridge) compatibility, the client also includes `loginDocGesData` (username/password/appID) in `requestModel` — this is needed by some bridge deployments that reconstruct the DocGes login model server-side.
|
|
158
|
+
- All file content is base64-encoded in transit (handled automatically by the client).
|
|
159
|
+
|
|
160
|
+
## Project structure
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
docges-api-py/
|
|
164
|
+
├── src/docges_api_py/
|
|
165
|
+
│ ├── __init__.py # Exports AsyncDocGes, models
|
|
166
|
+
│ ├── client.py # AsyncDocGes client (all endpoints)
|
|
167
|
+
│ └── models/
|
|
168
|
+
│ ├── __init__.py # Re-exports all models
|
|
169
|
+
│ ├── auth.py # AuthRequest, AuthResponse
|
|
170
|
+
│ ├── document.py # Document
|
|
171
|
+
│ ├── requests.py # Request models (Pydantic v2)
|
|
172
|
+
│ └── responses.py # Response models (ResCat, ResFileDownload, etc.)
|
|
173
|
+
├── tests/
|
|
174
|
+
│ ├── conftest.py
|
|
175
|
+
│ ├── test_client_auth.py
|
|
176
|
+
│ ├── test_initial_cats.py
|
|
177
|
+
│ ├── test_content_methods.py
|
|
178
|
+
│ ├── test_remaining_methods.py
|
|
179
|
+
│ ├── test_check_dir_struct.py
|
|
180
|
+
│ ├── test_models_requests.py
|
|
181
|
+
│ ├── test_models_responses.py
|
|
182
|
+
│ ├── test_models_init.py
|
|
183
|
+
│ ├── test_endpoints.py
|
|
184
|
+
│ ├── test_retry.py
|
|
185
|
+
│ ├── test_token_refresh.py
|
|
186
|
+
│ └── test_examples.py
|
|
187
|
+
├── examples/
|
|
188
|
+
│ ├── 01_auth.py
|
|
189
|
+
│ ├── 02_initial_cats.py
|
|
190
|
+
│ ├── 03_browse_category.py
|
|
191
|
+
│ ├── 04_search.py
|
|
192
|
+
│ ├── 05_upload.py
|
|
193
|
+
│ ├── 06_download.py
|
|
194
|
+
│ ├── 07_category_crud.py
|
|
195
|
+
│ ├── 08_document_operations.py
|
|
196
|
+
│ └── 09_dir_structure.py
|
|
197
|
+
├── docs/
|
|
198
|
+
│ └── MIGRATION.md
|
|
199
|
+
├── scripts/
|
|
200
|
+
│ └── docges_debug/ # Debug helpers for payload investigation
|
|
201
|
+
├── pyproject.toml
|
|
202
|
+
├── ruff.toml
|
|
203
|
+
├── mypy.ini
|
|
204
|
+
└── README.md
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Contributing
|
|
208
|
+
|
|
209
209
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "docges-api-py"
|
|
7
|
-
version = "0.1.
|
|
8
|
-
description = "Async, typed Python client for DocGes REST API"
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.12"
|
|
11
|
-
license = { text = "MIT" }
|
|
12
|
-
authors = [
|
|
13
|
-
{ name = "ct.galega", email = "soporte@ctgalega.com" }
|
|
14
|
-
]
|
|
15
|
-
dependencies = [
|
|
16
|
-
"httpx>=0.27",
|
|
17
|
-
"pydantic>=2.0",
|
|
18
|
-
]
|
|
19
|
-
|
|
20
|
-
[project.optional-dependencies]
|
|
21
|
-
dev = [
|
|
22
|
-
"pytest>=8.0",
|
|
23
|
-
"pytest-asyncio>=0.23",
|
|
24
|
-
"respx>=0.22",
|
|
25
|
-
"pytest-cov>=5.0",
|
|
26
|
-
"ruff>=0.4",
|
|
27
|
-
"mypy>=1.10",
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
[tool.setuptools.packages.find]
|
|
31
|
-
where = ["src"]
|
|
32
|
-
|
|
33
|
-
[tool.pytest.ini_options]
|
|
34
|
-
asyncio_mode = "auto"
|
|
35
|
-
testpaths = ["tests"]
|
|
36
|
-
|
|
37
|
-
[tool.ruff]
|
|
38
|
-
target-version = "py312"
|
|
39
|
-
line-length = 120
|
|
40
|
-
|
|
41
|
-
[tool.ruff.lint]
|
|
42
|
-
select = ["E", "F", "W", "I", "UP", "B", "SIM", "RUF"]
|
|
43
|
-
|
|
44
|
-
[tool.mypy]
|
|
45
|
-
python_version = "3.12"
|
|
46
|
-
warn_return_any = true
|
|
47
|
-
warn_unused_configs = true
|
|
48
|
-
disallow_untyped_defs = true
|
|
49
|
-
|
|
50
|
-
[tool.coverage.run]
|
|
51
|
-
source = ["docges_api_py"]
|
|
52
|
-
omit = ["tests/*"]
|
|
53
|
-
|
|
54
|
-
[tool.coverage.report]
|
|
55
|
-
fail_under = 80
|
|
56
|
-
show_missing = true
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "docges-api-py"
|
|
7
|
+
version = "0.1.8"
|
|
8
|
+
description = "Async, typed Python client for DocGes REST API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "ct.galega", email = "soporte@ctgalega.com" }
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"httpx>=0.27",
|
|
17
|
+
"pydantic>=2.0",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.optional-dependencies]
|
|
21
|
+
dev = [
|
|
22
|
+
"pytest>=8.0",
|
|
23
|
+
"pytest-asyncio>=0.23",
|
|
24
|
+
"respx>=0.22",
|
|
25
|
+
"pytest-cov>=5.0",
|
|
26
|
+
"ruff>=0.4",
|
|
27
|
+
"mypy>=1.10",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[tool.setuptools.packages.find]
|
|
31
|
+
where = ["src"]
|
|
32
|
+
|
|
33
|
+
[tool.pytest.ini_options]
|
|
34
|
+
asyncio_mode = "auto"
|
|
35
|
+
testpaths = ["tests"]
|
|
36
|
+
|
|
37
|
+
[tool.ruff]
|
|
38
|
+
target-version = "py312"
|
|
39
|
+
line-length = 120
|
|
40
|
+
|
|
41
|
+
[tool.ruff.lint]
|
|
42
|
+
select = ["E", "F", "W", "I", "UP", "B", "SIM", "RUF"]
|
|
43
|
+
|
|
44
|
+
[tool.mypy]
|
|
45
|
+
python_version = "3.12"
|
|
46
|
+
warn_return_any = true
|
|
47
|
+
warn_unused_configs = true
|
|
48
|
+
disallow_untyped_defs = true
|
|
49
|
+
|
|
50
|
+
[tool.coverage.run]
|
|
51
|
+
source = ["docges_api_py"]
|
|
52
|
+
omit = ["tests/*"]
|
|
53
|
+
|
|
54
|
+
[tool.coverage.report]
|
|
55
|
+
fail_under = 80
|
|
56
|
+
show_missing = true
|