Skip to content

Commit 7105f29

Browse files
committed
finish up
1 parent d6ac11d commit 7105f29

9 files changed

+938
-445
lines changed

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)

tests/cassettes/test_integration/test_api_keys.yaml

+86-32
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
interactions:
22
- request:
3-
body: '{"key_name": "pytest-3951"}'
3+
body: '{"key_name": "pytest-8050"}'
44
headers:
55
Accept:
66
- application/json
@@ -18,22 +18,36 @@ interactions:
1818
uri: https://console.neon.tech/api/v2/api_keys
1919
response:
2020
body:
21-
string: '{"id":821303,"key":"z46yynhjt27n5eaif3l7hnn8fh1romg3dal6j6lh1c5wp1kg9wluz9ivu0qfkg87","name":"pytest-3951","created_at":"2024-02-07T14:04:01Z"}'
21+
string: '{"id":1954948,"key":"m5azy6fs2cea9mr9b37e5k6wclu7olast37zrt3f1mjhha02gl8if38pb2tmdsot","name":"pytest-8050","created_at":"2025-01-16T21:01:58Z","created_by":"92cdd2ee-a6d8-4647-868f-124531123b03"}'
2222
headers:
23+
CF-Cache-Status:
24+
- DYNAMIC
25+
CF-RAY:
26+
- 90310b393875de9b-EWR
2327
Connection:
2428
- keep-alive
25-
Content-Length:
26-
- '143'
29+
Content-Encoding:
30+
- gzip
2731
Content-Type:
28-
- application/json
32+
- application/json; charset=utf-8
2933
Date:
30-
- Wed, 07 Feb 2024 14:04:01 GMT
31-
Strict-Transport-Security:
32-
- max-age=15724800; includeSubDomains
33-
Vary:
34+
- Thu, 16 Jan 2025 21:01:58 GMT
35+
Server:
36+
- cloudflare
37+
Transfer-Encoding:
38+
- chunked
39+
referrer-policy:
40+
- strict-origin-when-cross-origin
41+
strict-transport-security:
42+
- max-age=63072000; includeSubDomains; preload
43+
vary:
3444
- Origin
35-
X-Neon-Ret-Request-Id:
36-
- 980e46c9d9405afa07b0a9d77e9042c7
45+
x-content-type-options:
46+
- nosniff
47+
x-frame-options:
48+
- SAMEORIGIN
49+
x-neon-ret-request-id:
50+
- 332164ee-24a6-440d-a486-77679f124fd4
3751
status:
3852
code: 200
3953
message: OK
@@ -54,22 +68,48 @@ interactions:
5468
uri: https://console.neon.tech/api/v2/api_keys
5569
response:
5670
body:
57-
string: '[{"id":821303,"name":"pytest-3951","created_at":"2024-02-07T14:04:01Z","last_used_at":null,"last_used_from_addr":""},{"id":768620,"name":"neon_client","created_at":"2024-01-23T21:56:07Z","last_used_at":"2024-02-07T14:04:01Z","last_used_from_addr":"204.111.161.156"}]'
71+
string: '[{"id":1954948,"name":"pytest-8050","created_at":"2025-01-16T21:01:58Z","created_by":{"id":"92cdd2ee-a6d8-4647-868f-124531123b03","name":"David
72+
Gomes","image":"https://lh3.googleusercontent.com/a/ACg8ocIW4y_ki038IdI89ZxbbfuRuXtJyTuDYdTJZkMzWLaBHEdN7AY=s96-c"},"last_used_at":null,"last_used_from_addr":""},{"id":1937557,"name":"other
73+
test","created_at":"2025-01-03T20:02:41Z","created_by":{"id":"92cdd2ee-a6d8-4647-868f-124531123b03","name":"David
74+
Gomes","image":"https://lh3.googleusercontent.com/a/ACg8ocIW4y_ki038IdI89ZxbbfuRuXtJyTuDYdTJZkMzWLaBHEdN7AY=s96-c"},"last_used_at":"2025-01-03T20:06:28Z","last_used_from_addr":"52.200.136.63"},{"id":1934773,"name":"quick_test","created_at":"2025-01-01T21:15:36Z","created_by":{"id":"92cdd2ee-a6d8-4647-868f-124531123b03","name":"David
75+
Gomes","image":"https://lh3.googleusercontent.com/a/ACg8ocIW4y_ki038IdI89ZxbbfuRuXtJyTuDYdTJZkMzWLaBHEdN7AY=s96-c"},"last_used_at":"2025-01-03T13:03:20Z","last_used_from_addr":"54.234.118.252"},{"id":1934772,"name":"composio","created_at":"2025-01-01T21:15:02Z","created_by":{"id":"92cdd2ee-a6d8-4647-868f-124531123b03","name":"David
76+
Gomes","image":"https://lh3.googleusercontent.com/a/ACg8ocIW4y_ki038IdI89ZxbbfuRuXtJyTuDYdTJZkMzWLaBHEdN7AY=s96-c"},"last_used_at":null,"last_used_from_addr":""},{"id":1885316,"name":"claude","created_at":"2024-12-02T08:07:54Z","created_by":{"id":"92cdd2ee-a6d8-4647-868f-124531123b03","name":"David
77+
Gomes","image":"https://lh3.googleusercontent.com/a/ACg8ocIW4y_ki038IdI89ZxbbfuRuXtJyTuDYdTJZkMzWLaBHEdN7AY=s96-c"},"last_used_at":null,"last_used_from_addr":""},{"id":1835348,"name":"another
78+
one","created_at":"2024-11-17T17:48:24Z","created_by":{"id":"92cdd2ee-a6d8-4647-868f-124531123b03","name":"David
79+
Gomes","image":"https://lh3.googleusercontent.com/a/ACg8ocIW4y_ki038IdI89ZxbbfuRuXtJyTuDYdTJZkMzWLaBHEdN7AY=s96-c"},"last_used_at":"2024-11-17T17:49:31Z","last_used_from_addr":"113.203.180.132,35.160.120.126"},{"id":1831722,"name":"agent","created_at":"2024-11-16T13:12:47Z","created_by":{"id":"92cdd2ee-a6d8-4647-868f-124531123b03","name":"David
80+
Gomes","image":"https://lh3.googleusercontent.com/a/ACg8ocIW4y_ki038IdI89ZxbbfuRuXtJyTuDYdTJZkMzWLaBHEdN7AY=s96-c"},"last_used_at":"2025-01-14T21:21:34Z","last_used_from_addr":"172.56.167.151"},{"id":1813799,"name":"python
81+
demo api key","created_at":"2024-11-10T16:44:30Z","created_by":{"id":"92cdd2ee-a6d8-4647-868f-124531123b03","name":"David
82+
Gomes","image":"https://lh3.googleusercontent.com/a/ACg8ocIW4y_ki038IdI89ZxbbfuRuXtJyTuDYdTJZkMzWLaBHEdN7AY=s96-c"},"last_used_at":"2025-01-16T21:01:58Z","last_used_from_addr":"172.254.226.90"},{"id":1633393,"name":"test","created_at":"2024-09-21T19:51:43Z","created_by":{"id":"92cdd2ee-a6d8-4647-868f-124531123b03","name":"David
83+
Gomes","image":"https://lh3.googleusercontent.com/a/ACg8ocIW4y_ki038IdI89ZxbbfuRuXtJyTuDYdTJZkMzWLaBHEdN7AY=s96-c"},"last_used_at":"2024-09-22T06:13:16Z","last_used_from_addr":"113.203.180.132"}]'
5884
headers:
85+
CF-Cache-Status:
86+
- DYNAMIC
87+
CF-RAY:
88+
- 90310b3a988272b9-EWR
5989
Connection:
6090
- keep-alive
61-
Content-Length:
62-
- '266'
91+
Content-Encoding:
92+
- gzip
6393
Content-Type:
64-
- application/json
94+
- application/json; charset=utf-8
6595
Date:
66-
- Wed, 07 Feb 2024 14:04:01 GMT
67-
Strict-Transport-Security:
68-
- max-age=15724800; includeSubDomains
69-
Vary:
96+
- Thu, 16 Jan 2025 21:01:58 GMT
97+
Server:
98+
- cloudflare
99+
Transfer-Encoding:
100+
- chunked
101+
referrer-policy:
102+
- strict-origin-when-cross-origin
103+
strict-transport-security:
104+
- max-age=63072000; includeSubDomains; preload
105+
vary:
70106
- Origin
71-
X-Neon-Ret-Request-Id:
72-
- b4439d52416bca497dd5ce25fe598756
107+
x-content-type-options:
108+
- nosniff
109+
x-frame-options:
110+
- SAMEORIGIN
111+
x-neon-ret-request-id:
112+
- 929237b6-fa5d-4afb-bd37-c394f4180323
73113
status:
74114
code: 200
75115
message: OK
@@ -89,25 +129,39 @@ interactions:
89129
User-Agent:
90130
- neon-client/python version=(0.1.0)
91131
method: DELETE
92-
uri: https://console.neon.tech/api/v2/api_keys/821303
132+
uri: https://console.neon.tech/api/v2/api_keys/1954948
93133
response:
94134
body:
95-
string: '{"id":821303,"name":"pytest-3951","revoked":true,"last_used_at":null,"last_used_from_addr":""}'
135+
string: '{"id":1954948,"name":"pytest-8050","created_at":"2025-01-16T21:01:58Z","created_by":"92cdd2ee-a6d8-4647-868f-124531123b03","last_used_at":null,"last_used_from_addr":"","revoked":true}'
96136
headers:
137+
CF-Cache-Status:
138+
- DYNAMIC
139+
CF-RAY:
140+
- 90310b3bbc9d7292-EWR
97141
Connection:
98142
- keep-alive
99-
Content-Length:
100-
- '94'
143+
Content-Encoding:
144+
- gzip
101145
Content-Type:
102-
- application/json
146+
- application/json; charset=utf-8
103147
Date:
104-
- Wed, 07 Feb 2024 14:04:02 GMT
105-
Strict-Transport-Security:
106-
- max-age=15724800; includeSubDomains
107-
Vary:
148+
- Thu, 16 Jan 2025 21:01:59 GMT
149+
Server:
150+
- cloudflare
151+
Transfer-Encoding:
152+
- chunked
153+
referrer-policy:
154+
- strict-origin-when-cross-origin
155+
strict-transport-security:
156+
- max-age=63072000; includeSubDomains; preload
157+
vary:
108158
- Origin
109-
X-Neon-Ret-Request-Id:
110-
- 5ba0f1a7236a57ed7f9d30e3631b2fef
159+
x-content-type-options:
160+
- nosniff
161+
x-frame-options:
162+
- SAMEORIGIN
163+
x-neon-ret-request-id:
164+
- fb342a59-a74a-47ce-a1da-46f8d6d1d2a1
111165
status:
112166
code: 200
113167
message: OK

0 commit comments

Comments
 (0)