data-pebbles 0.0.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 (59) hide show
  1. data_pebbles-0.0.1/PKG-INFO +143 -0
  2. data_pebbles-0.0.1/README.md +130 -0
  3. data_pebbles-0.0.1/pyproject.toml +34 -0
  4. data_pebbles-0.0.1/src/data_pebbles/__init__.py +10 -0
  5. data_pebbles-0.0.1/src/data_pebbles/client/__init__.py +8 -0
  6. data_pebbles-0.0.1/src/data_pebbles/client/api/__init__.py +1 -0
  7. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_bronze_layer/__init__.py +1 -0
  8. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_bronze_layer/activate_version_bronze_source_id_versions_version_patch.py +172 -0
  9. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_bronze_layer/create_source_bronze_post.py +164 -0
  10. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_bronze_layer/delete_source_bronze_source_id_delete.py +158 -0
  11. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_bronze_layer/delete_version_bronze_source_id_versions_version_delete.py +172 -0
  12. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_bronze_layer/download_version_bronze_source_id_versions_version_get.py +172 -0
  13. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_bronze_layer/get_source_bronze_source_id_get.py +160 -0
  14. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_bronze_layer/list_sources_bronze_get.py +132 -0
  15. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_bronze_layer/list_versions_bronze_source_id_versions_get.py +165 -0
  16. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_bronze_layer/update_source_bronze_source_id_patch.py +182 -0
  17. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_bronze_layer/upload_version_bronze_source_id_versions_post.py +180 -0
  18. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_gold_layer/__init__.py +1 -0
  19. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_gold_layer/create_source_gold_post.py +164 -0
  20. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_gold_layer/delete_source_gold_source_id_delete.py +158 -0
  21. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_gold_layer/download_version_gold_source_id_versions_version_get.py +172 -0
  22. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_gold_layer/get_source_gold_source_id_get.py +160 -0
  23. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_gold_layer/list_sources_gold_get.py +132 -0
  24. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_gold_layer/list_versions_gold_source_id_versions_get.py +165 -0
  25. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_gold_layer/update_source_gold_source_id_patch.py +182 -0
  26. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_gold_layer/upload_version_gold_source_id_versions_post.py +202 -0
  27. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_silver_layer/__init__.py +1 -0
  28. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_silver_layer/create_source_silver_post.py +164 -0
  29. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_silver_layer/delete_source_silver_source_id_delete.py +158 -0
  30. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_silver_layer/download_version_silver_source_id_versions_version_get.py +172 -0
  31. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_silver_layer/get_source_silver_source_id_get.py +160 -0
  32. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_silver_layer/list_sources_silver_get.py +132 -0
  33. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_silver_layer/list_versions_silver_source_id_versions_get.py +165 -0
  34. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_silver_layer/update_source_silver_source_id_patch.py +182 -0
  35. data_pebbles-0.0.1/src/data_pebbles/client/api/api_endpoints_for_interacting_with_the_silver_layer/upload_version_silver_source_id_versions_post.py +200 -0
  36. data_pebbles-0.0.1/src/data_pebbles/client/client.py +282 -0
  37. data_pebbles-0.0.1/src/data_pebbles/client/errors.py +16 -0
  38. data_pebbles-0.0.1/src/data_pebbles/client/models/__init__.py +47 -0
  39. data_pebbles-0.0.1/src/data_pebbles/client/models/body_upload_version_bronze_source_id_versions_post.py +73 -0
  40. data_pebbles-0.0.1/src/data_pebbles/client/models/body_upload_version_gold_source_id_versions_post.py +73 -0
  41. data_pebbles-0.0.1/src/data_pebbles/client/models/body_upload_version_silver_source_id_versions_post.py +73 -0
  42. data_pebbles-0.0.1/src/data_pebbles/client/models/create_gold_source_request.py +61 -0
  43. data_pebbles-0.0.1/src/data_pebbles/client/models/create_silver_source_request.py +61 -0
  44. data_pebbles-0.0.1/src/data_pebbles/client/models/create_source_request.py +61 -0
  45. data_pebbles-0.0.1/src/data_pebbles/client/models/gold_lineage_response.py +93 -0
  46. data_pebbles-0.0.1/src/data_pebbles/client/models/gold_metadata_response.py +77 -0
  47. data_pebbles-0.0.1/src/data_pebbles/client/models/http_validation_error.py +79 -0
  48. data_pebbles-0.0.1/src/data_pebbles/client/models/metadata_response.py +77 -0
  49. data_pebbles-0.0.1/src/data_pebbles/client/models/silver_lineage_response.py +93 -0
  50. data_pebbles-0.0.1/src/data_pebbles/client/models/silver_metadata_response.py +77 -0
  51. data_pebbles-0.0.1/src/data_pebbles/client/models/update_gold_source_request.py +61 -0
  52. data_pebbles-0.0.1/src/data_pebbles/client/models/update_silver_source_request.py +61 -0
  53. data_pebbles-0.0.1/src/data_pebbles/client/models/update_source_request.py +61 -0
  54. data_pebbles-0.0.1/src/data_pebbles/client/models/validation_error.py +123 -0
  55. data_pebbles-0.0.1/src/data_pebbles/client/models/validation_error_context.py +46 -0
  56. data_pebbles-0.0.1/src/data_pebbles/client/models/version_response.py +109 -0
  57. data_pebbles-0.0.1/src/data_pebbles/client/types.py +54 -0
  58. data_pebbles-0.0.1/src/data_pebbles/py.typed +0 -0
  59. data_pebbles-0.0.1/src/data_pebbles/sdk.py +572 -0
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.3
2
+ Name: data-pebbles
3
+ Version: 0.0.1
4
+ Summary: A Python library for interacting with the open source data catalog Data Pebbles.
5
+ Author: Leon David Zipp
6
+ Author-email: Leon David Zipp <leondavidzipp@proton.me>
7
+ Requires-Dist: attrs>=24.2.0
8
+ Requires-Dist: httpx>=0.27.0
9
+ Requires-Dist: mlflow>=2.0.0
10
+ Requires-Dist: polars>=1.0.0
11
+ Requires-Python: >=3.13
12
+ Description-Content-Type: text/markdown
13
+
14
+ # Data Pebbles SDK
15
+
16
+ Python SDK for the [Data Pebbles](https://github.com/LeonDavidZipp/data-pebbles) platform — manage data across bronze, silver, and gold layers with built-in lineage tracking.
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ pip install data-pebbles
22
+ ```
23
+
24
+ Requires Python 3.13+. Dependencies: `polars`, `httpx`, `mlflow`.
25
+
26
+ ## Quick Start
27
+
28
+ ```python
29
+ from data_pebbles import DataPebbles
30
+
31
+ dp = DataPebbles("http://localhost:8000", token="your-token")
32
+
33
+ # Bronze: upload raw files (.csv, .parquet, .json, .xlsx)
34
+ dp.bronze.create_source("raw_sales")
35
+ dp.bronze.upload(1, file_path="sales.csv")
36
+ raw = dp.bronze.download(1)
37
+
38
+ # Silver: cleaned LazyFrames with lineage
39
+ dp.silver.create_source("clean_sales")
40
+ dp.silver.upload(2, lf, from_source_id=1)
41
+ lf = dp.silver.download(2)
42
+
43
+ # Gold: aggregated LazyFrames with multi-source lineage
44
+ dp.gold.create_source("sales_summary")
45
+ dp.gold.upload(3, lf, from_source_ids=[2])
46
+ ```
47
+
48
+ The client can be used as a context manager:
49
+
50
+ ```python
51
+ with DataPebbles("http://localhost:8000") as dp:
52
+ sources = dp.bronze.list_sources()
53
+ ```
54
+
55
+ ## Layers
56
+
57
+ ### Bronze
58
+
59
+ Stores raw, unprocessed files. Only `.csv`, `.parquet`, `.json`, and `.xlsx` files are accepted.
60
+
61
+ | Method | Description |
62
+ | --- | --- |
63
+ | `create_source(name)` | Create a new source |
64
+ | `list_sources()` | List all sources |
65
+ | `get_source(source_id)` | Get source metadata |
66
+ | `update_source(source_id, name)` | Rename a source |
67
+ | `delete_source(source_id)` | Delete a source |
68
+ | `list_versions(source_id)` | List all versions |
69
+ | `upload(source_id, *, file_path=None, data=None, file_name="upload")` | Upload a file by path or raw bytes |
70
+ | `download(source_id, *, version=None)` | Download raw bytes (defaults to latest version) |
71
+ | `activate_version(source_id, version)` | Set a version as active |
72
+ | `delete_version(source_id, version)` | Delete a version |
73
+
74
+ ### Silver
75
+
76
+ Stores cleaned, structured data as Parquet. Works with Polars DataFrames/LazyFrames and tracks lineage back to bronze.
77
+
78
+ | Method | Description |
79
+ | --- | --- |
80
+ | `create_source(name)` | Create a new source |
81
+ | `list_sources()` | List all sources |
82
+ | `get_source(source_id)` | Get source metadata |
83
+ | `update_source(source_id, name)` | Rename a source |
84
+ | `delete_source(source_id)` | Delete a source |
85
+ | `list_versions(source_id)` | List all versions with lineage |
86
+ | `upload(source_id, data, *, from_source_id)` | Upload a DataFrame/LazyFrame with bronze lineage |
87
+ | `download(source_id, *, version=None)` | Download as a Polars LazyFrame |
88
+
89
+ ### Gold
90
+
91
+ Stores aggregated, business-ready data as Parquet. Supports multi-source lineage from silver.
92
+
93
+ | Method | Description |
94
+ | --- | --- |
95
+ | `create_source(name)` | Create a new source |
96
+ | `list_sources()` | List all sources |
97
+ | `get_source(source_id)` | Get source metadata |
98
+ | `update_source(source_id, name)` | Rename a source |
99
+ | `delete_source(source_id)` | Delete a source |
100
+ | `list_versions(source_id)` | List all versions with lineage |
101
+ | `upload(source_id, data, *, from_source_ids)` | Upload a DataFrame/LazyFrame with silver lineage |
102
+ | `download(source_id, *, version=None)` | Download as a Polars LazyFrame |
103
+
104
+ ## Transform Decorators
105
+
106
+ Automate downloading, transforming, and uploading data between layers with lineage tracking.
107
+
108
+ ### silver_transform
109
+
110
+ Transforms bronze → silver. The decorator auto-parses bronze data into a `LazyFrame` based on the original file extension. The decorated function receives a `LazyFrame` and returns a `LazyFrame`.
111
+
112
+ ```python
113
+ @dp.silver_transform(target_id=2, from_bronze_id=1)
114
+ def clean(lf: pl.LazyFrame) -> pl.LazyFrame:
115
+ return lf.filter(pl.col("amount") > 0)
116
+
117
+ clean() # uses latest bronze version
118
+ clean(version=5) # uses a specific bronze version
119
+ ```
120
+
121
+ For CSV files with a non-standard delimiter, use `csv_separator`:
122
+
123
+ ```python
124
+ @dp.silver_transform(target_id=2, from_bronze_id=1, csv_separator=";")
125
+ def clean_eu(lf: pl.LazyFrame) -> pl.LazyFrame:
126
+ return lf.filter(pl.col("amount") > 0)
127
+ ```
128
+
129
+ ### gold_transform
130
+
131
+ Transforms silver → gold. The decorated function receives a dict mapping silver source IDs to their LazyFrames and returns a `LazyFrame`.
132
+
133
+ ```python
134
+ @dp.gold_transform(target_id=3, from_silver_ids=[1, 2])
135
+ def aggregate(sources: dict[int, pl.LazyFrame]) -> pl.LazyFrame:
136
+ return (
137
+ pl.concat(sources.values())
138
+ .group_by("category")
139
+ .agg(pl.sum("amount"))
140
+ )
141
+
142
+ aggregate()
143
+ ```
@@ -0,0 +1,130 @@
1
+ # Data Pebbles SDK
2
+
3
+ Python SDK for the [Data Pebbles](https://github.com/LeonDavidZipp/data-pebbles) platform — manage data across bronze, silver, and gold layers with built-in lineage tracking.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install data-pebbles
9
+ ```
10
+
11
+ Requires Python 3.13+. Dependencies: `polars`, `httpx`, `mlflow`.
12
+
13
+ ## Quick Start
14
+
15
+ ```python
16
+ from data_pebbles import DataPebbles
17
+
18
+ dp = DataPebbles("http://localhost:8000", token="your-token")
19
+
20
+ # Bronze: upload raw files (.csv, .parquet, .json, .xlsx)
21
+ dp.bronze.create_source("raw_sales")
22
+ dp.bronze.upload(1, file_path="sales.csv")
23
+ raw = dp.bronze.download(1)
24
+
25
+ # Silver: cleaned LazyFrames with lineage
26
+ dp.silver.create_source("clean_sales")
27
+ dp.silver.upload(2, lf, from_source_id=1)
28
+ lf = dp.silver.download(2)
29
+
30
+ # Gold: aggregated LazyFrames with multi-source lineage
31
+ dp.gold.create_source("sales_summary")
32
+ dp.gold.upload(3, lf, from_source_ids=[2])
33
+ ```
34
+
35
+ The client can be used as a context manager:
36
+
37
+ ```python
38
+ with DataPebbles("http://localhost:8000") as dp:
39
+ sources = dp.bronze.list_sources()
40
+ ```
41
+
42
+ ## Layers
43
+
44
+ ### Bronze
45
+
46
+ Stores raw, unprocessed files. Only `.csv`, `.parquet`, `.json`, and `.xlsx` files are accepted.
47
+
48
+ | Method | Description |
49
+ | --- | --- |
50
+ | `create_source(name)` | Create a new source |
51
+ | `list_sources()` | List all sources |
52
+ | `get_source(source_id)` | Get source metadata |
53
+ | `update_source(source_id, name)` | Rename a source |
54
+ | `delete_source(source_id)` | Delete a source |
55
+ | `list_versions(source_id)` | List all versions |
56
+ | `upload(source_id, *, file_path=None, data=None, file_name="upload")` | Upload a file by path or raw bytes |
57
+ | `download(source_id, *, version=None)` | Download raw bytes (defaults to latest version) |
58
+ | `activate_version(source_id, version)` | Set a version as active |
59
+ | `delete_version(source_id, version)` | Delete a version |
60
+
61
+ ### Silver
62
+
63
+ Stores cleaned, structured data as Parquet. Works with Polars DataFrames/LazyFrames and tracks lineage back to bronze.
64
+
65
+ | Method | Description |
66
+ | --- | --- |
67
+ | `create_source(name)` | Create a new source |
68
+ | `list_sources()` | List all sources |
69
+ | `get_source(source_id)` | Get source metadata |
70
+ | `update_source(source_id, name)` | Rename a source |
71
+ | `delete_source(source_id)` | Delete a source |
72
+ | `list_versions(source_id)` | List all versions with lineage |
73
+ | `upload(source_id, data, *, from_source_id)` | Upload a DataFrame/LazyFrame with bronze lineage |
74
+ | `download(source_id, *, version=None)` | Download as a Polars LazyFrame |
75
+
76
+ ### Gold
77
+
78
+ Stores aggregated, business-ready data as Parquet. Supports multi-source lineage from silver.
79
+
80
+ | Method | Description |
81
+ | --- | --- |
82
+ | `create_source(name)` | Create a new source |
83
+ | `list_sources()` | List all sources |
84
+ | `get_source(source_id)` | Get source metadata |
85
+ | `update_source(source_id, name)` | Rename a source |
86
+ | `delete_source(source_id)` | Delete a source |
87
+ | `list_versions(source_id)` | List all versions with lineage |
88
+ | `upload(source_id, data, *, from_source_ids)` | Upload a DataFrame/LazyFrame with silver lineage |
89
+ | `download(source_id, *, version=None)` | Download as a Polars LazyFrame |
90
+
91
+ ## Transform Decorators
92
+
93
+ Automate downloading, transforming, and uploading data between layers with lineage tracking.
94
+
95
+ ### silver_transform
96
+
97
+ Transforms bronze → silver. The decorator auto-parses bronze data into a `LazyFrame` based on the original file extension. The decorated function receives a `LazyFrame` and returns a `LazyFrame`.
98
+
99
+ ```python
100
+ @dp.silver_transform(target_id=2, from_bronze_id=1)
101
+ def clean(lf: pl.LazyFrame) -> pl.LazyFrame:
102
+ return lf.filter(pl.col("amount") > 0)
103
+
104
+ clean() # uses latest bronze version
105
+ clean(version=5) # uses a specific bronze version
106
+ ```
107
+
108
+ For CSV files with a non-standard delimiter, use `csv_separator`:
109
+
110
+ ```python
111
+ @dp.silver_transform(target_id=2, from_bronze_id=1, csv_separator=";")
112
+ def clean_eu(lf: pl.LazyFrame) -> pl.LazyFrame:
113
+ return lf.filter(pl.col("amount") > 0)
114
+ ```
115
+
116
+ ### gold_transform
117
+
118
+ Transforms silver → gold. The decorated function receives a dict mapping silver source IDs to their LazyFrames and returns a `LazyFrame`.
119
+
120
+ ```python
121
+ @dp.gold_transform(target_id=3, from_silver_ids=[1, 2])
122
+ def aggregate(sources: dict[int, pl.LazyFrame]) -> pl.LazyFrame:
123
+ return (
124
+ pl.concat(sources.values())
125
+ .group_by("category")
126
+ .agg(pl.sum("amount"))
127
+ )
128
+
129
+ aggregate()
130
+ ```
@@ -0,0 +1,34 @@
1
+ [project]
2
+ name = "data-pebbles"
3
+ version = "0.0.1"
4
+ description = "A Python library for interacting with the open source data catalog Data Pebbles."
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Leon David Zipp", email = "leondavidzipp@proton.me" }
8
+ ]
9
+ requires-python = ">=3.13"
10
+ dependencies = [
11
+ "attrs>=24.2.0",
12
+ "httpx>=0.27.0",
13
+ "mlflow>=2.0.0",
14
+ "polars>=1.0.0",
15
+ ]
16
+
17
+ [build-system]
18
+ requires = ["uv_build>=0.9.26,<0.10.0"]
19
+ build-backend = "uv_build"
20
+
21
+ [tool.pyright]
22
+ exclude = ["src/data_pebbles/client", ".venv", "**/__pycache__", "tests"]
23
+
24
+ [tool.mypy]
25
+ exclude = ["src/data_pebbles/client", ".venv", "**/__pycache__", "tests"]
26
+
27
+ [tool.ruff]
28
+ exclude = ["src/data_pebbles/client"]
29
+
30
+ [dependency-groups]
31
+ dev = [
32
+ "pytest>=9.0.2",
33
+ "ruff>=0.15.0",
34
+ ]
@@ -0,0 +1,10 @@
1
+ import mlflow
2
+
3
+ from data_pebbles.sdk import (
4
+ BronzeLayer,
5
+ DataPebbles,
6
+ GoldLayer,
7
+ SilverLayer,
8
+ )
9
+
10
+ __all__ = ["DataPebbles", "BronzeLayer", "SilverLayer", "GoldLayer", "mlflow"]
@@ -0,0 +1,8 @@
1
+ """A client library for accessing FastAPI"""
2
+
3
+ from .client import AuthenticatedClient, Client
4
+
5
+ __all__ = (
6
+ "AuthenticatedClient",
7
+ "Client",
8
+ )
@@ -0,0 +1 @@
1
+ """Contains methods for accessing the API"""
@@ -0,0 +1 @@
1
+ """Contains endpoint functions for accessing the API"""
@@ -0,0 +1,172 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+ from urllib.parse import quote
4
+
5
+ import httpx
6
+
7
+ from ... import errors
8
+ from ...client import AuthenticatedClient, Client
9
+ from ...models.http_validation_error import HTTPValidationError
10
+ from ...types import Response
11
+
12
+
13
+ def _get_kwargs(
14
+ source_id: int,
15
+ version: int,
16
+ ) -> dict[str, Any]:
17
+ _kwargs: dict[str, Any] = {
18
+ "method": "patch",
19
+ "url": "/bronze/{source_id}/versions/{version}".format(
20
+ source_id=quote(str(source_id), safe=""),
21
+ version=quote(str(version), safe=""),
22
+ ),
23
+ }
24
+
25
+ return _kwargs
26
+
27
+
28
+ def _parse_response(
29
+ *, client: AuthenticatedClient | Client, response: httpx.Response
30
+ ) -> Any | HTTPValidationError | None:
31
+ if response.status_code == 200:
32
+ response_200 = response.json()
33
+ return response_200
34
+
35
+ if response.status_code == 422:
36
+ response_422 = HTTPValidationError.from_dict(response.json())
37
+
38
+ return response_422
39
+
40
+ if client.raise_on_unexpected_status:
41
+ raise errors.UnexpectedStatus(response.status_code, response.content)
42
+ else:
43
+ return None
44
+
45
+
46
+ def _build_response(
47
+ *, client: AuthenticatedClient | Client, response: httpx.Response
48
+ ) -> Response[Any | HTTPValidationError]:
49
+ return Response(
50
+ status_code=HTTPStatus(response.status_code),
51
+ content=response.content,
52
+ headers=response.headers,
53
+ parsed=_parse_response(client=client, response=response),
54
+ )
55
+
56
+
57
+ def sync_detailed(
58
+ source_id: int,
59
+ version: int,
60
+ *,
61
+ client: AuthenticatedClient | Client,
62
+ ) -> Response[Any | HTTPValidationError]:
63
+ """Activate Version
64
+
65
+ Args:
66
+ source_id (int):
67
+ version (int):
68
+
69
+ Raises:
70
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
71
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
72
+
73
+ Returns:
74
+ Response[Any | HTTPValidationError]
75
+ """
76
+
77
+ kwargs = _get_kwargs(
78
+ source_id=source_id,
79
+ version=version,
80
+ )
81
+
82
+ response = client.get_httpx_client().request(
83
+ **kwargs,
84
+ )
85
+
86
+ return _build_response(client=client, response=response)
87
+
88
+
89
+ def sync(
90
+ source_id: int,
91
+ version: int,
92
+ *,
93
+ client: AuthenticatedClient | Client,
94
+ ) -> Any | HTTPValidationError | None:
95
+ """Activate Version
96
+
97
+ Args:
98
+ source_id (int):
99
+ version (int):
100
+
101
+ Raises:
102
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
103
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
104
+
105
+ Returns:
106
+ Any | HTTPValidationError
107
+ """
108
+
109
+ return sync_detailed(
110
+ source_id=source_id,
111
+ version=version,
112
+ client=client,
113
+ ).parsed
114
+
115
+
116
+ async def asyncio_detailed(
117
+ source_id: int,
118
+ version: int,
119
+ *,
120
+ client: AuthenticatedClient | Client,
121
+ ) -> Response[Any | HTTPValidationError]:
122
+ """Activate Version
123
+
124
+ Args:
125
+ source_id (int):
126
+ version (int):
127
+
128
+ Raises:
129
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
130
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
131
+
132
+ Returns:
133
+ Response[Any | HTTPValidationError]
134
+ """
135
+
136
+ kwargs = _get_kwargs(
137
+ source_id=source_id,
138
+ version=version,
139
+ )
140
+
141
+ response = await client.get_async_httpx_client().request(**kwargs)
142
+
143
+ return _build_response(client=client, response=response)
144
+
145
+
146
+ async def asyncio(
147
+ source_id: int,
148
+ version: int,
149
+ *,
150
+ client: AuthenticatedClient | Client,
151
+ ) -> Any | HTTPValidationError | None:
152
+ """Activate Version
153
+
154
+ Args:
155
+ source_id (int):
156
+ version (int):
157
+
158
+ Raises:
159
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
160
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
161
+
162
+ Returns:
163
+ Any | HTTPValidationError
164
+ """
165
+
166
+ return (
167
+ await asyncio_detailed(
168
+ source_id=source_id,
169
+ version=version,
170
+ client=client,
171
+ )
172
+ ).parsed
@@ -0,0 +1,164 @@
1
+ from http import HTTPStatus
2
+ from typing import Any
3
+
4
+ import httpx
5
+
6
+ from ... import errors
7
+ from ...client import AuthenticatedClient, Client
8
+ from ...models.create_source_request import CreateSourceRequest
9
+ from ...models.http_validation_error import HTTPValidationError
10
+ from ...types import Response
11
+
12
+
13
+ def _get_kwargs(
14
+ *,
15
+ body: CreateSourceRequest,
16
+ ) -> dict[str, Any]:
17
+ headers: dict[str, Any] = {}
18
+
19
+ _kwargs: dict[str, Any] = {
20
+ "method": "post",
21
+ "url": "/bronze/",
22
+ }
23
+
24
+ _kwargs["json"] = body.to_dict()
25
+
26
+ headers["Content-Type"] = "application/json"
27
+
28
+ _kwargs["headers"] = headers
29
+ return _kwargs
30
+
31
+
32
+ def _parse_response(
33
+ *, client: AuthenticatedClient | Client, response: httpx.Response
34
+ ) -> Any | HTTPValidationError | None:
35
+ if response.status_code == 200:
36
+ response_200 = response.json()
37
+ return response_200
38
+
39
+ if response.status_code == 422:
40
+ response_422 = HTTPValidationError.from_dict(response.json())
41
+
42
+ return response_422
43
+
44
+ if client.raise_on_unexpected_status:
45
+ raise errors.UnexpectedStatus(response.status_code, response.content)
46
+ else:
47
+ return None
48
+
49
+
50
+ def _build_response(
51
+ *, client: AuthenticatedClient | Client, response: httpx.Response
52
+ ) -> Response[Any | HTTPValidationError]:
53
+ return Response(
54
+ status_code=HTTPStatus(response.status_code),
55
+ content=response.content,
56
+ headers=response.headers,
57
+ parsed=_parse_response(client=client, response=response),
58
+ )
59
+
60
+
61
+ def sync_detailed(
62
+ *,
63
+ client: AuthenticatedClient | Client,
64
+ body: CreateSourceRequest,
65
+ ) -> Response[Any | HTTPValidationError]:
66
+ """Create Source
67
+
68
+ Args:
69
+ body (CreateSourceRequest):
70
+
71
+ Raises:
72
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
73
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
74
+
75
+ Returns:
76
+ Response[Any | HTTPValidationError]
77
+ """
78
+
79
+ kwargs = _get_kwargs(
80
+ body=body,
81
+ )
82
+
83
+ response = client.get_httpx_client().request(
84
+ **kwargs,
85
+ )
86
+
87
+ return _build_response(client=client, response=response)
88
+
89
+
90
+ def sync(
91
+ *,
92
+ client: AuthenticatedClient | Client,
93
+ body: CreateSourceRequest,
94
+ ) -> Any | HTTPValidationError | None:
95
+ """Create Source
96
+
97
+ Args:
98
+ body (CreateSourceRequest):
99
+
100
+ Raises:
101
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
102
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
103
+
104
+ Returns:
105
+ Any | HTTPValidationError
106
+ """
107
+
108
+ return sync_detailed(
109
+ client=client,
110
+ body=body,
111
+ ).parsed
112
+
113
+
114
+ async def asyncio_detailed(
115
+ *,
116
+ client: AuthenticatedClient | Client,
117
+ body: CreateSourceRequest,
118
+ ) -> Response[Any | HTTPValidationError]:
119
+ """Create Source
120
+
121
+ Args:
122
+ body (CreateSourceRequest):
123
+
124
+ Raises:
125
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
126
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
127
+
128
+ Returns:
129
+ Response[Any | HTTPValidationError]
130
+ """
131
+
132
+ kwargs = _get_kwargs(
133
+ body=body,
134
+ )
135
+
136
+ response = await client.get_async_httpx_client().request(**kwargs)
137
+
138
+ return _build_response(client=client, response=response)
139
+
140
+
141
+ async def asyncio(
142
+ *,
143
+ client: AuthenticatedClient | Client,
144
+ body: CreateSourceRequest,
145
+ ) -> Any | HTTPValidationError | None:
146
+ """Create Source
147
+
148
+ Args:
149
+ body (CreateSourceRequest):
150
+
151
+ Raises:
152
+ errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
153
+ httpx.TimeoutException: If the request takes longer than Client.timeout.
154
+
155
+ Returns:
156
+ Any | HTTPValidationError
157
+ """
158
+
159
+ return (
160
+ await asyncio_detailed(
161
+ client=client,
162
+ body=body,
163
+ )
164
+ ).parsed