From ac1e643ce90a4aad902bf27e01c73df9b838e1e1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 19 Apr 2024 00:14:51 +0000 Subject: [PATCH] feat(api): update via SDK Studio (#343) --- .stats.yml | 2 +- api.md | 70 ++- .../resources/stream/captions/__init__.py | 33 ++ .../resources/stream/captions/captions.py | 201 ++++++++ .../stream/captions/language/__init__.py | 33 ++ .../language/language.py} | 171 ++++--- .../resources/stream/captions/language/vtt.py | 170 +++++++ src/cloudflare/resources/stream/stream.py | 1 + .../resources/zero_trust/__init__.py | 14 + .../zero_trust/risk_scoring/__init__.py | 47 ++ .../zero_trust/risk_scoring/behaviours.py | 256 +++++++++++ .../zero_trust/risk_scoring/risk_scoring.py | 373 +++++++++++++++ .../zero_trust/risk_scoring/summary.py | 189 ++++++++ .../resources/zero_trust/zero_trust.py | 33 ++ src/cloudflare/types/stream/__init__.py | 3 - .../types/stream/captions/__init__.py | 7 + .../stream/captions/language/__init__.py | 6 + .../language/vtt_get_params.py} | 4 +- .../language/vtt_get_response.py} | 4 +- .../stream/captions/language_delete_params.py | 17 + .../captions/language_delete_response.py | 6 + .../language_update_params.py} | 4 +- src/cloudflare/types/zero_trust/__init__.py | 3 + .../types/zero_trust/risk_scoring/__init__.py | 9 + .../risk_scoring/behaviour_get_response.py | 22 + .../risk_scoring/behaviour_update_params.py | 18 + .../risk_scoring/behaviour_update_response.py | 22 + .../risk_scoring/summary_get_params.py | 17 + .../risk_scoring/summary_get_response.py | 28 ++ .../zero_trust/risk_scoring_get_params.py | 20 + .../zero_trust/risk_scoring_get_response.py | 33 ++ .../zero_trust/risk_scoring_reset_response.py | 7 + .../api_resources/stream/captions/__init__.py | 1 + .../stream/captions/language/__init__.py | 1 + .../stream/captions/language/test_vtt.py | 161 +++++++ .../stream/captions/test_language.py | 430 ++++++++++++++++++ tests/api_resources/stream/test_captions.py | 285 +----------- .../zero_trust/risk_scoring/__init__.py | 1 + .../risk_scoring/test_behaviours.py | 221 +++++++++ .../zero_trust/risk_scoring/test_summary.py | 130 ++++++ .../zero_trust/test_risk_scoring.py | 256 +++++++++++ 41 files changed, 2944 insertions(+), 365 deletions(-) create mode 100644 src/cloudflare/resources/stream/captions/__init__.py create mode 100644 src/cloudflare/resources/stream/captions/captions.py create mode 100644 src/cloudflare/resources/stream/captions/language/__init__.py rename src/cloudflare/resources/stream/{captions.py => captions/language/language.py} (75%) create mode 100644 src/cloudflare/resources/stream/captions/language/vtt.py create mode 100644 src/cloudflare/resources/zero_trust/risk_scoring/__init__.py create mode 100644 src/cloudflare/resources/zero_trust/risk_scoring/behaviours.py create mode 100644 src/cloudflare/resources/zero_trust/risk_scoring/risk_scoring.py create mode 100644 src/cloudflare/resources/zero_trust/risk_scoring/summary.py create mode 100644 src/cloudflare/types/stream/captions/__init__.py create mode 100644 src/cloudflare/types/stream/captions/language/__init__.py rename src/cloudflare/types/stream/{caption_delete_params.py => captions/language/vtt_get_params.py} (80%) rename src/cloudflare/types/stream/{caption_delete_response.py => captions/language/vtt_get_response.py} (58%) create mode 100644 src/cloudflare/types/stream/captions/language_delete_params.py create mode 100644 src/cloudflare/types/stream/captions/language_delete_response.py rename src/cloudflare/types/stream/{caption_update_params.py => captions/language_update_params.py} (82%) create mode 100644 src/cloudflare/types/zero_trust/risk_scoring/__init__.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring/behaviour_get_response.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_params.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_response.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring/summary_get_params.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring/summary_get_response.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring_get_params.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring_get_response.py create mode 100644 src/cloudflare/types/zero_trust/risk_scoring_reset_response.py create mode 100644 tests/api_resources/stream/captions/__init__.py create mode 100644 tests/api_resources/stream/captions/language/__init__.py create mode 100644 tests/api_resources/stream/captions/language/test_vtt.py create mode 100644 tests/api_resources/stream/captions/test_language.py create mode 100644 tests/api_resources/zero_trust/risk_scoring/__init__.py create mode 100644 tests/api_resources/zero_trust/risk_scoring/test_behaviours.py create mode 100644 tests/api_resources/zero_trust/risk_scoring/test_summary.py create mode 100644 tests/api_resources/zero_trust/test_risk_scoring.py diff --git a/.stats.yml b/.stats.yml index ae473c1891a..860345bb66e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 1259 +configured_endpoints: 1266 diff --git a/api.md b/api.md index 0a5b2b7d6ca..8fba3b38d71 100644 --- a/api.md +++ b/api.md @@ -4389,14 +4389,38 @@ Methods: Types: ```python -from cloudflare.types.stream import Caption, CaptionDeleteResponse, CaptionGetResponse +from cloudflare.types.stream import Caption, CaptionGetResponse ``` Methods: -- client.stream.captions.update(language, \*, account_id, identifier, \*\*params) -> Optional -- client.stream.captions.delete(language, \*, account_id, identifier, \*\*params) -> str -- client.stream.captions.get(identifier, \*, account_id) -> Optional +- client.stream.captions.get(identifier, \*, account_id) -> Optional + +### Language + +Types: + +```python +from cloudflare.types.stream.captions import LanguageDeleteResponse +``` + +Methods: + +- client.stream.captions.language.update(language, \*, account_id, identifier, \*\*params) -> Optional +- client.stream.captions.language.delete(language, \*, account_id, identifier, \*\*params) -> str +- client.stream.captions.language.get(language, \*, account_id, identifier) -> Optional + +#### Vtt + +Types: + +```python +from cloudflare.types.stream.captions.language import VttGetResponse +``` + +Methods: + +- client.stream.captions.language.vtt.get(language, \*, account_id, identifier, \*\*params) -> str ## Downloads @@ -5920,6 +5944,44 @@ Methods: - client.zero_trust.networks.virtual_networks.delete(virtual_network_id, \*, account_id, \*\*params) -> VirtualNetworkDeleteResponse - client.zero_trust.networks.virtual_networks.edit(virtual_network_id, \*, account_id, \*\*params) -> VirtualNetworkEditResponse +## RiskScoring + +Types: + +```python +from cloudflare.types.zero_trust import RiskScoringGetResponse, RiskScoringResetResponse +``` + +Methods: + +- client.zero_trust.risk_scoring.get(user_id, \*, account_identifier, \*\*params) -> RiskScoringGetResponse +- client.zero_trust.risk_scoring.reset(user_id, \*, account_identifier) -> RiskScoringResetResponse + +### Behaviours + +Types: + +```python +from cloudflare.types.zero_trust.risk_scoring import BehaviourUpdateResponse, BehaviourGetResponse +``` + +Methods: + +- client.zero_trust.risk_scoring.behaviours.update(account_identifier, \*\*params) -> BehaviourUpdateResponse +- client.zero_trust.risk_scoring.behaviours.get(account_identifier) -> BehaviourGetResponse + +### Summary + +Types: + +```python +from cloudflare.types.zero_trust.risk_scoring import SummaryGetResponse +``` + +Methods: + +- client.zero_trust.risk_scoring.summary.get(account_identifier, \*\*params) -> SummaryGetResponse + # Challenges ## Widgets diff --git a/src/cloudflare/resources/stream/captions/__init__.py b/src/cloudflare/resources/stream/captions/__init__.py new file mode 100644 index 00000000000..837b74732bc --- /dev/null +++ b/src/cloudflare/resources/stream/captions/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .captions import ( + Captions, + AsyncCaptions, + CaptionsWithRawResponse, + AsyncCaptionsWithRawResponse, + CaptionsWithStreamingResponse, + AsyncCaptionsWithStreamingResponse, +) +from .language import ( + Language, + AsyncLanguage, + LanguageWithRawResponse, + AsyncLanguageWithRawResponse, + LanguageWithStreamingResponse, + AsyncLanguageWithStreamingResponse, +) + +__all__ = [ + "Language", + "AsyncLanguage", + "LanguageWithRawResponse", + "AsyncLanguageWithRawResponse", + "LanguageWithStreamingResponse", + "AsyncLanguageWithStreamingResponse", + "Captions", + "AsyncCaptions", + "CaptionsWithRawResponse", + "AsyncCaptionsWithRawResponse", + "CaptionsWithStreamingResponse", + "AsyncCaptionsWithStreamingResponse", +] diff --git a/src/cloudflare/resources/stream/captions/captions.py b/src/cloudflare/resources/stream/captions/captions.py new file mode 100644 index 00000000000..429849b28d2 --- /dev/null +++ b/src/cloudflare/resources/stream/captions/captions.py @@ -0,0 +1,201 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Type, Optional, cast + +import httpx + +from .language import ( + Language, + AsyncLanguage, + LanguageWithRawResponse, + AsyncLanguageWithRawResponse, + LanguageWithStreamingResponse, + AsyncLanguageWithStreamingResponse, +) +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +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.stream import CaptionGetResponse +from .language.language import Language, AsyncLanguage + +__all__ = ["Captions", "AsyncCaptions"] + + +class Captions(SyncAPIResource): + @cached_property + def language(self) -> Language: + return Language(self._client) + + @cached_property + def with_raw_response(self) -> CaptionsWithRawResponse: + return CaptionsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> CaptionsWithStreamingResponse: + return CaptionsWithStreamingResponse(self) + + def get( + self, + identifier: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CaptionGetResponse]: + """ + Lists the available captions or subtitles for a specific video. + + Args: + account_id: Identifier + + identifier: A Cloudflare-generated unique identifier for a media item. + + 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}") + if not identifier: + raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") + return self._get( + f"/accounts/{account_id}/stream/{identifier}/captions", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CaptionGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CaptionGetResponse]], ResultWrapper[CaptionGetResponse]), + ) + + +class AsyncCaptions(AsyncAPIResource): + @cached_property + def language(self) -> AsyncLanguage: + return AsyncLanguage(self._client) + + @cached_property + def with_raw_response(self) -> AsyncCaptionsWithRawResponse: + return AsyncCaptionsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncCaptionsWithStreamingResponse: + return AsyncCaptionsWithStreamingResponse(self) + + async def get( + self, + identifier: str, + *, + account_id: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> Optional[CaptionGetResponse]: + """ + Lists the available captions or subtitles for a specific video. + + Args: + account_id: Identifier + + identifier: A Cloudflare-generated unique identifier for a media item. + + 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}") + if not identifier: + raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") + return await self._get( + f"/accounts/{account_id}/stream/{identifier}/captions", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[Optional[CaptionGetResponse]]._unwrapper, + ), + cast_to=cast(Type[Optional[CaptionGetResponse]], ResultWrapper[CaptionGetResponse]), + ) + + +class CaptionsWithRawResponse: + def __init__(self, captions: Captions) -> None: + self._captions = captions + + self.get = to_raw_response_wrapper( + captions.get, + ) + + @cached_property + def language(self) -> LanguageWithRawResponse: + return LanguageWithRawResponse(self._captions.language) + + +class AsyncCaptionsWithRawResponse: + def __init__(self, captions: AsyncCaptions) -> None: + self._captions = captions + + self.get = async_to_raw_response_wrapper( + captions.get, + ) + + @cached_property + def language(self) -> AsyncLanguageWithRawResponse: + return AsyncLanguageWithRawResponse(self._captions.language) + + +class CaptionsWithStreamingResponse: + def __init__(self, captions: Captions) -> None: + self._captions = captions + + self.get = to_streamed_response_wrapper( + captions.get, + ) + + @cached_property + def language(self) -> LanguageWithStreamingResponse: + return LanguageWithStreamingResponse(self._captions.language) + + +class AsyncCaptionsWithStreamingResponse: + def __init__(self, captions: AsyncCaptions) -> None: + self._captions = captions + + self.get = async_to_streamed_response_wrapper( + captions.get, + ) + + @cached_property + def language(self) -> AsyncLanguageWithStreamingResponse: + return AsyncLanguageWithStreamingResponse(self._captions.language) diff --git a/src/cloudflare/resources/stream/captions/language/__init__.py b/src/cloudflare/resources/stream/captions/language/__init__.py new file mode 100644 index 00000000000..eab80923178 --- /dev/null +++ b/src/cloudflare/resources/stream/captions/language/__init__.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .vtt import ( + Vtt, + AsyncVtt, + VttWithRawResponse, + AsyncVttWithRawResponse, + VttWithStreamingResponse, + AsyncVttWithStreamingResponse, +) +from .language import ( + Language, + AsyncLanguage, + LanguageWithRawResponse, + AsyncLanguageWithRawResponse, + LanguageWithStreamingResponse, + AsyncLanguageWithStreamingResponse, +) + +__all__ = [ + "Vtt", + "AsyncVtt", + "VttWithRawResponse", + "AsyncVttWithRawResponse", + "VttWithStreamingResponse", + "AsyncVttWithStreamingResponse", + "Language", + "AsyncLanguage", + "LanguageWithRawResponse", + "AsyncLanguageWithRawResponse", + "LanguageWithStreamingResponse", + "AsyncLanguageWithStreamingResponse", +] diff --git a/src/cloudflare/resources/stream/captions.py b/src/cloudflare/resources/stream/captions/language/language.py similarity index 75% rename from src/cloudflare/resources/stream/captions.py rename to src/cloudflare/resources/stream/captions/language/language.py index dce7828c93d..3e238b202d2 100644 --- a/src/cloudflare/resources/stream/captions.py +++ b/src/cloudflare/resources/stream/captions/language/language.py @@ -6,42 +6,49 @@ import httpx -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import ( +from .vtt import ( + Vtt, + AsyncVtt, + VttWithRawResponse, + AsyncVttWithRawResponse, + VttWithStreamingResponse, + AsyncVttWithStreamingResponse, +) +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 ( +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 ( +from ....._wrappers import ResultWrapper +from ....._base_client import ( make_request_options, ) -from ...types.stream import ( - Caption, - CaptionGetResponse, - CaptionDeleteResponse, - caption_delete_params, - caption_update_params, -) +from .....types.stream import Caption +from .....types.stream.captions import LanguageDeleteResponse, language_delete_params, language_update_params -__all__ = ["Captions", "AsyncCaptions"] +__all__ = ["Language", "AsyncLanguage"] -class Captions(SyncAPIResource): +class Language(SyncAPIResource): @cached_property - def with_raw_response(self) -> CaptionsWithRawResponse: - return CaptionsWithRawResponse(self) + def vtt(self) -> Vtt: + return Vtt(self._client) @cached_property - def with_streaming_response(self) -> CaptionsWithStreamingResponse: - return CaptionsWithStreamingResponse(self) + def with_raw_response(self) -> LanguageWithRawResponse: + return LanguageWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> LanguageWithStreamingResponse: + return LanguageWithStreamingResponse(self) def update( self, @@ -86,7 +93,7 @@ def update( raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") return self._put( f"/accounts/{account_id}/stream/{identifier}/captions/{language}", - body=maybe_transform({"file": file}, caption_update_params.CaptionUpdateParams), + body=maybe_transform({"file": file}, language_update_params.LanguageUpdateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -137,37 +144,40 @@ def delete( raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") return self._delete( f"/accounts/{account_id}/stream/{identifier}/captions/{language}", - body=maybe_transform(body, caption_delete_params.CaptionDeleteParams), + body=maybe_transform(body, language_delete_params.LanguageDeleteParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[CaptionDeleteResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[LanguageDeleteResponse]]._unwrapper, ), cast_to=cast(Type[str], ResultWrapper[str]), ) def get( self, - identifier: str, + language: str, *, account_id: str, + identifier: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[CaptionGetResponse]: + ) -> Optional[Caption]: """ - Lists the available captions or subtitles for a specific video. + Lists the captions or subtitles for provided language. Args: account_id: Identifier identifier: A Cloudflare-generated unique identifier for a media item. + language: The language tag in BCP 47 format. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -180,27 +190,33 @@ def get( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") + if not language: + raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") return self._get( - f"/accounts/{account_id}/stream/{identifier}/captions", + f"/accounts/{account_id}/stream/{identifier}/captions/{language}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[CaptionGetResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Caption]]._unwrapper, ), - cast_to=cast(Type[Optional[CaptionGetResponse]], ResultWrapper[CaptionGetResponse]), + cast_to=cast(Type[Optional[Caption]], ResultWrapper[Caption]), ) -class AsyncCaptions(AsyncAPIResource): +class AsyncLanguage(AsyncAPIResource): + @cached_property + def vtt(self) -> AsyncVtt: + return AsyncVtt(self._client) + @cached_property - def with_raw_response(self) -> AsyncCaptionsWithRawResponse: - return AsyncCaptionsWithRawResponse(self) + def with_raw_response(self) -> AsyncLanguageWithRawResponse: + return AsyncLanguageWithRawResponse(self) @cached_property - def with_streaming_response(self) -> AsyncCaptionsWithStreamingResponse: - return AsyncCaptionsWithStreamingResponse(self) + def with_streaming_response(self) -> AsyncLanguageWithStreamingResponse: + return AsyncLanguageWithStreamingResponse(self) async def update( self, @@ -245,7 +261,7 @@ async def update( raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") return await self._put( f"/accounts/{account_id}/stream/{identifier}/captions/{language}", - body=await async_maybe_transform({"file": file}, caption_update_params.CaptionUpdateParams), + body=await async_maybe_transform({"file": file}, language_update_params.LanguageUpdateParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, @@ -296,37 +312,40 @@ async def delete( raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") return await self._delete( f"/accounts/{account_id}/stream/{identifier}/captions/{language}", - body=await async_maybe_transform(body, caption_delete_params.CaptionDeleteParams), + body=await async_maybe_transform(body, language_delete_params.LanguageDeleteParams), options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[CaptionDeleteResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[LanguageDeleteResponse]]._unwrapper, ), cast_to=cast(Type[str], ResultWrapper[str]), ) async def get( self, - identifier: str, + language: str, *, account_id: str, + identifier: str, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> Optional[CaptionGetResponse]: + ) -> Optional[Caption]: """ - Lists the available captions or subtitles for a specific video. + Lists the captions or subtitles for provided language. Args: account_id: Identifier identifier: A Cloudflare-generated unique identifier for a media item. + language: The language tag in BCP 47 format. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -339,74 +358,92 @@ async def get( raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") if not identifier: raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") + if not language: + raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") return await self._get( - f"/accounts/{account_id}/stream/{identifier}/captions", + f"/accounts/{account_id}/stream/{identifier}/captions/{language}", options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout, - post_parser=ResultWrapper[Optional[CaptionGetResponse]]._unwrapper, + post_parser=ResultWrapper[Optional[Caption]]._unwrapper, ), - cast_to=cast(Type[Optional[CaptionGetResponse]], ResultWrapper[CaptionGetResponse]), + cast_to=cast(Type[Optional[Caption]], ResultWrapper[Caption]), ) -class CaptionsWithRawResponse: - def __init__(self, captions: Captions) -> None: - self._captions = captions +class LanguageWithRawResponse: + def __init__(self, language: Language) -> None: + self._language = language self.update = to_raw_response_wrapper( - captions.update, + language.update, ) self.delete = to_raw_response_wrapper( - captions.delete, + language.delete, ) self.get = to_raw_response_wrapper( - captions.get, + language.get, ) + @cached_property + def vtt(self) -> VttWithRawResponse: + return VttWithRawResponse(self._language.vtt) + -class AsyncCaptionsWithRawResponse: - def __init__(self, captions: AsyncCaptions) -> None: - self._captions = captions +class AsyncLanguageWithRawResponse: + def __init__(self, language: AsyncLanguage) -> None: + self._language = language self.update = async_to_raw_response_wrapper( - captions.update, + language.update, ) self.delete = async_to_raw_response_wrapper( - captions.delete, + language.delete, ) self.get = async_to_raw_response_wrapper( - captions.get, + language.get, ) + @cached_property + def vtt(self) -> AsyncVttWithRawResponse: + return AsyncVttWithRawResponse(self._language.vtt) + -class CaptionsWithStreamingResponse: - def __init__(self, captions: Captions) -> None: - self._captions = captions +class LanguageWithStreamingResponse: + def __init__(self, language: Language) -> None: + self._language = language self.update = to_streamed_response_wrapper( - captions.update, + language.update, ) self.delete = to_streamed_response_wrapper( - captions.delete, + language.delete, ) self.get = to_streamed_response_wrapper( - captions.get, + language.get, ) + @cached_property + def vtt(self) -> VttWithStreamingResponse: + return VttWithStreamingResponse(self._language.vtt) + -class AsyncCaptionsWithStreamingResponse: - def __init__(self, captions: AsyncCaptions) -> None: - self._captions = captions +class AsyncLanguageWithStreamingResponse: + def __init__(self, language: AsyncLanguage) -> None: + self._language = language self.update = async_to_streamed_response_wrapper( - captions.update, + language.update, ) self.delete = async_to_streamed_response_wrapper( - captions.delete, + language.delete, ) self.get = async_to_streamed_response_wrapper( - captions.get, + language.get, ) + + @cached_property + def vtt(self) -> AsyncVttWithStreamingResponse: + return AsyncVttWithStreamingResponse(self._language.vtt) diff --git a/src/cloudflare/resources/stream/captions/language/vtt.py b/src/cloudflare/resources/stream/captions/language/vtt.py new file mode 100644 index 00000000000..cbf4bbcc04d --- /dev/null +++ b/src/cloudflare/resources/stream/captions/language/vtt.py @@ -0,0 +1,170 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven +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 ....._base_client import ( + make_request_options, +) + +__all__ = ["Vtt", "AsyncVtt"] + + +class Vtt(SyncAPIResource): + @cached_property + def with_raw_response(self) -> VttWithRawResponse: + return VttWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> VttWithStreamingResponse: + return VttWithStreamingResponse(self) + + def get( + self, + language: str, + *, + account_id: str, + identifier: str, + body: object, + # 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, + ) -> str: + """ + Return WebVTT captions for a provided language. + + Args: + account_id: Identifier + + identifier: A Cloudflare-generated unique identifier for a media item. + + language: The language tag in BCP 47 format. + + 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}") + if not identifier: + raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") + if not language: + raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") + extra_headers = {"Accept": "text/vtt", **(extra_headers or {})} + return self._get( + f"/accounts/{account_id}/stream/{identifier}/captions/{language}/vtt", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=str, + ) + + +class AsyncVtt(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncVttWithRawResponse: + return AsyncVttWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncVttWithStreamingResponse: + return AsyncVttWithStreamingResponse(self) + + async def get( + self, + language: str, + *, + account_id: str, + identifier: str, + body: object, + # 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, + ) -> str: + """ + Return WebVTT captions for a provided language. + + Args: + account_id: Identifier + + identifier: A Cloudflare-generated unique identifier for a media item. + + language: The language tag in BCP 47 format. + + 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}") + if not identifier: + raise ValueError(f"Expected a non-empty value for `identifier` but received {identifier!r}") + if not language: + raise ValueError(f"Expected a non-empty value for `language` but received {language!r}") + extra_headers = {"Accept": "text/vtt", **(extra_headers or {})} + return await self._get( + f"/accounts/{account_id}/stream/{identifier}/captions/{language}/vtt", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=str, + ) + + +class VttWithRawResponse: + def __init__(self, vtt: Vtt) -> None: + self._vtt = vtt + + self.get = to_raw_response_wrapper( + vtt.get, + ) + + +class AsyncVttWithRawResponse: + def __init__(self, vtt: AsyncVtt) -> None: + self._vtt = vtt + + self.get = async_to_raw_response_wrapper( + vtt.get, + ) + + +class VttWithStreamingResponse: + def __init__(self, vtt: Vtt) -> None: + self._vtt = vtt + + self.get = to_streamed_response_wrapper( + vtt.get, + ) + + +class AsyncVttWithStreamingResponse: + def __init__(self, vtt: AsyncVtt) -> None: + self._vtt = vtt + + self.get = async_to_streamed_response_wrapper( + vtt.get, + ) diff --git a/src/cloudflare/resources/stream/stream.py b/src/cloudflare/resources/stream/stream.py index ce2fa665d64..af8a0c513a3 100644 --- a/src/cloudflare/resources/stream/stream.py +++ b/src/cloudflare/resources/stream/stream.py @@ -132,6 +132,7 @@ make_request_options, ) from ...types.stream import Video, stream_list_params, stream_create_params, stream_delete_params +from .captions.captions import Captions, AsyncCaptions from .live_inputs.live_inputs import LiveInputs, AsyncLiveInputs __all__ = ["Stream", "AsyncStream"] diff --git a/src/cloudflare/resources/zero_trust/__init__.py b/src/cloudflare/resources/zero_trust/__init__.py index 1558206aa79..75a0d0da0cd 100644 --- a/src/cloudflare/resources/zero_trust/__init__.py +++ b/src/cloudflare/resources/zero_trust/__init__.py @@ -72,6 +72,14 @@ ZeroTrustWithStreamingResponse, AsyncZeroTrustWithStreamingResponse, ) +from .risk_scoring import ( + RiskScoring, + AsyncRiskScoring, + RiskScoringWithRawResponse, + AsyncRiskScoringWithRawResponse, + RiskScoringWithStreamingResponse, + AsyncRiskScoringWithStreamingResponse, +) from .organizations import ( Organizations, AsyncOrganizations, @@ -164,6 +172,12 @@ "AsyncNetworksWithRawResponse", "NetworksWithStreamingResponse", "AsyncNetworksWithStreamingResponse", + "RiskScoring", + "AsyncRiskScoring", + "RiskScoringWithRawResponse", + "AsyncRiskScoringWithRawResponse", + "RiskScoringWithStreamingResponse", + "AsyncRiskScoringWithStreamingResponse", "ZeroTrust", "AsyncZeroTrust", "ZeroTrustWithRawResponse", diff --git a/src/cloudflare/resources/zero_trust/risk_scoring/__init__.py b/src/cloudflare/resources/zero_trust/risk_scoring/__init__.py new file mode 100644 index 00000000000..93432bf9f4d --- /dev/null +++ b/src/cloudflare/resources/zero_trust/risk_scoring/__init__.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from .summary import ( + Summary, + AsyncSummary, + SummaryWithRawResponse, + AsyncSummaryWithRawResponse, + SummaryWithStreamingResponse, + AsyncSummaryWithStreamingResponse, +) +from .behaviours import ( + Behaviours, + AsyncBehaviours, + BehavioursWithRawResponse, + AsyncBehavioursWithRawResponse, + BehavioursWithStreamingResponse, + AsyncBehavioursWithStreamingResponse, +) +from .risk_scoring import ( + RiskScoring, + AsyncRiskScoring, + RiskScoringWithRawResponse, + AsyncRiskScoringWithRawResponse, + RiskScoringWithStreamingResponse, + AsyncRiskScoringWithStreamingResponse, +) + +__all__ = [ + "Behaviours", + "AsyncBehaviours", + "BehavioursWithRawResponse", + "AsyncBehavioursWithRawResponse", + "BehavioursWithStreamingResponse", + "AsyncBehavioursWithStreamingResponse", + "Summary", + "AsyncSummary", + "SummaryWithRawResponse", + "AsyncSummaryWithRawResponse", + "SummaryWithStreamingResponse", + "AsyncSummaryWithStreamingResponse", + "RiskScoring", + "AsyncRiskScoring", + "RiskScoringWithRawResponse", + "AsyncRiskScoringWithRawResponse", + "RiskScoringWithStreamingResponse", + "AsyncRiskScoringWithStreamingResponse", +] diff --git a/src/cloudflare/resources/zero_trust/risk_scoring/behaviours.py b/src/cloudflare/resources/zero_trust/risk_scoring/behaviours.py new file mode 100644 index 00000000000..9690e7108cd --- /dev/null +++ b/src/cloudflare/resources/zero_trust/risk_scoring/behaviours.py @@ -0,0 +1,256 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Type, cast + +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.zero_trust.risk_scoring import BehaviourGetResponse, BehaviourUpdateResponse, behaviour_update_params + +__all__ = ["Behaviours", "AsyncBehaviours"] + + +class Behaviours(SyncAPIResource): + @cached_property + def with_raw_response(self) -> BehavioursWithRawResponse: + return BehavioursWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> BehavioursWithStreamingResponse: + return BehavioursWithStreamingResponse(self) + + def update( + self, + account_identifier: str, + *, + behaviors: Dict[str, behaviour_update_params.Behaviors] | 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, + ) -> BehaviourUpdateResponse: + """ + Update configuration for risk behaviors + + Args: + account_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_identifier: + raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") + return self._put( + f"/accounts/{account_identifier}/zt_risk_scoring/behaviors", + body=maybe_transform({"behaviors": behaviors}, behaviour_update_params.BehaviourUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[BehaviourUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[BehaviourUpdateResponse], ResultWrapper[BehaviourUpdateResponse]), + ) + + def get( + self, + account_identifier: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> BehaviourGetResponse: + """ + Get all behaviors and associated configuration + + Args: + account_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_identifier: + raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") + return self._get( + f"/accounts/{account_identifier}/zt_risk_scoring/behaviors", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[BehaviourGetResponse]._unwrapper, + ), + cast_to=cast(Type[BehaviourGetResponse], ResultWrapper[BehaviourGetResponse]), + ) + + +class AsyncBehaviours(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncBehavioursWithRawResponse: + return AsyncBehavioursWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncBehavioursWithStreamingResponse: + return AsyncBehavioursWithStreamingResponse(self) + + async def update( + self, + account_identifier: str, + *, + behaviors: Dict[str, behaviour_update_params.Behaviors] | 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, + ) -> BehaviourUpdateResponse: + """ + Update configuration for risk behaviors + + Args: + account_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_identifier: + raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") + return await self._put( + f"/accounts/{account_identifier}/zt_risk_scoring/behaviors", + body=await async_maybe_transform({"behaviors": behaviors}, behaviour_update_params.BehaviourUpdateParams), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[BehaviourUpdateResponse]._unwrapper, + ), + cast_to=cast(Type[BehaviourUpdateResponse], ResultWrapper[BehaviourUpdateResponse]), + ) + + async def get( + self, + account_identifier: str, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> BehaviourGetResponse: + """ + Get all behaviors and associated configuration + + Args: + account_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_identifier: + raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") + return await self._get( + f"/accounts/{account_identifier}/zt_risk_scoring/behaviors", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[BehaviourGetResponse]._unwrapper, + ), + cast_to=cast(Type[BehaviourGetResponse], ResultWrapper[BehaviourGetResponse]), + ) + + +class BehavioursWithRawResponse: + def __init__(self, behaviours: Behaviours) -> None: + self._behaviours = behaviours + + self.update = to_raw_response_wrapper( + behaviours.update, + ) + self.get = to_raw_response_wrapper( + behaviours.get, + ) + + +class AsyncBehavioursWithRawResponse: + def __init__(self, behaviours: AsyncBehaviours) -> None: + self._behaviours = behaviours + + self.update = async_to_raw_response_wrapper( + behaviours.update, + ) + self.get = async_to_raw_response_wrapper( + behaviours.get, + ) + + +class BehavioursWithStreamingResponse: + def __init__(self, behaviours: Behaviours) -> None: + self._behaviours = behaviours + + self.update = to_streamed_response_wrapper( + behaviours.update, + ) + self.get = to_streamed_response_wrapper( + behaviours.get, + ) + + +class AsyncBehavioursWithStreamingResponse: + def __init__(self, behaviours: AsyncBehaviours) -> None: + self._behaviours = behaviours + + self.update = async_to_streamed_response_wrapper( + behaviours.update, + ) + self.get = async_to_streamed_response_wrapper( + behaviours.get, + ) diff --git a/src/cloudflare/resources/zero_trust/risk_scoring/risk_scoring.py b/src/cloudflare/resources/zero_trust/risk_scoring/risk_scoring.py new file mode 100644 index 00000000000..2035a4118eb --- /dev/null +++ b/src/cloudflare/resources/zero_trust/risk_scoring/risk_scoring.py @@ -0,0 +1,373 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Any, Type, cast +from typing_extensions import Literal + +import httpx + +from .summary import ( + Summary, + AsyncSummary, + SummaryWithRawResponse, + AsyncSummaryWithRawResponse, + SummaryWithStreamingResponse, + AsyncSummaryWithStreamingResponse, +) +from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from ...._utils import ( + maybe_transform, + async_maybe_transform, +) +from ...._compat import cached_property +from .behaviours import ( + Behaviours, + AsyncBehaviours, + BehavioursWithRawResponse, + AsyncBehavioursWithRawResponse, + BehavioursWithStreamingResponse, + AsyncBehavioursWithStreamingResponse, +) +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.zero_trust import RiskScoringGetResponse, RiskScoringResetResponse, risk_scoring_get_params + +__all__ = ["RiskScoring", "AsyncRiskScoring"] + + +class RiskScoring(SyncAPIResource): + @cached_property + def behaviours(self) -> Behaviours: + return Behaviours(self._client) + + @cached_property + def summary(self) -> Summary: + return Summary(self._client) + + @cached_property + def with_raw_response(self) -> RiskScoringWithRawResponse: + return RiskScoringWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> RiskScoringWithStreamingResponse: + return RiskScoringWithStreamingResponse(self) + + def get( + self, + user_id: str, + *, + account_identifier: str, + direction: Literal["desc", "asc"] | NotGiven = NOT_GIVEN, + order_by: Literal["timestamp", "risk_level"] | NotGiven = NOT_GIVEN, + page: int | NotGiven = NOT_GIVEN, + per_page: int | 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, + ) -> RiskScoringGetResponse: + """ + Get risk event/score information for a specific user + + Args: + account_identifier: Identifier + + user_id: The ID for a user + + 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_identifier: + raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") + if not user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + return self._get( + f"/accounts/{account_identifier}/zt_risk_scoring/{user_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "direction": direction, + "order_by": order_by, + "page": page, + "per_page": per_page, + }, + risk_scoring_get_params.RiskScoringGetParams, + ), + post_parser=ResultWrapper[RiskScoringGetResponse]._unwrapper, + ), + cast_to=cast(Type[RiskScoringGetResponse], ResultWrapper[RiskScoringGetResponse]), + ) + + def reset( + self, + user_id: str, + *, + account_identifier: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RiskScoringResetResponse: + """ + Clear the risk score for a particular user + + Args: + account_identifier: Identifier + + user_id: The ID for a user + + 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_identifier: + raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") + if not user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + return cast( + RiskScoringResetResponse, + self._post( + f"/accounts/{account_identifier}/zt_risk_scoring/{user_id}/reset", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RiskScoringResetResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RiskScoringResetResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + +class AsyncRiskScoring(AsyncAPIResource): + @cached_property + def behaviours(self) -> AsyncBehaviours: + return AsyncBehaviours(self._client) + + @cached_property + def summary(self) -> AsyncSummary: + return AsyncSummary(self._client) + + @cached_property + def with_raw_response(self) -> AsyncRiskScoringWithRawResponse: + return AsyncRiskScoringWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncRiskScoringWithStreamingResponse: + return AsyncRiskScoringWithStreamingResponse(self) + + async def get( + self, + user_id: str, + *, + account_identifier: str, + direction: Literal["desc", "asc"] | NotGiven = NOT_GIVEN, + order_by: Literal["timestamp", "risk_level"] | NotGiven = NOT_GIVEN, + page: int | NotGiven = NOT_GIVEN, + per_page: int | 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, + ) -> RiskScoringGetResponse: + """ + Get risk event/score information for a specific user + + Args: + account_identifier: Identifier + + user_id: The ID for a user + + 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_identifier: + raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") + if not user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + return await self._get( + f"/accounts/{account_identifier}/zt_risk_scoring/{user_id}", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "direction": direction, + "order_by": order_by, + "page": page, + "per_page": per_page, + }, + risk_scoring_get_params.RiskScoringGetParams, + ), + post_parser=ResultWrapper[RiskScoringGetResponse]._unwrapper, + ), + cast_to=cast(Type[RiskScoringGetResponse], ResultWrapper[RiskScoringGetResponse]), + ) + + async def reset( + self, + user_id: str, + *, + account_identifier: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> RiskScoringResetResponse: + """ + Clear the risk score for a particular user + + Args: + account_identifier: Identifier + + user_id: The ID for a user + + 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_identifier: + raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") + if not user_id: + raise ValueError(f"Expected a non-empty value for `user_id` but received {user_id!r}") + return cast( + RiskScoringResetResponse, + await self._post( + f"/accounts/{account_identifier}/zt_risk_scoring/{user_id}/reset", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[RiskScoringResetResponse]._unwrapper, + ), + cast_to=cast( + Any, ResultWrapper[RiskScoringResetResponse] + ), # Union types cannot be passed in as arguments in the type system + ), + ) + + +class RiskScoringWithRawResponse: + def __init__(self, risk_scoring: RiskScoring) -> None: + self._risk_scoring = risk_scoring + + self.get = to_raw_response_wrapper( + risk_scoring.get, + ) + self.reset = to_raw_response_wrapper( + risk_scoring.reset, + ) + + @cached_property + def behaviours(self) -> BehavioursWithRawResponse: + return BehavioursWithRawResponse(self._risk_scoring.behaviours) + + @cached_property + def summary(self) -> SummaryWithRawResponse: + return SummaryWithRawResponse(self._risk_scoring.summary) + + +class AsyncRiskScoringWithRawResponse: + def __init__(self, risk_scoring: AsyncRiskScoring) -> None: + self._risk_scoring = risk_scoring + + self.get = async_to_raw_response_wrapper( + risk_scoring.get, + ) + self.reset = async_to_raw_response_wrapper( + risk_scoring.reset, + ) + + @cached_property + def behaviours(self) -> AsyncBehavioursWithRawResponse: + return AsyncBehavioursWithRawResponse(self._risk_scoring.behaviours) + + @cached_property + def summary(self) -> AsyncSummaryWithRawResponse: + return AsyncSummaryWithRawResponse(self._risk_scoring.summary) + + +class RiskScoringWithStreamingResponse: + def __init__(self, risk_scoring: RiskScoring) -> None: + self._risk_scoring = risk_scoring + + self.get = to_streamed_response_wrapper( + risk_scoring.get, + ) + self.reset = to_streamed_response_wrapper( + risk_scoring.reset, + ) + + @cached_property + def behaviours(self) -> BehavioursWithStreamingResponse: + return BehavioursWithStreamingResponse(self._risk_scoring.behaviours) + + @cached_property + def summary(self) -> SummaryWithStreamingResponse: + return SummaryWithStreamingResponse(self._risk_scoring.summary) + + +class AsyncRiskScoringWithStreamingResponse: + def __init__(self, risk_scoring: AsyncRiskScoring) -> None: + self._risk_scoring = risk_scoring + + self.get = async_to_streamed_response_wrapper( + risk_scoring.get, + ) + self.reset = async_to_streamed_response_wrapper( + risk_scoring.reset, + ) + + @cached_property + def behaviours(self) -> AsyncBehavioursWithStreamingResponse: + return AsyncBehavioursWithStreamingResponse(self._risk_scoring.behaviours) + + @cached_property + def summary(self) -> AsyncSummaryWithStreamingResponse: + return AsyncSummaryWithStreamingResponse(self._risk_scoring.summary) diff --git a/src/cloudflare/resources/zero_trust/risk_scoring/summary.py b/src/cloudflare/resources/zero_trust/risk_scoring/summary.py new file mode 100644 index 00000000000..2494f380c97 --- /dev/null +++ b/src/cloudflare/resources/zero_trust/risk_scoring/summary.py @@ -0,0 +1,189 @@ +# 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.zero_trust.risk_scoring import SummaryGetResponse, summary_get_params + +__all__ = ["Summary", "AsyncSummary"] + + +class Summary(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SummaryWithRawResponse: + return SummaryWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SummaryWithStreamingResponse: + return SummaryWithStreamingResponse(self) + + def get( + self, + account_identifier: str, + *, + direction: Literal["desc", "asc"] | NotGiven = NOT_GIVEN, + order_by: Literal["timestamp", "event_count", "max_risk_level"] | NotGiven = NOT_GIVEN, + page: int | NotGiven = NOT_GIVEN, + per_page: int | 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, + ) -> SummaryGetResponse: + """ + Get risk score info for all users in the account + + Args: + account_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_identifier: + raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") + return self._get( + f"/accounts/{account_identifier}/zt_risk_scoring/summary", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "direction": direction, + "order_by": order_by, + "page": page, + "per_page": per_page, + }, + summary_get_params.SummaryGetParams, + ), + post_parser=ResultWrapper[SummaryGetResponse]._unwrapper, + ), + cast_to=cast(Type[SummaryGetResponse], ResultWrapper[SummaryGetResponse]), + ) + + +class AsyncSummary(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSummaryWithRawResponse: + return AsyncSummaryWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSummaryWithStreamingResponse: + return AsyncSummaryWithStreamingResponse(self) + + async def get( + self, + account_identifier: str, + *, + direction: Literal["desc", "asc"] | NotGiven = NOT_GIVEN, + order_by: Literal["timestamp", "event_count", "max_risk_level"] | NotGiven = NOT_GIVEN, + page: int | NotGiven = NOT_GIVEN, + per_page: int | 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, + ) -> SummaryGetResponse: + """ + Get risk score info for all users in the account + + Args: + account_identifier: Identifier + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not account_identifier: + raise ValueError(f"Expected a non-empty value for `account_identifier` but received {account_identifier!r}") + return await self._get( + f"/accounts/{account_identifier}/zt_risk_scoring/summary", + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + { + "direction": direction, + "order_by": order_by, + "page": page, + "per_page": per_page, + }, + summary_get_params.SummaryGetParams, + ), + post_parser=ResultWrapper[SummaryGetResponse]._unwrapper, + ), + cast_to=cast(Type[SummaryGetResponse], ResultWrapper[SummaryGetResponse]), + ) + + +class SummaryWithRawResponse: + def __init__(self, summary: Summary) -> None: + self._summary = summary + + self.get = to_raw_response_wrapper( + summary.get, + ) + + +class AsyncSummaryWithRawResponse: + def __init__(self, summary: AsyncSummary) -> None: + self._summary = summary + + self.get = async_to_raw_response_wrapper( + summary.get, + ) + + +class SummaryWithStreamingResponse: + def __init__(self, summary: Summary) -> None: + self._summary = summary + + self.get = to_streamed_response_wrapper( + summary.get, + ) + + +class AsyncSummaryWithStreamingResponse: + def __init__(self, summary: AsyncSummary) -> None: + self._summary = summary + + self.get = async_to_streamed_response_wrapper( + summary.get, + ) diff --git a/src/cloudflare/resources/zero_trust/zero_trust.py b/src/cloudflare/resources/zero_trust/zero_trust.py index 108c0a02003..c305e8c341f 100644 --- a/src/cloudflare/resources/zero_trust/zero_trust.py +++ b/src/cloudflare/resources/zero_trust/zero_trust.py @@ -70,6 +70,14 @@ ) from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource +from .risk_scoring import ( + RiskScoring, + AsyncRiskScoring, + RiskScoringWithRawResponse, + AsyncRiskScoringWithRawResponse, + RiskScoringWithStreamingResponse, + AsyncRiskScoringWithStreamingResponse, +) from .access.access import Access, AsyncAccess from .organizations import ( Organizations, @@ -99,6 +107,7 @@ ConnectivitySettingsWithStreamingResponse, AsyncConnectivitySettingsWithStreamingResponse, ) +from .risk_scoring.risk_scoring import RiskScoring, AsyncRiskScoring __all__ = ["ZeroTrust", "AsyncZeroTrust"] @@ -148,6 +157,10 @@ def gateway(self) -> Gateway: def networks(self) -> Networks: return Networks(self._client) + @cached_property + def risk_scoring(self) -> RiskScoring: + return RiskScoring(self._client) + @cached_property def with_raw_response(self) -> ZeroTrustWithRawResponse: return ZeroTrustWithRawResponse(self) @@ -202,6 +215,10 @@ def gateway(self) -> AsyncGateway: def networks(self) -> AsyncNetworks: return AsyncNetworks(self._client) + @cached_property + def risk_scoring(self) -> AsyncRiskScoring: + return AsyncRiskScoring(self._client) + @cached_property def with_raw_response(self) -> AsyncZeroTrustWithRawResponse: return AsyncZeroTrustWithRawResponse(self) @@ -259,6 +276,10 @@ def gateway(self) -> GatewayWithRawResponse: def networks(self) -> NetworksWithRawResponse: return NetworksWithRawResponse(self._zero_trust.networks) + @cached_property + def risk_scoring(self) -> RiskScoringWithRawResponse: + return RiskScoringWithRawResponse(self._zero_trust.risk_scoring) + class AsyncZeroTrustWithRawResponse: def __init__(self, zero_trust: AsyncZeroTrust) -> None: @@ -308,6 +329,10 @@ def gateway(self) -> AsyncGatewayWithRawResponse: def networks(self) -> AsyncNetworksWithRawResponse: return AsyncNetworksWithRawResponse(self._zero_trust.networks) + @cached_property + def risk_scoring(self) -> AsyncRiskScoringWithRawResponse: + return AsyncRiskScoringWithRawResponse(self._zero_trust.risk_scoring) + class ZeroTrustWithStreamingResponse: def __init__(self, zero_trust: ZeroTrust) -> None: @@ -357,6 +382,10 @@ def gateway(self) -> GatewayWithStreamingResponse: def networks(self) -> NetworksWithStreamingResponse: return NetworksWithStreamingResponse(self._zero_trust.networks) + @cached_property + def risk_scoring(self) -> RiskScoringWithStreamingResponse: + return RiskScoringWithStreamingResponse(self._zero_trust.risk_scoring) + class AsyncZeroTrustWithStreamingResponse: def __init__(self, zero_trust: AsyncZeroTrust) -> None: @@ -405,3 +434,7 @@ def gateway(self) -> AsyncGatewayWithStreamingResponse: @cached_property def networks(self) -> AsyncNetworksWithStreamingResponse: return AsyncNetworksWithStreamingResponse(self._zero_trust.networks) + + @cached_property + def risk_scoring(self) -> AsyncRiskScoringWithStreamingResponse: + return AsyncRiskScoringWithStreamingResponse(self._zero_trust.risk_scoring) diff --git a/src/cloudflare/types/stream/__init__.py b/src/cloudflare/types/stream/__init__.py index 8ef5dc26c18..f9400109986 100644 --- a/src/cloudflare/types/stream/__init__.py +++ b/src/cloudflare/types/stream/__init__.py @@ -23,8 +23,6 @@ from .stream_create_params import StreamCreateParams as StreamCreateParams from .stream_delete_params import StreamDeleteParams as StreamDeleteParams from .webhook_get_response import WebhookGetResponse as WebhookGetResponse -from .caption_delete_params import CaptionDeleteParams as CaptionDeleteParams -from .caption_update_params import CaptionUpdateParams as CaptionUpdateParams from .download_get_response import DownloadGetResponse as DownloadGetResponse from .token_create_response import TokenCreateResponse as TokenCreateResponse from .webhook_delete_params import WebhookDeleteParams as WebhookDeleteParams @@ -33,7 +31,6 @@ from .live_input_list_params import LiveInputListParams as LiveInputListParams from .audio_track_copy_params import AudioTrackCopyParams as AudioTrackCopyParams from .audio_track_edit_params import AudioTrackEditParams as AudioTrackEditParams -from .caption_delete_response import CaptionDeleteResponse as CaptionDeleteResponse from .watermark_create_params import WatermarkCreateParams as WatermarkCreateParams from .watermark_delete_params import WatermarkDeleteParams as WatermarkDeleteParams from .webhook_delete_response import WebhookDeleteResponse as WebhookDeleteResponse diff --git a/src/cloudflare/types/stream/captions/__init__.py b/src/cloudflare/types/stream/captions/__init__.py new file mode 100644 index 00000000000..f34bcc36978 --- /dev/null +++ b/src/cloudflare/types/stream/captions/__init__.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .language_delete_params import LanguageDeleteParams as LanguageDeleteParams +from .language_update_params import LanguageUpdateParams as LanguageUpdateParams +from .language_delete_response import LanguageDeleteResponse as LanguageDeleteResponse diff --git a/src/cloudflare/types/stream/captions/language/__init__.py b/src/cloudflare/types/stream/captions/language/__init__.py new file mode 100644 index 00000000000..75348af4f88 --- /dev/null +++ b/src/cloudflare/types/stream/captions/language/__init__.py @@ -0,0 +1,6 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .vtt_get_params import VttGetParams as VttGetParams +from .vtt_get_response import VttGetResponse as VttGetResponse diff --git a/src/cloudflare/types/stream/caption_delete_params.py b/src/cloudflare/types/stream/captions/language/vtt_get_params.py similarity index 80% rename from src/cloudflare/types/stream/caption_delete_params.py rename to src/cloudflare/types/stream/captions/language/vtt_get_params.py index f36bd55c716..3a9b6648aea 100644 --- a/src/cloudflare/types/stream/caption_delete_params.py +++ b/src/cloudflare/types/stream/captions/language/vtt_get_params.py @@ -4,10 +4,10 @@ from typing_extensions import Required, TypedDict -__all__ = ["CaptionDeleteParams"] +__all__ = ["VttGetParams"] -class CaptionDeleteParams(TypedDict, total=False): +class VttGetParams(TypedDict, total=False): account_id: Required[str] """Identifier""" diff --git a/src/cloudflare/types/stream/caption_delete_response.py b/src/cloudflare/types/stream/captions/language/vtt_get_response.py similarity index 58% rename from src/cloudflare/types/stream/caption_delete_response.py rename to src/cloudflare/types/stream/captions/language/vtt_get_response.py index 67c99da0b8f..b4f2213435c 100644 --- a/src/cloudflare/types/stream/caption_delete_response.py +++ b/src/cloudflare/types/stream/captions/language/vtt_get_response.py @@ -1,6 +1,6 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -__all__ = ["CaptionDeleteResponse"] +__all__ = ["VttGetResponse"] -CaptionDeleteResponse = str +VttGetResponse = str diff --git a/src/cloudflare/types/stream/captions/language_delete_params.py b/src/cloudflare/types/stream/captions/language_delete_params.py new file mode 100644 index 00000000000..348f01f68e0 --- /dev/null +++ b/src/cloudflare/types/stream/captions/language_delete_params.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["LanguageDeleteParams"] + + +class LanguageDeleteParams(TypedDict, total=False): + account_id: Required[str] + """Identifier""" + + identifier: Required[str] + """A Cloudflare-generated unique identifier for a media item.""" + + body: Required[object] diff --git a/src/cloudflare/types/stream/captions/language_delete_response.py b/src/cloudflare/types/stream/captions/language_delete_response.py new file mode 100644 index 00000000000..4c79b0573b6 --- /dev/null +++ b/src/cloudflare/types/stream/captions/language_delete_response.py @@ -0,0 +1,6 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +__all__ = ["LanguageDeleteResponse"] + +LanguageDeleteResponse = str diff --git a/src/cloudflare/types/stream/caption_update_params.py b/src/cloudflare/types/stream/captions/language_update_params.py similarity index 82% rename from src/cloudflare/types/stream/caption_update_params.py rename to src/cloudflare/types/stream/captions/language_update_params.py index f75ea53cbd8..66f85180bf2 100644 --- a/src/cloudflare/types/stream/caption_update_params.py +++ b/src/cloudflare/types/stream/captions/language_update_params.py @@ -4,10 +4,10 @@ from typing_extensions import Required, TypedDict -__all__ = ["CaptionUpdateParams"] +__all__ = ["LanguageUpdateParams"] -class CaptionUpdateParams(TypedDict, total=False): +class LanguageUpdateParams(TypedDict, total=False): account_id: Required[str] """Identifier""" diff --git a/src/cloudflare/types/zero_trust/__init__.py b/src/cloudflare/types/zero_trust/__init__.py index 4b4db35774e..733d9109806 100644 --- a/src/cloudflare/types/zero_trust/__init__.py +++ b/src/cloudflare/types/zero_trust/__init__.py @@ -60,15 +60,18 @@ from .tunnel_delete_response import TunnelDeleteResponse as TunnelDeleteResponse from .gateway_create_response import GatewayCreateResponse as GatewayCreateResponse from .gsuite_group_rule_param import GSuiteGroupRuleParam as GSuiteGroupRuleParam +from .risk_scoring_get_params import RiskScoringGetParams as RiskScoringGetParams from .external_evaluation_rule import ExternalEvaluationRule as ExternalEvaluationRule from .github_organization_rule import GitHubOrganizationRule as GitHubOrganizationRule from .service_token_rule_param import ServiceTokenRuleParam as ServiceTokenRuleParam from .device_experience_monitor import DeviceExperienceMonitor as DeviceExperienceMonitor +from .risk_scoring_get_response import RiskScoringGetResponse as RiskScoringGetResponse from .access_device_posture_rule import AccessDevicePostureRule as AccessDevicePostureRule from .authentication_method_rule import AuthenticationMethodRule as AuthenticationMethodRule from .generic_oauth_config_param import GenericOAuthConfigParam as GenericOAuthConfigParam from .organization_create_params import OrganizationCreateParams as OrganizationCreateParams from .organization_update_params import OrganizationUpdateParams as OrganizationUpdateParams +from .risk_scoring_reset_response import RiskScoringResetResponse as RiskScoringResetResponse from .any_valid_service_token_rule import AnyValidServiceTokenRule as AnyValidServiceTokenRule from .external_evaluation_rule_param import ExternalEvaluationRuleParam as ExternalEvaluationRuleParam from .github_organization_rule_param import GitHubOrganizationRuleParam as GitHubOrganizationRuleParam diff --git a/src/cloudflare/types/zero_trust/risk_scoring/__init__.py b/src/cloudflare/types/zero_trust/risk_scoring/__init__.py new file mode 100644 index 00000000000..dce834add7c --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring/__init__.py @@ -0,0 +1,9 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .summary_get_params import SummaryGetParams as SummaryGetParams +from .summary_get_response import SummaryGetResponse as SummaryGetResponse +from .behaviour_get_response import BehaviourGetResponse as BehaviourGetResponse +from .behaviour_update_params import BehaviourUpdateParams as BehaviourUpdateParams +from .behaviour_update_response import BehaviourUpdateResponse as BehaviourUpdateResponse diff --git a/src/cloudflare/types/zero_trust/risk_scoring/behaviour_get_response.py b/src/cloudflare/types/zero_trust/risk_scoring/behaviour_get_response.py new file mode 100644 index 00000000000..5233be19794 --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring/behaviour_get_response.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["BehaviourGetResponse", "Behaviors"] + + +class Behaviors(BaseModel): + description: Optional[str] = None + + enabled: Optional[bool] = None + + name: Optional[str] = None + + risk_level: Optional[Literal["low", "medium", "high"]] = None + + +class BehaviourGetResponse(BaseModel): + behaviors: Optional[Dict[str, Behaviors]] = None diff --git a/src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_params.py b/src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_params.py new file mode 100644 index 00000000000..c0180b2da17 --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_params.py @@ -0,0 +1,18 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Optional +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["BehaviourUpdateParams", "Behaviors"] + + +class BehaviourUpdateParams(TypedDict, total=False): + behaviors: Dict[str, Behaviors] + + +class Behaviors(TypedDict, total=False): + enabled: Required[bool] + + risk_level: Required[Optional[Literal["low", "medium", "high"]]] diff --git a/src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_response.py b/src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_response.py new file mode 100644 index 00000000000..ff2cb7b3fef --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring/behaviour_update_response.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Dict, Optional +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["BehaviourUpdateResponse", "Behaviors"] + + +class Behaviors(BaseModel): + description: Optional[str] = None + + enabled: Optional[bool] = None + + name: Optional[str] = None + + risk_level: Optional[Literal["low", "medium", "high"]] = None + + +class BehaviourUpdateResponse(BaseModel): + behaviors: Optional[Dict[str, Behaviors]] = None diff --git a/src/cloudflare/types/zero_trust/risk_scoring/summary_get_params.py b/src/cloudflare/types/zero_trust/risk_scoring/summary_get_params.py new file mode 100644 index 00000000000..591d0359289 --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring/summary_get_params.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, TypedDict + +__all__ = ["SummaryGetParams"] + + +class SummaryGetParams(TypedDict, total=False): + direction: Literal["desc", "asc"] + + order_by: Literal["timestamp", "event_count", "max_risk_level"] + + page: int + + per_page: int diff --git a/src/cloudflare/types/zero_trust/risk_scoring/summary_get_response.py b/src/cloudflare/types/zero_trust/risk_scoring/summary_get_response.py new file mode 100644 index 00000000000..c15eb288655 --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring/summary_get_response.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ...._models import BaseModel + +__all__ = ["SummaryGetResponse", "User"] + + +class User(BaseModel): + email: str + + event_count: int + + last_event: datetime + + max_risk_level: Optional[Literal["low", "medium", "high"]] = None + + name: str + + user_id: str + """The ID for a user""" + + +class SummaryGetResponse(BaseModel): + users: Optional[List[User]] = None diff --git a/src/cloudflare/types/zero_trust/risk_scoring_get_params.py b/src/cloudflare/types/zero_trust/risk_scoring_get_params.py new file mode 100644 index 00000000000..05adf69a3b3 --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring_get_params.py @@ -0,0 +1,20 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, Required, TypedDict + +__all__ = ["RiskScoringGetParams"] + + +class RiskScoringGetParams(TypedDict, total=False): + account_identifier: Required[str] + """Identifier""" + + direction: Literal["desc", "asc"] + + order_by: Literal["timestamp", "risk_level"] + + page: int + + per_page: int diff --git a/src/cloudflare/types/zero_trust/risk_scoring_get_response.py b/src/cloudflare/types/zero_trust/risk_scoring_get_response.py new file mode 100644 index 00000000000..2b6ae19f438 --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring_get_response.py @@ -0,0 +1,33 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from datetime import datetime +from typing_extensions import Literal + +from ..._models import BaseModel + +__all__ = ["RiskScoringGetResponse", "Event"] + + +class Event(BaseModel): + id: str + + name: str + + risk_level: Optional[Literal["low", "medium", "high"]] = None + + timestamp: datetime + + event_details: Optional[object] = None + + +class RiskScoringGetResponse(BaseModel): + email: Optional[str] = None + + events: Optional[List[Event]] = None + + last_reset_time: Optional[datetime] = None + + name: Optional[str] = None + + risk_level: Optional[Literal["low", "medium", "high"]] = None diff --git a/src/cloudflare/types/zero_trust/risk_scoring_reset_response.py b/src/cloudflare/types/zero_trust/risk_scoring_reset_response.py new file mode 100644 index 00000000000..ffc6a070c07 --- /dev/null +++ b/src/cloudflare/types/zero_trust/risk_scoring_reset_response.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import Union, Optional + +__all__ = ["RiskScoringResetResponse"] + +RiskScoringResetResponse = Union[Optional[str], Optional[object]] diff --git a/tests/api_resources/stream/captions/__init__.py b/tests/api_resources/stream/captions/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/stream/captions/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/stream/captions/language/__init__.py b/tests/api_resources/stream/captions/language/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/stream/captions/language/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/stream/captions/language/test_vtt.py b/tests/api_resources/stream/captions/language/test_vtt.py new file mode 100644 index 00000000000..f8ec81a3422 --- /dev/null +++ b/tests/api_resources/stream/captions/language/test_vtt.py @@ -0,0 +1,161 @@ +# 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 + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestVtt: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + vtt = client.stream.captions.language.vtt.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) + assert_matches_type(str, vtt, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.stream.captions.language.vtt.with_raw_response.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + vtt = response.parse() + assert_matches_type(str, vtt, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.stream.captions.language.vtt.with_streaming_response.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + vtt = response.parse() + assert_matches_type(str, vtt, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.stream.captions.language.vtt.with_raw_response.get( + "tr", + account_id="", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): + client.stream.captions.language.vtt.with_raw_response.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `language` but received ''"): + client.stream.captions.language.vtt.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) + + +class TestAsyncVtt: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + vtt = await async_client.stream.captions.language.vtt.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) + assert_matches_type(str, vtt, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.stream.captions.language.vtt.with_raw_response.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + vtt = await response.parse() + assert_matches_type(str, vtt, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.stream.captions.language.vtt.with_streaming_response.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + vtt = await response.parse() + assert_matches_type(str, vtt, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.stream.captions.language.vtt.with_raw_response.get( + "tr", + account_id="", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): + await async_client.stream.captions.language.vtt.with_raw_response.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `language` but received ''"): + await async_client.stream.captions.language.vtt.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) diff --git a/tests/api_resources/stream/captions/test_language.py b/tests/api_resources/stream/captions/test_language.py new file mode 100644 index 00000000000..59e1bdcb7b2 --- /dev/null +++ b/tests/api_resources/stream/captions/test_language.py @@ -0,0 +1,430 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, Optional, cast + +import pytest + +from cloudflare import Cloudflare, AsyncCloudflare +from tests.utils import assert_matches_type +from cloudflare.types.stream import Caption + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestLanguage: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + language = client.stream.captions.language.update( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + file="@/Users/kyle/Desktop/tr.vtt", + ) + assert_matches_type(Optional[Caption], language, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.stream.captions.language.with_raw_response.update( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + file="@/Users/kyle/Desktop/tr.vtt", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + language = response.parse() + assert_matches_type(Optional[Caption], language, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.stream.captions.language.with_streaming_response.update( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + file="@/Users/kyle/Desktop/tr.vtt", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + language = response.parse() + assert_matches_type(Optional[Caption], language, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.stream.captions.language.with_raw_response.update( + "tr", + account_id="", + identifier="ea95132c15732412d22c1476fa83f27a", + file="@/Users/kyle/Desktop/tr.vtt", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): + client.stream.captions.language.with_raw_response.update( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="", + file="@/Users/kyle/Desktop/tr.vtt", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `language` but received ''"): + client.stream.captions.language.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + file="@/Users/kyle/Desktop/tr.vtt", + ) + + @pytest.mark.skip() + @parametrize + def test_method_delete(self, client: Cloudflare) -> None: + language = client.stream.captions.language.delete( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) + assert_matches_type(str, language, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_delete(self, client: Cloudflare) -> None: + response = client.stream.captions.language.with_raw_response.delete( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + language = response.parse() + assert_matches_type(str, language, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_delete(self, client: Cloudflare) -> None: + with client.stream.captions.language.with_streaming_response.delete( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + language = response.parse() + assert_matches_type(str, language, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_delete(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.stream.captions.language.with_raw_response.delete( + "tr", + account_id="", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): + client.stream.captions.language.with_raw_response.delete( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `language` but received ''"): + client.stream.captions.language.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + language = client.stream.captions.language.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) + assert_matches_type(Optional[Caption], language, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.stream.captions.language.with_raw_response.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + language = response.parse() + assert_matches_type(Optional[Caption], language, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.stream.captions.language.with_streaming_response.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + language = response.parse() + assert_matches_type(Optional[Caption], language, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + client.stream.captions.language.with_raw_response.get( + "tr", + account_id="", + identifier="ea95132c15732412d22c1476fa83f27a", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): + client.stream.captions.language.with_raw_response.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `language` but received ''"): + client.stream.captions.language.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) + + +class TestAsyncLanguage: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + language = await async_client.stream.captions.language.update( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + file="@/Users/kyle/Desktop/tr.vtt", + ) + assert_matches_type(Optional[Caption], language, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.stream.captions.language.with_raw_response.update( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + file="@/Users/kyle/Desktop/tr.vtt", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + language = await response.parse() + assert_matches_type(Optional[Caption], language, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.stream.captions.language.with_streaming_response.update( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + file="@/Users/kyle/Desktop/tr.vtt", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + language = await response.parse() + assert_matches_type(Optional[Caption], language, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.stream.captions.language.with_raw_response.update( + "tr", + account_id="", + identifier="ea95132c15732412d22c1476fa83f27a", + file="@/Users/kyle/Desktop/tr.vtt", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): + await async_client.stream.captions.language.with_raw_response.update( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="", + file="@/Users/kyle/Desktop/tr.vtt", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `language` but received ''"): + await async_client.stream.captions.language.with_raw_response.update( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + file="@/Users/kyle/Desktop/tr.vtt", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_delete(self, async_client: AsyncCloudflare) -> None: + language = await async_client.stream.captions.language.delete( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) + assert_matches_type(str, language, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: + response = await async_client.stream.captions.language.with_raw_response.delete( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + language = await response.parse() + assert_matches_type(str, language, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: + async with async_client.stream.captions.language.with_streaming_response.delete( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + language = await response.parse() + assert_matches_type(str, language, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.stream.captions.language.with_raw_response.delete( + "tr", + account_id="", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): + await async_client.stream.captions.language.with_raw_response.delete( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="", + body={}, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `language` but received ''"): + await async_client.stream.captions.language.with_raw_response.delete( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + body={}, + ) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + language = await async_client.stream.captions.language.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) + assert_matches_type(Optional[Caption], language, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.stream.captions.language.with_raw_response.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + language = await response.parse() + assert_matches_type(Optional[Caption], language, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.stream.captions.language.with_streaming_response.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + language = await response.parse() + assert_matches_type(Optional[Caption], language, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): + await async_client.stream.captions.language.with_raw_response.get( + "tr", + account_id="", + identifier="ea95132c15732412d22c1476fa83f27a", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): + await async_client.stream.captions.language.with_raw_response.get( + "tr", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `language` but received ''"): + await async_client.stream.captions.language.with_raw_response.get( + "", + account_id="023e105f4ecef8ad9ca31a8372d0c353", + identifier="ea95132c15732412d22c1476fa83f27a", + ) diff --git a/tests/api_resources/stream/test_captions.py b/tests/api_resources/stream/test_captions.py index ddcc3b051ce..b2466c27733 100644 --- a/tests/api_resources/stream/test_captions.py +++ b/tests/api_resources/stream/test_captions.py @@ -9,10 +9,7 @@ from cloudflare import Cloudflare, AsyncCloudflare from tests.utils import assert_matches_type -from cloudflare.types.stream import ( - Caption, - CaptionGetResponse, -) +from cloudflare.types.stream import CaptionGetResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -20,146 +17,6 @@ class TestCaptions: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() - @parametrize - def test_method_update(self, client: Cloudflare) -> None: - caption = client.stream.captions.update( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - file="@/Users/kyle/Desktop/tr.vtt", - ) - assert_matches_type(Optional[Caption], caption, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_raw_response_update(self, client: Cloudflare) -> None: - response = client.stream.captions.with_raw_response.update( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - file="@/Users/kyle/Desktop/tr.vtt", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - caption = response.parse() - assert_matches_type(Optional[Caption], caption, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_streaming_response_update(self, client: Cloudflare) -> None: - with client.stream.captions.with_streaming_response.update( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - file="@/Users/kyle/Desktop/tr.vtt", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - caption = response.parse() - assert_matches_type(Optional[Caption], caption, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - def test_path_params_update(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.stream.captions.with_raw_response.update( - "tr", - account_id="", - identifier="ea95132c15732412d22c1476fa83f27a", - file="@/Users/kyle/Desktop/tr.vtt", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - client.stream.captions.with_raw_response.update( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="", - file="@/Users/kyle/Desktop/tr.vtt", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `language` but received ''"): - client.stream.captions.with_raw_response.update( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - file="@/Users/kyle/Desktop/tr.vtt", - ) - - @pytest.mark.skip() - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - caption = client.stream.captions.delete( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - body={}, - ) - assert_matches_type(str, caption, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.stream.captions.with_raw_response.delete( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - body={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - caption = response.parse() - assert_matches_type(str, caption, path=["response"]) - - @pytest.mark.skip() - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.stream.captions.with_streaming_response.delete( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - caption = response.parse() - assert_matches_type(str, caption, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.stream.captions.with_raw_response.delete( - "tr", - account_id="", - identifier="ea95132c15732412d22c1476fa83f27a", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - client.stream.captions.with_raw_response.delete( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `language` but received ''"): - client.stream.captions.with_raw_response.delete( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - body={}, - ) - @pytest.mark.skip() @parametrize def test_method_get(self, client: Cloudflare) -> None: @@ -216,146 +73,6 @@ def test_path_params_get(self, client: Cloudflare) -> None: class TestAsyncCaptions: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() - @parametrize - async def test_method_update(self, async_client: AsyncCloudflare) -> None: - caption = await async_client.stream.captions.update( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - file="@/Users/kyle/Desktop/tr.vtt", - ) - assert_matches_type(Optional[Caption], caption, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: - response = await async_client.stream.captions.with_raw_response.update( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - file="@/Users/kyle/Desktop/tr.vtt", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - caption = await response.parse() - assert_matches_type(Optional[Caption], caption, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: - async with async_client.stream.captions.with_streaming_response.update( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - file="@/Users/kyle/Desktop/tr.vtt", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - caption = await response.parse() - assert_matches_type(Optional[Caption], caption, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.stream.captions.with_raw_response.update( - "tr", - account_id="", - identifier="ea95132c15732412d22c1476fa83f27a", - file="@/Users/kyle/Desktop/tr.vtt", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - await async_client.stream.captions.with_raw_response.update( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="", - file="@/Users/kyle/Desktop/tr.vtt", - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `language` but received ''"): - await async_client.stream.captions.with_raw_response.update( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - file="@/Users/kyle/Desktop/tr.vtt", - ) - - @pytest.mark.skip() - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - caption = await async_client.stream.captions.delete( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - body={}, - ) - assert_matches_type(str, caption, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.stream.captions.with_raw_response.delete( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - body={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - caption = await response.parse() - assert_matches_type(str, caption, path=["response"]) - - @pytest.mark.skip() - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.stream.captions.with_streaming_response.delete( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - body={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - caption = await response.parse() - assert_matches_type(str, caption, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @pytest.mark.skip() - @parametrize - async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.stream.captions.with_raw_response.delete( - "tr", - account_id="", - identifier="ea95132c15732412d22c1476fa83f27a", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `identifier` but received ''"): - await async_client.stream.captions.with_raw_response.delete( - "tr", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="", - body={}, - ) - - with pytest.raises(ValueError, match=r"Expected a non-empty value for `language` but received ''"): - await async_client.stream.captions.with_raw_response.delete( - "", - account_id="023e105f4ecef8ad9ca31a8372d0c353", - identifier="ea95132c15732412d22c1476fa83f27a", - body={}, - ) - @pytest.mark.skip() @parametrize async def test_method_get(self, async_client: AsyncCloudflare) -> None: diff --git a/tests/api_resources/zero_trust/risk_scoring/__init__.py b/tests/api_resources/zero_trust/risk_scoring/__init__.py new file mode 100644 index 00000000000..fd8019a9a1a --- /dev/null +++ b/tests/api_resources/zero_trust/risk_scoring/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/zero_trust/risk_scoring/test_behaviours.py b/tests/api_resources/zero_trust/risk_scoring/test_behaviours.py new file mode 100644 index 00000000000..274bc9a39d4 --- /dev/null +++ b/tests/api_resources/zero_trust/risk_scoring/test_behaviours.py @@ -0,0 +1,221 @@ +# 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.zero_trust.risk_scoring import ( + BehaviourGetResponse, + BehaviourUpdateResponse, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestBehaviours: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_update(self, client: Cloudflare) -> None: + behaviour = client.zero_trust.risk_scoring.behaviours.update( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(BehaviourUpdateResponse, behaviour, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_update_with_all_params(self, client: Cloudflare) -> None: + behaviour = client.zero_trust.risk_scoring.behaviours.update( + "023e105f4ecef8ad9ca31a8372d0c353", + behaviors={ + "foo": { + "enabled": True, + "risk_level": "low", + } + }, + ) + assert_matches_type(BehaviourUpdateResponse, behaviour, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_update(self, client: Cloudflare) -> None: + response = client.zero_trust.risk_scoring.behaviours.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + behaviour = response.parse() + assert_matches_type(BehaviourUpdateResponse, behaviour, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_update(self, client: Cloudflare) -> None: + with client.zero_trust.risk_scoring.behaviours.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + behaviour = response.parse() + assert_matches_type(BehaviourUpdateResponse, behaviour, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_update(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_identifier` but received ''"): + client.zero_trust.risk_scoring.behaviours.with_raw_response.update( + "", + ) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + behaviour = client.zero_trust.risk_scoring.behaviours.get( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(BehaviourGetResponse, behaviour, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.risk_scoring.behaviours.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + behaviour = response.parse() + assert_matches_type(BehaviourGetResponse, behaviour, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.risk_scoring.behaviours.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + behaviour = response.parse() + assert_matches_type(BehaviourGetResponse, behaviour, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_identifier` but received ''"): + client.zero_trust.risk_scoring.behaviours.with_raw_response.get( + "", + ) + + +class TestAsyncBehaviours: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_update(self, async_client: AsyncCloudflare) -> None: + behaviour = await async_client.zero_trust.risk_scoring.behaviours.update( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(BehaviourUpdateResponse, behaviour, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncCloudflare) -> None: + behaviour = await async_client.zero_trust.risk_scoring.behaviours.update( + "023e105f4ecef8ad9ca31a8372d0c353", + behaviors={ + "foo": { + "enabled": True, + "risk_level": "low", + } + }, + ) + assert_matches_type(BehaviourUpdateResponse, behaviour, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_update(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.risk_scoring.behaviours.with_raw_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + behaviour = await response.parse() + assert_matches_type(BehaviourUpdateResponse, behaviour, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_update(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.risk_scoring.behaviours.with_streaming_response.update( + "023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + behaviour = await response.parse() + assert_matches_type(BehaviourUpdateResponse, behaviour, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_update(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_identifier` but received ''"): + await async_client.zero_trust.risk_scoring.behaviours.with_raw_response.update( + "", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + behaviour = await async_client.zero_trust.risk_scoring.behaviours.get( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(BehaviourGetResponse, behaviour, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.risk_scoring.behaviours.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + behaviour = await response.parse() + assert_matches_type(BehaviourGetResponse, behaviour, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.risk_scoring.behaviours.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + behaviour = await response.parse() + assert_matches_type(BehaviourGetResponse, behaviour, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_identifier` but received ''"): + await async_client.zero_trust.risk_scoring.behaviours.with_raw_response.get( + "", + ) diff --git a/tests/api_resources/zero_trust/risk_scoring/test_summary.py b/tests/api_resources/zero_trust/risk_scoring/test_summary.py new file mode 100644 index 00000000000..37e56ed2449 --- /dev/null +++ b/tests/api_resources/zero_trust/risk_scoring/test_summary.py @@ -0,0 +1,130 @@ +# 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.zero_trust.risk_scoring import SummaryGetResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSummary: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + summary = client.zero_trust.risk_scoring.summary.get( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SummaryGetResponse, summary, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + summary = client.zero_trust.risk_scoring.summary.get( + "023e105f4ecef8ad9ca31a8372d0c353", + direction="desc", + order_by="timestamp", + page=0, + per_page=0, + ) + assert_matches_type(SummaryGetResponse, summary, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.risk_scoring.summary.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + summary = response.parse() + assert_matches_type(SummaryGetResponse, summary, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.risk_scoring.summary.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + summary = response.parse() + assert_matches_type(SummaryGetResponse, summary, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_identifier` but received ''"): + client.zero_trust.risk_scoring.summary.with_raw_response.get( + "", + ) + + +class TestAsyncSummary: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + summary = await async_client.zero_trust.risk_scoring.summary.get( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(SummaryGetResponse, summary, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + summary = await async_client.zero_trust.risk_scoring.summary.get( + "023e105f4ecef8ad9ca31a8372d0c353", + direction="desc", + order_by="timestamp", + page=0, + per_page=0, + ) + assert_matches_type(SummaryGetResponse, summary, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.risk_scoring.summary.with_raw_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + summary = await response.parse() + assert_matches_type(SummaryGetResponse, summary, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.risk_scoring.summary.with_streaming_response.get( + "023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + summary = await response.parse() + assert_matches_type(SummaryGetResponse, summary, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_identifier` but received ''"): + await async_client.zero_trust.risk_scoring.summary.with_raw_response.get( + "", + ) diff --git a/tests/api_resources/zero_trust/test_risk_scoring.py b/tests/api_resources/zero_trust/test_risk_scoring.py new file mode 100644 index 00000000000..a6b124a3dc7 --- /dev/null +++ b/tests/api_resources/zero_trust/test_risk_scoring.py @@ -0,0 +1,256 @@ +# 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.zero_trust import RiskScoringGetResponse, RiskScoringResetResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestRiskScoring: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + def test_method_get(self, client: Cloudflare) -> None: + risk_scoring = client.zero_trust.risk_scoring.get( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RiskScoringGetResponse, risk_scoring, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_method_get_with_all_params(self, client: Cloudflare) -> None: + risk_scoring = client.zero_trust.risk_scoring.get( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + direction="desc", + order_by="timestamp", + page=0, + per_page=0, + ) + assert_matches_type(RiskScoringGetResponse, risk_scoring, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_get(self, client: Cloudflare) -> None: + response = client.zero_trust.risk_scoring.with_raw_response.get( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + risk_scoring = response.parse() + assert_matches_type(RiskScoringGetResponse, risk_scoring, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_get(self, client: Cloudflare) -> None: + with client.zero_trust.risk_scoring.with_streaming_response.get( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + risk_scoring = response.parse() + assert_matches_type(RiskScoringGetResponse, risk_scoring, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_get(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_identifier` but received ''"): + client.zero_trust.risk_scoring.with_raw_response.get( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + client.zero_trust.risk_scoring.with_raw_response.get( + "", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + def test_method_reset(self, client: Cloudflare) -> None: + risk_scoring = client.zero_trust.risk_scoring.reset( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RiskScoringResetResponse, risk_scoring, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_raw_response_reset(self, client: Cloudflare) -> None: + response = client.zero_trust.risk_scoring.with_raw_response.reset( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + risk_scoring = response.parse() + assert_matches_type(RiskScoringResetResponse, risk_scoring, path=["response"]) + + @pytest.mark.skip() + @parametrize + def test_streaming_response_reset(self, client: Cloudflare) -> None: + with client.zero_trust.risk_scoring.with_streaming_response.reset( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + risk_scoring = response.parse() + assert_matches_type(RiskScoringResetResponse, risk_scoring, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + def test_path_params_reset(self, client: Cloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_identifier` but received ''"): + client.zero_trust.risk_scoring.with_raw_response.reset( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + client.zero_trust.risk_scoring.with_raw_response.reset( + "", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + + +class TestAsyncRiskScoring: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @pytest.mark.skip() + @parametrize + async def test_method_get(self, async_client: AsyncCloudflare) -> None: + risk_scoring = await async_client.zero_trust.risk_scoring.get( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RiskScoringGetResponse, risk_scoring, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_method_get_with_all_params(self, async_client: AsyncCloudflare) -> None: + risk_scoring = await async_client.zero_trust.risk_scoring.get( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + direction="desc", + order_by="timestamp", + page=0, + per_page=0, + ) + assert_matches_type(RiskScoringGetResponse, risk_scoring, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.risk_scoring.with_raw_response.get( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + risk_scoring = await response.parse() + assert_matches_type(RiskScoringGetResponse, risk_scoring, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.risk_scoring.with_streaming_response.get( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + risk_scoring = await response.parse() + assert_matches_type(RiskScoringGetResponse, risk_scoring, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_identifier` but received ''"): + await async_client.zero_trust.risk_scoring.with_raw_response.get( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + await async_client.zero_trust.risk_scoring.with_raw_response.get( + "", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + + @pytest.mark.skip() + @parametrize + async def test_method_reset(self, async_client: AsyncCloudflare) -> None: + risk_scoring = await async_client.zero_trust.risk_scoring.reset( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + assert_matches_type(RiskScoringResetResponse, risk_scoring, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_raw_response_reset(self, async_client: AsyncCloudflare) -> None: + response = await async_client.zero_trust.risk_scoring.with_raw_response.reset( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + risk_scoring = await response.parse() + assert_matches_type(RiskScoringResetResponse, risk_scoring, path=["response"]) + + @pytest.mark.skip() + @parametrize + async def test_streaming_response_reset(self, async_client: AsyncCloudflare) -> None: + async with async_client.zero_trust.risk_scoring.with_streaming_response.reset( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + risk_scoring = await response.parse() + assert_matches_type(RiskScoringResetResponse, risk_scoring, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @pytest.mark.skip() + @parametrize + async def test_path_params_reset(self, async_client: AsyncCloudflare) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_identifier` but received ''"): + await async_client.zero_trust.risk_scoring.with_raw_response.reset( + "f2108713-1206-4e84-8b80-0e71a6a1c67b", + account_identifier="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `user_id` but received ''"): + await async_client.zero_trust.risk_scoring.with_raw_response.reset( + "", + account_identifier="023e105f4ecef8ad9ca31a8372d0c353", + )