docges-api-py 0.1.0__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 (28) hide show
  1. docges_api_py-0.1.0/LICENSE +21 -0
  2. docges_api_py-0.1.0/PKG-INFO +154 -0
  3. docges_api_py-0.1.0/README.md +134 -0
  4. docges_api_py-0.1.0/pyproject.toml +56 -0
  5. docges_api_py-0.1.0/setup.cfg +4 -0
  6. docges_api_py-0.1.0/src/docges_api_py/__init__.py +69 -0
  7. docges_api_py-0.1.0/src/docges_api_py/client.py +416 -0
  8. docges_api_py-0.1.0/src/docges_api_py/models/__init__.py +45 -0
  9. docges_api_py-0.1.0/src/docges_api_py/models/auth.py +17 -0
  10. docges_api_py-0.1.0/src/docges_api_py/models/document.py +15 -0
  11. docges_api_py-0.1.0/src/docges_api_py/models/requests.py +103 -0
  12. docges_api_py-0.1.0/src/docges_api_py/models/responses.py +108 -0
  13. docges_api_py-0.1.0/src/docges_api_py.egg-info/PKG-INFO +154 -0
  14. docges_api_py-0.1.0/src/docges_api_py.egg-info/SOURCES.txt +26 -0
  15. docges_api_py-0.1.0/src/docges_api_py.egg-info/dependency_links.txt +1 -0
  16. docges_api_py-0.1.0/src/docges_api_py.egg-info/requires.txt +10 -0
  17. docges_api_py-0.1.0/src/docges_api_py.egg-info/top_level.txt +1 -0
  18. docges_api_py-0.1.0/tests/test_client_auth.py +56 -0
  19. docges_api_py-0.1.0/tests/test_content_methods.py +101 -0
  20. docges_api_py-0.1.0/tests/test_endpoints.py +37 -0
  21. docges_api_py-0.1.0/tests/test_get_document.py +56 -0
  22. docges_api_py-0.1.0/tests/test_initial_cats.py +55 -0
  23. docges_api_py-0.1.0/tests/test_models_init.py +38 -0
  24. docges_api_py-0.1.0/tests/test_models_requests.py +83 -0
  25. docges_api_py-0.1.0/tests/test_models_responses.py +86 -0
  26. docges_api_py-0.1.0/tests/test_remaining_methods.py +173 -0
  27. docges_api_py-0.1.0/tests/test_retry.py +67 -0
  28. docges_api_py-0.1.0/tests/test_token_refresh.py +54 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Your Name / Organization
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,154 @@
1
+ Metadata-Version: 2.4
2
+ Name: docges-api-py
3
+ Version: 0.1.0
4
+ Summary: Async, typed Python client for DocGes REST API
5
+ Author-email: "ct.galega" <soporte@ctgalega.com>
6
+ License: MIT
7
+ Requires-Python: >=3.12
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: httpx>=0.27
11
+ Requires-Dist: pydantic>=2.0
12
+ Provides-Extra: dev
13
+ Requires-Dist: pytest>=8.0; extra == "dev"
14
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
15
+ Requires-Dist: respx>=0.22; extra == "dev"
16
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
17
+ Requires-Dist: ruff>=0.4; extra == "dev"
18
+ Requires-Dist: mypy>=1.10; extra == "dev"
19
+ Dynamic: license-file
20
+
21
+ # docges-api-py
22
+
23
+ Async, typed Python client for the DocGes REST API.
24
+
25
+ > **Work in progress** — bootstrapped via SDD (Spec-Driven Development).
26
+ > Phase 1-4 completed: async client with auth, retry, token refresh, and tests.
27
+ > Phase 5 completed: All core endpoints implemented.
28
+
29
+ ## Features
30
+
31
+ - ✅ Async HTTP client using `httpx`
32
+ - ✅ Typed request/response models with Pydantic v2
33
+ - ✅ Configurable retries and timeouts
34
+ - ✅ Token-based auth with automatic refresh (TTL)
35
+ - ✅ Full test coverage (pytest + respx)
36
+ - ✅ Complete DocGes API client (upload, download, search, categories)
37
+
38
+ ## Implemented endpoints
39
+
40
+ ### Auth
41
+ - `auth()` — authenticate against `/Auth/Login`
42
+
43
+ ### Content Tree
44
+ - `get_initial_cats()` — load initial categories via `/Content/LoadIniCats`
45
+ - `get_cat_info(sid)` — load category children via `/Content/LoadChilds`
46
+
47
+ ### Document Operations
48
+ - `upload_file(category_sid, file_path)` — upload via `/Content/UploadExtended`
49
+ - `download_content(sid)` — download via `/Content/Download` (returns `ResFileDownload`)
50
+ - `get_document(sid)` — deprecated wrapper (calls `download_content()`)
51
+
52
+ ### Search
53
+ - `search_content(field_values, date_values)` — search via `/Content/SearchContent`
54
+
55
+ ### Category Management
56
+ - `create_category(parent_sid, name)` — create via `/Content/CreateCategory`
57
+ - `rename_category(sid, new_name)` — rename via `/Content/RenameCategory`
58
+ - `delete_category(sid)` — delete via `/Content/DeleteCategory`
59
+
60
+ ### Document Management
61
+ - `remove_document(sid)` — remove via `/Content/RemoveDocument`
62
+ - `move_content(content_sid, destination_sid)` — move via `/Content/Move`
63
+ - `update_content(sid, erp_relation, erp_property)` — update via `/Content/Update`
64
+
65
+ ## Quick start
66
+
67
+ ```bash
68
+ pip install -e ".[dev]"
69
+ ```
70
+
71
+ ```python
72
+ import asyncio
73
+ from docges_api_py import AsyncDocGes
74
+
75
+ async def main():
76
+ async with AsyncDocGes(
77
+ "https://docges.example.com", "user", "password", "appid"
78
+ ) as client:
79
+ # Auth
80
+ auth_resp = await client.auth()
81
+ print(f"Token (partial): {auth_resp.token[:8]}...")
82
+
83
+ # Load initial categories
84
+ cats = await client.get_initial_cats()
85
+ print(f"Initial categories: {len(cats.CategoriasHijas)}")
86
+
87
+ # Search documents
88
+ results = await client.search_content(
89
+ field_values=[{"field": "name", "mode": "contains", "text": "invoice"}]
90
+ )
91
+ print(f"Search results: {len(results.results)}")
92
+
93
+ asyncio.run(main())
94
+ ```
95
+
96
+ See `examples/quickstart.py` for a more complete example.
97
+
98
+ ## Development
99
+
100
+ ```bash
101
+ pip install -e ".[dev]"
102
+ ruff check src/ tests/
103
+ mypy src/
104
+ pytest --cov=docges_api_py
105
+ ```
106
+
107
+ ## Migration
108
+
109
+ The library is being migrated from a sync `requests`-based client (see `wm-sync` reference code). See `docs/MIGRATION.md` for details.
110
+
111
+ Key changes:
112
+ - Replaced `requests` (sync) with `httpx.AsyncClient`
113
+ - Replaced raw `__dict__` serialization with Pydantic v2 models
114
+ - Replaced silent `return None` with typed exceptions (`AuthenticationError`, `RequestError`)
115
+ - Added configurable retries with exponential backoff
116
+
117
+ ## Project structure
118
+
119
+ ```
120
+ docges-api-py/
121
+ ├── src/docges_api_py/
122
+ │ ├── __init__.py # Exports AsyncDocGes, models (ResCat, ResFileDownload, etc.)
123
+ │ ├── client.py # AsyncDocGes client (auth + all endpoints)
124
+ │ └── models/
125
+ │ ├── auth.py # AuthRequest, AuthResponse
126
+ │ ├── document.py # Document
127
+ │ ├── requests.py # Request models (ReqUpload, ReqSearchContent, etc.)
128
+ │ ├── responses.py # Response models (ResCat, ResFileDownload, etc.)
129
+ │ └── __init__.py # Model exports
130
+ ├── tests/
131
+ │ ├── conftest.py
132
+ │ ├── test_client_auth.py
133
+ │ ├── test_initial_cats.py
134
+ │ ├── test_content_methods.py
135
+ │ ├── test_remaining_methods.py
136
+ │ ├── test_models_requests.py
137
+ │ ├── test_models_responses.py
138
+ │ ├── test_models_init.py
139
+ │ ├── test_endpoints.py
140
+ │ ├── test_retry.py
141
+ │ └── test_token_refresh.py
142
+ ├── examples/
143
+ │ └── quickstart.py
144
+ ├── docs/
145
+ │ └── MIGRATION.md
146
+ ├── pyproject.toml
147
+ ├── ruff.toml
148
+ ├── mypy.ini
149
+ └── README.md
150
+ ```
151
+
152
+ ## Contributing
153
+
154
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
@@ -0,0 +1,134 @@
1
+ # docges-api-py
2
+
3
+ Async, typed Python client for the DocGes REST API.
4
+
5
+ > **Work in progress** — bootstrapped via SDD (Spec-Driven Development).
6
+ > Phase 1-4 completed: async client with auth, retry, token refresh, and tests.
7
+ > Phase 5 completed: All core endpoints implemented.
8
+
9
+ ## Features
10
+
11
+ - ✅ Async HTTP client using `httpx`
12
+ - ✅ Typed request/response models with Pydantic v2
13
+ - ✅ Configurable retries and timeouts
14
+ - ✅ Token-based auth with automatic refresh (TTL)
15
+ - ✅ Full test coverage (pytest + respx)
16
+ - ✅ Complete DocGes API client (upload, download, search, categories)
17
+
18
+ ## Implemented endpoints
19
+
20
+ ### Auth
21
+ - `auth()` — authenticate against `/Auth/Login`
22
+
23
+ ### Content Tree
24
+ - `get_initial_cats()` — load initial categories via `/Content/LoadIniCats`
25
+ - `get_cat_info(sid)` — load category children via `/Content/LoadChilds`
26
+
27
+ ### Document Operations
28
+ - `upload_file(category_sid, file_path)` — upload via `/Content/UploadExtended`
29
+ - `download_content(sid)` — download via `/Content/Download` (returns `ResFileDownload`)
30
+ - `get_document(sid)` — deprecated wrapper (calls `download_content()`)
31
+
32
+ ### Search
33
+ - `search_content(field_values, date_values)` — search via `/Content/SearchContent`
34
+
35
+ ### Category Management
36
+ - `create_category(parent_sid, name)` — create via `/Content/CreateCategory`
37
+ - `rename_category(sid, new_name)` — rename via `/Content/RenameCategory`
38
+ - `delete_category(sid)` — delete via `/Content/DeleteCategory`
39
+
40
+ ### Document Management
41
+ - `remove_document(sid)` — remove via `/Content/RemoveDocument`
42
+ - `move_content(content_sid, destination_sid)` — move via `/Content/Move`
43
+ - `update_content(sid, erp_relation, erp_property)` — update via `/Content/Update`
44
+
45
+ ## Quick start
46
+
47
+ ```bash
48
+ pip install -e ".[dev]"
49
+ ```
50
+
51
+ ```python
52
+ import asyncio
53
+ from docges_api_py import AsyncDocGes
54
+
55
+ async def main():
56
+ async with AsyncDocGes(
57
+ "https://docges.example.com", "user", "password", "appid"
58
+ ) as client:
59
+ # Auth
60
+ auth_resp = await client.auth()
61
+ print(f"Token (partial): {auth_resp.token[:8]}...")
62
+
63
+ # Load initial categories
64
+ cats = await client.get_initial_cats()
65
+ print(f"Initial categories: {len(cats.CategoriasHijas)}")
66
+
67
+ # Search documents
68
+ results = await client.search_content(
69
+ field_values=[{"field": "name", "mode": "contains", "text": "invoice"}]
70
+ )
71
+ print(f"Search results: {len(results.results)}")
72
+
73
+ asyncio.run(main())
74
+ ```
75
+
76
+ See `examples/quickstart.py` for a more complete example.
77
+
78
+ ## Development
79
+
80
+ ```bash
81
+ pip install -e ".[dev]"
82
+ ruff check src/ tests/
83
+ mypy src/
84
+ pytest --cov=docges_api_py
85
+ ```
86
+
87
+ ## Migration
88
+
89
+ The library is being migrated from a sync `requests`-based client (see `wm-sync` reference code). See `docs/MIGRATION.md` for details.
90
+
91
+ Key changes:
92
+ - Replaced `requests` (sync) with `httpx.AsyncClient`
93
+ - Replaced raw `__dict__` serialization with Pydantic v2 models
94
+ - Replaced silent `return None` with typed exceptions (`AuthenticationError`, `RequestError`)
95
+ - Added configurable retries with exponential backoff
96
+
97
+ ## Project structure
98
+
99
+ ```
100
+ docges-api-py/
101
+ ├── src/docges_api_py/
102
+ │ ├── __init__.py # Exports AsyncDocGes, models (ResCat, ResFileDownload, etc.)
103
+ │ ├── client.py # AsyncDocGes client (auth + all endpoints)
104
+ │ └── models/
105
+ │ ├── auth.py # AuthRequest, AuthResponse
106
+ │ ├── document.py # Document
107
+ │ ├── requests.py # Request models (ReqUpload, ReqSearchContent, etc.)
108
+ │ ├── responses.py # Response models (ResCat, ResFileDownload, etc.)
109
+ │ └── __init__.py # Model exports
110
+ ├── tests/
111
+ │ ├── conftest.py
112
+ │ ├── test_client_auth.py
113
+ │ ├── test_initial_cats.py
114
+ │ ├── test_content_methods.py
115
+ │ ├── test_remaining_methods.py
116
+ │ ├── test_models_requests.py
117
+ │ ├── test_models_responses.py
118
+ │ ├── test_models_init.py
119
+ │ ├── test_endpoints.py
120
+ │ ├── test_retry.py
121
+ │ └── test_token_refresh.py
122
+ ├── examples/
123
+ │ └── quickstart.py
124
+ ├── docs/
125
+ │ └── MIGRATION.md
126
+ ├── pyproject.toml
127
+ ├── ruff.toml
128
+ ├── mypy.ini
129
+ └── README.md
130
+ ```
131
+
132
+ ## Contributing
133
+
134
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
@@ -0,0 +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.0"
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
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,69 @@
1
+ """DocGes API Python client — async, typed, tested."""
2
+
3
+ from docges_api_py.client import AsyncDocGes, Endpoints, DocGesError, AuthenticationError, RequestError
4
+ from docges_api_py.models import (
5
+ # Auth
6
+ AuthRequest,
7
+ AuthResponse,
8
+ # Document
9
+ Document,
10
+ # Requests
11
+ ReqData,
12
+ ReqAuthData,
13
+ FileUpload,
14
+ ReqUpload,
15
+ SearchFilterValue,
16
+ SearchDateValue,
17
+ ReqSearchContent,
18
+ ReqCreateCategory,
19
+ ReqRenameCategory,
20
+ ReqDeleteCategory,
21
+ ReqMoveContent,
22
+ ReqUpdateContent,
23
+ ReqRemoveContent,
24
+ # Responses
25
+ ResCat,
26
+ ResCatItem,
27
+ ResSearch,
28
+ ResSearchItem,
29
+ ResFileDownload,
30
+ FileDownloadResponse,
31
+ ResultActionModel,
32
+ )
33
+
34
+ __version__ = "0.2.0" # Phase 5: All endpoints implemented
35
+ __all__ = [
36
+ # Client
37
+ "AsyncDocGes",
38
+ "Endpoints",
39
+ "DocGesError",
40
+ "AuthenticationError",
41
+ "RequestError",
42
+ # Auth
43
+ "AuthRequest",
44
+ "AuthResponse",
45
+ # Document
46
+ "Document",
47
+ # Requests
48
+ "ReqData",
49
+ "ReqAuthData",
50
+ "FileUpload",
51
+ "ReqUpload",
52
+ "SearchFilterValue",
53
+ "SearchDateValue",
54
+ "ReqSearchContent",
55
+ "ReqCreateCategory",
56
+ "ReqRenameCategory",
57
+ "ReqDeleteCategory",
58
+ "ReqMoveContent",
59
+ "ReqUpdateContent",
60
+ "ReqRemoveContent",
61
+ # Responses
62
+ "ResCat",
63
+ "ResCatItem",
64
+ "ResSearch",
65
+ "ResSearchItem",
66
+ "ResFileDownload",
67
+ "FileDownloadResponse",
68
+ "ResultActionModel",
69
+ ]