diff --git a/.stats.yml b/.stats.yml index 343225bf43e..4985c92649b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 1702 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3a98ff8678360cbcb06d9de010a178736703c559351020d019e478cabc36a459.yml openapi_spec_hash: ccd6a7d73340e32900371f494e0b371e -config_hash: 02efc0b488a456e69c13dc4a934c658a +config_hash: 597c14ab32ec8c7121c4e81a6681c26e diff --git a/api.md b/api.md index b568800541b..39c854aa040 100644 --- a/api.md +++ b/api.md @@ -2535,41 +2535,21 @@ Methods: ### Telemetry -#### Keys - -Types: - -```python -from cloudflare.types.workers.observability.telemetry import KeyCreateResponse -``` - -Methods: - -- client.workers.observability.telemetry.keys.create(\*, account_id, \*\*params) -> SyncSinglePage[KeyCreateResponse] - -#### Query - Types: ```python -from cloudflare.types.workers.observability.telemetry import QueryCreateResponse -``` - -Methods: - -- client.workers.observability.telemetry.query.create(\*, account_id, \*\*params) -> QueryCreateResponse - -#### Values - -Types: - -```python -from cloudflare.types.workers.observability.telemetry import ValueCreateResponse +from cloudflare.types.workers.observability import ( + TelemetryKeysResponse, + TelemetryQueryResponse, + TelemetryValuesResponse, +) ``` Methods: -- client.workers.observability.telemetry.values.create(\*, account_id, \*\*params) -> SyncSinglePage[ValueCreateResponse] +- client.workers.observability.telemetry.keys(\*, account_id, \*\*params) -> SyncSinglePage[TelemetryKeysResponse] +- client.workers.observability.telemetry.query(\*, account_id, \*\*params) -> TelemetryQueryResponse +- client.workers.observability.telemetry.values(\*, account_id, \*\*params) -> SyncSinglePage[TelemetryValuesResponse] # KV diff --git a/src/cloudflare/resources/workers/observability/observability.py b/src/cloudflare/resources/workers/observability/observability.py index e3b857fa30e..7e09842a71a 100644 --- a/src/cloudflare/resources/workers/observability/observability.py +++ b/src/cloudflare/resources/workers/observability/observability.py @@ -2,9 +2,7 @@ from __future__ import annotations -from ...._compat import cached_property -from ...._resource import SyncAPIResource, AsyncAPIResource -from .telemetry.telemetry import ( +from .telemetry import ( TelemetryResource, AsyncTelemetryResource, TelemetryResourceWithRawResponse, @@ -12,6 +10,8 @@ TelemetryResourceWithStreamingResponse, AsyncTelemetryResourceWithStreamingResponse, ) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource __all__ = ["ObservabilityResource", "AsyncObservabilityResource"] diff --git a/src/cloudflare/resources/workers/observability/telemetry.py b/src/cloudflare/resources/workers/observability/telemetry.py new file mode 100644 index 00000000000..f88715ba0aa --- /dev/null +++ b/src/cloudflare/resources/workers/observability/telemetry.py @@ -0,0 +1,497 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Type, Iterable, cast +from typing_extensions import Literal + +import httpx + +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + maybe_transform, + async_maybe_transform, +) +from ...._compat import cached_property +from ...._resource import SyncAPIResource, AsyncAPIResource +from ...._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from ...._wrappers import ResultWrapper +from ....pagination import SyncSinglePage, AsyncSinglePage +from ...._base_client import AsyncPaginator, make_request_options +from ....types.workers.observability import telemetry_keys_params, telemetry_query_params, telemetry_values_params +from ....types.workers.observability.telemetry_keys_response import TelemetryKeysResponse +from ....types.workers.observability.telemetry_query_response import TelemetryQueryResponse +from ....types.workers.observability.telemetry_values_response import TelemetryValuesResponse + +__all__ = ["TelemetryResource", "AsyncTelemetryResource"] + + +class TelemetryResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> TelemetryResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return TelemetryResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> TelemetryResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return TelemetryResourceWithStreamingResponse(self) + + def keys( + self, + *, + account_id: str, + datasets: List[str] | NotGiven = NOT_GIVEN, + filters: Iterable[telemetry_keys_params.Filter] | NotGiven = NOT_GIVEN, + key_needle: telemetry_keys_params.KeyNeedle | NotGiven = NOT_GIVEN, + limit: float | NotGiven = NOT_GIVEN, + needle: telemetry_keys_params.Needle | NotGiven = NOT_GIVEN, + timeframe: telemetry_keys_params.Timeframe | 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, + ) -> SyncSinglePage[TelemetryKeysResponse]: + """ + List all the keys in your telemetry events. + + Args: + key_needle: Search for a specific substring in the keys. + + needle: Search for a specific substring in the event. + + 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._get_api_list( + f"/accounts/{account_id}/workers/observability/telemetry/keys", + page=SyncSinglePage[TelemetryKeysResponse], + body=maybe_transform( + { + "datasets": datasets, + "filters": filters, + "key_needle": key_needle, + "limit": limit, + "needle": needle, + "timeframe": timeframe, + }, + telemetry_keys_params.TelemetryKeysParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=TelemetryKeysResponse, + method="post", + ) + + def query( + self, + *, + account_id: str, + query_id: str, + timeframe: telemetry_query_params.Timeframe, + chart: bool | NotGiven = NOT_GIVEN, + compare: bool | NotGiven = NOT_GIVEN, + dry: bool | NotGiven = NOT_GIVEN, + granularity: float | NotGiven = NOT_GIVEN, + ignore_series: bool | NotGiven = NOT_GIVEN, + limit: float | NotGiven = NOT_GIVEN, + offset: str | NotGiven = NOT_GIVEN, + offset_by: float | NotGiven = NOT_GIVEN, + offset_direction: str | NotGiven = NOT_GIVEN, + parameters: telemetry_query_params.Parameters | NotGiven = NOT_GIVEN, + pattern_type: Literal["message", "error"] | NotGiven = NOT_GIVEN, + view: Literal["traces", "events", "calculations", "invocations", "requests", "patterns"] | 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, + ) -> TelemetryQueryResponse: + """ + Runs a temporary or saved query + + Args: + 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._post( + f"/accounts/{account_id}/workers/observability/telemetry/query", + body=maybe_transform( + { + "query_id": query_id, + "timeframe": timeframe, + "chart": chart, + "compare": compare, + "dry": dry, + "granularity": granularity, + "ignore_series": ignore_series, + "limit": limit, + "offset": offset, + "offset_by": offset_by, + "offset_direction": offset_direction, + "parameters": parameters, + "pattern_type": pattern_type, + "view": view, + }, + telemetry_query_params.TelemetryQueryParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TelemetryQueryResponse]._unwrapper, + ), + cast_to=cast(Type[TelemetryQueryResponse], ResultWrapper[TelemetryQueryResponse]), + ) + + def values( + self, + *, + account_id: str, + datasets: List[str], + key: str, + timeframe: telemetry_values_params.Timeframe, + type: Literal["string", "boolean", "number"], + filters: Iterable[telemetry_values_params.Filter] | NotGiven = NOT_GIVEN, + limit: float | NotGiven = NOT_GIVEN, + needle: telemetry_values_params.Needle | 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, + ) -> SyncSinglePage[TelemetryValuesResponse]: + """ + List unique values found in your events + + Args: + needle: Search for a specific substring in the event. + + 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._get_api_list( + f"/accounts/{account_id}/workers/observability/telemetry/values", + page=SyncSinglePage[TelemetryValuesResponse], + body=maybe_transform( + { + "datasets": datasets, + "key": key, + "timeframe": timeframe, + "type": type, + "filters": filters, + "limit": limit, + "needle": needle, + }, + telemetry_values_params.TelemetryValuesParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=TelemetryValuesResponse, + method="post", + ) + + +class AsyncTelemetryResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncTelemetryResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers + """ + return AsyncTelemetryResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncTelemetryResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response + """ + return AsyncTelemetryResourceWithStreamingResponse(self) + + def keys( + self, + *, + account_id: str, + datasets: List[str] | NotGiven = NOT_GIVEN, + filters: Iterable[telemetry_keys_params.Filter] | NotGiven = NOT_GIVEN, + key_needle: telemetry_keys_params.KeyNeedle | NotGiven = NOT_GIVEN, + limit: float | NotGiven = NOT_GIVEN, + needle: telemetry_keys_params.Needle | NotGiven = NOT_GIVEN, + timeframe: telemetry_keys_params.Timeframe | 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, + ) -> AsyncPaginator[TelemetryKeysResponse, AsyncSinglePage[TelemetryKeysResponse]]: + """ + List all the keys in your telemetry events. + + Args: + key_needle: Search for a specific substring in the keys. + + needle: Search for a specific substring in the event. + + 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._get_api_list( + f"/accounts/{account_id}/workers/observability/telemetry/keys", + page=AsyncSinglePage[TelemetryKeysResponse], + body=maybe_transform( + { + "datasets": datasets, + "filters": filters, + "key_needle": key_needle, + "limit": limit, + "needle": needle, + "timeframe": timeframe, + }, + telemetry_keys_params.TelemetryKeysParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=TelemetryKeysResponse, + method="post", + ) + + async def query( + self, + *, + account_id: str, + query_id: str, + timeframe: telemetry_query_params.Timeframe, + chart: bool | NotGiven = NOT_GIVEN, + compare: bool | NotGiven = NOT_GIVEN, + dry: bool | NotGiven = NOT_GIVEN, + granularity: float | NotGiven = NOT_GIVEN, + ignore_series: bool | NotGiven = NOT_GIVEN, + limit: float | NotGiven = NOT_GIVEN, + offset: str | NotGiven = NOT_GIVEN, + offset_by: float | NotGiven = NOT_GIVEN, + offset_direction: str | NotGiven = NOT_GIVEN, + parameters: telemetry_query_params.Parameters | NotGiven = NOT_GIVEN, + pattern_type: Literal["message", "error"] | NotGiven = NOT_GIVEN, + view: Literal["traces", "events", "calculations", "invocations", "requests", "patterns"] | 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, + ) -> TelemetryQueryResponse: + """ + Runs a temporary or saved query + + Args: + 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._post( + f"/accounts/{account_id}/workers/observability/telemetry/query", + body=await async_maybe_transform( + { + "query_id": query_id, + "timeframe": timeframe, + "chart": chart, + "compare": compare, + "dry": dry, + "granularity": granularity, + "ignore_series": ignore_series, + "limit": limit, + "offset": offset, + "offset_by": offset_by, + "offset_direction": offset_direction, + "parameters": parameters, + "pattern_type": pattern_type, + "view": view, + }, + telemetry_query_params.TelemetryQueryParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[TelemetryQueryResponse]._unwrapper, + ), + cast_to=cast(Type[TelemetryQueryResponse], ResultWrapper[TelemetryQueryResponse]), + ) + + def values( + self, + *, + account_id: str, + datasets: List[str], + key: str, + timeframe: telemetry_values_params.Timeframe, + type: Literal["string", "boolean", "number"], + filters: Iterable[telemetry_values_params.Filter] | NotGiven = NOT_GIVEN, + limit: float | NotGiven = NOT_GIVEN, + needle: telemetry_values_params.Needle | 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, + ) -> AsyncPaginator[TelemetryValuesResponse, AsyncSinglePage[TelemetryValuesResponse]]: + """ + List unique values found in your events + + Args: + needle: Search for a specific substring in the event. + + 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._get_api_list( + f"/accounts/{account_id}/workers/observability/telemetry/values", + page=AsyncSinglePage[TelemetryValuesResponse], + body=maybe_transform( + { + "datasets": datasets, + "key": key, + "timeframe": timeframe, + "type": type, + "filters": filters, + "limit": limit, + "needle": needle, + }, + telemetry_values_params.TelemetryValuesParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + model=TelemetryValuesResponse, + method="post", + ) + + +class TelemetryResourceWithRawResponse: + def __init__(self, telemetry: TelemetryResource) -> None: + self._telemetry = telemetry + + self.keys = to_raw_response_wrapper( + telemetry.keys, + ) + self.query = to_raw_response_wrapper( + telemetry.query, + ) + self.values = to_raw_response_wrapper( + telemetry.values, + ) + + +class AsyncTelemetryResourceWithRawResponse: + def __init__(self, telemetry: AsyncTelemetryResource) -> None: + self._telemetry = telemetry + + self.keys = async_to_raw_response_wrapper( + telemetry.keys, + ) + self.query = async_to_raw_response_wrapper( + telemetry.query, + ) + self.values = async_to_raw_response_wrapper( + telemetry.values, + ) + + +class TelemetryResourceWithStreamingResponse: + def __init__(self, telemetry: TelemetryResource) -> None: + self._telemetry = telemetry + + self.keys = to_streamed_response_wrapper( + telemetry.keys, + ) + self.query = to_streamed_response_wrapper( + telemetry.query, + ) + self.values = to_streamed_response_wrapper( + telemetry.values, + ) + + +class AsyncTelemetryResourceWithStreamingResponse: + def __init__(self, telemetry: AsyncTelemetryResource) -> None: + self._telemetry = telemetry + + self.keys = async_to_streamed_response_wrapper( + telemetry.keys, + ) + self.query = async_to_streamed_response_wrapper( + telemetry.query, + ) + self.values = async_to_streamed_response_wrapper( + telemetry.values, + ) diff --git a/src/cloudflare/resources/workers/observability/telemetry/__init__.py b/src/cloudflare/resources/workers/observability/telemetry/__init__.py deleted file mode 100644 index 4aff6968ae7..00000000000 --- a/src/cloudflare/resources/workers/observability/telemetry/__init__.py +++ /dev/null @@ -1,61 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .keys import ( - KeysResource, - AsyncKeysResource, - KeysResourceWithRawResponse, - AsyncKeysResourceWithRawResponse, - KeysResourceWithStreamingResponse, - AsyncKeysResourceWithStreamingResponse, -) -from .query import ( - QueryResource, - AsyncQueryResource, - QueryResourceWithRawResponse, - AsyncQueryResourceWithRawResponse, - QueryResourceWithStreamingResponse, - AsyncQueryResourceWithStreamingResponse, -) -from .values import ( - ValuesResource, - AsyncValuesResource, - ValuesResourceWithRawResponse, - AsyncValuesResourceWithRawResponse, - ValuesResourceWithStreamingResponse, - AsyncValuesResourceWithStreamingResponse, -) -from .telemetry import ( - TelemetryResource, - AsyncTelemetryResource, - TelemetryResourceWithRawResponse, - AsyncTelemetryResourceWithRawResponse, - TelemetryResourceWithStreamingResponse, - AsyncTelemetryResourceWithStreamingResponse, -) - -__all__ = [ - "KeysResource", - "AsyncKeysResource", - "KeysResourceWithRawResponse", - "AsyncKeysResourceWithRawResponse", - "KeysResourceWithStreamingResponse", - "AsyncKeysResourceWithStreamingResponse", - "QueryResource", - "AsyncQueryResource", - "QueryResourceWithRawResponse", - "AsyncQueryResourceWithRawResponse", - "QueryResourceWithStreamingResponse", - "AsyncQueryResourceWithStreamingResponse", - "ValuesResource", - "AsyncValuesResource", - "ValuesResourceWithRawResponse", - "AsyncValuesResourceWithRawResponse", - "ValuesResourceWithStreamingResponse", - "AsyncValuesResourceWithStreamingResponse", - "TelemetryResource", - "AsyncTelemetryResource", - "TelemetryResourceWithRawResponse", - "AsyncTelemetryResourceWithRawResponse", - "TelemetryResourceWithStreamingResponse", - "AsyncTelemetryResourceWithStreamingResponse", -] diff --git a/src/cloudflare/resources/workers/observability/telemetry/keys.py b/src/cloudflare/resources/workers/observability/telemetry/keys.py deleted file mode 100644 index 36ce62232a1..00000000000 --- a/src/cloudflare/resources/workers/observability/telemetry/keys.py +++ /dev/null @@ -1,214 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import List, Iterable - -import httpx - -from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ....._utils import maybe_transform -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource -from ....._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from .....pagination import SyncSinglePage, AsyncSinglePage -from ....._base_client import AsyncPaginator, make_request_options -from .....types.workers.observability.telemetry import key_create_params -from .....types.workers.observability.telemetry.key_create_response import KeyCreateResponse - -__all__ = ["KeysResource", "AsyncKeysResource"] - - -class KeysResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> KeysResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return KeysResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> KeysResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return KeysResourceWithStreamingResponse(self) - - def create( - self, - *, - account_id: str, - datasets: List[str] | NotGiven = NOT_GIVEN, - filters: Iterable[key_create_params.Filter] | NotGiven = NOT_GIVEN, - key_needle: key_create_params.KeyNeedle | NotGiven = NOT_GIVEN, - limit: float | NotGiven = NOT_GIVEN, - needle: key_create_params.Needle | NotGiven = NOT_GIVEN, - timeframe: key_create_params.Timeframe | 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, - ) -> SyncSinglePage[KeyCreateResponse]: - """ - List all the keys in your telemetry events. - - Args: - key_needle: Search for a specific substring in the keys. - - needle: Search for a specific substring in the event. - - 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._get_api_list( - f"/accounts/{account_id}/workers/observability/telemetry/keys", - page=SyncSinglePage[KeyCreateResponse], - body=maybe_transform( - { - "datasets": datasets, - "filters": filters, - "key_needle": key_needle, - "limit": limit, - "needle": needle, - "timeframe": timeframe, - }, - key_create_params.KeyCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=KeyCreateResponse, - method="post", - ) - - -class AsyncKeysResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncKeysResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return AsyncKeysResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncKeysResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return AsyncKeysResourceWithStreamingResponse(self) - - def create( - self, - *, - account_id: str, - datasets: List[str] | NotGiven = NOT_GIVEN, - filters: Iterable[key_create_params.Filter] | NotGiven = NOT_GIVEN, - key_needle: key_create_params.KeyNeedle | NotGiven = NOT_GIVEN, - limit: float | NotGiven = NOT_GIVEN, - needle: key_create_params.Needle | NotGiven = NOT_GIVEN, - timeframe: key_create_params.Timeframe | 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, - ) -> AsyncPaginator[KeyCreateResponse, AsyncSinglePage[KeyCreateResponse]]: - """ - List all the keys in your telemetry events. - - Args: - key_needle: Search for a specific substring in the keys. - - needle: Search for a specific substring in the event. - - 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._get_api_list( - f"/accounts/{account_id}/workers/observability/telemetry/keys", - page=AsyncSinglePage[KeyCreateResponse], - body=maybe_transform( - { - "datasets": datasets, - "filters": filters, - "key_needle": key_needle, - "limit": limit, - "needle": needle, - "timeframe": timeframe, - }, - key_create_params.KeyCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=KeyCreateResponse, - method="post", - ) - - -class KeysResourceWithRawResponse: - def __init__(self, keys: KeysResource) -> None: - self._keys = keys - - self.create = to_raw_response_wrapper( - keys.create, - ) - - -class AsyncKeysResourceWithRawResponse: - def __init__(self, keys: AsyncKeysResource) -> None: - self._keys = keys - - self.create = async_to_raw_response_wrapper( - keys.create, - ) - - -class KeysResourceWithStreamingResponse: - def __init__(self, keys: KeysResource) -> None: - self._keys = keys - - self.create = to_streamed_response_wrapper( - keys.create, - ) - - -class AsyncKeysResourceWithStreamingResponse: - def __init__(self, keys: AsyncKeysResource) -> None: - self._keys = keys - - self.create = async_to_streamed_response_wrapper( - keys.create, - ) diff --git a/src/cloudflare/resources/workers/observability/telemetry/query.py b/src/cloudflare/resources/workers/observability/telemetry/query.py deleted file mode 100644 index ee5cea6cef7..00000000000 --- a/src/cloudflare/resources/workers/observability/telemetry/query.py +++ /dev/null @@ -1,246 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Type, cast -from typing_extensions import Literal - -import httpx - -from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ....._utils import ( - maybe_transform, - async_maybe_transform, -) -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource -from ....._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ....._wrappers import ResultWrapper -from ....._base_client import make_request_options -from .....types.workers.observability.telemetry import query_create_params -from .....types.workers.observability.telemetry.query_create_response import QueryCreateResponse - -__all__ = ["QueryResource", "AsyncQueryResource"] - - -class QueryResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> QueryResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return QueryResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> QueryResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return QueryResourceWithStreamingResponse(self) - - def create( - self, - *, - account_id: str, - query_id: str, - timeframe: query_create_params.Timeframe, - chart: bool | NotGiven = NOT_GIVEN, - compare: bool | NotGiven = NOT_GIVEN, - dry: bool | NotGiven = NOT_GIVEN, - granularity: float | NotGiven = NOT_GIVEN, - ignore_series: bool | NotGiven = NOT_GIVEN, - limit: float | NotGiven = NOT_GIVEN, - offset: str | NotGiven = NOT_GIVEN, - offset_by: float | NotGiven = NOT_GIVEN, - offset_direction: str | NotGiven = NOT_GIVEN, - parameters: query_create_params.Parameters | NotGiven = NOT_GIVEN, - pattern_type: Literal["message", "error"] | NotGiven = NOT_GIVEN, - view: Literal["traces", "events", "calculations", "invocations", "requests", "patterns"] | 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, - ) -> QueryCreateResponse: - """ - Runs a temporary or saved query - - Args: - 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._post( - f"/accounts/{account_id}/workers/observability/telemetry/query", - body=maybe_transform( - { - "query_id": query_id, - "timeframe": timeframe, - "chart": chart, - "compare": compare, - "dry": dry, - "granularity": granularity, - "ignore_series": ignore_series, - "limit": limit, - "offset": offset, - "offset_by": offset_by, - "offset_direction": offset_direction, - "parameters": parameters, - "pattern_type": pattern_type, - "view": view, - }, - query_create_params.QueryCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[QueryCreateResponse]._unwrapper, - ), - cast_to=cast(Type[QueryCreateResponse], ResultWrapper[QueryCreateResponse]), - ) - - -class AsyncQueryResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncQueryResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return AsyncQueryResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncQueryResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return AsyncQueryResourceWithStreamingResponse(self) - - async def create( - self, - *, - account_id: str, - query_id: str, - timeframe: query_create_params.Timeframe, - chart: bool | NotGiven = NOT_GIVEN, - compare: bool | NotGiven = NOT_GIVEN, - dry: bool | NotGiven = NOT_GIVEN, - granularity: float | NotGiven = NOT_GIVEN, - ignore_series: bool | NotGiven = NOT_GIVEN, - limit: float | NotGiven = NOT_GIVEN, - offset: str | NotGiven = NOT_GIVEN, - offset_by: float | NotGiven = NOT_GIVEN, - offset_direction: str | NotGiven = NOT_GIVEN, - parameters: query_create_params.Parameters | NotGiven = NOT_GIVEN, - pattern_type: Literal["message", "error"] | NotGiven = NOT_GIVEN, - view: Literal["traces", "events", "calculations", "invocations", "requests", "patterns"] | 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, - ) -> QueryCreateResponse: - """ - Runs a temporary or saved query - - Args: - 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._post( - f"/accounts/{account_id}/workers/observability/telemetry/query", - body=await async_maybe_transform( - { - "query_id": query_id, - "timeframe": timeframe, - "chart": chart, - "compare": compare, - "dry": dry, - "granularity": granularity, - "ignore_series": ignore_series, - "limit": limit, - "offset": offset, - "offset_by": offset_by, - "offset_direction": offset_direction, - "parameters": parameters, - "pattern_type": pattern_type, - "view": view, - }, - query_create_params.QueryCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[QueryCreateResponse]._unwrapper, - ), - cast_to=cast(Type[QueryCreateResponse], ResultWrapper[QueryCreateResponse]), - ) - - -class QueryResourceWithRawResponse: - def __init__(self, query: QueryResource) -> None: - self._query = query - - self.create = to_raw_response_wrapper( - query.create, - ) - - -class AsyncQueryResourceWithRawResponse: - def __init__(self, query: AsyncQueryResource) -> None: - self._query = query - - self.create = async_to_raw_response_wrapper( - query.create, - ) - - -class QueryResourceWithStreamingResponse: - def __init__(self, query: QueryResource) -> None: - self._query = query - - self.create = to_streamed_response_wrapper( - query.create, - ) - - -class AsyncQueryResourceWithStreamingResponse: - def __init__(self, query: AsyncQueryResource) -> None: - self._query = query - - self.create = async_to_streamed_response_wrapper( - query.create, - ) diff --git a/src/cloudflare/resources/workers/observability/telemetry/telemetry.py b/src/cloudflare/resources/workers/observability/telemetry/telemetry.py deleted file mode 100644 index b085b6d17a0..00000000000 --- a/src/cloudflare/resources/workers/observability/telemetry/telemetry.py +++ /dev/null @@ -1,166 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from .keys import ( - KeysResource, - AsyncKeysResource, - KeysResourceWithRawResponse, - AsyncKeysResourceWithRawResponse, - KeysResourceWithStreamingResponse, - AsyncKeysResourceWithStreamingResponse, -) -from .query import ( - QueryResource, - AsyncQueryResource, - QueryResourceWithRawResponse, - AsyncQueryResourceWithRawResponse, - QueryResourceWithStreamingResponse, - AsyncQueryResourceWithStreamingResponse, -) -from .values import ( - ValuesResource, - AsyncValuesResource, - ValuesResourceWithRawResponse, - AsyncValuesResourceWithRawResponse, - ValuesResourceWithStreamingResponse, - AsyncValuesResourceWithStreamingResponse, -) -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource - -__all__ = ["TelemetryResource", "AsyncTelemetryResource"] - - -class TelemetryResource(SyncAPIResource): - @cached_property - def keys(self) -> KeysResource: - return KeysResource(self._client) - - @cached_property - def query(self) -> QueryResource: - return QueryResource(self._client) - - @cached_property - def values(self) -> ValuesResource: - return ValuesResource(self._client) - - @cached_property - def with_raw_response(self) -> TelemetryResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return TelemetryResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> TelemetryResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return TelemetryResourceWithStreamingResponse(self) - - -class AsyncTelemetryResource(AsyncAPIResource): - @cached_property - def keys(self) -> AsyncKeysResource: - return AsyncKeysResource(self._client) - - @cached_property - def query(self) -> AsyncQueryResource: - return AsyncQueryResource(self._client) - - @cached_property - def values(self) -> AsyncValuesResource: - return AsyncValuesResource(self._client) - - @cached_property - def with_raw_response(self) -> AsyncTelemetryResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return AsyncTelemetryResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncTelemetryResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return AsyncTelemetryResourceWithStreamingResponse(self) - - -class TelemetryResourceWithRawResponse: - def __init__(self, telemetry: TelemetryResource) -> None: - self._telemetry = telemetry - - @cached_property - def keys(self) -> KeysResourceWithRawResponse: - return KeysResourceWithRawResponse(self._telemetry.keys) - - @cached_property - def query(self) -> QueryResourceWithRawResponse: - return QueryResourceWithRawResponse(self._telemetry.query) - - @cached_property - def values(self) -> ValuesResourceWithRawResponse: - return ValuesResourceWithRawResponse(self._telemetry.values) - - -class AsyncTelemetryResourceWithRawResponse: - def __init__(self, telemetry: AsyncTelemetryResource) -> None: - self._telemetry = telemetry - - @cached_property - def keys(self) -> AsyncKeysResourceWithRawResponse: - return AsyncKeysResourceWithRawResponse(self._telemetry.keys) - - @cached_property - def query(self) -> AsyncQueryResourceWithRawResponse: - return AsyncQueryResourceWithRawResponse(self._telemetry.query) - - @cached_property - def values(self) -> AsyncValuesResourceWithRawResponse: - return AsyncValuesResourceWithRawResponse(self._telemetry.values) - - -class TelemetryResourceWithStreamingResponse: - def __init__(self, telemetry: TelemetryResource) -> None: - self._telemetry = telemetry - - @cached_property - def keys(self) -> KeysResourceWithStreamingResponse: - return KeysResourceWithStreamingResponse(self._telemetry.keys) - - @cached_property - def query(self) -> QueryResourceWithStreamingResponse: - return QueryResourceWithStreamingResponse(self._telemetry.query) - - @cached_property - def values(self) -> ValuesResourceWithStreamingResponse: - return ValuesResourceWithStreamingResponse(self._telemetry.values) - - -class AsyncTelemetryResourceWithStreamingResponse: - def __init__(self, telemetry: AsyncTelemetryResource) -> None: - self._telemetry = telemetry - - @cached_property - def keys(self) -> AsyncKeysResourceWithStreamingResponse: - return AsyncKeysResourceWithStreamingResponse(self._telemetry.keys) - - @cached_property - def query(self) -> AsyncQueryResourceWithStreamingResponse: - return AsyncQueryResourceWithStreamingResponse(self._telemetry.query) - - @cached_property - def values(self) -> AsyncValuesResourceWithStreamingResponse: - return AsyncValuesResourceWithStreamingResponse(self._telemetry.values) diff --git a/src/cloudflare/resources/workers/observability/telemetry/values.py b/src/cloudflare/resources/workers/observability/telemetry/values.py deleted file mode 100644 index 5271e58cca0..00000000000 --- a/src/cloudflare/resources/workers/observability/telemetry/values.py +++ /dev/null @@ -1,215 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import List, Iterable -from typing_extensions import Literal - -import httpx - -from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ....._utils import maybe_transform -from ....._compat import cached_property -from ....._resource import SyncAPIResource, AsyncAPIResource -from ....._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from .....pagination import SyncSinglePage, AsyncSinglePage -from ....._base_client import AsyncPaginator, make_request_options -from .....types.workers.observability.telemetry import value_create_params -from .....types.workers.observability.telemetry.value_create_response import ValueCreateResponse - -__all__ = ["ValuesResource", "AsyncValuesResource"] - - -class ValuesResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> ValuesResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return ValuesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> ValuesResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return ValuesResourceWithStreamingResponse(self) - - def create( - self, - *, - account_id: str, - datasets: List[str], - key: str, - timeframe: value_create_params.Timeframe, - type: Literal["string", "boolean", "number"], - filters: Iterable[value_create_params.Filter] | NotGiven = NOT_GIVEN, - limit: float | NotGiven = NOT_GIVEN, - needle: value_create_params.Needle | 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, - ) -> SyncSinglePage[ValueCreateResponse]: - """ - List unique values found in your events - - Args: - needle: Search for a specific substring in the event. - - 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._get_api_list( - f"/accounts/{account_id}/workers/observability/telemetry/values", - page=SyncSinglePage[ValueCreateResponse], - body=maybe_transform( - { - "datasets": datasets, - "key": key, - "timeframe": timeframe, - "type": type, - "filters": filters, - "limit": limit, - "needle": needle, - }, - value_create_params.ValueCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=ValueCreateResponse, - method="post", - ) - - -class AsyncValuesResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncValuesResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return AsyncValuesResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncValuesResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return AsyncValuesResourceWithStreamingResponse(self) - - def create( - self, - *, - account_id: str, - datasets: List[str], - key: str, - timeframe: value_create_params.Timeframe, - type: Literal["string", "boolean", "number"], - filters: Iterable[value_create_params.Filter] | NotGiven = NOT_GIVEN, - limit: float | NotGiven = NOT_GIVEN, - needle: value_create_params.Needle | 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, - ) -> AsyncPaginator[ValueCreateResponse, AsyncSinglePage[ValueCreateResponse]]: - """ - List unique values found in your events - - Args: - needle: Search for a specific substring in the event. - - 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._get_api_list( - f"/accounts/{account_id}/workers/observability/telemetry/values", - page=AsyncSinglePage[ValueCreateResponse], - body=maybe_transform( - { - "datasets": datasets, - "key": key, - "timeframe": timeframe, - "type": type, - "filters": filters, - "limit": limit, - "needle": needle, - }, - value_create_params.ValueCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - model=ValueCreateResponse, - method="post", - ) - - -class ValuesResourceWithRawResponse: - def __init__(self, values: ValuesResource) -> None: - self._values = values - - self.create = to_raw_response_wrapper( - values.create, - ) - - -class AsyncValuesResourceWithRawResponse: - def __init__(self, values: AsyncValuesResource) -> None: - self._values = values - - self.create = async_to_raw_response_wrapper( - values.create, - ) - - -class ValuesResourceWithStreamingResponse: - def __init__(self, values: ValuesResource) -> None: - self._values = values - - self.create = to_streamed_response_wrapper( - values.create, - ) - - -class AsyncValuesResourceWithStreamingResponse: - def __init__(self, values: AsyncValuesResource) -> None: - self._values = values - - self.create = async_to_streamed_response_wrapper( - values.create, - ) diff --git a/src/cloudflare/types/workers/observability/__init__.py b/src/cloudflare/types/workers/observability/__init__.py index f8ee8b14b1c..0aaa1d0adea 100644 --- a/src/cloudflare/types/workers/observability/__init__.py +++ b/src/cloudflare/types/workers/observability/__init__.py @@ -1,3 +1,10 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. from __future__ import annotations + +from .telemetry_keys_params import TelemetryKeysParams as TelemetryKeysParams +from .telemetry_query_params import TelemetryQueryParams as TelemetryQueryParams +from .telemetry_keys_response import TelemetryKeysResponse as TelemetryKeysResponse +from .telemetry_values_params import TelemetryValuesParams as TelemetryValuesParams +from .telemetry_query_response import TelemetryQueryResponse as TelemetryQueryResponse +from .telemetry_values_response import TelemetryValuesResponse as TelemetryValuesResponse diff --git a/src/cloudflare/types/workers/observability/telemetry/__init__.py b/src/cloudflare/types/workers/observability/telemetry/__init__.py deleted file mode 100644 index 35b5dfceae1..00000000000 --- a/src/cloudflare/types/workers/observability/telemetry/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from .key_create_params import KeyCreateParams as KeyCreateParams -from .key_create_response import KeyCreateResponse as KeyCreateResponse -from .query_create_params import QueryCreateParams as QueryCreateParams -from .value_create_params import ValueCreateParams as ValueCreateParams -from .query_create_response import QueryCreateResponse as QueryCreateResponse -from .value_create_response import ValueCreateResponse as ValueCreateResponse diff --git a/src/cloudflare/types/workers/observability/telemetry/key_create_params.py b/src/cloudflare/types/workers/observability/telemetry_keys_params.py similarity index 92% rename from src/cloudflare/types/workers/observability/telemetry/key_create_params.py rename to src/cloudflare/types/workers/observability/telemetry_keys_params.py index 4844981e5c9..7daf5c51af5 100644 --- a/src/cloudflare/types/workers/observability/telemetry/key_create_params.py +++ b/src/cloudflare/types/workers/observability/telemetry_keys_params.py @@ -5,12 +5,12 @@ from typing import List, Union, Iterable from typing_extensions import Literal, Required, Annotated, TypedDict -from ....._utils import PropertyInfo +from ...._utils import PropertyInfo -__all__ = ["KeyCreateParams", "Filter", "KeyNeedle", "Needle", "Timeframe"] +__all__ = ["TelemetryKeysParams", "Filter", "KeyNeedle", "Needle", "Timeframe"] -class KeyCreateParams(TypedDict, total=False): +class TelemetryKeysParams(TypedDict, total=False): account_id: Required[str] datasets: List[str] diff --git a/src/cloudflare/types/workers/observability/telemetry/key_create_response.py b/src/cloudflare/types/workers/observability/telemetry_keys_response.py similarity index 72% rename from src/cloudflare/types/workers/observability/telemetry/key_create_response.py rename to src/cloudflare/types/workers/observability/telemetry_keys_response.py index c08eacc3979..ebe8e775743 100644 --- a/src/cloudflare/types/workers/observability/telemetry/key_create_response.py +++ b/src/cloudflare/types/workers/observability/telemetry_keys_response.py @@ -4,12 +4,12 @@ from pydantic import Field as FieldInfo -from ....._models import BaseModel +from ...._models import BaseModel -__all__ = ["KeyCreateResponse"] +__all__ = ["TelemetryKeysResponse"] -class KeyCreateResponse(BaseModel): +class TelemetryKeysResponse(BaseModel): key: str last_seen_at: float = FieldInfo(alias="lastSeenAt") diff --git a/src/cloudflare/types/workers/observability/telemetry/query_create_params.py b/src/cloudflare/types/workers/observability/telemetry_query_params.py similarity index 97% rename from src/cloudflare/types/workers/observability/telemetry/query_create_params.py rename to src/cloudflare/types/workers/observability/telemetry_query_params.py index 4f8af2a01a3..0568f1af1c2 100644 --- a/src/cloudflare/types/workers/observability/telemetry/query_create_params.py +++ b/src/cloudflare/types/workers/observability/telemetry_query_params.py @@ -5,10 +5,10 @@ from typing import List, Union, Iterable from typing_extensions import Literal, Required, Annotated, TypedDict -from ....._utils import PropertyInfo +from ...._utils import PropertyInfo __all__ = [ - "QueryCreateParams", + "TelemetryQueryParams", "Timeframe", "Parameters", "ParametersCalculation", @@ -20,7 +20,7 @@ ] -class QueryCreateParams(TypedDict, total=False): +class TelemetryQueryParams(TypedDict, total=False): account_id: Required[str] query_id: Required[Annotated[str, PropertyInfo(alias="queryId")]] diff --git a/src/cloudflare/types/workers/observability/telemetry/query_create_response.py b/src/cloudflare/types/workers/observability/telemetry_query_response.py similarity index 99% rename from src/cloudflare/types/workers/observability/telemetry/query_create_response.py rename to src/cloudflare/types/workers/observability/telemetry_query_response.py index 95ea6bb664a..64a5a102f8f 100644 --- a/src/cloudflare/types/workers/observability/telemetry/query_create_response.py +++ b/src/cloudflare/types/workers/observability/telemetry_query_response.py @@ -5,10 +5,10 @@ from pydantic import Field as FieldInfo -from ....._models import BaseModel +from ...._models import BaseModel __all__ = [ - "QueryCreateResponse", + "TelemetryQueryResponse", "Run", "RunQuery", "RunQueryParameters", @@ -834,7 +834,7 @@ class Pattern(BaseModel): service: str -class QueryCreateResponse(BaseModel): +class TelemetryQueryResponse(BaseModel): run: Run """A Workers Observability Query Object""" diff --git a/src/cloudflare/types/workers/observability/telemetry/value_create_params.py b/src/cloudflare/types/workers/observability/telemetry_values_params.py similarity index 91% rename from src/cloudflare/types/workers/observability/telemetry/value_create_params.py rename to src/cloudflare/types/workers/observability/telemetry_values_params.py index df3e3ee4027..9a510dd8846 100644 --- a/src/cloudflare/types/workers/observability/telemetry/value_create_params.py +++ b/src/cloudflare/types/workers/observability/telemetry_values_params.py @@ -5,12 +5,12 @@ from typing import List, Union, Iterable from typing_extensions import Literal, Required, Annotated, TypedDict -from ....._utils import PropertyInfo +from ...._utils import PropertyInfo -__all__ = ["ValueCreateParams", "Timeframe", "Filter", "Needle"] +__all__ = ["TelemetryValuesParams", "Timeframe", "Filter", "Needle"] -class ValueCreateParams(TypedDict, total=False): +class TelemetryValuesParams(TypedDict, total=False): account_id: Required[str] datasets: Required[List[str]] diff --git a/src/cloudflare/types/workers/observability/telemetry/value_create_response.py b/src/cloudflare/types/workers/observability/telemetry_values_response.py similarity index 70% rename from src/cloudflare/types/workers/observability/telemetry/value_create_response.py rename to src/cloudflare/types/workers/observability/telemetry_values_response.py index e643ae1392a..1d7d431f350 100644 --- a/src/cloudflare/types/workers/observability/telemetry/value_create_response.py +++ b/src/cloudflare/types/workers/observability/telemetry_values_response.py @@ -3,12 +3,12 @@ from typing import Union from typing_extensions import Literal -from ....._models import BaseModel +from ...._models import BaseModel -__all__ = ["ValueCreateResponse"] +__all__ = ["TelemetryValuesResponse"] -class ValueCreateResponse(BaseModel): +class TelemetryValuesResponse(BaseModel): dataset: str key: str diff --git a/tests/api_resources/workers/observability/telemetry/__init__.py b/tests/api_resources/workers/observability/telemetry/__init__.py deleted file mode 100644 index fd8019a9a1a..00000000000 --- a/tests/api_resources/workers/observability/telemetry/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/workers/observability/telemetry/test_keys.py b/tests/api_resources/workers/observability/telemetry/test_keys.py deleted file mode 100644 index e9cd1f33073..00000000000 --- a/tests/api_resources/workers/observability/telemetry/test_keys.py +++ /dev/null @@ -1,161 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.workers.observability.telemetry import KeyCreateResponse - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestKeys: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_create(self, client: Cloudflare) -> None: - key = client.workers.observability.telemetry.keys.create( - account_id="account_id", - ) - assert_matches_type(SyncSinglePage[KeyCreateResponse], key, path=["response"]) - - @parametrize - def test_method_create_with_all_params(self, client: Cloudflare) -> None: - key = client.workers.observability.telemetry.keys.create( - account_id="account_id", - datasets=["string"], - filters=[ - { - "key": "key", - "operation": "includes", - "type": "string", - "value": "string", - } - ], - key_needle={ - "value": "string", - "is_regex": True, - "match_case": True, - }, - limit=0, - needle={ - "value": "string", - "is_regex": True, - "match_case": True, - }, - timeframe={ - "from": 0, - "to": 0, - }, - ) - assert_matches_type(SyncSinglePage[KeyCreateResponse], key, path=["response"]) - - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.workers.observability.telemetry.keys.with_raw_response.create( - account_id="account_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - key = response.parse() - assert_matches_type(SyncSinglePage[KeyCreateResponse], key, path=["response"]) - - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.workers.observability.telemetry.keys.with_streaming_response.create( - account_id="account_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - key = response.parse() - assert_matches_type(SyncSinglePage[KeyCreateResponse], key, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.workers.observability.telemetry.keys.with_raw_response.create( - account_id="", - ) - - -class TestAsyncKeys: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: - key = await async_client.workers.observability.telemetry.keys.create( - account_id="account_id", - ) - assert_matches_type(AsyncSinglePage[KeyCreateResponse], key, path=["response"]) - - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: - key = await async_client.workers.observability.telemetry.keys.create( - account_id="account_id", - datasets=["string"], - filters=[ - { - "key": "key", - "operation": "includes", - "type": "string", - "value": "string", - } - ], - key_needle={ - "value": "string", - "is_regex": True, - "match_case": True, - }, - limit=0, - needle={ - "value": "string", - "is_regex": True, - "match_case": True, - }, - timeframe={ - "from": 0, - "to": 0, - }, - ) - assert_matches_type(AsyncSinglePage[KeyCreateResponse], key, path=["response"]) - - @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.workers.observability.telemetry.keys.with_raw_response.create( - account_id="account_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - key = await response.parse() - assert_matches_type(AsyncSinglePage[KeyCreateResponse], key, path=["response"]) - - @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.workers.observability.telemetry.keys.with_streaming_response.create( - account_id="account_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - key = await response.parse() - assert_matches_type(AsyncSinglePage[KeyCreateResponse], key, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.workers.observability.telemetry.keys.with_raw_response.create( - account_id="", - ) diff --git a/tests/api_resources/workers/observability/telemetry/test_query.py b/tests/api_resources/workers/observability/telemetry/test_query.py deleted file mode 100644 index 693957d4137..00000000000 --- a/tests/api_resources/workers/observability/telemetry/test_query.py +++ /dev/null @@ -1,270 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.types.workers.observability.telemetry import QueryCreateResponse - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestQuery: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_create(self, client: Cloudflare) -> None: - query = client.workers.observability.telemetry.query.create( - account_id="account_id", - query_id="queryId", - timeframe={ - "from": 0, - "to": 0, - }, - ) - assert_matches_type(QueryCreateResponse, query, path=["response"]) - - @parametrize - def test_method_create_with_all_params(self, client: Cloudflare) -> None: - query = client.workers.observability.telemetry.query.create( - account_id="account_id", - query_id="queryId", - timeframe={ - "from": 0, - "to": 0, - }, - chart=True, - compare=True, - dry=True, - granularity=0, - ignore_series=True, - limit=100, - offset="offset", - offset_by=0, - offset_direction="offsetDirection", - parameters={ - "calculations": [ - { - "operator": "uniq", - "alias": "alias", - "key": "key", - "key_type": "string", - } - ], - "datasets": ["string"], - "filter_combination": "and", - "filters": [ - { - "key": "key", - "operation": "includes", - "type": "string", - "value": "string", - } - ], - "group_bys": [ - { - "type": "string", - "value": "value", - } - ], - "havings": [ - { - "key": "key", - "operation": "eq", - "value": 0, - } - ], - "limit": 0, - "needle": { - "value": "string", - "is_regex": True, - "match_case": True, - }, - "order_by": { - "value": "value", - "order": "asc", - }, - }, - pattern_type="message", - view="traces", - ) - assert_matches_type(QueryCreateResponse, query, path=["response"]) - - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.workers.observability.telemetry.query.with_raw_response.create( - account_id="account_id", - query_id="queryId", - timeframe={ - "from": 0, - "to": 0, - }, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - query = response.parse() - assert_matches_type(QueryCreateResponse, query, path=["response"]) - - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.workers.observability.telemetry.query.with_streaming_response.create( - account_id="account_id", - query_id="queryId", - timeframe={ - "from": 0, - "to": 0, - }, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - query = response.parse() - assert_matches_type(QueryCreateResponse, query, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.workers.observability.telemetry.query.with_raw_response.create( - account_id="", - query_id="queryId", - timeframe={ - "from": 0, - "to": 0, - }, - ) - - -class TestAsyncQuery: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: - query = await async_client.workers.observability.telemetry.query.create( - account_id="account_id", - query_id="queryId", - timeframe={ - "from": 0, - "to": 0, - }, - ) - assert_matches_type(QueryCreateResponse, query, path=["response"]) - - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: - query = await async_client.workers.observability.telemetry.query.create( - account_id="account_id", - query_id="queryId", - timeframe={ - "from": 0, - "to": 0, - }, - chart=True, - compare=True, - dry=True, - granularity=0, - ignore_series=True, - limit=100, - offset="offset", - offset_by=0, - offset_direction="offsetDirection", - parameters={ - "calculations": [ - { - "operator": "uniq", - "alias": "alias", - "key": "key", - "key_type": "string", - } - ], - "datasets": ["string"], - "filter_combination": "and", - "filters": [ - { - "key": "key", - "operation": "includes", - "type": "string", - "value": "string", - } - ], - "group_bys": [ - { - "type": "string", - "value": "value", - } - ], - "havings": [ - { - "key": "key", - "operation": "eq", - "value": 0, - } - ], - "limit": 0, - "needle": { - "value": "string", - "is_regex": True, - "match_case": True, - }, - "order_by": { - "value": "value", - "order": "asc", - }, - }, - pattern_type="message", - view="traces", - ) - assert_matches_type(QueryCreateResponse, query, path=["response"]) - - @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.workers.observability.telemetry.query.with_raw_response.create( - account_id="account_id", - query_id="queryId", - timeframe={ - "from": 0, - "to": 0, - }, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - query = await response.parse() - assert_matches_type(QueryCreateResponse, query, path=["response"]) - - @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.workers.observability.telemetry.query.with_streaming_response.create( - account_id="account_id", - query_id="queryId", - timeframe={ - "from": 0, - "to": 0, - }, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - query = await response.parse() - assert_matches_type(QueryCreateResponse, query, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.workers.observability.telemetry.query.with_raw_response.create( - account_id="", - query_id="queryId", - timeframe={ - "from": 0, - "to": 0, - }, - ) diff --git a/tests/api_resources/workers/observability/telemetry/test_values.py b/tests/api_resources/workers/observability/telemetry/test_values.py deleted file mode 100644 index 7aba89536be..00000000000 --- a/tests/api_resources/workers/observability/telemetry/test_values.py +++ /dev/null @@ -1,211 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.workers.observability.telemetry import ValueCreateResponse - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestValues: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_create(self, client: Cloudflare) -> None: - value = client.workers.observability.telemetry.values.create( - account_id="account_id", - datasets=["string"], - key="key", - timeframe={ - "from": 0, - "to": 0, - }, - type="string", - ) - assert_matches_type(SyncSinglePage[ValueCreateResponse], value, path=["response"]) - - @parametrize - def test_method_create_with_all_params(self, client: Cloudflare) -> None: - value = client.workers.observability.telemetry.values.create( - account_id="account_id", - datasets=["string"], - key="key", - timeframe={ - "from": 0, - "to": 0, - }, - type="string", - filters=[ - { - "key": "key", - "operation": "includes", - "type": "string", - "value": "string", - } - ], - limit=0, - needle={ - "value": "string", - "is_regex": True, - "match_case": True, - }, - ) - assert_matches_type(SyncSinglePage[ValueCreateResponse], value, path=["response"]) - - @parametrize - def test_raw_response_create(self, client: Cloudflare) -> None: - response = client.workers.observability.telemetry.values.with_raw_response.create( - account_id="account_id", - datasets=["string"], - key="key", - timeframe={ - "from": 0, - "to": 0, - }, - type="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - value = response.parse() - assert_matches_type(SyncSinglePage[ValueCreateResponse], value, path=["response"]) - - @parametrize - def test_streaming_response_create(self, client: Cloudflare) -> None: - with client.workers.observability.telemetry.values.with_streaming_response.create( - account_id="account_id", - datasets=["string"], - key="key", - timeframe={ - "from": 0, - "to": 0, - }, - type="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - value = response.parse() - assert_matches_type(SyncSinglePage[ValueCreateResponse], value, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_create(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.workers.observability.telemetry.values.with_raw_response.create( - account_id="", - datasets=["string"], - key="key", - timeframe={ - "from": 0, - "to": 0, - }, - type="string", - ) - - -class TestAsyncValues: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_create(self, async_client: AsyncCloudflare) -> None: - value = await async_client.workers.observability.telemetry.values.create( - account_id="account_id", - datasets=["string"], - key="key", - timeframe={ - "from": 0, - "to": 0, - }, - type="string", - ) - assert_matches_type(AsyncSinglePage[ValueCreateResponse], value, path=["response"]) - - @parametrize - async def test_method_create_with_all_params(self, async_client: AsyncCloudflare) -> None: - value = await async_client.workers.observability.telemetry.values.create( - account_id="account_id", - datasets=["string"], - key="key", - timeframe={ - "from": 0, - "to": 0, - }, - type="string", - filters=[ - { - "key": "key", - "operation": "includes", - "type": "string", - "value": "string", - } - ], - limit=0, - needle={ - "value": "string", - "is_regex": True, - "match_case": True, - }, - ) - assert_matches_type(AsyncSinglePage[ValueCreateResponse], value, path=["response"]) - - @parametrize - async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: - response = await async_client.workers.observability.telemetry.values.with_raw_response.create( - account_id="account_id", - datasets=["string"], - key="key", - timeframe={ - "from": 0, - "to": 0, - }, - type="string", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - value = await response.parse() - assert_matches_type(AsyncSinglePage[ValueCreateResponse], value, path=["response"]) - - @parametrize - async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: - async with async_client.workers.observability.telemetry.values.with_streaming_response.create( - account_id="account_id", - datasets=["string"], - key="key", - timeframe={ - "from": 0, - "to": 0, - }, - type="string", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - value = await response.parse() - assert_matches_type(AsyncSinglePage[ValueCreateResponse], value, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.workers.observability.telemetry.values.with_raw_response.create( - account_id="", - datasets=["string"], - key="key", - timeframe={ - "from": 0, - "to": 0, - }, - type="string", - ) diff --git a/tests/api_resources/workers/observability/test_telemetry.py b/tests/api_resources/workers/observability/test_telemetry.py new file mode 100644 index 00000000000..ba1b1bc90fc --- /dev/null +++ b/tests/api_resources/workers/observability/test_telemetry.py @@ -0,0 +1,601 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.pagination import SyncSinglePage, AsyncSinglePage +from cloudflare.types.workers.observability import ( + TelemetryKeysResponse, + TelemetryQueryResponse, + TelemetryValuesResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestTelemetry: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_keys(self, client: Cloudflare) -> None: + telemetry = client.workers.observability.telemetry.keys( + account_id="account_id", + ) + assert_matches_type(SyncSinglePage[TelemetryKeysResponse], telemetry, path=["response"]) + + @parametrize + def test_method_keys_with_all_params(self, client: Cloudflare) -> None: + telemetry = client.workers.observability.telemetry.keys( + account_id="account_id", + datasets=["string"], + filters=[ + { + "key": "key", + "operation": "includes", + "type": "string", + "value": "string", + } + ], + key_needle={ + "value": "string", + "is_regex": True, + "match_case": True, + }, + limit=0, + needle={ + "value": "string", + "is_regex": True, + "match_case": True, + }, + timeframe={ + "from": 0, + "to": 0, + }, + ) + assert_matches_type(SyncSinglePage[TelemetryKeysResponse], telemetry, path=["response"]) + + @parametrize + def test_raw_response_keys(self, client: Cloudflare) -> None: + response = client.workers.observability.telemetry.with_raw_response.keys( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + telemetry = response.parse() + assert_matches_type(SyncSinglePage[TelemetryKeysResponse], telemetry, path=["response"]) + + @parametrize + def test_streaming_response_keys(self, client: Cloudflare) -> None: + with client.workers.observability.telemetry.with_streaming_response.keys( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + telemetry = response.parse() + assert_matches_type(SyncSinglePage[TelemetryKeysResponse], telemetry, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_keys(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.workers.observability.telemetry.with_raw_response.keys( + account_id="", + ) + + @parametrize + def test_method_query(self, client: Cloudflare) -> None: + telemetry = client.workers.observability.telemetry.query( + account_id="account_id", + query_id="queryId", + timeframe={ + "from": 0, + "to": 0, + }, + ) + assert_matches_type(TelemetryQueryResponse, telemetry, path=["response"]) + + @parametrize + def test_method_query_with_all_params(self, client: Cloudflare) -> None: + telemetry = client.workers.observability.telemetry.query( + account_id="account_id", + query_id="queryId", + timeframe={ + "from": 0, + "to": 0, + }, + chart=True, + compare=True, + dry=True, + granularity=0, + ignore_series=True, + limit=100, + offset="offset", + offset_by=0, + offset_direction="offsetDirection", + parameters={ + "calculations": [ + { + "operator": "uniq", + "alias": "alias", + "key": "key", + "key_type": "string", + } + ], + "datasets": ["string"], + "filter_combination": "and", + "filters": [ + { + "key": "key", + "operation": "includes", + "type": "string", + "value": "string", + } + ], + "group_bys": [ + { + "type": "string", + "value": "value", + } + ], + "havings": [ + { + "key": "key", + "operation": "eq", + "value": 0, + } + ], + "limit": 0, + "needle": { + "value": "string", + "is_regex": True, + "match_case": True, + }, + "order_by": { + "value": "value", + "order": "asc", + }, + }, + pattern_type="message", + view="traces", + ) + assert_matches_type(TelemetryQueryResponse, telemetry, path=["response"]) + + @parametrize + def test_raw_response_query(self, client: Cloudflare) -> None: + response = client.workers.observability.telemetry.with_raw_response.query( + account_id="account_id", + query_id="queryId", + timeframe={ + "from": 0, + "to": 0, + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + telemetry = response.parse() + assert_matches_type(TelemetryQueryResponse, telemetry, path=["response"]) + + @parametrize + def test_streaming_response_query(self, client: Cloudflare) -> None: + with client.workers.observability.telemetry.with_streaming_response.query( + account_id="account_id", + query_id="queryId", + timeframe={ + "from": 0, + "to": 0, + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + telemetry = response.parse() + assert_matches_type(TelemetryQueryResponse, telemetry, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_query(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.workers.observability.telemetry.with_raw_response.query( + account_id="", + query_id="queryId", + timeframe={ + "from": 0, + "to": 0, + }, + ) + + @parametrize + def test_method_values(self, client: Cloudflare) -> None: + telemetry = client.workers.observability.telemetry.values( + account_id="account_id", + datasets=["string"], + key="key", + timeframe={ + "from": 0, + "to": 0, + }, + type="string", + ) + assert_matches_type(SyncSinglePage[TelemetryValuesResponse], telemetry, path=["response"]) + + @parametrize + def test_method_values_with_all_params(self, client: Cloudflare) -> None: + telemetry = client.workers.observability.telemetry.values( + account_id="account_id", + datasets=["string"], + key="key", + timeframe={ + "from": 0, + "to": 0, + }, + type="string", + filters=[ + { + "key": "key", + "operation": "includes", + "type": "string", + "value": "string", + } + ], + limit=0, + needle={ + "value": "string", + "is_regex": True, + "match_case": True, + }, + ) + assert_matches_type(SyncSinglePage[TelemetryValuesResponse], telemetry, path=["response"]) + + @parametrize + def test_raw_response_values(self, client: Cloudflare) -> None: + response = client.workers.observability.telemetry.with_raw_response.values( + account_id="account_id", + datasets=["string"], + key="key", + timeframe={ + "from": 0, + "to": 0, + }, + type="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + telemetry = response.parse() + assert_matches_type(SyncSinglePage[TelemetryValuesResponse], telemetry, path=["response"]) + + @parametrize + def test_streaming_response_values(self, client: Cloudflare) -> None: + with client.workers.observability.telemetry.with_streaming_response.values( + account_id="account_id", + datasets=["string"], + key="key", + timeframe={ + "from": 0, + "to": 0, + }, + type="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + telemetry = response.parse() + assert_matches_type(SyncSinglePage[TelemetryValuesResponse], telemetry, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_values(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.workers.observability.telemetry.with_raw_response.values( + account_id="", + datasets=["string"], + key="key", + timeframe={ + "from": 0, + "to": 0, + }, + type="string", + ) + + +class TestAsyncTelemetry: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_keys(self, async_client: AsyncCloudflare) -> None: + telemetry = await async_client.workers.observability.telemetry.keys( + account_id="account_id", + ) + assert_matches_type(AsyncSinglePage[TelemetryKeysResponse], telemetry, path=["response"]) + + @parametrize + async def test_method_keys_with_all_params(self, async_client: AsyncCloudflare) -> None: + telemetry = await async_client.workers.observability.telemetry.keys( + account_id="account_id", + datasets=["string"], + filters=[ + { + "key": "key", + "operation": "includes", + "type": "string", + "value": "string", + } + ], + key_needle={ + "value": "string", + "is_regex": True, + "match_case": True, + }, + limit=0, + needle={ + "value": "string", + "is_regex": True, + "match_case": True, + }, + timeframe={ + "from": 0, + "to": 0, + }, + ) + assert_matches_type(AsyncSinglePage[TelemetryKeysResponse], telemetry, path=["response"]) + + @parametrize + async def test_raw_response_keys(self, async_client: AsyncCloudflare) -> None: + response = await async_client.workers.observability.telemetry.with_raw_response.keys( + account_id="account_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + telemetry = await response.parse() + assert_matches_type(AsyncSinglePage[TelemetryKeysResponse], telemetry, path=["response"]) + + @parametrize + async def test_streaming_response_keys(self, async_client: AsyncCloudflare) -> None: + async with async_client.workers.observability.telemetry.with_streaming_response.keys( + account_id="account_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + telemetry = await response.parse() + assert_matches_type(AsyncSinglePage[TelemetryKeysResponse], telemetry, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_keys(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.workers.observability.telemetry.with_raw_response.keys( + account_id="", + ) + + @parametrize + async def test_method_query(self, async_client: AsyncCloudflare) -> None: + telemetry = await async_client.workers.observability.telemetry.query( + account_id="account_id", + query_id="queryId", + timeframe={ + "from": 0, + "to": 0, + }, + ) + assert_matches_type(TelemetryQueryResponse, telemetry, path=["response"]) + + @parametrize + async def test_method_query_with_all_params(self, async_client: AsyncCloudflare) -> None: + telemetry = await async_client.workers.observability.telemetry.query( + account_id="account_id", + query_id="queryId", + timeframe={ + "from": 0, + "to": 0, + }, + chart=True, + compare=True, + dry=True, + granularity=0, + ignore_series=True, + limit=100, + offset="offset", + offset_by=0, + offset_direction="offsetDirection", + parameters={ + "calculations": [ + { + "operator": "uniq", + "alias": "alias", + "key": "key", + "key_type": "string", + } + ], + "datasets": ["string"], + "filter_combination": "and", + "filters": [ + { + "key": "key", + "operation": "includes", + "type": "string", + "value": "string", + } + ], + "group_bys": [ + { + "type": "string", + "value": "value", + } + ], + "havings": [ + { + "key": "key", + "operation": "eq", + "value": 0, + } + ], + "limit": 0, + "needle": { + "value": "string", + "is_regex": True, + "match_case": True, + }, + "order_by": { + "value": "value", + "order": "asc", + }, + }, + pattern_type="message", + view="traces", + ) + assert_matches_type(TelemetryQueryResponse, telemetry, path=["response"]) + + @parametrize + async def test_raw_response_query(self, async_client: AsyncCloudflare) -> None: + response = await async_client.workers.observability.telemetry.with_raw_response.query( + account_id="account_id", + query_id="queryId", + timeframe={ + "from": 0, + "to": 0, + }, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + telemetry = await response.parse() + assert_matches_type(TelemetryQueryResponse, telemetry, path=["response"]) + + @parametrize + async def test_streaming_response_query(self, async_client: AsyncCloudflare) -> None: + async with async_client.workers.observability.telemetry.with_streaming_response.query( + account_id="account_id", + query_id="queryId", + timeframe={ + "from": 0, + "to": 0, + }, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + telemetry = await response.parse() + assert_matches_type(TelemetryQueryResponse, telemetry, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_query(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.workers.observability.telemetry.with_raw_response.query( + account_id="", + query_id="queryId", + timeframe={ + "from": 0, + "to": 0, + }, + ) + + @parametrize + async def test_method_values(self, async_client: AsyncCloudflare) -> None: + telemetry = await async_client.workers.observability.telemetry.values( + account_id="account_id", + datasets=["string"], + key="key", + timeframe={ + "from": 0, + "to": 0, + }, + type="string", + ) + assert_matches_type(AsyncSinglePage[TelemetryValuesResponse], telemetry, path=["response"]) + + @parametrize + async def test_method_values_with_all_params(self, async_client: AsyncCloudflare) -> None: + telemetry = await async_client.workers.observability.telemetry.values( + account_id="account_id", + datasets=["string"], + key="key", + timeframe={ + "from": 0, + "to": 0, + }, + type="string", + filters=[ + { + "key": "key", + "operation": "includes", + "type": "string", + "value": "string", + } + ], + limit=0, + needle={ + "value": "string", + "is_regex": True, + "match_case": True, + }, + ) + assert_matches_type(AsyncSinglePage[TelemetryValuesResponse], telemetry, path=["response"]) + + @parametrize + async def test_raw_response_values(self, async_client: AsyncCloudflare) -> None: + response = await async_client.workers.observability.telemetry.with_raw_response.values( + account_id="account_id", + datasets=["string"], + key="key", + timeframe={ + "from": 0, + "to": 0, + }, + type="string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + telemetry = await response.parse() + assert_matches_type(AsyncSinglePage[TelemetryValuesResponse], telemetry, path=["response"]) + + @parametrize + async def test_streaming_response_values(self, async_client: AsyncCloudflare) -> None: + async with async_client.workers.observability.telemetry.with_streaming_response.values( + account_id="account_id", + datasets=["string"], + key="key", + timeframe={ + "from": 0, + "to": 0, + }, + type="string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + telemetry = await response.parse() + assert_matches_type(AsyncSinglePage[TelemetryValuesResponse], telemetry, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_values(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.workers.observability.telemetry.with_raw_response.values( + account_id="", + datasets=["string"], + key="key", + timeframe={ + "from": 0, + "to": 0, + }, + type="string", + )