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