Skip to content

Commit 32c3715

Browse files
feat(api): Add infrastructure targets bulk deletion endpoint
1 parent de2b2d0 commit 32c3715

File tree

6 files changed

+42
-6
lines changed

6 files changed

+42
-6
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 1741
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3c64e6b4765e941e2c348841e409930f3d720dca12a5278e2d974f2901763615.yml
33
openapi_spec_hash: e7dd315099896c954926181a718140de
4-
config_hash: 2782b93d61eb52118b969d0541d46a01
4+
config_hash: cbdf70f7c241783c9f039f2c0ba7fa0e

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5687,7 +5687,7 @@ Methods:
56875687
- <code title="put /accounts/{account_id}/infrastructure/targets/{target_id}">client.zero_trust.access.infrastructure.targets.<a href="./src/cloudflare/resources/zero_trust/access/infrastructure/targets.py">update</a>(target_id, \*, account_id, \*\*<a href="src/cloudflare/types/zero_trust/access/infrastructure/target_update_params.py">params</a>) -> <a href="./src/cloudflare/types/zero_trust/access/infrastructure/target_update_response.py">Optional[TargetUpdateResponse]</a></code>
56885688
- <code title="get /accounts/{account_id}/infrastructure/targets">client.zero_trust.access.infrastructure.targets.<a href="./src/cloudflare/resources/zero_trust/access/infrastructure/targets.py">list</a>(\*, account_id, \*\*<a href="src/cloudflare/types/zero_trust/access/infrastructure/target_list_params.py">params</a>) -> <a href="./src/cloudflare/types/zero_trust/access/infrastructure/target_list_response.py">SyncV4PagePaginationArray[TargetListResponse]</a></code>
56895689
- <code title="delete /accounts/{account_id}/infrastructure/targets/{target_id}">client.zero_trust.access.infrastructure.targets.<a href="./src/cloudflare/resources/zero_trust/access/infrastructure/targets.py">delete</a>(target_id, \*, account_id) -> None</code>
5690-
- <code title="delete /accounts/{account_id}/infrastructure/targets/batch">client.zero_trust.access.infrastructure.targets.<a href="./src/cloudflare/resources/zero_trust/access/infrastructure/targets.py">bulk_delete</a>(\*, account_id) -> None</code>
5690+
- <code title="post /accounts/{account_id}/infrastructure/targets/batch_delete">client.zero_trust.access.infrastructure.targets.<a href="./src/cloudflare/resources/zero_trust/access/infrastructure/targets.py">bulk_delete</a>(\*, account_id, \*\*<a href="src/cloudflare/types/zero_trust/access/infrastructure/target_bulk_delete_params.py">params</a>) -> None</code>
56915691
- <code title="put /accounts/{account_id}/infrastructure/targets/batch">client.zero_trust.access.infrastructure.targets.<a href="./src/cloudflare/resources/zero_trust/access/infrastructure/targets.py">bulk_update</a>(\*, account_id, \*\*<a href="src/cloudflare/types/zero_trust/access/infrastructure/target_bulk_update_params.py">params</a>) -> <a href="./src/cloudflare/types/zero_trust/access/infrastructure/target_bulk_update_response.py">SyncSinglePage[TargetBulkUpdateResponse]</a></code>
56925692
- <code title="get /accounts/{account_id}/infrastructure/targets/{target_id}">client.zero_trust.access.infrastructure.targets.<a href="./src/cloudflare/resources/zero_trust/access/infrastructure/targets.py">get</a>(target_id, \*, account_id) -> <a href="./src/cloudflare/types/zero_trust/access/infrastructure/target_get_response.py">Optional[TargetGetResponse]</a></code>
56935693

src/cloudflare/resources/zero_trust/access/infrastructure/targets.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
target_list_params,
2626
target_create_params,
2727
target_update_params,
28+
target_bulk_delete_params,
2829
target_bulk_update_params,
2930
)
3031
from .....types.zero_trust.access.infrastructure.target_get_response import TargetGetResponse
@@ -347,6 +348,7 @@ def bulk_delete(
347348
self,
348349
*,
349350
account_id: str,
351+
target_ids: List[str],
350352
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
351353
# The extra values given here take precedence over values defined on the client or passed to this method.
352354
extra_headers: Headers | None = None,
@@ -360,6 +362,8 @@ def bulk_delete(
360362
Args:
361363
account_id: Account identifier
362364
365+
target_ids: List of target IDs to bulk delete
366+
363367
extra_headers: Send extra headers
364368
365369
extra_query: Add additional query parameters to the request
@@ -371,8 +375,9 @@ def bulk_delete(
371375
if not account_id:
372376
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
373377
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
374-
return self._delete(
375-
f"/accounts/{account_id}/infrastructure/targets/batch",
378+
return self._post(
379+
f"/accounts/{account_id}/infrastructure/targets/batch_delete",
380+
body=maybe_transform({"target_ids": target_ids}, target_bulk_delete_params.TargetBulkDeleteParams),
376381
options=make_request_options(
377382
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
378383
),
@@ -774,6 +779,7 @@ async def bulk_delete(
774779
self,
775780
*,
776781
account_id: str,
782+
target_ids: List[str],
777783
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
778784
# The extra values given here take precedence over values defined on the client or passed to this method.
779785
extra_headers: Headers | None = None,
@@ -787,6 +793,8 @@ async def bulk_delete(
787793
Args:
788794
account_id: Account identifier
789795
796+
target_ids: List of target IDs to bulk delete
797+
790798
extra_headers: Send extra headers
791799
792800
extra_query: Add additional query parameters to the request
@@ -798,8 +806,11 @@ async def bulk_delete(
798806
if not account_id:
799807
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
800808
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
801-
return await self._delete(
802-
f"/accounts/{account_id}/infrastructure/targets/batch",
809+
return await self._post(
810+
f"/accounts/{account_id}/infrastructure/targets/batch_delete",
811+
body=await async_maybe_transform(
812+
{"target_ids": target_ids}, target_bulk_delete_params.TargetBulkDeleteParams
813+
),
803814
options=make_request_options(
804815
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
805816
),

src/cloudflare/types/zero_trust/access/infrastructure/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
from .target_update_params import TargetUpdateParams as TargetUpdateParams
1010
from .target_create_response import TargetCreateResponse as TargetCreateResponse
1111
from .target_update_response import TargetUpdateResponse as TargetUpdateResponse
12+
from .target_bulk_delete_params import TargetBulkDeleteParams as TargetBulkDeleteParams
1213
from .target_bulk_update_params import TargetBulkUpdateParams as TargetBulkUpdateParams
1314
from .target_bulk_update_response import TargetBulkUpdateResponse as TargetBulkUpdateResponse
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing import List
6+
from typing_extensions import Required, TypedDict
7+
8+
__all__ = ["TargetBulkDeleteParams"]
9+
10+
11+
class TargetBulkDeleteParams(TypedDict, total=False):
12+
account_id: Required[str]
13+
"""Account identifier"""
14+
15+
target_ids: Required[List[str]]
16+
"""List of target IDs to bulk delete"""

tests/api_resources/zero_trust/access/infrastructure/test_targets.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,15 @@ def test_path_params_delete(self, client: Cloudflare) -> None:
283283
def test_method_bulk_delete(self, client: Cloudflare) -> None:
284284
target = client.zero_trust.access.infrastructure.targets.bulk_delete(
285285
account_id="023e105f4ecef8ad9ca31a8372d0c353",
286+
target_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
286287
)
287288
assert target is None
288289

289290
@parametrize
290291
def test_raw_response_bulk_delete(self, client: Cloudflare) -> None:
291292
response = client.zero_trust.access.infrastructure.targets.with_raw_response.bulk_delete(
292293
account_id="023e105f4ecef8ad9ca31a8372d0c353",
294+
target_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
293295
)
294296

295297
assert response.is_closed is True
@@ -301,6 +303,7 @@ def test_raw_response_bulk_delete(self, client: Cloudflare) -> None:
301303
def test_streaming_response_bulk_delete(self, client: Cloudflare) -> None:
302304
with client.zero_trust.access.infrastructure.targets.with_streaming_response.bulk_delete(
303305
account_id="023e105f4ecef8ad9ca31a8372d0c353",
306+
target_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
304307
) as response:
305308
assert not response.is_closed
306309
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -315,6 +318,7 @@ def test_path_params_bulk_delete(self, client: Cloudflare) -> None:
315318
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
316319
client.zero_trust.access.infrastructure.targets.with_raw_response.bulk_delete(
317320
account_id="",
321+
target_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
318322
)
319323

320324
@parametrize
@@ -689,13 +693,15 @@ async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None:
689693
async def test_method_bulk_delete(self, async_client: AsyncCloudflare) -> None:
690694
target = await async_client.zero_trust.access.infrastructure.targets.bulk_delete(
691695
account_id="023e105f4ecef8ad9ca31a8372d0c353",
696+
target_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
692697
)
693698
assert target is None
694699

695700
@parametrize
696701
async def test_raw_response_bulk_delete(self, async_client: AsyncCloudflare) -> None:
697702
response = await async_client.zero_trust.access.infrastructure.targets.with_raw_response.bulk_delete(
698703
account_id="023e105f4ecef8ad9ca31a8372d0c353",
704+
target_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
699705
)
700706

701707
assert response.is_closed is True
@@ -707,6 +713,7 @@ async def test_raw_response_bulk_delete(self, async_client: AsyncCloudflare) ->
707713
async def test_streaming_response_bulk_delete(self, async_client: AsyncCloudflare) -> None:
708714
async with async_client.zero_trust.access.infrastructure.targets.with_streaming_response.bulk_delete(
709715
account_id="023e105f4ecef8ad9ca31a8372d0c353",
716+
target_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
710717
) as response:
711718
assert not response.is_closed
712719
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
@@ -721,6 +728,7 @@ async def test_path_params_bulk_delete(self, async_client: AsyncCloudflare) -> N
721728
with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"):
722729
await async_client.zero_trust.access.infrastructure.targets.with_raw_response.bulk_delete(
723730
account_id="",
731+
target_ids=["182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"],
724732
)
725733

726734
@parametrize

0 commit comments

Comments
 (0)