phisaver-client 1.0.4__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 (134) hide show
  1. phisaver_client-1.0.4/.envrc +5 -0
  2. phisaver_client-1.0.4/.gitignore +23 -0
  3. phisaver_client-1.0.4/.vscode/settings.json +16 -0
  4. phisaver_client-1.0.4/LICENSE +21 -0
  5. phisaver_client-1.0.4/Makefile +49 -0
  6. phisaver_client-1.0.4/PKG-INFO +56 -0
  7. phisaver_client-1.0.4/README.md +26 -0
  8. phisaver_client-1.0.4/USAGE_EXAMPLES.md +178 -0
  9. phisaver_client-1.0.4/openapi_python_client.yaml +7 -0
  10. phisaver_client-1.0.4/pyproject.toml +51 -0
  11. phisaver_client-1.0.4/src/.gitignore +23 -0
  12. phisaver_client-1.0.4/src/README.md +124 -0
  13. phisaver_client-1.0.4/src/phisaver_client/.gitignore +23 -0
  14. phisaver_client-1.0.4/src/phisaver_client/README.md +124 -0
  15. phisaver_client-1.0.4/src/phisaver_client/__init__.py +8 -0
  16. phisaver_client-1.0.4/src/phisaver_client/api/__init__.py +1 -0
  17. phisaver_client-1.0.4/src/phisaver_client/api/devices/__init__.py +1 -0
  18. phisaver_client-1.0.4/src/phisaver_client/api/devices/devices_create.py +168 -0
  19. phisaver_client-1.0.4/src/phisaver_client/api/devices/devices_destroy.py +95 -0
  20. phisaver_client-1.0.4/src/phisaver_client/api/devices/devices_list.py +124 -0
  21. phisaver_client-1.0.4/src/phisaver_client/api/devices/devices_partial_update.py +188 -0
  22. phisaver_client-1.0.4/src/phisaver_client/api/devices/devices_retrieve.py +146 -0
  23. phisaver_client-1.0.4/src/phisaver_client/api/devices/devices_update.py +184 -0
  24. phisaver_client-1.0.4/src/phisaver_client/api/fleets/__init__.py +1 -0
  25. phisaver_client-1.0.4/src/phisaver_client/api/fleets/fleets_colours_retrieve.py +158 -0
  26. phisaver_client-1.0.4/src/phisaver_client/api/fleets/fleets_create.py +188 -0
  27. phisaver_client-1.0.4/src/phisaver_client/api/fleets/fleets_destroy.py +105 -0
  28. phisaver_client-1.0.4/src/phisaver_client/api/fleets/fleets_list.py +144 -0
  29. phisaver_client-1.0.4/src/phisaver_client/api/fleets/fleets_partial_update.py +208 -0
  30. phisaver_client-1.0.4/src/phisaver_client/api/fleets/fleets_retrieve.py +166 -0
  31. phisaver_client-1.0.4/src/phisaver_client/api/fleets/fleets_update.py +204 -0
  32. phisaver_client-1.0.4/src/phisaver_client/api/login/__init__.py +1 -0
  33. phisaver_client-1.0.4/src/phisaver_client/api/login/login_create.py +197 -0
  34. phisaver_client-1.0.4/src/phisaver_client/api/logout/__init__.py +1 -0
  35. phisaver_client-1.0.4/src/phisaver_client/api/logout/logout_create.py +135 -0
  36. phisaver_client-1.0.4/src/phisaver_client/api/password/__init__.py +1 -0
  37. phisaver_client-1.0.4/src/phisaver_client/api/password/password_change_create.py +185 -0
  38. phisaver_client-1.0.4/src/phisaver_client/api/password/password_reset_confirm_create.py +193 -0
  39. phisaver_client-1.0.4/src/phisaver_client/api/password/password_reset_create.py +185 -0
  40. phisaver_client-1.0.4/src/phisaver_client/api/token/__init__.py +1 -0
  41. phisaver_client-1.0.4/src/phisaver_client/api/token/token_create.py +168 -0
  42. phisaver_client-1.0.4/src/phisaver_client/api/ts/__init__.py +1 -0
  43. phisaver_client-1.0.4/src/phisaver_client/api/ts/ts_heatmap_retrieve.py +407 -0
  44. phisaver_client-1.0.4/src/phisaver_client/api/ts/ts_metrics_retrieve.py +411 -0
  45. phisaver_client-1.0.4/src/phisaver_client/api/ts/ts_series_retrieve.py +442 -0
  46. phisaver_client-1.0.4/src/phisaver_client/api/ts/ts_table_retrieve.py +431 -0
  47. phisaver_client-1.0.4/src/phisaver_client/api/user/__init__.py +1 -0
  48. phisaver_client-1.0.4/src/phisaver_client/api/user/user_partial_update.py +204 -0
  49. phisaver_client-1.0.4/src/phisaver_client/api/user/user_retrieve.py +151 -0
  50. phisaver_client-1.0.4/src/phisaver_client/api/user/user_update.py +203 -0
  51. phisaver_client-1.0.4/src/phisaver_client/api/users/__init__.py +1 -0
  52. phisaver_client-1.0.4/src/phisaver_client/api/users/users_claim_partial_update.py +218 -0
  53. phisaver_client-1.0.4/src/phisaver_client/api/users/users_create.py +168 -0
  54. phisaver_client-1.0.4/src/phisaver_client/api/users/users_current_retrieve.py +119 -0
  55. phisaver_client-1.0.4/src/phisaver_client/api/users/users_destroy.py +95 -0
  56. phisaver_client-1.0.4/src/phisaver_client/api/users/users_list.py +124 -0
  57. phisaver_client-1.0.4/src/phisaver_client/api/users/users_partial_update.py +188 -0
  58. phisaver_client-1.0.4/src/phisaver_client/api/users/users_retrieve.py +146 -0
  59. phisaver_client-1.0.4/src/phisaver_client/api/users/users_update.py +184 -0
  60. phisaver_client-1.0.4/src/phisaver_client/api/vpnclients/__init__.py +1 -0
  61. phisaver_client-1.0.4/src/phisaver_client/api/vpnclients/vpnclients_create.py +168 -0
  62. phisaver_client-1.0.4/src/phisaver_client/api/vpnclients/vpnclients_destroy.py +95 -0
  63. phisaver_client-1.0.4/src/phisaver_client/api/vpnclients/vpnclients_list.py +124 -0
  64. phisaver_client-1.0.4/src/phisaver_client/api/vpnclients/vpnclients_partial_update.py +188 -0
  65. phisaver_client-1.0.4/src/phisaver_client/api/vpnclients/vpnclients_retrieve.py +146 -0
  66. phisaver_client-1.0.4/src/phisaver_client/api/vpnclients/vpnclients_update.py +184 -0
  67. phisaver_client-1.0.4/src/phisaver_client/client.py +268 -0
  68. phisaver_client-1.0.4/src/phisaver_client/errors.py +16 -0
  69. phisaver_client-1.0.4/src/phisaver_client/helpers.py +86 -0
  70. phisaver_client-1.0.4/src/phisaver_client/models/__init__.py +119 -0
  71. phisaver_client-1.0.4/src/phisaver_client/models/auth_token.py +93 -0
  72. phisaver_client-1.0.4/src/phisaver_client/models/colour_palette.py +106 -0
  73. phisaver_client-1.0.4/src/phisaver_client/models/device.py +357 -0
  74. phisaver_client-1.0.4/src/phisaver_client/models/device_video.py +147 -0
  75. phisaver_client-1.0.4/src/phisaver_client/models/fleet.py +144 -0
  76. phisaver_client-1.0.4/src/phisaver_client/models/fleet_devices_details.py +46 -0
  77. phisaver_client-1.0.4/src/phisaver_client/models/login.py +98 -0
  78. phisaver_client-1.0.4/src/phisaver_client/models/metric_label.py +89 -0
  79. phisaver_client-1.0.4/src/phisaver_client/models/password_change.py +83 -0
  80. phisaver_client-1.0.4/src/phisaver_client/models/password_reset.py +74 -0
  81. phisaver_client-1.0.4/src/phisaver_client/models/password_reset_confirm.py +104 -0
  82. phisaver_client-1.0.4/src/phisaver_client/models/patched_device.py +401 -0
  83. phisaver_client-1.0.4/src/phisaver_client/models/patched_fleet.py +167 -0
  84. phisaver_client-1.0.4/src/phisaver_client/models/patched_fleet_devices_details.py +46 -0
  85. phisaver_client-1.0.4/src/phisaver_client/models/patched_user.py +162 -0
  86. phisaver_client-1.0.4/src/phisaver_client/models/patched_user_details.py +86 -0
  87. phisaver_client-1.0.4/src/phisaver_client/models/patched_vpn_client.py +101 -0
  88. phisaver_client-1.0.4/src/phisaver_client/models/rates.py +93 -0
  89. phisaver_client-1.0.4/src/phisaver_client/models/rest_auth_detail.py +61 -0
  90. phisaver_client-1.0.4/src/phisaver_client/models/token.py +62 -0
  91. phisaver_client-1.0.4/src/phisaver_client/models/ts_heatmap_retrieve_attribute.py +18 -0
  92. phisaver_client-1.0.4/src/phisaver_client/models/ts_heatmap_retrieve_engine.py +14 -0
  93. phisaver_client-1.0.4/src/phisaver_client/models/ts_heatmap_retrieve_format.py +14 -0
  94. phisaver_client-1.0.4/src/phisaver_client/models/ts_heatmap_retrieve_metcat.py +18 -0
  95. phisaver_client-1.0.4/src/phisaver_client/models/ts_heatmap_retrieve_response_200.py +46 -0
  96. phisaver_client-1.0.4/src/phisaver_client/models/ts_heatmap_retrieve_source.py +16 -0
  97. phisaver_client-1.0.4/src/phisaver_client/models/ts_heatmap_retrieve_timeformat.py +15 -0
  98. phisaver_client-1.0.4/src/phisaver_client/models/ts_heatmap_retrieve_units.py +13 -0
  99. phisaver_client-1.0.4/src/phisaver_client/models/ts_metrics_retrieve_attribute.py +18 -0
  100. phisaver_client-1.0.4/src/phisaver_client/models/ts_metrics_retrieve_engine.py +14 -0
  101. phisaver_client-1.0.4/src/phisaver_client/models/ts_metrics_retrieve_format.py +14 -0
  102. phisaver_client-1.0.4/src/phisaver_client/models/ts_metrics_retrieve_metcat.py +18 -0
  103. phisaver_client-1.0.4/src/phisaver_client/models/ts_metrics_retrieve_response_200.py +46 -0
  104. phisaver_client-1.0.4/src/phisaver_client/models/ts_metrics_retrieve_source.py +16 -0
  105. phisaver_client-1.0.4/src/phisaver_client/models/ts_metrics_retrieve_timeformat.py +15 -0
  106. phisaver_client-1.0.4/src/phisaver_client/models/ts_metrics_retrieve_units.py +16 -0
  107. phisaver_client-1.0.4/src/phisaver_client/models/ts_series_retrieve_attribute.py +18 -0
  108. phisaver_client-1.0.4/src/phisaver_client/models/ts_series_retrieve_engine.py +14 -0
  109. phisaver_client-1.0.4/src/phisaver_client/models/ts_series_retrieve_format.py +14 -0
  110. phisaver_client-1.0.4/src/phisaver_client/models/ts_series_retrieve_function.py +13 -0
  111. phisaver_client-1.0.4/src/phisaver_client/models/ts_series_retrieve_metcat.py +18 -0
  112. phisaver_client-1.0.4/src/phisaver_client/models/ts_series_retrieve_response_200.py +46 -0
  113. phisaver_client-1.0.4/src/phisaver_client/models/ts_series_retrieve_source.py +16 -0
  114. phisaver_client-1.0.4/src/phisaver_client/models/ts_series_retrieve_timeformat.py +15 -0
  115. phisaver_client-1.0.4/src/phisaver_client/models/ts_series_retrieve_units.py +16 -0
  116. phisaver_client-1.0.4/src/phisaver_client/models/ts_table_retrieve_attribute.py +18 -0
  117. phisaver_client-1.0.4/src/phisaver_client/models/ts_table_retrieve_engine.py +14 -0
  118. phisaver_client-1.0.4/src/phisaver_client/models/ts_table_retrieve_format.py +14 -0
  119. phisaver_client-1.0.4/src/phisaver_client/models/ts_table_retrieve_function.py +13 -0
  120. phisaver_client-1.0.4/src/phisaver_client/models/ts_table_retrieve_metcat.py +18 -0
  121. phisaver_client-1.0.4/src/phisaver_client/models/ts_table_retrieve_response_200.py +46 -0
  122. phisaver_client-1.0.4/src/phisaver_client/models/ts_table_retrieve_source.py +16 -0
  123. phisaver_client-1.0.4/src/phisaver_client/models/ts_table_retrieve_timeformat.py +15 -0
  124. phisaver_client-1.0.4/src/phisaver_client/models/ts_table_retrieve_units.py +16 -0
  125. phisaver_client-1.0.4/src/phisaver_client/models/user.py +157 -0
  126. phisaver_client-1.0.4/src/phisaver_client/models/user_details.py +84 -0
  127. phisaver_client-1.0.4/src/phisaver_client/models/vpn_client.py +95 -0
  128. phisaver_client-1.0.4/src/phisaver_client/py.typed +1 -0
  129. phisaver_client-1.0.4/src/phisaver_client/pyproject.toml +27 -0
  130. phisaver_client-1.0.4/src/phisaver_client/types.py +54 -0
  131. phisaver_client-1.0.4/src/pyproject.toml +26 -0
  132. phisaver_client-1.0.4/test/__init__.py +0 -0
  133. phisaver_client-1.0.4/test/test_phisaver_api_client.py +99 -0
  134. phisaver_client-1.0.4/uv.lock +1443 -0
@@ -0,0 +1,5 @@
1
+ dotenv ../.env
2
+ source .venv/bin/activate
3
+ # bug fix: https://github.com/direnv/direnv/wiki/PS1
4
+ unset PS1
5
+
@@ -0,0 +1,23 @@
1
+ __pycache__/
2
+ build/
3
+ dist/
4
+ *.egg-info/
5
+ .pytest_cache/
6
+
7
+ # pyenv
8
+ .python-version
9
+
10
+ # Environments
11
+ .env
12
+ .venv
13
+
14
+ # mypy
15
+ .mypy_cache/
16
+ .dmypy.json
17
+ dmypy.json
18
+
19
+ # JetBrains
20
+ .idea/
21
+
22
+ /coverage.xml
23
+ /.coverage
@@ -0,0 +1,16 @@
1
+ {
2
+ "python.testing.pytestArgs": [
3
+ "test"
4
+ ],
5
+ "python.testing.unittestEnabled": false,
6
+ "python.testing.pytestEnabled": true,
7
+ "[python]": {
8
+ "editor.formatOnSave": true,
9
+ "editor.defaultFormatter": "charliermarsh.ruff",
10
+ "editor.codeActionsOnSave": {
11
+ "source.fixAll": "explicit",
12
+ "source.organizeImports": "explicit"
13
+ }
14
+ },
15
+ "debugpy.debugJustMyCode": true
16
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Brett Beeson
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,49 @@
1
+ RUN = uv run
2
+
3
+ help: ## Show this help.
4
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
5
+
6
+ buildtools: ## Install development dependencies
7
+ uv pip install -e ".[dev]"
8
+
9
+ schema:
10
+ @echo Run the following command to generate the schema:
11
+ @echo pushd ../server/
12
+ @echo make schema
13
+ @echo popd
14
+
15
+
16
+ autogen: FORCE ## Generate the OpenAPI client code
17
+ $(RUN) openapi-python-client generate --output-path src/ --overwrite --path ../server/schema.yml --config openapi_python_client.yaml
18
+
19
+ runserver: ## Run the django server
20
+ @echo Run these commands
21
+ @echo pushd ../server/
22
+ @echo "make runserver &"
23
+ @echo popd
24
+
25
+ clean-dist: ## Clean build artifacts
26
+ rm -rf dist/ build/ *.egg-info src/*.egg-info
27
+
28
+ build: buildtools clean-dist ## Build distribution packages
29
+ $(RUN) python -m build
30
+
31
+ test-upload: build ## Upload to Test PyPI (test first!)
32
+ @echo "Uploading to Test PyPI..."
33
+ twine upload --repository testpypi dist/*
34
+ @echo "Test with: pip install --index-url https://test.pypi.org/simple/ phisaver-client"
35
+
36
+ upload: build ## Upload to PyPI (PRODUCTION)
37
+ @echo "WARNING: Publishing to PRODUCTION PyPI!"
38
+ @echo "Version: $$(grep '^version' pyproject.toml | cut -d'"' -f2)"
39
+ @read -p "Continue? [y/N] " confirm && [ "$$confirm" = "y" ]
40
+ @echo "Uploading to PyPI..."
41
+ twine upload dist/*
42
+ @echo "Published! Install with: pip install phisaver-client"
43
+
44
+ check-version: ## Show current version
45
+ @grep '^version' pyproject.toml
46
+
47
+ FORCE: ## Force the rule to always run
48
+ @true
49
+
@@ -0,0 +1,56 @@
1
+ Metadata-Version: 2.4
2
+ Name: phisaver-client
3
+ Version: 1.0.4
4
+ Summary: A client library for accessing Phisaver API
5
+ Project-URL: Homepage, https://github.com/phisaver/phisaver-client
6
+ Project-URL: Repository, https://github.com/phisaver/phisaver-client
7
+ Author-email: Brett Beeson <brett@phisaver.com>
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Keywords: api,client,openapi,phisaver
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: Implementation :: CPython
19
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
20
+ Requires-Python: >=3.9
21
+ Requires-Dist: attrs>=22.2.0
22
+ Requires-Dist: httpx>=0.28.1
23
+ Requires-Dist: python-dateutil>=2.8.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: build>=1.0.0; extra == 'dev'
26
+ Requires-Dist: openapi-python-client>=0.25.2; extra == 'dev'
27
+ Requires-Dist: pytest>=7.0; extra == 'dev'
28
+ Requires-Dist: twine>=5.0.0; extra == 'dev'
29
+ Description-Content-Type: text/markdown
30
+
31
+ This package provides a client for the PhiSaver API. It is auto-generated using OpenAPI specifications from that API.
32
+
33
+
34
+ ## Install
35
+
36
+ ```bash
37
+ pip install phisaver-client
38
+ ```
39
+
40
+
41
+ <!-- ## Usage
42
+ ```
43
+ import phisaver_client
44
+
45
+ For testing from Test PyPI:
46
+ ```bash
47
+ pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ phisaver-client
48
+ ```
49
+
50
+
51
+
52
+ ``` -->
53
+
54
+ ## Documentation
55
+
56
+ The documentation for the client can be found at: https://github.com/phisaver/phisaver-client
@@ -0,0 +1,26 @@
1
+ This package provides a client for the PhiSaver API. It is auto-generated using OpenAPI specifications from that API.
2
+
3
+
4
+ ## Install
5
+
6
+ ```bash
7
+ pip install phisaver-client
8
+ ```
9
+
10
+
11
+ <!-- ## Usage
12
+ ```
13
+ import phisaver_client
14
+
15
+ For testing from Test PyPI:
16
+ ```bash
17
+ pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ phisaver-client
18
+ ```
19
+
20
+
21
+
22
+ ``` -->
23
+
24
+ ## Documentation
25
+
26
+ The documentation for the client can be found at: https://github.com/phisaver/phisaver-client
@@ -0,0 +1,178 @@
1
+ # PhiSaver Client Usage Examples
2
+
3
+ ## Authentication
4
+
5
+ ```python
6
+ from phisaver_client import get_client_from_env, get_client
7
+
8
+ # Option 1: Use environment variables
9
+ # Set PHISAVER_URL, PHISAVER_USERNAME, PHISAVER_PASSWORD
10
+ client = get_client_from_env()
11
+
12
+ # Option 2: Pass credentials explicitly
13
+ client = get_client(
14
+ base_url="https://app.phisaver.com",
15
+ username="your-email@example.com",
16
+ password="your-password"
17
+ )
18
+ ```
19
+
20
+ ## Time Series Data
21
+
22
+ ### Method 1: Dict-like Access (Recommended)
23
+
24
+ The response models support `__getitem__`, so you can use them like dictionaries:
25
+
26
+ ```python
27
+ from phisaver_client.api.ts import ts_series_retrieve
28
+
29
+ # Fetch time series data
30
+ result = ts_series_retrieve.sync(
31
+ client=client,
32
+ bin_="1h", # 1-hour bins
33
+ sites="demo1", # Device ID
34
+ start=start_time,
35
+ stop=end_time,
36
+ )
37
+
38
+ # Direct dict-like access (NO .additional_properties needed!)
39
+ production_data = result["demo1"]["Production"]
40
+ net_data = result["demo1"]["Net"]
41
+
42
+ for timestamp, value in production_data:
43
+ print(f"Production at {timestamp}: {value}W")
44
+ ```
45
+
46
+ ### Method 2: Using as_dict() Helper
47
+
48
+ For explicit conversion to plain dict:
49
+
50
+ ```python
51
+ from phisaver_client import as_dict
52
+ from phisaver_client.api.ts import ts_series_retrieve
53
+
54
+ result = ts_series_retrieve.sync(
55
+ client=client,
56
+ bin_="1h",
57
+ sites="demo1,demo2", # Multiple devices
58
+ )
59
+
60
+ # Convert to plain dict
61
+ data = as_dict(result)
62
+
63
+ # Iterate over all devices and metrics
64
+ for device_id, metrics in data.items():
65
+ print(f"Device: {device_id}")
66
+ for metric_name, timeseries in metrics.items():
67
+ print(f" {metric_name}: {len(timeseries)} data points")
68
+ # Each timeseries is a list of [timestamp, value] pairs
69
+ ```
70
+
71
+ ### Method 3: With Type Hints
72
+
73
+ ```python
74
+ from phisaver_client import TimeSeriesData
75
+ from phisaver_client.api.ts import ts_series_retrieve
76
+
77
+ def process_energy_data(client, site: str) -> TimeSeriesData:
78
+ """Fetch and return time series data with proper typing"""
79
+ result = ts_series_retrieve.sync(
80
+ client=client,
81
+ bin_="15min",
82
+ sites=site,
83
+ attribute="power",
84
+ units="kW",
85
+ )
86
+
87
+ # Type hints available for IDE autocomplete
88
+ data: TimeSeriesData = as_dict(result)
89
+ return data
90
+
91
+ # Usage
92
+ data = process_energy_data(client, "demo1")
93
+ production = data["demo1"]["Production"] # Full IDE support
94
+ ```
95
+
96
+ ## Query Parameters
97
+
98
+ Common parameters for time series queries:
99
+
100
+ ```python
101
+ from datetime import datetime, timedelta
102
+ from phisaver_client.api.ts import ts_series_retrieve
103
+
104
+ end = datetime.now()
105
+ start = end - timedelta(days=7)
106
+
107
+ result = ts_series_retrieve.sync(
108
+ client=client,
109
+ bin_="1h", # Aggregation interval
110
+ sites="demo1,demo2", # Comma-separated device IDs
111
+ start=start, # Start time
112
+ stop=end, # End time
113
+ attribute="power", # Metric type
114
+ function="mean", # Aggregation function
115
+ units="kW", # Units
116
+ named=True, # Use device names instead of IDs
117
+ timeformat="iso", # Timestamp format (iso/epoch/epochms)
118
+ )
119
+ ```
120
+
121
+ ## Error Handling
122
+
123
+ ```python
124
+ from phisaver_client.api.ts import ts_series_retrieve
125
+ import httpx
126
+
127
+ try:
128
+ result = ts_series_retrieve.sync_detailed( # Use sync_detailed for status code
129
+ client=client,
130
+ bin_="1h",
131
+ sites="demo1",
132
+ )
133
+
134
+ if result.status_code == 200:
135
+ data = result.parsed
136
+ print(f"Success! Got data for {len(data)} devices")
137
+ else:
138
+ print(f"Error: {result.status_code}")
139
+
140
+ except httpx.TimeoutException:
141
+ print("Request timed out")
142
+ except Exception as e:
143
+ print(f"Error: {e}")
144
+ ```
145
+
146
+ ## Device Management
147
+
148
+ ```python
149
+ from phisaver_client.api.devices import devices_list
150
+
151
+ # List all devices
152
+ devices = devices_list.sync(client=client)
153
+
154
+ for device in devices:
155
+ print(f"{device.ref}: {device.name}")
156
+ ```
157
+
158
+ ## Best Practices
159
+
160
+ 1. **Use dict-like access** - No need for `.additional_properties`
161
+ 2. **Use `sync_detailed()`** when you need status codes
162
+ 3. **Use `sync()`** when you just need the data (returns `None` on error)
163
+ 4. **Set proper timeouts** in client construction
164
+ 5. **Use type hints** from helpers module for better IDE support
165
+
166
+ ## Common Pitfalls
167
+
168
+ ❌ **Don't do this:**
169
+ ```python
170
+ data = result.additional_properties["demo1"]["Production"]
171
+ ```
172
+
173
+ ✅ **Do this instead:**
174
+ ```python
175
+ data = result["demo1"]["Production"]
176
+ # or
177
+ data = as_dict(result)["demo1"]["Production"]
178
+ ```
@@ -0,0 +1,7 @@
1
+ literal_enums: true
2
+ package_name: openapi_python_client
3
+ output_dir: .
4
+
5
+ project_name_override: phisaver_client
6
+ package_name_override: phisaver_client
7
+ # output_path is not available, set in cli command
@@ -0,0 +1,51 @@
1
+ [project]
2
+ name = "phisaver-client"
3
+ version = "1.0.4"
4
+ description = "A client library for accessing Phisaver API"
5
+ authors = [{ name = "Brett Beeson", email = "brett@phisaver.com" }]
6
+ readme = "README.md"
7
+ license = { text = "MIT" }
8
+ requires-python = ">=3.9"
9
+ keywords = ["phisaver", "api", "client", "openapi"]
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Intended Audience :: Developers",
13
+ "Programming Language :: Python :: 3",
14
+ "Programming Language :: Python :: 3.9",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: Implementation :: CPython",
19
+ "Programming Language :: Python :: Implementation :: PyPy",
20
+ ]
21
+ dependencies = [
22
+ "httpx>=0.28.1",
23
+ "attrs>=22.2.0",
24
+ "python-dateutil>=2.8.0",
25
+ ]
26
+
27
+ [project.urls]
28
+ Homepage = "https://github.com/phisaver/phisaver-client"
29
+ Repository = "https://github.com/phisaver/phisaver-client"
30
+
31
+
32
+ [project.optional-dependencies]
33
+ dev = [
34
+ "openapi-python-client>=0.25.2",
35
+ "pytest>=7.0",
36
+ "build>=1.0.0",
37
+ "twine>=5.0.0",
38
+ ]
39
+
40
+ [build-system]
41
+ requires = ["hatchling"]
42
+ build-backend = "hatchling.build"
43
+
44
+ [tool.hatch.build.targets.wheel]
45
+ packages = ["src/phisaver_client"]
46
+
47
+ [tool.ruff]
48
+ line-length = 120
49
+
50
+ [tool.ruff.lint]
51
+ select = ["F", "I", "UP"]
@@ -0,0 +1,23 @@
1
+ __pycache__/
2
+ build/
3
+ dist/
4
+ *.egg-info/
5
+ .pytest_cache/
6
+
7
+ # pyenv
8
+ .python-version
9
+
10
+ # Environments
11
+ .env
12
+ .venv
13
+
14
+ # mypy
15
+ .mypy_cache/
16
+ .dmypy.json
17
+ dmypy.json
18
+
19
+ # JetBrains
20
+ .idea/
21
+
22
+ /coverage.xml
23
+ /.coverage
@@ -0,0 +1,124 @@
1
+ # phisaver_client
2
+ A client library for accessing Phisaver API
3
+
4
+ ## Usage
5
+ First, create a client:
6
+
7
+ ```python
8
+ from phisaver_client import Client
9
+
10
+ client = Client(base_url="https://api.example.com")
11
+ ```
12
+
13
+ If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead:
14
+
15
+ ```python
16
+ from phisaver_client import AuthenticatedClient
17
+
18
+ client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
19
+ ```
20
+
21
+ Now call your endpoint and use your models:
22
+
23
+ ```python
24
+ from phisaver_client.models import MyDataModel
25
+ from phisaver_client.api.my_tag import get_my_data_model
26
+ from phisaver_client.types import Response
27
+
28
+ with client as client:
29
+ my_data: MyDataModel = get_my_data_model.sync(client=client)
30
+ # or if you need more info (e.g. status_code)
31
+ response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
32
+ ```
33
+
34
+ Or do the same thing with an async version:
35
+
36
+ ```python
37
+ from phisaver_client.models import MyDataModel
38
+ from phisaver_client.api.my_tag import get_my_data_model
39
+ from phisaver_client.types import Response
40
+
41
+ async with client as client:
42
+ my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
43
+ response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
44
+ ```
45
+
46
+ By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
47
+
48
+ ```python
49
+ client = AuthenticatedClient(
50
+ base_url="https://internal_api.example.com",
51
+ token="SuperSecretToken",
52
+ verify_ssl="/path/to/certificate_bundle.pem",
53
+ )
54
+ ```
55
+
56
+ You can also disable certificate validation altogether, but beware that **this is a security risk**.
57
+
58
+ ```python
59
+ client = AuthenticatedClient(
60
+ base_url="https://internal_api.example.com",
61
+ token="SuperSecretToken",
62
+ verify_ssl=False
63
+ )
64
+ ```
65
+
66
+ Things to know:
67
+ 1. Every path/method combo becomes a Python module with four functions:
68
+ 1. `sync`: Blocking request that returns parsed data (if successful) or `None`
69
+ 1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
70
+ 1. `asyncio`: Like `sync` but async instead of blocking
71
+ 1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking
72
+
73
+ 1. All path/query params, and bodies become method arguments.
74
+ 1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
75
+ 1. Any endpoint which did not have a tag will be in `phisaver_client.api.default`
76
+
77
+ ## Advanced customizations
78
+
79
+ There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):
80
+
81
+ ```python
82
+ from phisaver_client import Client
83
+
84
+ def log_request(request):
85
+ print(f"Request event hook: {request.method} {request.url} - Waiting for response")
86
+
87
+ def log_response(response):
88
+ request = response.request
89
+ print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
90
+
91
+ client = Client(
92
+ base_url="https://api.example.com",
93
+ httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
94
+ )
95
+
96
+ # Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
97
+ ```
98
+
99
+ You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):
100
+
101
+ ```python
102
+ import httpx
103
+ from phisaver_client import Client
104
+
105
+ client = Client(
106
+ base_url="https://api.example.com",
107
+ )
108
+ # Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
109
+ client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
110
+ ```
111
+
112
+ ## Building / publishing this package
113
+ This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:
114
+ 1. Update the metadata in pyproject.toml (e.g. authors, version)
115
+ 1. If you're using a private repository, configure it with Poetry
116
+ 1. `poetry config repositories.<your-repository-name> <url-to-your-repository>`
117
+ 1. `poetry config http-basic.<your-repository-name> <username> <password>`
118
+ 1. Publish the client with `poetry publish --build -r <your-repository-name>` or, if for public PyPI, just `poetry publish --build`
119
+
120
+ If you want to install this client into another project without publishing it (e.g. for development) then:
121
+ 1. If that project **is using Poetry**, you can simply do `poetry add <path-to-this-client>` from that project
122
+ 1. If that project is not using Poetry:
123
+ 1. Build a wheel with `poetry build -f wheel`
124
+ 1. Install that wheel from the other project `pip install <path-to-wheel>`
@@ -0,0 +1,23 @@
1
+ __pycache__/
2
+ build/
3
+ dist/
4
+ *.egg-info/
5
+ .pytest_cache/
6
+
7
+ # pyenv
8
+ .python-version
9
+
10
+ # Environments
11
+ .env
12
+ .venv
13
+
14
+ # mypy
15
+ .mypy_cache/
16
+ .dmypy.json
17
+ dmypy.json
18
+
19
+ # JetBrains
20
+ .idea/
21
+
22
+ /coverage.xml
23
+ /.coverage