Skip to content

Commit

Permalink
feat(infrastructure_targets): add bulk endpoints (#2246)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Dec 6, 2024
1 parent c12dfc0 commit e2f5e1b
Show file tree
Hide file tree
Showing 7 changed files with 508 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1448
configured_endpoints: 1450
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-0530d6510c5b139af850d24a4f932d5139c8d321a955ffa101b0debafbd75465.yml
3 changes: 3 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5215,6 +5215,7 @@ from cloudflare.types.zero_trust.access.infrastructure import (
TargetCreateResponse,
TargetUpdateResponse,
TargetListResponse,
TargetBulkUpdateResponse,
TargetGetResponse,
)
```
Expand All @@ -5225,6 +5226,8 @@ Methods:
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>

### Applications
Expand Down
180 changes: 178 additions & 2 deletions src/cloudflare/resources/zero_trust/access/infrastructure/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Type, Union, Optional, cast
from typing import Type, Union, Iterable, Optional, cast
from datetime import datetime

import httpx
Expand All @@ -23,11 +23,17 @@
from ....._wrappers import ResultWrapper
from .....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray
from ....._base_client import AsyncPaginator, make_request_options
from .....types.zero_trust.access.infrastructure import target_list_params, target_create_params, target_update_params
from .....types.zero_trust.access.infrastructure import (
target_list_params,
target_create_params,
target_update_params,
target_bulk_update_params,
)
from .....types.zero_trust.access.infrastructure.target_get_response import TargetGetResponse
from .....types.zero_trust.access.infrastructure.target_list_response import TargetListResponse
from .....types.zero_trust.access.infrastructure.target_create_response import TargetCreateResponse
from .....types.zero_trust.access.infrastructure.target_update_response import TargetUpdateResponse
from .....types.zero_trust.access.infrastructure.target_bulk_update_response import TargetBulkUpdateResponse

__all__ = ["TargetsResource", "AsyncTargetsResource"]

Expand Down Expand Up @@ -286,6 +292,79 @@ def delete(
cast_to=NoneType,
)

def bulk_delete(
self,
*,
account_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> None:
"""
Removes one or more targets.
Args:
account_id: Account identifier
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
return self._delete(
f"/accounts/{account_id}/infrastructure/targets/batch",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=NoneType,
)

def bulk_update(
self,
*,
account_id: str,
body: Iterable[target_bulk_update_params.Body],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> TargetBulkUpdateResponse:
"""
Adds one or more targets.
Args:
account_id: Account identifier
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return self._put(
f"/accounts/{account_id}/infrastructure/targets/batch",
body=maybe_transform(body, Iterable[target_bulk_update_params.Body]),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=TargetBulkUpdateResponse,
)

def get(
self,
target_id: str,
Expand Down Expand Up @@ -585,6 +664,79 @@ async def delete(
cast_to=NoneType,
)

async def bulk_delete(
self,
*,
account_id: str,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> None:
"""
Removes one or more targets.
Args:
account_id: Account identifier
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
return await self._delete(
f"/accounts/{account_id}/infrastructure/targets/batch",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=NoneType,
)

async def bulk_update(
self,
*,
account_id: str,
body: Iterable[target_bulk_update_params.Body],
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> TargetBulkUpdateResponse:
"""
Adds one or more targets.
Args:
account_id: Account identifier
extra_headers: Send extra headers
extra_query: Add additional query parameters to the request
extra_body: Add additional JSON properties to the request
timeout: Override the client-level default timeout for this request, in seconds
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return await self._put(
f"/accounts/{account_id}/infrastructure/targets/batch",
body=await async_maybe_transform(body, Iterable[target_bulk_update_params.Body]),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=TargetBulkUpdateResponse,
)

async def get(
self,
target_id: str,
Expand Down Expand Up @@ -646,6 +798,12 @@ def __init__(self, targets: TargetsResource) -> None:
self.delete = to_raw_response_wrapper(
targets.delete,
)
self.bulk_delete = to_raw_response_wrapper(
targets.bulk_delete,
)
self.bulk_update = to_raw_response_wrapper(
targets.bulk_update,
)
self.get = to_raw_response_wrapper(
targets.get,
)
Expand All @@ -667,6 +825,12 @@ def __init__(self, targets: AsyncTargetsResource) -> None:
self.delete = async_to_raw_response_wrapper(
targets.delete,
)
self.bulk_delete = async_to_raw_response_wrapper(
targets.bulk_delete,
)
self.bulk_update = async_to_raw_response_wrapper(
targets.bulk_update,
)
self.get = async_to_raw_response_wrapper(
targets.get,
)
Expand All @@ -688,6 +852,12 @@ def __init__(self, targets: TargetsResource) -> None:
self.delete = to_streamed_response_wrapper(
targets.delete,
)
self.bulk_delete = to_streamed_response_wrapper(
targets.bulk_delete,
)
self.bulk_update = to_streamed_response_wrapper(
targets.bulk_update,
)
self.get = to_streamed_response_wrapper(
targets.get,
)
Expand All @@ -709,6 +879,12 @@ def __init__(self, targets: AsyncTargetsResource) -> None:
self.delete = async_to_streamed_response_wrapper(
targets.delete,
)
self.bulk_delete = async_to_streamed_response_wrapper(
targets.bulk_delete,
)
self.bulk_update = async_to_streamed_response_wrapper(
targets.bulk_update,
)
self.get = async_to_streamed_response_wrapper(
targets.get,
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
from .target_update_params import TargetUpdateParams as TargetUpdateParams
from .target_create_response import TargetCreateResponse as TargetCreateResponse
from .target_update_response import TargetUpdateResponse as TargetUpdateResponse
from .target_bulk_update_params import TargetBulkUpdateParams as TargetBulkUpdateParams
from .target_bulk_update_response import TargetBulkUpdateResponse as TargetBulkUpdateResponse
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

from typing import Iterable
from typing_extensions import Required, TypedDict

__all__ = ["TargetBulkUpdateParams", "Body", "BodyIP", "BodyIPIPV4", "BodyIPIPV6"]


class TargetBulkUpdateParams(TypedDict, total=False):
account_id: Required[str]
"""Account identifier"""

body: Required[Iterable[Body]]


class BodyIPIPV4(TypedDict, total=False):
ip_addr: str
"""IP address of the target"""

virtual_network_id: str
"""(optional) Private virtual network identifier for the target.
If omitted, the default virtual network ID will be used.
"""


class BodyIPIPV6(TypedDict, total=False):
ip_addr: str
"""IP address of the target"""

virtual_network_id: str
"""(optional) Private virtual network identifier for the target.
If omitted, the default virtual network ID will be used.
"""


class BodyIP(TypedDict, total=False):
ipv4: BodyIPIPV4
"""The target's IPv4 address"""

ipv6: BodyIPIPV6
"""The target's IPv6 address"""


class Body(TypedDict, total=False):
hostname: Required[str]
"""A non-unique field that refers to a target.
Case insensitive, maximum length of 255 characters, supports the use of special
characters dash and period, does not support spaces, and must start and end with
an alphanumeric character.
"""

ip: Required[BodyIP]
"""The IPv4/IPv6 address that identifies where to reach a target"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List, Optional
from datetime import datetime
from typing_extensions import TypeAlias

from ....._models import BaseModel

__all__ = [
"TargetBulkUpdateResponse",
"TargetBulkUpdateResponseItem",
"TargetBulkUpdateResponseItemIP",
"TargetBulkUpdateResponseItemIPIPV4",
"TargetBulkUpdateResponseItemIPIPV6",
]


class TargetBulkUpdateResponseItemIPIPV4(BaseModel):
ip_addr: Optional[str] = None
"""IP address of the target"""

virtual_network_id: Optional[str] = None
"""(optional) Private virtual network identifier for the target.
If omitted, the default virtual network ID will be used.
"""


class TargetBulkUpdateResponseItemIPIPV6(BaseModel):
ip_addr: Optional[str] = None
"""IP address of the target"""

virtual_network_id: Optional[str] = None
"""(optional) Private virtual network identifier for the target.
If omitted, the default virtual network ID will be used.
"""


class TargetBulkUpdateResponseItemIP(BaseModel):
ipv4: Optional[TargetBulkUpdateResponseItemIPIPV4] = None
"""The target's IPv4 address"""

ipv6: Optional[TargetBulkUpdateResponseItemIPIPV6] = None
"""The target's IPv6 address"""


class TargetBulkUpdateResponseItem(BaseModel):
id: str
"""Target identifier"""

created_at: datetime
"""Date and time at which the target was created"""

hostname: str
"""A non-unique field that refers to a target"""

ip: TargetBulkUpdateResponseItemIP
"""The IPv4/IPv6 address that identifies where to reach a target"""

modified_at: datetime
"""Date and time at which the target was modified"""


TargetBulkUpdateResponse: TypeAlias = List[TargetBulkUpdateResponseItem]
Loading

0 comments on commit e2f5e1b

Please sign in to comment.