Skip to content

Commit bb4bd21

Browse files
feat(api): api update
1 parent b79fd2f commit bb4bd21

File tree

5 files changed

+32
-38
lines changed

5 files changed

+32
-38
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 1733
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2d8efd1c4f1daadc851ed83c6715729fe7deed595b79e9fe637c1e25c613e859.yml
3-
openapi_spec_hash: 4d618fb7ff5153293142acae9a048520
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-71fe745fb2ce858e189088945891de70bb3246e184690421288e4bb111060d13.yml
3+
openapi_spec_hash: b1ad086b16f1f426f257a04885802191
44
config_hash: dfeb8d5cdc5b0e8ce06686b558ed124e

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5643,7 +5643,7 @@ Methods:
56435643
- <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>
56445644
- <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>
56455645
- <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>
5646-
- <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>
5646+
- <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>
56475647
- <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>
56485648

56495649
### Applications

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
async_to_streamed_response_wrapper,
2020
)
2121
from ....._wrappers import ResultWrapper
22-
from .....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
22+
from .....pagination import SyncSinglePage, AsyncSinglePage, SyncV4PagePaginationArray, AsyncV4PagePaginationArray
2323
from ....._base_client import AsyncPaginator, make_request_options
2424
from .....types.zero_trust.access.infrastructure import (
2525
target_list_params,
@@ -390,7 +390,7 @@ def bulk_update(
390390
extra_query: Query | None = None,
391391
extra_body: Body | None = None,
392392
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
393-
) -> TargetBulkUpdateResponse:
393+
) -> SyncSinglePage[TargetBulkUpdateResponse]:
394394
"""
395395
Adds one or more targets.
396396
@@ -407,13 +407,15 @@ def bulk_update(
407407
"""
408408
if not account_id:
409409
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
410-
return self._put(
410+
return self._get_api_list(
411411
f"/accounts/{account_id}/infrastructure/targets/batch",
412+
page=SyncSinglePage[TargetBulkUpdateResponse],
412413
body=maybe_transform(body, Iterable[target_bulk_update_params.Body]),
413414
options=make_request_options(
414415
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
415416
),
416-
cast_to=TargetBulkUpdateResponse,
417+
model=TargetBulkUpdateResponse,
418+
method="put",
417419
)
418420

419421
def get(
@@ -804,7 +806,7 @@ async def bulk_delete(
804806
cast_to=NoneType,
805807
)
806808

807-
async def bulk_update(
809+
def bulk_update(
808810
self,
809811
*,
810812
account_id: str,
@@ -815,7 +817,7 @@ async def bulk_update(
815817
extra_query: Query | None = None,
816818
extra_body: Body | None = None,
817819
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
818-
) -> TargetBulkUpdateResponse:
820+
) -> AsyncPaginator[TargetBulkUpdateResponse, AsyncSinglePage[TargetBulkUpdateResponse]]:
819821
"""
820822
Adds one or more targets.
821823
@@ -832,13 +834,15 @@ async def bulk_update(
832834
"""
833835
if not account_id:
834836
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
835-
return await self._put(
837+
return self._get_api_list(
836838
f"/accounts/{account_id}/infrastructure/targets/batch",
837-
body=await async_maybe_transform(body, Iterable[target_bulk_update_params.Body]),
839+
page=AsyncSinglePage[TargetBulkUpdateResponse],
840+
body=maybe_transform(body, Iterable[target_bulk_update_params.Body]),
838841
options=make_request_options(
839842
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
840843
),
841-
cast_to=TargetBulkUpdateResponse,
844+
model=TargetBulkUpdateResponse,
845+
method="put",
842846
)
843847

844848
async def get(
Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import List, Optional
3+
from typing import Optional
44
from datetime import datetime
5-
from typing_extensions import TypeAlias
65

76
from ....._models import BaseModel
87

9-
__all__ = [
10-
"TargetBulkUpdateResponse",
11-
"TargetBulkUpdateResponseItem",
12-
"TargetBulkUpdateResponseItemIP",
13-
"TargetBulkUpdateResponseItemIPIPV4",
14-
"TargetBulkUpdateResponseItemIPIPV6",
15-
]
8+
__all__ = ["TargetBulkUpdateResponse", "IP", "IPIPV4", "IPIPV6"]
169

1710

18-
class TargetBulkUpdateResponseItemIPIPV4(BaseModel):
11+
class IPIPV4(BaseModel):
1912
ip_addr: Optional[str] = None
2013
"""IP address of the target"""
2114

@@ -26,7 +19,7 @@ class TargetBulkUpdateResponseItemIPIPV4(BaseModel):
2619
"""
2720

2821

29-
class TargetBulkUpdateResponseItemIPIPV6(BaseModel):
22+
class IPIPV6(BaseModel):
3023
ip_addr: Optional[str] = None
3124
"""IP address of the target"""
3225

@@ -37,15 +30,15 @@ class TargetBulkUpdateResponseItemIPIPV6(BaseModel):
3730
"""
3831

3932

40-
class TargetBulkUpdateResponseItemIP(BaseModel):
41-
ipv4: Optional[TargetBulkUpdateResponseItemIPIPV4] = None
33+
class IP(BaseModel):
34+
ipv4: Optional[IPIPV4] = None
4235
"""The target's IPv4 address"""
4336

44-
ipv6: Optional[TargetBulkUpdateResponseItemIPIPV6] = None
37+
ipv6: Optional[IPIPV6] = None
4538
"""The target's IPv6 address"""
4639

4740

48-
class TargetBulkUpdateResponseItem(BaseModel):
41+
class TargetBulkUpdateResponse(BaseModel):
4942
id: str
5043
"""Target identifier"""
5144

@@ -55,11 +48,8 @@ class TargetBulkUpdateResponseItem(BaseModel):
5548
hostname: str
5649
"""A non-unique field that refers to a target"""
5750

58-
ip: TargetBulkUpdateResponseItemIP
51+
ip: IP
5952
"""The IPv4/IPv6 address that identifies where to reach a target"""
6053

6154
modified_at: datetime
6255
"""Date and time at which the target was modified"""
63-
64-
65-
TargetBulkUpdateResponse: TypeAlias = List[TargetBulkUpdateResponseItem]

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from cloudflare import Cloudflare, AsyncCloudflare
1111
from tests.utils import assert_matches_type
1212
from cloudflare._utils import parse_datetime
13-
from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
13+
from cloudflare.pagination import SyncSinglePage, AsyncSinglePage, SyncV4PagePaginationArray, AsyncV4PagePaginationArray
1414
from cloudflare.types.zero_trust.access.infrastructure import (
1515
TargetGetResponse,
1616
TargetListResponse,
@@ -328,7 +328,7 @@ def test_method_bulk_update(self, client: Cloudflare) -> None:
328328
}
329329
],
330330
)
331-
assert_matches_type(TargetBulkUpdateResponse, target, path=["response"])
331+
assert_matches_type(SyncSinglePage[TargetBulkUpdateResponse], target, path=["response"])
332332

333333
@parametrize
334334
def test_raw_response_bulk_update(self, client: Cloudflare) -> None:
@@ -345,7 +345,7 @@ def test_raw_response_bulk_update(self, client: Cloudflare) -> None:
345345
assert response.is_closed is True
346346
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
347347
target = response.parse()
348-
assert_matches_type(TargetBulkUpdateResponse, target, path=["response"])
348+
assert_matches_type(SyncSinglePage[TargetBulkUpdateResponse], target, path=["response"])
349349

350350
@parametrize
351351
def test_streaming_response_bulk_update(self, client: Cloudflare) -> None:
@@ -362,7 +362,7 @@ def test_streaming_response_bulk_update(self, client: Cloudflare) -> None:
362362
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
363363

364364
target = response.parse()
365-
assert_matches_type(TargetBulkUpdateResponse, target, path=["response"])
365+
assert_matches_type(SyncSinglePage[TargetBulkUpdateResponse], target, path=["response"])
366366

367367
assert cast(Any, response.is_closed) is True
368368

@@ -734,7 +734,7 @@ async def test_method_bulk_update(self, async_client: AsyncCloudflare) -> None:
734734
}
735735
],
736736
)
737-
assert_matches_type(TargetBulkUpdateResponse, target, path=["response"])
737+
assert_matches_type(AsyncSinglePage[TargetBulkUpdateResponse], target, path=["response"])
738738

739739
@parametrize
740740
async def test_raw_response_bulk_update(self, async_client: AsyncCloudflare) -> None:
@@ -751,7 +751,7 @@ async def test_raw_response_bulk_update(self, async_client: AsyncCloudflare) ->
751751
assert response.is_closed is True
752752
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
753753
target = await response.parse()
754-
assert_matches_type(TargetBulkUpdateResponse, target, path=["response"])
754+
assert_matches_type(AsyncSinglePage[TargetBulkUpdateResponse], target, path=["response"])
755755

756756
@parametrize
757757
async def test_streaming_response_bulk_update(self, async_client: AsyncCloudflare) -> None:
@@ -768,7 +768,7 @@ async def test_streaming_response_bulk_update(self, async_client: AsyncCloudflar
768768
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
769769

770770
target = await response.parse()
771-
assert_matches_type(TargetBulkUpdateResponse, target, path=["response"])
771+
assert_matches_type(AsyncSinglePage[TargetBulkUpdateResponse], target, path=["response"])
772772

773773
assert cast(Any, response.is_closed) is True
774774

0 commit comments

Comments
 (0)