Datasphere-API 0.0.0__tar.gz → 0.1.1__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 (51) hide show
  1. datasphere_api-0.1.1/.commitlintrc.json +7 -0
  2. datasphere_api-0.1.1/.editorconfig +27 -0
  3. datasphere_api-0.1.1/.gitattributes +2 -0
  4. datasphere_api-0.1.1/.github/dependabot.yml +11 -0
  5. datasphere_api-0.1.1/.github/workflows/ci.yml +78 -0
  6. datasphere_api-0.1.1/.github/workflows/release-please.yml +19 -0
  7. datasphere_api-0.1.1/.github/workflows/release.yml +60 -0
  8. datasphere_api-0.1.1/.gitignore +15 -0
  9. datasphere_api-0.1.1/.pre-commit-config.yaml +32 -0
  10. datasphere_api-0.1.1/.python-version +1 -0
  11. datasphere_api-0.1.1/.release-please-config.json +25 -0
  12. datasphere_api-0.1.1/.release-please-manifest.json +1 -0
  13. datasphere_api-0.1.1/.vscode/extensions.json +7 -0
  14. datasphere_api-0.1.1/.vscode/settings.json +3 -0
  15. datasphere_api-0.1.1/CHANGELOG.md +35 -0
  16. datasphere_api-0.1.1/LICENSE +21 -0
  17. datasphere_api-0.1.1/PKG-INFO +148 -0
  18. datasphere_api-0.1.1/README.md +123 -0
  19. datasphere_api-0.1.1/pyproject.toml +72 -0
  20. datasphere_api-0.1.1/src/datasphere_api/__init__.py +27 -0
  21. datasphere_api-0.1.1/src/datasphere_api/auth.py +273 -0
  22. datasphere_api-0.1.1/src/datasphere_api/client.py +219 -0
  23. datasphere_api-0.1.1/src/datasphere_api/config.py +52 -0
  24. datasphere_api-0.1.1/src/datasphere_api/exceptions.py +22 -0
  25. datasphere_api-0.1.1/src/datasphere_api/models.py +305 -0
  26. datasphere_api-0.1.1/src/datasphere_api/py.typed +0 -0
  27. datasphere_api-0.1.1/src/datasphere_api/resources/__init__.py +0 -0
  28. datasphere_api-0.1.1/src/datasphere_api/resources/analytical_models.py +631 -0
  29. datasphere_api-0.1.1/src/datasphere_api/resources/base.py +19 -0
  30. datasphere_api-0.1.1/src/datasphere_api/resources/remote_tables.py +213 -0
  31. datasphere_api-0.1.1/src/datasphere_api/resources/task_chains.py +167 -0
  32. datasphere_api-0.1.1/src/datasphere_api/resources/views.py +1248 -0
  33. datasphere_api-0.1.1/tests/__init__.py +0 -0
  34. datasphere_api-0.1.1/tests/conftest.py +30 -0
  35. datasphere_api-0.1.1/tests/test_analytical_models.py +109 -0
  36. datasphere_api-0.1.1/tests/test_auth.py +91 -0
  37. datasphere_api-0.1.1/tests/test_client.py +101 -0
  38. datasphere_api-0.1.1/tests/test_config.py +33 -0
  39. datasphere_api-0.1.1/tests/test_remote_tables.py +113 -0
  40. datasphere_api-0.1.1/tests/test_task_chains.py +80 -0
  41. datasphere_api-0.1.1/tests/test_views.py +225 -0
  42. datasphere_api-0.1.1/uv.lock +568 -0
  43. datasphere_api-0.0.0/Datasphere_API.egg-info/PKG-INFO +0 -40
  44. datasphere_api-0.0.0/Datasphere_API.egg-info/SOURCES.txt +0 -7
  45. datasphere_api-0.0.0/Datasphere_API.egg-info/dependency_links.txt +0 -1
  46. datasphere_api-0.0.0/Datasphere_API.egg-info/top_level.txt +0 -1
  47. datasphere_api-0.0.0/PKG-INFO +0 -40
  48. datasphere_api-0.0.0/README.md +0 -4
  49. datasphere_api-0.0.0/__init__.py +0 -2
  50. datasphere_api-0.0.0/setup.cfg +0 -4
  51. datasphere_api-0.0.0/setup.py +0 -49
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": ["@commitlint/config-conventional"],
3
+ "rules": {
4
+ "body-max-line-length": [0, "always", 100],
5
+ "footer-max-line-length": [0, "always", 100]
6
+ }
7
+ }
@@ -0,0 +1,27 @@
1
+ # Reference: https://editorconfig.org
2
+ # Top-most EditorConfig file
3
+ root = true
4
+
5
+ # Unix-style newlines with a newline ending every file
6
+ [*]
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+
10
+ # Default charset
11
+ charset = utf-8
12
+
13
+ # Indentation
14
+ indent_style = space
15
+ indent_size = 4
16
+
17
+ # Whitespace
18
+ trim_trailing_whitespace = true
19
+
20
+ [*.py]
21
+ max_line_length = 79
22
+
23
+ [*.{yml,yaml,json,toml}]
24
+ indent_size = 2
25
+
26
+ [*.md]
27
+ trim_trailing_whitespace = false
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
@@ -0,0 +1,11 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+
8
+ - package-ecosystem: "uv"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "weekly"
@@ -0,0 +1,78 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ concurrency:
12
+ group: ci-${{ github.ref }}
13
+ cancel-in-progress: true
14
+
15
+ jobs:
16
+ lint:
17
+ name: Lint (ruff)
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - uses: astral-sh/setup-uv@v7
22
+ with:
23
+ enable-cache: true
24
+ - run: uv sync --no-dev
25
+ - run: uv run --with ruff ruff check .
26
+
27
+ test:
28
+ name: Test (Python ${{ matrix.python-version }} on ${{ matrix.os }})
29
+ runs-on: ${{ matrix.os }}
30
+ strategy:
31
+ fail-fast: false
32
+ matrix:
33
+ os: [ubuntu-latest, macos-latest, windows-latest]
34
+ python-version: ["3.12", "3.13", "3.14"]
35
+ steps:
36
+ - uses: actions/checkout@v4
37
+ - uses: astral-sh/setup-uv@v7
38
+ with:
39
+ enable-cache: true
40
+ - run: uv python install ${{ matrix.python-version }}
41
+ - run: uv sync --python ${{ matrix.python-version }}
42
+ - run: uv run pytest
43
+
44
+ commitlint:
45
+ name: Commit messages
46
+ runs-on: ubuntu-latest
47
+ if: github.event_name == 'pull_request'
48
+ permissions:
49
+ contents: read
50
+ pull-requests: read
51
+ steps:
52
+ - uses: actions/checkout@v4
53
+ with:
54
+ fetch-depth: 0
55
+ - uses: wagoid/commitlint-github-action@v6
56
+ with:
57
+ configFile: .commitlintrc.json
58
+
59
+ branch-name:
60
+ name: Branch name
61
+ runs-on: ubuntu-latest
62
+ if: github.event_name == 'pull_request'
63
+ steps:
64
+ - name: Validate branch name
65
+ run: |
66
+ name="${{ github.head_ref }}"
67
+ # Exempt automation branches whose names follow each tool's
68
+ # own convention (Dependabot, release-please).
69
+ if [[ "$name" == dependabot/* ]] \
70
+ || [[ "$name" == release-please--* ]]; then
71
+ echo "::notice::Skipping branch-name check for bot branch '$name'"
72
+ exit 0
73
+ fi
74
+ pattern='^(feat|fix|chore|docs|style|refactor|perf|test|build|ci|revert)/[a-z0-9._-]+$'
75
+ if ! echo "$name" | grep -Eq "$pattern"; then
76
+ echo "::error::Branch '$name' must match: $pattern"
77
+ exit 1
78
+ fi
@@ -0,0 +1,19 @@
1
+ name: release-please
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+
7
+ permissions:
8
+ contents: write
9
+ pull-requests: write
10
+
11
+ jobs:
12
+ release-please:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: googleapis/release-please-action@v5
16
+ with:
17
+ token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
18
+ config-file: .release-please-config.json
19
+ manifest-file: .release-please-manifest.json
@@ -0,0 +1,60 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ concurrency:
11
+ group: release-${{ github.ref }}
12
+ cancel-in-progress: false
13
+
14
+ jobs:
15
+ build:
16
+ name: Build distributions
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: astral-sh/setup-uv@v7
21
+ - run: uv build
22
+ - uses: actions/upload-artifact@v7
23
+ with:
24
+ name: dist
25
+ path: dist/
26
+ if-no-files-found: error
27
+
28
+ publish-pypi:
29
+ name: Publish to PyPI
30
+ needs: build
31
+ runs-on: ubuntu-latest
32
+ environment:
33
+ name: pypi
34
+ url: https://pypi.org/p/Datasphere-API
35
+ permissions:
36
+ id-token: write
37
+ steps:
38
+ - uses: actions/download-artifact@v8
39
+ with:
40
+ name: dist
41
+ path: dist/
42
+ - uses: pypa/gh-action-pypi-publish@release/v1
43
+ with:
44
+ skip-existing: true
45
+
46
+ github-release:
47
+ name: Upload distributions to GitHub Release
48
+ needs: publish-pypi
49
+ runs-on: ubuntu-latest
50
+ permissions:
51
+ contents: write
52
+ steps:
53
+ - uses: actions/download-artifact@v8
54
+ with:
55
+ name: dist
56
+ path: dist/
57
+ - uses: softprops/action-gh-release@v3
58
+ with:
59
+ tag_name: ${{ github.ref_name }}
60
+ files: dist/*
@@ -0,0 +1,15 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # Tool caches
13
+ .pytest_cache/
14
+ .ruff_cache/
15
+ .coverage
@@ -0,0 +1,32 @@
1
+ default_language_version:
2
+ python: python3.12
3
+
4
+ repos:
5
+ - repo: https://github.com/pre-commit/pre-commit-hooks
6
+ rev: v5.0.0
7
+ hooks:
8
+ - id: trailing-whitespace
9
+ - id: end-of-file-fixer
10
+ - id: check-yaml
11
+ - id: check-toml
12
+ - id: check-added-large-files
13
+ - id: check-merge-conflict
14
+ - id: mixed-line-ending
15
+ args: [--fix=lf]
16
+
17
+ - repo: https://github.com/astral-sh/ruff-pre-commit
18
+ rev: v0.15.12
19
+ hooks:
20
+ - id: ruff
21
+ args: [--fix]
22
+
23
+ - repo: https://github.com/compilerla/conventional-pre-commit
24
+ rev: v3.6.0
25
+ hooks:
26
+ - id: conventional-pre-commit
27
+ stages: [commit-msg]
28
+
29
+ - repo: https://github.com/gitleaks/gitleaks
30
+ rev: v8.30.1
31
+ hooks:
32
+ - id: gitleaks
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,25 @@
1
+ {
2
+ "release-type": "python",
3
+ "bump-minor-pre-major": false,
4
+ "bump-patch-for-minor-pre-major": true,
5
+ "include-component-in-tag": false,
6
+ "pull-request-title-pattern": "chore: release ${version}",
7
+ "packages": {
8
+ ".": {
9
+ "package-name": "Datasphere-API",
10
+ "changelog-path": "CHANGELOG.md"
11
+ }
12
+ },
13
+ "changelog-sections": [
14
+ { "type": "feat", "section": "Features" },
15
+ { "type": "fix", "section": "Bug Fixes" },
16
+ { "type": "perf", "section": "Performance" },
17
+ { "type": "refactor", "section": "Refactoring" },
18
+ { "type": "docs", "section": "Documentation" },
19
+ { "type": "ci", "section": "Continuous Integration", "hidden": true },
20
+ { "type": "chore", "section": "Misc", "hidden": true },
21
+ { "type": "test", "section": "Tests", "hidden": true },
22
+ { "type": "style", "section": "Style", "hidden": true },
23
+ { "type": "build", "section": "Build", "hidden": true }
24
+ ]
25
+ }
@@ -0,0 +1 @@
1
+ {".":"0.1.1"}
@@ -0,0 +1,7 @@
1
+ {
2
+ "recommendations": [
3
+ "charliermarsh.ruff",
4
+ "editorconfig.editorconfig",
5
+ "vivaxy.vscode-conventional-commits"
6
+ ]
7
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "editor.rulers": [79]
3
+ }
@@ -0,0 +1,35 @@
1
+ # Changelog
2
+
3
+ ## [0.1.1](https://github.com/peterschwps/SAP-Datasphere-API/compare/v0.1.0...v0.1.1) (2026-07-07)
4
+
5
+
6
+ ### Documentation
7
+
8
+ * added readme badges ([7a96367](https://github.com/peterschwps/SAP-Datasphere-API/commit/7a96367516c011ad859063ef2aab9c37ee53a44e))
9
+
10
+ ## 0.1.0 (2026-07-07)
11
+
12
+
13
+ ### Features
14
+
15
+ * added analytical models resource ([b8a939f](https://github.com/peterschwps/SAP-Datasphere-API/commit/b8a939f54c54f058f5896999e904d46f60bf5d44))
16
+ * added async datasphere client ([0c76823](https://github.com/peterschwps/SAP-Datasphere-API/commit/0c76823581056c23b6d3b5583b0db623552e57ad))
17
+ * added configuration and exceptions ([952a883](https://github.com/peterschwps/SAP-Datasphere-API/commit/952a883d42302361cf9696f042e002fe1e1c59d2))
18
+ * added data models ([6bd54ca](https://github.com/peterschwps/SAP-Datasphere-API/commit/6bd54ca6bee10a3116b1b6418f974a520e0e4dbb))
19
+ * added incremental result callbacks to all view batch methods ([cfa3bc7](https://github.com/peterschwps/SAP-Datasphere-API/commit/cfa3bc78235b28820af3ab49d1fe5f8dc244bbcc))
20
+ * added remote tables resource ([c30d832](https://github.com/peterschwps/SAP-Datasphere-API/commit/c30d832754c2ffef77b15ac41bb9b3e7dfe92ca7))
21
+ * added task chains resource ([024e3cd](https://github.com/peterschwps/SAP-Datasphere-API/commit/024e3cdfe25fab2e5a87867ab5584374d43313d1))
22
+ * added token store and oauth authentication ([9fc89b3](https://github.com/peterschwps/SAP-Datasphere-API/commit/9fc89b30deb1662a24938fabb32754d1e642b6ee))
23
+ * added views resource ([0e38058](https://github.com/peterschwps/SAP-Datasphere-API/commit/0e380581fe535ea0d3bb303fe2b2d4d40c7fe598))
24
+ * exported public api ([1a7bb5d](https://github.com/peterschwps/SAP-Datasphere-API/commit/1a7bb5dfbb99bd498ac4cd6bf7bdbee33f42dfeb))
25
+
26
+
27
+ ### Documentation
28
+
29
+ * added readme ([cab9a3d](https://github.com/peterschwps/SAP-Datasphere-API/commit/cab9a3d3f06d2cdad455d6823ea23e707ce29572))
30
+ * updated cli repository link ([9c83f95](https://github.com/peterschwps/SAP-Datasphere-API/commit/9c83f953e07b2e361e42649fd957a6f6367fa893))
31
+
32
+
33
+ ### Continuous Integration
34
+
35
+ * added release-please and pypi release pipeline ([e11b56e](https://github.com/peterschwps/SAP-Datasphere-API/commit/e11b56e1be80db58fbf4edd843cf210be9f2e6f2))
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Peter Schwips
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,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: Datasphere-API
3
+ Version: 0.1.1
4
+ Summary: Unofficial async Python client for the SAP Datasphere automation APIs.
5
+ Project-URL: Homepage, https://github.com/peterschwps/SAP-Datasphere-API
6
+ Project-URL: Repository, https://github.com/peterschwps/SAP-Datasphere-API
7
+ Project-URL: Issues, https://github.com/peterschwps/SAP-Datasphere-API/issues
8
+ Author: Peter Schwips
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: API,Async,Automation,Client,Datasphere,SAP
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.12
21
+ Requires-Dist: httpx>=0.28.1
22
+ Requires-Dist: platformdirs>=4.4.0
23
+ Requires-Dist: playwright>=1.54.0
24
+ Description-Content-Type: text/markdown
25
+
26
+ # Datasphere-API
27
+
28
+ [![CI](https://github.com/peterschwps/SAP-Datasphere-API/actions/workflows/ci.yml/badge.svg)](https://github.com/peterschwps/SAP-Datasphere-API/actions/workflows/ci.yml)
29
+ [![PyPI](https://img.shields.io/pypi/v/Datasphere-API)](https://pypi.org/project/Datasphere-API/)
30
+ [![Python](https://img.shields.io/pypi/pyversions/Datasphere-API)](https://pypi.org/project/Datasphere-API/)
31
+
32
+ Unofficial async Python client for the SAP Datasphere automation APIs.
33
+ This library powers the
34
+ [SAP-Datasphere-CLI](https://github.com/peterschwps/SAP-Datasphere-CLI)
35
+ and can be used to build your own automations (e.g. MCP servers or
36
+ scheduled jobs).
37
+
38
+ > [!NOTE]
39
+ > This project is not affiliated with, endorsed by, or supported by SAP.
40
+ > It uses the same internal HTTP endpoints as the SAP Datasphere web UI,
41
+ > which may change without notice.
42
+
43
+ ## Features
44
+
45
+ - **Views**: export view analytics (persistence candidates), search
46
+ views by attribute, persist/unpersist views, create/remove partitions,
47
+ lock/unlock partitions.
48
+ - **Remote Tables**: list tables with statistics information,
49
+ create/update statistics (Record Count / Simple / Histogram), refresh
50
+ statistics.
51
+ - **Task Chains**: run task chains and wait for their completion.
52
+ - **Analytical Models**: export models with all their views (optionally
53
+ per space), measure view persistence runtimes.
54
+ - **OAuth login included**: interactive authorization code flow via a
55
+ real Chrome/Edge window (Playwright) with automatic token refresh and
56
+ a shared token cache.
57
+
58
+ ## Installation
59
+
60
+ ```bash
61
+ uv add datasphere-api
62
+ # or
63
+ pip install datasphere-api
64
+ ```
65
+
66
+ The interactive login drives an installed Chrome or Edge browser via
67
+ Playwright channels — a regular Chrome/Edge installation is required,
68
+ no `playwright install` download is needed.
69
+
70
+ ## Quickstart
71
+
72
+ ```python
73
+ import asyncio
74
+
75
+ from datasphere_api import DatasphereClient, DatasphereConfig
76
+
77
+
78
+ async def main() -> None:
79
+ config = DatasphereConfig(
80
+ base_url="https://example.eu10.hcs.cloud.sap",
81
+ authorization_url=(
82
+ "https://example.authentication.eu10.hana.ondemand.com"
83
+ "/oauth/authorize"
84
+ ),
85
+ token_url=(
86
+ "https://example.authentication.eu10.hana.ondemand.com"
87
+ "/oauth/token"
88
+ ),
89
+ client_id="...",
90
+ client_secret="...",
91
+ )
92
+ client = DatasphereClient(config)
93
+ try:
94
+ await client.login()
95
+ results = await client.task_chains.run(
96
+ chains=[{"entity": "MY_CHAIN", "space": "MY_SPACE"}],
97
+ )
98
+ print(results)
99
+ finally:
100
+ await client.aclose()
101
+
102
+
103
+ asyncio.run(main())
104
+ ```
105
+
106
+ The URLs and credentials can be found in your tenant under
107
+ System > Administration (Tenant Links and App Integration). The OAuth
108
+ client has to be of type "Interactive Usage" with the redirect URI
109
+ `http://localhost:8080`.
110
+
111
+ ## Authentication
112
+
113
+ `client.login()` first tries to refresh cached tokens from the token
114
+ store (`session.json` in the user data directory of `Datasphere`). If no
115
+ tokens are cached or the refresh fails, a browser window opens for the
116
+ interactive login. All consumers of this library share the same token
117
+ cache, so a login in one tool also benefits the others.
118
+
119
+ ## Layered results
120
+
121
+ The library returns data on two levels:
122
+
123
+ - **Curated results** (recommended): high-level operations like
124
+ `views.persist_views()` or `remote_tables.create_statistics()` return
125
+ small, typed result structures (see `datasphere_api.models`). Their
126
+ keys intentionally match the CSV/JSON exports of the CLI.
127
+ - **Raw payloads**: low-level fetchers like `views.get_all_views()` or
128
+ `remote_tables.get_all_tables()` return the parsed API payload, typed
129
+ with broad TypedDicts. For anything not covered, `client.session` is
130
+ the authenticated `httpx.AsyncClient` — you can call any endpoint
131
+ directly.
132
+
133
+ Long-running batch operations accept an `on_result`/`on_update`
134
+ callback that is invoked after every finished item, so consumers can
135
+ save intermediate results during runs that take hours.
136
+
137
+ ## Development
138
+
139
+ ```bash
140
+ uv sync
141
+ uv run pytest
142
+ uv run ruff check .
143
+ uv run pyright
144
+ ```
145
+
146
+ ## License
147
+
148
+ [MIT](LICENSE)
@@ -0,0 +1,123 @@
1
+ # Datasphere-API
2
+
3
+ [![CI](https://github.com/peterschwps/SAP-Datasphere-API/actions/workflows/ci.yml/badge.svg)](https://github.com/peterschwps/SAP-Datasphere-API/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/Datasphere-API)](https://pypi.org/project/Datasphere-API/)
5
+ [![Python](https://img.shields.io/pypi/pyversions/Datasphere-API)](https://pypi.org/project/Datasphere-API/)
6
+
7
+ Unofficial async Python client for the SAP Datasphere automation APIs.
8
+ This library powers the
9
+ [SAP-Datasphere-CLI](https://github.com/peterschwps/SAP-Datasphere-CLI)
10
+ and can be used to build your own automations (e.g. MCP servers or
11
+ scheduled jobs).
12
+
13
+ > [!NOTE]
14
+ > This project is not affiliated with, endorsed by, or supported by SAP.
15
+ > It uses the same internal HTTP endpoints as the SAP Datasphere web UI,
16
+ > which may change without notice.
17
+
18
+ ## Features
19
+
20
+ - **Views**: export view analytics (persistence candidates), search
21
+ views by attribute, persist/unpersist views, create/remove partitions,
22
+ lock/unlock partitions.
23
+ - **Remote Tables**: list tables with statistics information,
24
+ create/update statistics (Record Count / Simple / Histogram), refresh
25
+ statistics.
26
+ - **Task Chains**: run task chains and wait for their completion.
27
+ - **Analytical Models**: export models with all their views (optionally
28
+ per space), measure view persistence runtimes.
29
+ - **OAuth login included**: interactive authorization code flow via a
30
+ real Chrome/Edge window (Playwright) with automatic token refresh and
31
+ a shared token cache.
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ uv add datasphere-api
37
+ # or
38
+ pip install datasphere-api
39
+ ```
40
+
41
+ The interactive login drives an installed Chrome or Edge browser via
42
+ Playwright channels — a regular Chrome/Edge installation is required,
43
+ no `playwright install` download is needed.
44
+
45
+ ## Quickstart
46
+
47
+ ```python
48
+ import asyncio
49
+
50
+ from datasphere_api import DatasphereClient, DatasphereConfig
51
+
52
+
53
+ async def main() -> None:
54
+ config = DatasphereConfig(
55
+ base_url="https://example.eu10.hcs.cloud.sap",
56
+ authorization_url=(
57
+ "https://example.authentication.eu10.hana.ondemand.com"
58
+ "/oauth/authorize"
59
+ ),
60
+ token_url=(
61
+ "https://example.authentication.eu10.hana.ondemand.com"
62
+ "/oauth/token"
63
+ ),
64
+ client_id="...",
65
+ client_secret="...",
66
+ )
67
+ client = DatasphereClient(config)
68
+ try:
69
+ await client.login()
70
+ results = await client.task_chains.run(
71
+ chains=[{"entity": "MY_CHAIN", "space": "MY_SPACE"}],
72
+ )
73
+ print(results)
74
+ finally:
75
+ await client.aclose()
76
+
77
+
78
+ asyncio.run(main())
79
+ ```
80
+
81
+ The URLs and credentials can be found in your tenant under
82
+ System > Administration (Tenant Links and App Integration). The OAuth
83
+ client has to be of type "Interactive Usage" with the redirect URI
84
+ `http://localhost:8080`.
85
+
86
+ ## Authentication
87
+
88
+ `client.login()` first tries to refresh cached tokens from the token
89
+ store (`session.json` in the user data directory of `Datasphere`). If no
90
+ tokens are cached or the refresh fails, a browser window opens for the
91
+ interactive login. All consumers of this library share the same token
92
+ cache, so a login in one tool also benefits the others.
93
+
94
+ ## Layered results
95
+
96
+ The library returns data on two levels:
97
+
98
+ - **Curated results** (recommended): high-level operations like
99
+ `views.persist_views()` or `remote_tables.create_statistics()` return
100
+ small, typed result structures (see `datasphere_api.models`). Their
101
+ keys intentionally match the CSV/JSON exports of the CLI.
102
+ - **Raw payloads**: low-level fetchers like `views.get_all_views()` or
103
+ `remote_tables.get_all_tables()` return the parsed API payload, typed
104
+ with broad TypedDicts. For anything not covered, `client.session` is
105
+ the authenticated `httpx.AsyncClient` — you can call any endpoint
106
+ directly.
107
+
108
+ Long-running batch operations accept an `on_result`/`on_update`
109
+ callback that is invoked after every finished item, so consumers can
110
+ save intermediate results during runs that take hours.
111
+
112
+ ## Development
113
+
114
+ ```bash
115
+ uv sync
116
+ uv run pytest
117
+ uv run ruff check .
118
+ uv run pyright
119
+ ```
120
+
121
+ ## License
122
+
123
+ [MIT](LICENSE)