Skip to content

Commit a5f7dc7

Browse files
feat(api): Add new bulk deletion endpoint for ZT infra targets
1 parent 8aca850 commit a5f7dc7

File tree

15 files changed

+234
-63
lines changed

15 files changed

+234
-63
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1751
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-411828654ba9f71c06be10985d2328b174497e826108c74e4537f9fc36538690.yml
3-
openapi_spec_hash: 696058d2e96a27a14330444b1975cde9
4-
config_hash: 259b5eeae0358ea7d7756b294847f140
1+
configured_endpoints: 1752
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-8af681407f6a8347fb5b5bb6cf6276123fd59a3930c0d41f0e0969a2460dbd72.yml
3+
openapi_spec_hash: 27a07fe056598eaa2505f33b35c23616
4+
config_hash: 135c41c52147f104907327e028f831e2

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5618,6 +5618,7 @@ Methods:
56185618
- <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>
56195619
- <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>
56205620
- <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>
5621+
- <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_v2</a>(\*, account_id, \*\*<a href="src/cloudflare/types/zero_trust/access/infrastructure/target_bulk_delete_v2_params.py">params</a>) -> None</code>
56215622
- <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>
56225623
- <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>
56235624

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

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
target_create_params,
2828
target_update_params,
2929
target_bulk_update_params,
30+
target_bulk_delete_v2_params,
3031
)
3132
from .....types.zero_trust.access.infrastructure.target_get_response import TargetGetResponse
3233
from .....types.zero_trust.access.infrastructure.target_list_response import TargetListResponse
@@ -381,6 +382,46 @@ def bulk_delete(
381382
cast_to=NoneType,
382383
)
383384

385+
def bulk_delete_v2(
386+
self,
387+
*,
388+
account_id: str,
389+
target_ids: List[str],
390+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
391+
# The extra values given here take precedence over values defined on the client or passed to this method.
392+
extra_headers: Headers | None = None,
393+
extra_query: Query | None = None,
394+
extra_body: Body | None = None,
395+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
396+
) -> None:
397+
"""
398+
Removes one or more targets.
399+
400+
Args:
401+
account_id: Account identifier
402+
403+
target_ids: List of target IDs to bulk delete
404+
405+
extra_headers: Send extra headers
406+
407+
extra_query: Add additional query parameters to the request
408+
409+
extra_body: Add additional JSON properties to the request
410+
411+
timeout: Override the client-level default timeout for this request, in seconds
412+
"""
413+
if not account_id:
414+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
415+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
416+
return self._post(
417+
f"/accounts/{account_id}/infrastructure/targets/batch_delete",
418+
body=maybe_transform({"target_ids": target_ids}, target_bulk_delete_v2_params.TargetBulkDeleteV2Params),
419+
options=make_request_options(
420+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
421+
),
422+
cast_to=NoneType,
423+
)
424+
384425
def bulk_update(
385426
self,
386427
*,
@@ -809,6 +850,48 @@ async def bulk_delete(
809850
cast_to=NoneType,
810851
)
811852

853+
async def bulk_delete_v2(
854+
self,
855+
*,
856+
account_id: str,
857+
target_ids: List[str],
858+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
859+
# The extra values given here take precedence over values defined on the client or passed to this method.
860+
extra_headers: Headers | None = None,
861+
extra_query: Query | None = None,
862+
extra_body: Body | None = None,
863+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
864+
) -> None:
865+
"""
866+
Removes one or more targets.
867+
868+
Args:
869+
account_id: Account identifier
870+
871+
target_ids: List of target IDs to bulk delete
872+
873+
extra_headers: Send extra headers
874+
875+
extra_query: Add additional query parameters to the request
876+
877+
extra_body: Add additional JSON properties to the request
878+
879+
timeout: Override the client-level default timeout for this request, in seconds
880+
"""
881+
if not account_id:
882+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
883+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
884+
return await self._post(
885+
f"/accounts/{account_id}/infrastructure/targets/batch_delete",
886+
body=await async_maybe_transform(
887+
{"target_ids": target_ids}, target_bulk_delete_v2_params.TargetBulkDeleteV2Params
888+
),
889+
options=make_request_options(
890+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
891+
),
892+
cast_to=NoneType,
893+
)
894+
812895
def bulk_update(
813896
self,
814897
*,
@@ -914,6 +997,9 @@ def __init__(self, targets: TargetsResource) -> None:
914997
targets.bulk_delete # pyright: ignore[reportDeprecated],
915998
)
916999
)
1000+
self.bulk_delete_v2 = to_raw_response_wrapper(
1001+
targets.bulk_delete_v2,
1002+
)
9171003
self.bulk_update = to_raw_response_wrapper(
9181004
targets.bulk_update,
9191005
)
@@ -943,6 +1029,9 @@ def __init__(self, targets: AsyncTargetsResource) -> None:
9431029
targets.bulk_delete # pyright: ignore[reportDeprecated],
9441030
)
9451031
)
1032+
self.bulk_delete_v2 = async_to_raw_response_wrapper(
1033+
targets.bulk_delete_v2,
1034+
)
9461035
self.bulk_update = async_to_raw_response_wrapper(
9471036
targets.bulk_update,
9481037
)
@@ -972,6 +1061,9 @@ def __init__(self, targets: TargetsResource) -> None:
9721061
targets.bulk_delete # pyright: ignore[reportDeprecated],
9731062
)
9741063
)
1064+
self.bulk_delete_v2 = to_streamed_response_wrapper(
1065+
targets.bulk_delete_v2,
1066+
)
9751067
self.bulk_update = to_streamed_response_wrapper(
9761068
targets.bulk_update,
9771069
)
@@ -1001,6 +1093,9 @@ def __init__(self, targets: AsyncTargetsResource) -> None:
10011093
targets.bulk_delete # pyright: ignore[reportDeprecated],
10021094
)
10031095
)
1096+
self.bulk_delete_v2 = async_to_streamed_response_wrapper(
1097+
targets.bulk_delete_v2,
1098+
)
10041099
self.bulk_update = async_to_streamed_response_wrapper(
10051100
targets.bulk_update,
10061101
)

src/cloudflare/resources/zero_trust/devices/devices.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,8 @@ def list(
194194
extra_body: Body | None = None,
195195
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
196196
) -> SyncSinglePage[Device]:
197-
"""List WARP devices.
198-
199-
Not supported when
200-
[multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
201-
is enabled for the account.
197+
"""
198+
List WARP registrations.
202199
203200
**Deprecated**: please use one of the following endpoints instead:
204201
@@ -238,11 +235,8 @@ def get(
238235
extra_body: Body | None = None,
239236
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
240237
) -> Optional[DeviceGetResponse]:
241-
"""Fetches a single WARP device.
242-
243-
Not supported when
244-
[multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
245-
is enabled for the account.
238+
"""
239+
Fetches a single WARP registration.
246240
247241
**Deprecated**: please use one of the following endpoints instead:
248242
@@ -358,11 +352,8 @@ def list(
358352
extra_body: Body | None = None,
359353
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
360354
) -> AsyncPaginator[Device, AsyncSinglePage[Device]]:
361-
"""List WARP devices.
362-
363-
Not supported when
364-
[multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
365-
is enabled for the account.
355+
"""
356+
List WARP registrations.
366357
367358
**Deprecated**: please use one of the following endpoints instead:
368359
@@ -402,11 +393,8 @@ async def get(
402393
extra_body: Body | None = None,
403394
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
404395
) -> Optional[DeviceGetResponse]:
405-
"""Fetches a single WARP device.
406-
407-
Not supported when
408-
[multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
409-
is enabled for the account.
396+
"""
397+
Fetches a single WARP registration.
410398
411399
**Deprecated**: please use one of the following endpoints instead:
412400

src/cloudflare/resources/zero_trust/devices/devices_.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def revoke(
230230
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
231231
) -> object:
232232
"""
233-
Revokes all WARP registrations associated with the specified device.
233+
Revokes all registrations associated with the specified device.
234234
235235
Args:
236236
extra_headers: Send extra headers
@@ -461,7 +461,7 @@ async def revoke(
461461
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
462462
) -> object:
463463
"""
464-
Revokes all WARP registrations associated with the specified device.
464+
Revokes all registrations associated with the specified device.
465465
466466
Args:
467467
extra_headers: Send extra headers

src/cloudflare/resources/zero_trust/devices/override_codes.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,12 @@ def list(
5757
extra_body: Body | None = None,
5858
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
5959
) -> SyncSinglePage[object]:
60-
"""Fetches a one-time use admin override code for a device.
60+
"""Fetches a one-time use admin override code for a registration.
6161
62-
This relies on the
63-
**Admin Override** setting being enabled in your device configuration. Not
64-
supported when
65-
[multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
66-
is enabled for the account. **Deprecated:** please use GET
62+
This relies on
63+
the **Admin Override** setting being enabled in your device configuration.
64+
65+
**Deprecated:** please use GET
6766
/accounts/{account_id}/devices/registrations/{registration_id}/override_codes
6867
instead.
6968
@@ -168,13 +167,12 @@ def list(
168167
extra_body: Body | None = None,
169168
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
170169
) -> AsyncPaginator[object, AsyncSinglePage[object]]:
171-
"""Fetches a one-time use admin override code for a device.
170+
"""Fetches a one-time use admin override code for a registration.
172171
173-
This relies on the
174-
**Admin Override** setting being enabled in your device configuration. Not
175-
supported when
176-
[multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
177-
is enabled for the account. **Deprecated:** please use GET
172+
This relies on
173+
the **Admin Override** setting being enabled in your device configuration.
174+
175+
**Deprecated:** please use GET
178176
/accounts/{account_id}/devices/registrations/{registration_id}/override_codes
179177
instead.
180178

src/cloudflare/resources/zero_trust/devices/registrations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def list(
7676
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
7777
) -> SyncCursorPagination[RegistrationListResponse]:
7878
"""
79-
Lists WARP registrations.
79+
List WARP registrations.
8080
8181
Args:
8282
id: Filter by registration ID.
@@ -388,7 +388,7 @@ def list(
388388
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
389389
) -> AsyncPaginator[RegistrationListResponse, AsyncCursorPagination[RegistrationListResponse]]:
390390
"""
391-
Lists WARP registrations.
391+
List WARP registrations.
392392
393393
Args:
394394
id: Filter by registration ID.

src/cloudflare/resources/zero_trust/devices/revoke.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,8 @@ def create(
5757
extra_body: Body | None = None,
5858
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
5959
) -> Optional[RevokeCreateResponse]:
60-
"""Revokes a list of devices.
61-
62-
Not supported when
63-
[multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
64-
is enabled.
60+
"""
61+
Revokes a list of registrations.
6562
6663
**Deprecated**: please use POST
6764
/accounts/{account_id}/devices/registrations/revoke instead.
@@ -131,11 +128,8 @@ async def create(
131128
extra_body: Body | None = None,
132129
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
133130
) -> Optional[RevokeCreateResponse]:
134-
"""Revokes a list of devices.
135-
136-
Not supported when
137-
[multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
138-
is enabled.
131+
"""
132+
Revokes a list of registrations.
139133
140134
**Deprecated**: please use POST
141135
/accounts/{account_id}/devices/registrations/revoke instead.

src/cloudflare/resources/zero_trust/devices/unrevoke.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,8 @@ def create(
5757
extra_body: Body | None = None,
5858
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
5959
) -> Optional[UnrevokeCreateResponse]:
60-
"""Unrevokes a list of devices.
61-
62-
Not supported when
63-
[multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
64-
is enabled.
60+
"""
61+
Unrevokes a list of registrations.
6562
6663
**Deprecated**: please use POST
6764
/accounts/{account_id}/devices/registrations/unrevoke instead.
@@ -131,11 +128,8 @@ async def create(
131128
extra_body: Body | None = None,
132129
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
133130
) -> Optional[UnrevokeCreateResponse]:
134-
"""Unrevokes a list of devices.
135-
136-
Not supported when
137-
[multi-user mode](https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/deployment/mdm-deployment/windows-multiuser/)
138-
is enabled.
131+
"""
132+
Unrevokes a list of registrations.
139133
140134
**Deprecated**: please use POST
141135
/accounts/{account_id}/devices/registrations/unrevoke instead.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
from .target_update_response import TargetUpdateResponse as TargetUpdateResponse
1212
from .target_bulk_update_params import TargetBulkUpdateParams as TargetBulkUpdateParams
1313
from .target_bulk_update_response import TargetBulkUpdateResponse as TargetBulkUpdateResponse
14+
from .target_bulk_delete_v2_params import TargetBulkDeleteV2Params as TargetBulkDeleteV2Params
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__ = ["TargetBulkDeleteV2Params"]
9+
10+
11+
class TargetBulkDeleteV2Params(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"""

src/cloudflare/types/zero_trust/devices/device_get_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class DeviceGetResponse(BaseModel):
5353
"""A string that uniquely identifies the hardware or virtual machine (VM)."""
5454

5555
last_seen_user: Optional[LastSeenUser] = None
56-
"""The last user to use the WARP device."""
56+
"""The last Access user to use the WARP device."""
5757

5858
mac_address: Optional[str] = None
5959
"""The device MAC address."""

src/cloudflare/types/zero_trust/devices/device_list_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class DeviceListResponse(BaseModel):
5353
"""A string that uniquely identifies the hardware or virtual machine (VM)."""
5454

5555
last_seen_user: Optional[LastSeenUser] = None
56-
"""The last user to use the WARP device."""
56+
"""The last Access user to use the WARP device."""
5757

5858
mac_address: Optional[str] = None
5959
"""The device MAC address."""

src/cloudflare/types/zero_trust/devices/registration_list_params.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ class Device(TypedDict, total=False):
6262

6363
class User(TypedDict, total=False):
6464
id: List[str]
65-
"""Filter by user ID."""
65+
"""Filter by Access user ID."""

0 commit comments

Comments
 (0)