10000 feat(infrastructure_targets): add bulk endpoints (#2246) · cloudflare/cloudflare-python@6d2efe9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6d2efe9

Browse files
feat(infrastructure_targets): add bulk endpoints (#2246)
1 parent 72acad6 commit 6d2efe9

File tree

7 files changed

+508
-3
lines changed

7 files changed

+508
-3
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 1448
1+
configured_endpoints: 1450
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0530d6510c5b139af850d24a4f932d5139c8d321a955ffa101b0debafbd75465.yml

api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5215,6 +5215,7 @@ from cloudflare.types.zero_trust.access.infrastructure import (
52155215
TargetCreateResponse,
52165216
TargetUpdateResponse,
52175217
TargetListResponse,
5218+
TargetBulkUpdateResponse,
52185219
TargetGetResponse,
52195220
)
52205221
```
@@ -5225,6 +5226,8 @@ Methods:
52255226
- <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>
52265227
- <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>
52275228
- <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>
5229+
- <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>
5230+
- <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">TargetBulkUpdateResponse</a></code>
52285231
- <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>
52295232

52305233
### Applications

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

Lines changed: 178 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from typing import Type, Union, Optional, cast
5+
from typing import Type, Union, Iterable, Optional, cast
66
from datetime import datetime
77

88
import httpx
@@ -23,11 +23,17 @@
2323
from ....._wrappers import ResultWrapper
2424
from .....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
2525
from ....._base_client import AsyncPaginator, make_request_options
26-
from .....types.zero_trust.access.infrastructure import target_list_params, target_create_params, target_update_params
26+
from .....types.zero_trust.access.infrastructure import (
27+
target_list_params,
28+
target_create_params,
29+
target_update_params,
30+
target_bulk_update_params,
31+
)
2732
from .....types.zero_trust.access.infrastructure.target_get_response import TargetGetResponse
2833
from .....types.zero_trust.access.infrastructure.target_list_response import TargetListResponse
2934
from .....types.zero_trust.access.infrastructure.target_create_response import TargetCreateResponse
3035
from .....types.zero_trust.access.infrastructure.target_update_response import TargetUpdateResponse
36+
from .....types.zero_trust.access.infrastructure.target_bulk_update_response import TargetBulkUpdateResponse
3137

3238
__all__ = ["TargetsResource", "AsyncTargetsResource"]
3339

@@ -286,6 +292,79 @@ def delete(
286292
cast_to=NoneType,
287293
)
288294

295+
def bulk_delete(
296+
self,
297+
*,
298+
account_id: str,
299+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
300+
# The extra values given here take precedence over values defined on the client or passed to this method.
301+
extra_headers: Headers | None = None,
302+
extra_query: Query | None = None,
303+
extra_body: Body | None = None,
304+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
305+
) -> None:
306+
"""
307+
Removes one or more targets.
308+
309+
Args:
310+
account_id: Account identifier
311+
312+
extra_headers: Send extra headers
313+
314+
extra_query: Add additional query parameters to the request
315+
316+
extra_body: Add additional JSON properties to the request
317+
318+
timeout: Override the client-level default timeout for this request, in seconds
319+
"""
320+
if not account_id:
321+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
322+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
323+
return self._delete(
324+
f"/accounts/{account_id}/infrastructure/targets/batch",
325+
options=make_request_options(
326+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
327+
),
328+
cast_to=NoneType,
329+
)
330+
331+
def bulk_update(
332+
self,
333+
*,
334+
ac 10000 count_id: str,
335+
body: Iterable[target_bulk_update_params.Body],
336+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
337+
# The extra values given here take precedence over values defined on the client or passed to this method.
338+
extra_headers: Headers | None = None,
339+
extra_query: Query | None = None,
340+
extra_body: Body | None = None,
341+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
342+
) -> TargetBulkUpdateResponse:
343+
"""
344+
Adds one or more targets.
345+
346+
Args:
347+
account_id: Account identifier
348+
349+
extra_headers: Send extra headers
350+
351+
extra_query: Add additional query parameters to the request
352+
353+
extra_body: Add additional JSON properties to the request
354+
355+
timeout: Override the client-level default timeout for this request, in seconds
356+
"""
357+
if not account_id:
358+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
359+
return self._put(
360+
f"/accounts/{account_id}/infrastructure/targets/batch",
361+
body=maybe_transform(body, Iterable[target_bulk_update_params.Body]),
362+
options=make_request_options(
363+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
364+
),
365+
cast_to=TargetBulkUpdateResponse,
366+
)
367+
289368
def get(
290369
self,
291370
target_id: str,
@@ -585,6 +664,79 @@ async def delete(
585664
cast_to=NoneType,
586665
)
587666

667+
async def bulk_delete(
668+
self,
669+
*,
670+
account_id: str,
671+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
672+
# The extra values given here take precedence over values defined on the client or passed to this method.
673+
extra_headers: Headers | None = None,
674+
extra_query: Query | None = None,
675+
extra_body: Body | None = None,
676+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
677+
) -> None:
678+
"""
679+
Removes one or more targets.
680+
681+
Args:
682+
account_id: Account identifier
683+
684+
extra_headers: Send extra headers
685+
686+
extra_query: Add additional query parameters to the request
687+
688+
extra_body: Add additional JSON properties to the request
689+
690+
timeout: Override the client-level default timeout for this request, in seconds
691+
"""
692+
if not account_id:
693+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
694+
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
695+
return await self._delete(
696+
f"/accounts/{account_id}/infrastructure/targets/batch",
697+
options=make_request_options(
698+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
699+
),
700+
cast_to=NoneType,
701+
)
702+
703+
async def bulk_update(
704+
self,
705+
*,
706+
account_id: str,
707+
body: Iterable[target_bulk_update_params.Body],
708+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
709+
# The extra values given here take precedence over values defined on the client or passed to this method.
710+
extra_headers: Headers | None = None,
711+
extra_query: Query | None = None,
712+
extra_body: Body | None = None,
713+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
714+
) -> TargetBulkUpdateResponse:
715+
"""
716+
Adds one or more targets.
717+
718+
Args:
719+
account_id: Account identifier
720+
721+
extra_headers: Send extra headers
722+
723+
extra_query: Add additional query parameters to the request
724+
725+
extra_body: Add additional JSON properties to the request
726+
727+
timeout: Override the client-level default timeout for this request, in seconds
728+
"""
729+
if not account_id:
730+
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
731+
return await self._put(
732+
f"/accounts/{account_id}/infrastructure/targets/batch",
733+
body=await async_maybe_transform(body, Iterable[target_bulk_update_params.Body]),
734+
options=make_request_options(
735+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
736+
),
737+
cast_to=TargetBulkUpdateResponse,
738+
)
739+
588740
async def get(
589741
self,
590742
target_id: str,
@@ -646,6 +798,12 @@ def __init__(self, targets: TargetsResource) -> None:
646798
self.delete = to_raw_response_wrapper(
647799
targets.delete,
648800
)
801+
self.bulk_delete = to_raw_response_wrapper(
802+
targets.bulk_delete,
803+
)
804+
self.bulk_update = to_raw_response_wrapper(
805+
targets.bulk_update,
806+
)
649807
self.get = to_raw_response_wrapper(
650808
targets.get,
651809
)
@@ -667,6 +825,12 @@ def __init__(self, targets: AsyncTargetsResource) -> None:
667825
self.delete = async_to_raw_response_wrapper(
668826
targets.delete,
669827
)
828+
self.bulk_delete = async_to_raw_response_wrapper(
829+
targets.bulk_delete,
830+
)
831+
self.bulk_update = async_to_raw_response_wrapper(
832+
targets.bulk_update,
833+
)
670834
self.get = async_to_raw_response_wrapper(
671835
targets.get,
672836
)
@@ -688,6 +852,12 @@ def __init__(self, targets: TargetsResource) -> None:
688852
self.delete = to_streamed_response_wrapper(
689853
targets.delete,
690854
)
855+
self.bulk_delete = to_streamed_response_wrapper(
856+
targets.bulk_delete,
857+
)
858+
self.bulk_update = to_streamed_response_wrapper(
859+
targets.bulk_update,
860+
)
691861
self.get = to_streamed_response_wrapper(
692862
targets.get,
693863
)
@@ -709,6 +879,12 @@ def __init__(self, targets: AsyncTargetsResource) -> None:
709879
self.delete = async_to_streamed_response_wrapper(
710880
targets.delete,
711881
)
882+
self.bulk_delete = async_to_streamed_response_wrapper(
883+
targets.bulk_delete,
884+
)
885+
self.bulk_update = async_to_streamed_response_wrapper(
886+
targets.bulk_update,
887+
)
712888
self.get = async_to_streamed_response_wrapper(
713889
targets.get,
714890
)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
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_update_params import TargetBulkUpdateParams as TargetBulkUpdateParams
13+
from .target_bulk_update_response import TargetBulkUpdateResponse as TargetBulkUpdateResponse
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 Iterable
6+
from typing_extensions import Required, TypedDict
7+
8+
__all__ = ["TargetBulkUpdateParams", "Body", "BodyIP", "BodyIPIPV4", "BodyIPIPV6"]
9+
10+
11+
class TargetBulkUpdateParams(TypedDict, total=False):
12+
account_id: Required[str]
13+
"""Account identifier"""
14+
15+
body: Required[Iterable[Body]]
16+
17+
18+
class BodyIPIPV4(TypedDict, total=False):
19+
ip_addr: str
20+
"""IP address of the target"""
21+
22+
virtual_network_id: str
23+
"""(optional) Private virtual network identifier for the target.
24+
25+
If omitted, the default virtual network ID will be used.
26+
"""
27+
28+
29+
class BodyIPIPV6(TypedDict, total=False):
30+
ip_addr: str
31+
"""IP address of the target"""
32+
33+
virtual_network_id: str
34+
"""(optional) Private virtual network identifier for the target.
35+
36+
If omitted, the default virtual network ID will be used.
37+
"""
38+
39+
40+
class BodyIP(TypedDict, total=False):
41+
ipv4: BodyIPIPV4
42+
"""The target's IPv4 address"""
43+
44+
ipv6: BodyIPIPV6
45+
"""The target's IPv6 address"""
46+
47+
48+
class Body(TypedDict, total=False):
49+
hostname: Required[str]
50+
"""A non-unique field that refers to a target.
51+
52+
Case insensitive, maximum length of 255 characters, supports the use of special
53+
characters dash and period, does not support spaces, and must start and end with
54+
an alphanumeric character.
55+
"""
56+
57+
ip: Required[BodyIP]
58+
"""The IPv4/IPv6 address that identifies where to reach a target"""
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Optional
4+
from datetime import datetime
5+
from typing_extensions import TypeAlias
6+
7+
from ....._models import BaseModel
8+
9+
__all__ = [
10+
"TargetBulkUpdateResponse",
11+
"TargetBulkUpdateResponseItem",
12+
"TargetBulkUpdateResponseItemIP",
13+
"TargetBulkUpdateResponseItemIPIPV4",
14+
"TargetBulkUpdateResponseItemIPIPV6",
15+
]
16+
17+
18+
class TargetBulkUpdateResponseItemIPIPV4(BaseModel):
19+
ip_addr: Optional[str] = None
20+
"""IP address of the target"""
21+
22+
virtual_network_id: Optional[str] = None
23+
"""(optional) Private virtual network identifier for the target.
24+
25+
If omitted, the default virtual network ID will be used.
26+
"""
27+
28+
29+
class TargetBulkUpdateResponseItemIPIPV6(BaseModel):
30+
ip_addr: Optional[str] = None
31+
"""IP address of the target"""
32+
33+
virtual_network_id: Optional[str] = None
34+
"""(optional) Private virtual network identifier for the target.
35+
36+
If omitted, the default virtual network ID will be used.
37+
"""
38+
39+
40+
class TargetBulkUpdateResponseItemIP(BaseModel):
41+
ipv4: Optional[TargetBulkUpdateResponseItemIPIPV4] = None
42+
"""The target's IPv4 address"""
43+
44+
ipv6: Optional[TargetBulkUpdateResponseItemIPIPV6] = None
45+
"""The target's IPv6 address"""
46+
47+
48+
class TargetBulkUpdateResponseItem(BaseModel):
49+
id: str
50+
"""Target identifier"""
51+
52+
created_at: datetime
53+
"""Date and time at which the target was created"""
54+
55+
hostname: str
56+
"""A non-unique field that refers to a target"""
57+
58+
ip: TargetBulkUpdateResponseItemIP
59+
"""The IPv4/IPv6 address that identifies where to reach a target"""
60+
61+
modified_at: datetime
62+
"""Date and time at which the target was modified"""
63+
64+
65+
TargetBulkUpdateResponse: TypeAlias = List[TargetBulkUpdateResponseItem]

0 commit comments

Comments
 (0)
0