1# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2
  3from __future__ import annotations
  4
  5import httpx
  6
  7from .... import _legacy_response
  8from ...._types import Body, Query, Headers, NotGiven, not_given
  9from ...._compat import cached_property
 10from ...._resource import SyncAPIResource, AsyncAPIResource
 11from ...._response import (
 12    StreamedBinaryAPIResponse,
 13    AsyncStreamedBinaryAPIResponse,
 14    to_custom_streamed_response_wrapper,
 15    async_to_custom_streamed_response_wrapper,
 16)
 17from ...._base_client import make_request_options
 18
 19__all__ = ["Content", "AsyncContent"]
 20
 21
 22class Content(SyncAPIResource):
 23    @cached_property
 24    def with_raw_response(self) -> ContentWithRawResponse:
 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/openai/openai-python#accessing-raw-response-data-eg-headers
 30        """
 31        return ContentWithRawResponse(self)
 32
 33    @cached_property
 34    def with_streaming_response(self) -> ContentWithStreamingResponse:
 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/openai/openai-python#with_streaming_response
 39        """
 40        return ContentWithStreamingResponse(self)
 41
 42    def retrieve(
 43        self,
 44        file_id: str,
 45        *,
 46        container_id: str,
 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    ) -> _legacy_response.HttpxBinaryResponseContent:
 54        """
 55        Retrieve Container File Content
 56
 57        Args:
 58          extra_headers: Send extra headers
 59
 60          extra_query: Add additional query parameters to the request
 61
 62          extra_body: Add additional JSON properties to the request
 63
 64          timeout: Override the client-level default timeout for this request, in seconds
 65        """
 66        if not container_id:
 67            raise ValueError(f"Expected a non-empty value for `container_id` but received {container_id!r}")
 68        if not file_id:
 69            raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
 70        extra_headers = {"Accept": "application/binary", **(extra_headers or {})}
 71        return self._get(
 72            f"/containers/{container_id}/files/{file_id}/content",
 73            options=make_request_options(
 74                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
 75            ),
 76            cast_to=_legacy_response.HttpxBinaryResponseContent,
 77        )
 78
 79
 80class AsyncContent(AsyncAPIResource):
 81    @cached_property
 82    def with_raw_response(self) -> AsyncContentWithRawResponse:
 83        """
 84        This property can be used as a prefix for any HTTP method call to return
 85        the raw response object instead of the parsed content.
 86
 87        For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
 88        """
 89        return AsyncContentWithRawResponse(self)
 90
 91    @cached_property
 92    def with_streaming_response(self) -> AsyncContentWithStreamingResponse:
 93        """
 94        An alternative to `.with_raw_response` that doesn't eagerly read the response body.
 95
 96        For more information, see https://www.github.com/openai/openai-python#with_streaming_response
 97        """
 98        return AsyncContentWithStreamingResponse(self)
 99
100    async def retrieve(
101        self,
102        file_id: str,
103        *,
104        container_id: str,
105        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
106        # The extra values given here take precedence over values defined on the client or passed to this method.
107        extra_headers: Headers | None = None,
108        extra_query: Query | None = None,
109        extra_body: Body | None = None,
110        timeout: float | httpx.Timeout | None | NotGiven = not_given,
111    ) -> _legacy_response.HttpxBinaryResponseContent:
112        """
113        Retrieve Container File Content
114
115        Args:
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 container_id:
125            raise ValueError(f"Expected a non-empty value for `container_id` but received {container_id!r}")
126        if not file_id:
127            raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
128        extra_headers = {"Accept": "application/binary", **(extra_headers or {})}
129        return await self._get(
130            f"/containers/{container_id}/files/{file_id}/content",
131            options=make_request_options(
132                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
133            ),
134            cast_to=_legacy_response.HttpxBinaryResponseContent,
135        )
136
137
138class ContentWithRawResponse:
139    def __init__(self, content: Content) -> None:
140        self._content = content
141
142        self.retrieve = _legacy_response.to_raw_response_wrapper(
143            content.retrieve,
144        )
145
146
147class AsyncContentWithRawResponse:
148    def __init__(self, content: AsyncContent) -> None:
149        self._content = content
150
151        self.retrieve = _legacy_response.async_to_raw_response_wrapper(
152            content.retrieve,
153        )
154
155
156class ContentWithStreamingResponse:
157    def __init__(self, content: Content) -> None:
158        self._content = content
159
160        self.retrieve = to_custom_streamed_response_wrapper(
161            content.retrieve,
162            StreamedBinaryAPIResponse,
163        )
164
165
166class AsyncContentWithStreamingResponse:
167    def __init__(self, content: AsyncContent) -> None:
168        self._content = content
169
170        self.retrieve = async_to_custom_streamed_response_wrapper(
171            content.retrieve,
172            AsyncStreamedBinaryAPIResponse,
173        )