Skip to content

Commit

Permalink
feat(api): update via SDK Studio (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Apr 9, 2024
1 parent 03e8cfe commit d6883da
Show file tree
Hide file tree
Showing 83 changed files with 1,264 additions and 858 deletions.
88 changes: 49 additions & 39 deletions api.md

Large diffs are not rendered by default.

58 changes: 27 additions & 31 deletions src/cloudflare/resources/intel/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@

from __future__ import annotations

from typing import Type, cast

import httpx

from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
from ..._utils import (
maybe_transform,
async_maybe_transform,
)
from ..._utils import maybe_transform
from ..._compat import cached_property
from ..._resource import SyncAPIResource, AsyncAPIResource
from ..._response import (
Expand All @@ -19,9 +14,10 @@
async_to_raw_response_wrapper,
async_to_streamed_response_wrapper,
)
from ..._wrappers import ResultWrapper
from ...types.intel import dns, dns_get_params
from ...pagination import SyncV4PagePagination, AsyncV4PagePagination
from ...types.intel import DNSListResponse, dns_list_params
from ..._base_client import (
AsyncPaginator,
make_request_options,
)

Expand All @@ -37,21 +33,21 @@ def with_raw_response(self) -> DNSWithRawResponse:
def with_streaming_response(self) -> DNSWithStreamingResponse:
return DNSWithStreamingResponse(self)

def get(
def list(
self,
*,
account_id: str,
ipv4: str | NotGiven = NOT_GIVEN,
page: float | NotGiven = NOT_GIVEN,
per_page: float | NotGiven = NOT_GIVEN,
start_end_params: dns_get_params.StartEndParams | NotGiven = NOT_GIVEN,
start_end_params: dns_list_params.StartEndParams | NotGiven = NOT_GIVEN,
# 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,
) -> dns.DNS:
) -> SyncV4PagePagination[DNSListResponse]:
"""
Get Passive DNS by IP
Expand All @@ -72,8 +68,9 @@ def get(
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return self._get(
return self._get_api_list(
f"/accounts/{account_id}/intel/dns",
page=SyncV4PagePagination[DNSListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
Expand All @@ -86,11 +83,10 @@ def get(
"per_page": per_page,
"start_end_params": start_end_params,
},
dns_get_params.DNSGetParams,
dns_list_params.DNSListParams,
),
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[dns.DNS], ResultWrapper[dns.DNS]),
model=DNSListResponse,
)


Expand All @@ -103,21 +99,21 @@ def with_raw_response(self) -> AsyncDNSWithRawResponse:
def with_streaming_response(self) -> AsyncDNSWithStreamingResponse:
return AsyncDNSWithStreamingResponse(self)

async def get(
def list(
self,
*,
account_id: str,
ipv4: str | NotGiven = NOT_GIVEN,
page: float | NotGiven = NOT_GIVEN,
per_page: float | NotGiven = NOT_GIVEN,
start_end_params: dns_get_params.StartEndParams | NotGiven = NOT_GIVEN,
start_end_params: dns_list_params.StartEndParams | NotGiven = NOT_GIVEN,
# 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,
) -> dns.DNS:
) -> AsyncPaginator[DNSListResponse, AsyncV4PagePagination[DNSListResponse]]:
"""
Get Passive DNS by IP
Expand All @@ -138,59 +134,59 @@ async def get(
"""
if not account_id:
raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}")
return await self._get(
return self._get_api_list(
f"/accounts/{account_id}/intel/dns",
page=AsyncV4PagePagination[DNSListResponse],
options=make_request_options(
extra_headers=extra_headers,
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform(
query=maybe_transform(
{
"ipv4": ipv4,
"page": page,
"per_page": per_page,
"start_end_params": start_end_params,
},
dns_get_params.DNSGetParams,
dns_list_params.DNSListParams,
),
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[dns.DNS], ResultWrapper[dns.DNS]),
model=DNSListResponse,
)


class DNSWithRawResponse:
def __init__(self, dns: DNS) -> None:
self._dns = dns

self.get = to_raw_response_wrapper(
dns.get,
self.list = to_raw_response_wrapper(
dns.list,
)


class AsyncDNSWithRawResponse:
def __init__(self, dns: AsyncDNS) -> None:
self._dns = dns

self.get = async_to_raw_response_wrapper(
dns.get,
self.list = async_to_raw_response_wrapper(
dns.list,
)


class DNSWithStreamingResponse:
def __init__(self, dns: DNS) -> None:
self._dns = dns

self.get = to_streamed_response_wrapper(
dns.get,
self.list = to_streamed_response_wrapper(
dns.list,
)


class AsyncDNSWithStreamingResponse:
def __init__(self, dns: AsyncDNS) -> None:
self._dns = dns

self.get = async_to_streamed_response_wrapper(
dns.get,
self.list = async_to_streamed_response_wrapper(
dns.list,
)
10 changes: 5 additions & 5 deletions src/cloudflare/resources/load_balancers/previews.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from ..._base_client import (
make_request_options,
)
from ...types.user.load_balancers import Preview
from ...types.load_balancers import PreviewGetResponse

__all__ = ["Previews", "AsyncPreviews"]

Expand All @@ -44,7 +44,7 @@ def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Preview:
) -> PreviewGetResponse:
"""
Get the result of a previous preview operation using the provided preview_id.
Expand Down Expand Up @@ -72,7 +72,7 @@ def get(
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Preview], ResultWrapper[Preview]),
cast_to=cast(Type[PreviewGetResponse], ResultWrapper[PreviewGetResponse]),
)


Expand All @@ -96,7 +96,7 @@ async def get(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> Preview:
) -> PreviewGetResponse:
"""
Get the result of a previous preview operation using the provided preview_id.
Expand Down Expand Up @@ -124,7 +124,7 @@ async def get(
timeout=timeout,
post_parser=ResultWrapper._unwrapper,
),
cast_to=cast(Type[Preview], ResultWrapper[Preview]),
cast_to=cast(Type[PreviewGetResponse], ResultWrapper[PreviewGetResponse]),
)


Expand Down
2 changes: 2 additions & 0 deletions src/cloudflare/resources/radar/bgp/bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
async_maybe_transform,
)
from ...._compat import cached_property
from .leaks.leaks import Leaks, AsyncLeaks
from ...._resource import SyncAPIResource, AsyncAPIResource
from ...._response import (
to_raw_response_wrapper,
Expand All @@ -59,6 +60,7 @@
from ...._base_client import (
make_request_options,
)
from .hijacks.hijacks import Hijacks, AsyncHijacks

__all__ = ["BGP", "AsyncBGP"]

Expand Down
33 changes: 33 additions & 0 deletions src/cloudflare/resources/radar/bgp/hijacks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .events import (
Events,
AsyncEvents,
EventsWithRawResponse,
AsyncEventsWithRawResponse,
EventsWithStreamingResponse,
AsyncEventsWithStreamingResponse,
)
from .hijacks import (
Hijacks,
AsyncHijacks,
HijacksWithRawResponse,
AsyncHijacksWithRawResponse,
HijacksWithStreamingResponse,
AsyncHijacksWithStreamingResponse,
)

__all__ = [
"Events",
"AsyncEvents",
"EventsWithRawResponse",
"AsyncEventsWithRawResponse",
"EventsWithStreamingResponse",
"AsyncEventsWithStreamingResponse",
"Hijacks",
"AsyncHijacks",
"HijacksWithRawResponse",
"AsyncHijacksWithRawResponse",
"HijacksWithStreamingResponse",
"AsyncHijacksWithStreamingResponse",
]
Loading

0 comments on commit d6883da

Please sign in to comment.