Skip to content

Commit 9584f44

Browse files
asonnenscheinclaude
andcommitted
- default page_size to 500 in list_reservations / list_jobs
(client, sync wrapper, CLI) to match SubscriptionsClient - drop section-divider banner comments from cli/quota.py and both quota test files - convert inline test comment to a docstring in test_list_reservations_respects_limit - align docstring cross-reference links to subscription_request.py style ([full.path.Class.method][]) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 6f03769 commit 9584f44

5 files changed

Lines changed: 20 additions & 91 deletions

File tree

planet/cli/quota.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ def quota(ctx, base_url):
6262
ctx.obj['BASE_URL'] = base_url
6363

6464

65-
# ---------------------------------------------------------------------------
66-
# Products
67-
# ---------------------------------------------------------------------------
68-
69-
7065
@quota.group()
7166
def products():
7267
"""Commands for inspecting products that support quota reservations."""
@@ -106,11 +101,6 @@ async def products_list(ctx, supports_reservation, pretty, compact):
106101
echo_json(results, pretty)
107102

108103

109-
# ---------------------------------------------------------------------------
110-
# Reservations
111-
# ---------------------------------------------------------------------------
112-
113-
114104
@quota.group()
115105
def reservations():
116106
"""Commands for managing quota reservations."""
@@ -131,8 +121,9 @@ def reservations():
131121
help='Filter by `{field}` or `{field}__{op}`. May be repeated.')
132122
@click.option('--page-size',
133123
type=click.INT,
134-
default=None,
135-
help='Number of reservations to return per page.')
124+
default=500,
125+
show_default=True,
126+
help='Number of results to return per page.')
136127
async def reservations_list(ctx,
137128
pretty,
138129
limit,
@@ -277,11 +268,6 @@ async def reservation_estimate(ctx,
277268
echo_json(result, pretty)
278269

279270

280-
# ---------------------------------------------------------------------------
281-
# Jobs
282-
# ---------------------------------------------------------------------------
283-
284-
285271
@quota.group()
286272
def jobs():
287273
"""Commands for tracking bulk quota reservation jobs."""

planet/clients/quota.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async def list_reservations(
110110
fields: Optional[str] = None,
111111
sort: Optional[str] = None,
112112
filters: Optional[Dict[str, Any]] = None,
113-
page_size: Optional[int] = None,
113+
page_size: int = 500,
114114
) -> AsyncIterator[dict]:
115115
"""Iterate over quota reservations.
116116
@@ -134,8 +134,7 @@ async def list_reservations(
134134
ClientError: on a client error.
135135
"""
136136
params = self._filter_params(fields=fields, sort=sort, filters=filters)
137-
if page_size is not None:
138-
params['limit'] = page_size
137+
params['limit'] = page_size
139138

140139
url = f'{self._reservations_url}/'
141140
try:
@@ -225,7 +224,7 @@ async def bulk_create_reservations(
225224
226225
Use this endpoint for large batches of AOI references. The response
227226
includes a `job_id` whose progress can be tracked with
228-
[`get_job`][planet.clients.quota.QuotaClient.get_job].
227+
[planet.clients.quota.QuotaClient.get_job][].
229228
230229
Parameters:
231230
aoi_refs: List of AOI feature references.
@@ -307,7 +306,7 @@ async def list_jobs(
307306
fields: Optional[str] = None,
308307
sort: Optional[str] = None,
309308
filters: Optional[Dict[str, Any]] = None,
310-
page_size: Optional[int] = None,
309+
page_size: int = 500,
311310
) -> AsyncIterator[dict]:
312311
"""Iterate over bulk quota reservation jobs.
313312
@@ -328,8 +327,7 @@ async def list_jobs(
328327
ClientError: on a client error.
329328
"""
330329
params = self._filter_params(fields=fields, sort=sort, filters=filters)
331-
if page_size is not None:
332-
params['limit'] = page_size
330+
params['limit'] = page_size
333331

334332
url = f'{self._reservations_url}/jobs'
335333
try:
@@ -378,9 +376,9 @@ async def list_products(
378376
"""List products available to the requesting user's organization.
379377
380378
Use this to look up the `product_id` (the `id` field) to pass into
381-
[`create_reservation`][planet.clients.quota.QuotaClient.create_reservation],
382-
[`bulk_create_reservations`][planet.clients.quota.QuotaClient.bulk_create_reservations],
383-
or [`estimate_reservation`][planet.clients.quota.QuotaClient.estimate_reservation].
379+
[planet.clients.quota.QuotaClient.create_reservation][],
380+
[planet.clients.quota.QuotaClient.bulk_create_reservations][],
381+
or [planet.clients.quota.QuotaClient.estimate_reservation][].
384382
385383
Parameters:
386384
supports_reservation: If True, only return products with

planet/sync/quota.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ def list_reservations(
5151
fields: Optional[str] = None,
5252
sort: Optional[str] = None,
5353
filters: Optional[Dict[str, Any]] = None,
54-
page_size: Optional[int] = None,
54+
page_size: int = 500,
5555
) -> Iterator[dict]:
5656
"""Iterate over quota reservations.
5757
58-
See [QuotaClient.list_reservations][planet.clients.quota.QuotaClient.list_reservations]
59-
for parameter details.
58+
See [planet.clients.quota.QuotaClient.list_reservations][] for
59+
parameter details.
6060
"""
6161
return self._client._aiter_to_iter(
6262
self._client.list_reservations(limit=limit,
@@ -98,7 +98,7 @@ def bulk_create_reservations(
9898
"""Submit a bulk quota reservation job.
9999
100100
Returns a payload with `job_id` and `status` - track progress with
101-
[get_job][planet.sync.quota.QuotaAPI.get_job].
101+
[planet.sync.quota.QuotaAPI.get_job][].
102102
"""
103103
return self._client._call_sync(
104104
self._client.bulk_create_reservations(aoi_refs,
@@ -123,7 +123,7 @@ def list_jobs(
123123
fields: Optional[str] = None,
124124
sort: Optional[str] = None,
125125
filters: Optional[Dict[str, Any]] = None,
126-
page_size: Optional[int] = None,
126+
page_size: int = 500,
127127
) -> Iterator[dict]:
128128
"""Iterate over bulk quota reservation jobs."""
129129
return self._client._aiter_to_iter(
@@ -144,9 +144,9 @@ def list_products(
144144
"""List products available to the requesting user's organization.
145145
146146
Use this to look up the `product_id` (the `id` field) to pass into
147-
[create_reservation][planet.sync.quota.QuotaAPI.create_reservation],
148-
[bulk_create_reservations][planet.sync.quota.QuotaAPI.bulk_create_reservations],
149-
or [estimate_reservation][planet.sync.quota.QuotaAPI.estimate_reservation].
147+
[planet.sync.quota.QuotaAPI.create_reservation][],
148+
[planet.sync.quota.QuotaAPI.bulk_create_reservations][],
149+
or [planet.sync.quota.QuotaAPI.estimate_reservation][].
150150
151151
Parameters:
152152
supports_reservation: If True, only return products with

tests/integration/test_quota_api.py

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ def _job(jid: str = "job-abc") -> dict:
8484
}
8585

8686

87-
# ---------------------------------------------------------------------------
88-
# list_reservations
89-
# ---------------------------------------------------------------------------
90-
91-
9287
@respx.mock
9388
async def test_list_reservations_single_page():
9489
mock_response(RESERVATIONS_URL, _reservations_page(0, 3))
@@ -116,7 +111,7 @@ async def test_list_reservations_paginated():
116111

117112
@respx.mock
118113
async def test_list_reservations_respects_limit():
119-
# Two pages of two items eachlimit=3 cuts iteration short.
114+
"""Two pages of two items each; limit=3 cuts iteration short."""
120115
next_url = f"{RESERVATIONS_URL}?cursor=abc"
121116
respx.get(RESERVATIONS_URL).mock(side_effect=[
122117
httpx.Response(200, json=_reservations_page(0, 2, next_url=next_url)),
@@ -149,11 +144,6 @@ async def test_list_reservations_query_params():
149144
assert sent["limit"] == "25"
150145

151146

152-
# ---------------------------------------------------------------------------
153-
# get_reservation
154-
# ---------------------------------------------------------------------------
155-
156-
157147
@respx.mock
158148
async def test_get_reservation():
159149
rid = 42
@@ -176,11 +166,6 @@ async def test_get_reservation_api_error():
176166
await cl_async.get_reservation(rid)
177167

178168

179-
# ---------------------------------------------------------------------------
180-
# create_reservation
181-
# ---------------------------------------------------------------------------
182-
183-
184169
@respx.mock
185170
async def test_create_reservation():
186171
payload = {
@@ -217,11 +202,6 @@ async def test_create_reservation_omits_collection_id_when_none():
217202
assert "collection_id" not in req_body
218203

219204

220-
# ---------------------------------------------------------------------------
221-
# bulk_create_reservations
222-
# ---------------------------------------------------------------------------
223-
224-
225205
@respx.mock
226206
async def test_bulk_create_reservations():
227207
bulk_url = f"{TEST_URL}/quota-reservations/bulk-reserve"
@@ -238,11 +218,6 @@ def assertf(resp):
238218
assert req_body == {"aoi_refs": [AOI_REF], "product_id": 100}
239219

240220

241-
# ---------------------------------------------------------------------------
242-
# estimate_reservation
243-
# ---------------------------------------------------------------------------
244-
245-
246221
@respx.mock
247222
async def test_estimate_reservation():
248223
estimate_url = f"{TEST_URL}/quota-reservations/estimate"
@@ -271,11 +246,6 @@ def assertf(resp):
271246
}
272247

273248

274-
# ---------------------------------------------------------------------------
275-
# Jobs
276-
# ---------------------------------------------------------------------------
277-
278-
279249
@respx.mock
280250
async def test_list_jobs():
281251
page = {"meta": {"count": 2}, "results": [_job("a"), _job("b")]}
@@ -305,11 +275,6 @@ async def test_get_job_empty_id_raises():
305275
await cl_async.get_job("")
306276

307277

308-
# ---------------------------------------------------------------------------
309-
# Products
310-
# ---------------------------------------------------------------------------
311-
312-
313278
@respx.mock
314279
async def test_list_products_list_payload():
315280
products = [

tests/integration/test_quota_cli.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ def _parse_json_lines(output: str):
4646
return [json.loads(line) for line in output.splitlines() if line.strip()]
4747

4848

49-
# ---------------------------------------------------------------------------
50-
# products
51-
# ---------------------------------------------------------------------------
52-
53-
5449
@respx.mock
5550
def test_cli_products_list():
5651
products = [
@@ -129,11 +124,6 @@ def test_cli_products_list_supports_reservation_flag():
129124
assert [p["id"] for p in json.loads(result.output)] == [1]
130125

131126

132-
# ---------------------------------------------------------------------------
133-
# reservations list / get
134-
# ---------------------------------------------------------------------------
135-
136-
137127
@respx.mock
138128
def test_cli_reservations_list():
139129
mock_response(RESERVATIONS_URL, _reservations_page(0, 3))
@@ -195,11 +185,6 @@ def test_cli_reservations_get():
195185
assert json.loads(result.output)["id"] == rid
196186

197187

198-
# ---------------------------------------------------------------------------
199-
# reservations create / bulk-reserve / estimate
200-
# ---------------------------------------------------------------------------
201-
202-
203188
@respx.mock
204189
def test_cli_reservation_create_aoi_ref_flags():
205190
"""Repeated --aoi-ref flags accumulate into a list."""
@@ -336,11 +321,6 @@ def test_cli_reservation_estimate():
336321
assert json.loads(result.output) == payload
337322

338323

339-
# ---------------------------------------------------------------------------
340-
# jobs list / get
341-
# ---------------------------------------------------------------------------
342-
343-
344324
@respx.mock
345325
def test_cli_jobs_list():
346326
page = {"meta": {"count": 2}, "results": [_job("a"), _job("b")]}

0 commit comments

Comments
 (0)