Skip to content

Commit 2dbcfa6

Browse files
authored
Bumps the Python types from the OpenAPI schema (#10)
1 parent b14cfa8 commit 2dbcfa6

12 files changed

+2567
-1406
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,19 @@ $ make record
125125

126126
This will record new cassettes for the tests. Make sure to commit these cassettes along with your changes.
127127

128+
### Updating the schema
129+
130+
In order to update the Python data types from the OpenAPI schema, you need to:
131+
132+
```
133+
$ mkdir neon_client/
134+
$ make schema
135+
# Now, take `neon_client/schema.py` and replace `neon_api/schema.py` with it.
136+
# Now, run:
137+
$ make test
138+
# You may have to run `make record` to update the fixtures.
139+
```
140+
128141
## License & Copyright
129142

130143
[Apache 2.0 Licensed](./LICENSE).

neon_api/client.py

+1-35
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def project(self, project_id: str) -> t.Dict[str, t.Any]:
215215

216216
return self._request("GET", r_path)
217217

218-
@returns_model(schema.ConnectionUri)
218+
@returns_model(schema.ConnectionURIResponse)
219219
def connection_uri(
220220
self,
221221
project_id: str,
@@ -797,37 +797,3 @@ def operation(self, project_id: str, operation_id: str) -> t.Dict[str, t.Any]:
797797
return self._request(
798798
"GET", f"projects/{ project_id }/operations/{ operation_id }"
799799
)
800-
801-
@returns_model(schema.ProjectsConsumptionResponse)
802-
def consumption(
803-
self,
804-
*,
805-
cursor: str = None,
806-
limit: int = None,
807-
from_date: datetime = None,
808-
to_date: datetime = None,
809-
) -> t.Dict[str, t.Any]:
810-
"""Experimental — get a list of consumption metrics for all projects.
811-
812-
:param cursor: The cursor for pagination (default is None).
813-
:param limit: The maximum number of projects to retrieve (default is None).
814-
:param from_date: The start date for the consumption metrics (default is None).
815-
:param to_date: The end date for the consumption metrics (default is None).
816-
:return: A dataclass representing the consumption metrics.
817-
818-
More info: https://api-docs.neon.tech/reference/listprojectsconsumption
819-
"""
820-
821-
# Convert datetime objects to ISO 8601 strings.
822-
from_date = (
823-
to_iso8601(from_date) if isinstance(from_date, datetime) else from_date
824-
)
825-
to_date = to_iso8601(to_date) if isinstance(to_date, datetime) else to_date
826-
827-
# Construct the request parameters.
828-
r_params = compact_mapping(
829-
{"cursor": cursor, "limit": limit, "from": from_date, "to": to_date}
830-
)
831-
832-
# Make the request.
833-
return self._request("GET", "consumption/projects", params=r_params)

0 commit comments

Comments
 (0)