|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +import httpx |
| 6 | + |
| 7 | +from ....._types import NOT_GIVEN, Body, Query, Headers, NotGiven |
| 8 | +from ....._compat import cached_property |
| 9 | +from ....._resource import SyncAPIResource, AsyncAPIResource |
| 10 | +from ....._response import ( |
| 11 | + to_raw_response_wrapper, |
| 12 | + to_streamed_response_wrapper, |
| 13 | + async_to_raw_response_wrapper, |
| 14 | + async_to_streamed_response_wrapper, |
| 15 | +) |
| 16 | +from ....._base_client import make_request_options |
| 17 | +from .....types.cloudforce_one.threat_events.datasets.health_get_response import HealthGetResponse |
| 18 | + |
| 19 | +__all__ = ["HealthResource", "AsyncHealthResource"] |
| 20 | + |
| 21 | + |
| 22 | +class HealthResource(SyncAPIResource): |
| 23 | + @cached_property |
| 24 | + def with_raw_response(self) -> HealthResourceWithRawResponse: |
| 25 | + """ |
| 26 | + This property can be used as a prefix for any HTTP method call to return |
| 27 | + the raw response object instead of the parsed content. |
| 28 | +
|
| 29 | + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers |
| 30 | + """ |
| 31 | + return HealthResourceWithRawResponse(self) |
| 32 | + |
| 33 | + @cached_property |
| 34 | + def with_streaming_response(self) -> HealthResourceWithStreamingResponse: |
| 35 | + """ |
| 36 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 37 | +
|
| 38 | + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response |
| 39 | + """ |
| 40 | + return HealthResourceWithStreamingResponse(self) |
| 41 | + |
| 42 | + def get( |
| 43 | + self, |
| 44 | + dataset_id: str, |
| 45 | + *, |
| 46 | + account_id: float, |
| 47 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 48 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 49 | + extra_headers: Headers | None = None, |
| 50 | + extra_query: Query | None = None, |
| 51 | + extra_body: Body | None = None, |
| 52 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 53 | + ) -> HealthGetResponse: |
| 54 | + """ |
| 55 | + Benchmark Durable Object warmup |
| 56 | +
|
| 57 | + Args: |
| 58 | + account_id: Account ID. |
| 59 | +
|
| 60 | + dataset_id: Dataset ID. |
| 61 | +
|
| 62 | + extra_headers: Send extra headers |
| 63 | +
|
| 64 | + extra_query: Add additional query parameters to the request |
| 65 | +
|
| 66 | + extra_body: Add additional JSON properties to the request |
| 67 | +
|
| 68 | + timeout: Override the client-level default timeout for this request, in seconds |
| 69 | + """ |
| 70 | + if not dataset_id: |
| 71 | + raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") |
| 72 | + return self._get( |
| 73 | + f"/accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}/health", |
| 74 | + options=make_request_options( |
| 75 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 76 | + ), |
| 77 | + cast_to=HealthGetResponse, |
| 78 | + ) |
| 79 | + |
| 80 | + |
| 81 | +class AsyncHealthResource(AsyncAPIResource): |
| 82 | + @cached_property |
| 83 | + def with_raw_response(self) -> AsyncHealthResourceWithRawResponse: |
| 84 | + """ |
| 85 | + This property can be used as a prefix for any HTTP method call to return |
| 86 | + the raw response object instead of the parsed content. |
| 87 | +
|
| 88 | + For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers |
| 89 | + """ |
| 90 | + return AsyncHealthResourceWithRawResponse(self) |
| 91 | + |
| 92 | + @cached_property |
| 93 | + def with_streaming_response(self) -> AsyncHealthResourceWithStreamingResponse: |
| 94 | + """ |
| 95 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 96 | +
|
| 97 | + For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response |
| 98 | + """ |
| 99 | + return AsyncHealthResourceWithStreamingResponse(self) |
| 100 | + |
| 101 | + async def get( |
| 102 | + self, |
| 103 | + dataset_id: str, |
| 104 | + *, |
| 105 | + account_id: float, |
| 106 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 107 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 108 | + extra_headers: Headers | None = None, |
| 109 | + extra_query: Query | None = None, |
| 110 | + extra_body: Body | None = None, |
| 111 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 112 | + ) -> HealthGetResponse: |
| 113 | + """ |
| 114 | + Benchmark Durable Object warmup |
| 115 | +
|
| 116 | + Args: |
| 117 | + account_id: Account ID. |
| 118 | +
|
| 119 | + dataset_id: Dataset ID. |
| 120 | +
|
| 121 | + extra_headers: Send extra headers |
| 122 | +
|
| 123 | + extra_query: Add additional query parameters to the request |
| 124 | +
|
| 125 | + extra_body: Add additional JSON properties to the request |
| 126 | +
|
| 127 | + timeout: Override the client-level default timeout for this request, in seconds |
| 128 | + """ |
| 129 | + if not dataset_id: |
| 130 | + raise ValueError(f"Expected a non-empty value for `dataset_id` but received {dataset_id!r}") |
| 131 | + return await self._get( |
| 132 | + f"/accounts/{account_id}/cloudforce-one/events/dataset/{dataset_id}/health", |
| 133 | + options=make_request_options( |
| 134 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 135 | + ), |
| 136 | + cast_to=HealthGetResponse, |
| 137 | + ) |
| 138 | + |
| 139 | + |
| 140 | +class HealthResourceWithRawResponse: |
| 141 | + def __init__(self, health: HealthResource) -> None: |
| 142 | + self._health = health |
| 143 | + |
| 144 | + self.get = to_raw_response_wrapper( |
| 145 | + health.get, |
| 146 | + ) |
| 147 | + |
| 148 | + |
| 149 | +class AsyncHealthResourceWithRawResponse: |
| 150 | + def __init__(self, health: AsyncHealthResource) -> None: |
| 151 | + self._health = health |
| 152 | + |
| 153 | + self.get = async_to_raw_response_wrapper( |
| 154 | + health.get, |
| 155 | + ) |
| 156 | + |
| 157 | + |
| 158 | +class HealthResourceWithStreamingResponse: |
| 159 | + def __init__(self, health: HealthResource) -> None: |
| 160 | + self._health = health |
| 161 | + |
| 162 | + self.get = to_streamed_response_wrapper( |
| 163 | + health.get, |
| 164 | + ) |
| 165 | + |
| 166 | + |
| 167 | +class AsyncHealthResourceWithStreamingResponse: |
| 168 | + def __init__(self, health: AsyncHealthResource) -> None: |
| 169 | + self._health = health |
| 170 | + |
| 171 | + self.get = async_to_streamed_response_wrapper( |
| 172 | + health.get, |
| 173 | + ) |
0 commit comments