|
| 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 ..._utils import ( |
| 9 | + maybe_transform, |
| 10 | + async_maybe_transform, |
| 11 | +) |
| 12 | +from ..._compat import cached_property |
| 13 | +from ..._resource import SyncAPIResource, AsyncAPIResource |
| 14 | +from ..._response import ( |
| 15 | + to_raw_response_wrapper, |
| 16 | + to_streamed_response_wrapper, |
| 17 | + async_to_raw_response_wrapper, |
| 18 | + async_to_streamed_response_wrapper, |
| 19 | +) |
| 20 | +from ..._base_client import make_request_options |
| 21 | +from ...types.storage import presigned_url_create_params |
| 22 | +from ...types.storage.presigned_url_create_response import PresignedURLCreateResponse |
| 23 | + |
| 24 | +__all__ = ["PresignedURLResource", "AsyncPresignedURLResource"] |
| 25 | + |
| 26 | + |
| 27 | +class PresignedURLResource(SyncAPIResource): |
| 28 | + @cached_property |
| 29 | + def with_raw_response(self) -> PresignedURLResourceWithRawResponse: |
| 30 | + return PresignedURLResourceWithRawResponse(self) |
| 31 | + |
| 32 | + @cached_property |
| 33 | + def with_streaming_response(self) -> PresignedURLResourceWithStreamingResponse: |
| 34 | + return PresignedURLResourceWithStreamingResponse(self) |
| 35 | + |
| 36 | + def create( |
| 37 | + self, |
| 38 | + *, |
| 39 | + object_name: str, |
| 40 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 41 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 42 | + extra_headers: Headers | None = None, |
| 43 | + extra_query: Query | None = None, |
| 44 | + extra_body: Body | None = None, |
| 45 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 46 | + ) -> PresignedURLCreateResponse: |
| 47 | + """ |
| 48 | + Retrieve a presigned url to post storage artifacts. |
| 49 | +
|
| 50 | + Args: |
| 51 | + object_name: The name of the object. |
| 52 | +
|
| 53 | + extra_headers: Send extra headers |
| 54 | +
|
| 55 | + extra_query: Add additional query parameters to the request |
| 56 | +
|
| 57 | + extra_body: Add additional JSON properties to the request |
| 58 | +
|
| 59 | + timeout: Override the client-level default timeout for this request, in seconds |
| 60 | + """ |
| 61 | + return self._post( |
| 62 | + "/storage/presigned-url", |
| 63 | + options=make_request_options( |
| 64 | + extra_headers=extra_headers, |
| 65 | + extra_query=extra_query, |
| 66 | + extra_body=extra_body, |
| 67 | + timeout=timeout, |
| 68 | + query=maybe_transform( |
| 69 | + {"object_name": object_name}, presigned_url_create_params.PresignedURLCreateParams |
| 70 | + ), |
| 71 | + ), |
| 72 | + cast_to=PresignedURLCreateResponse, |
| 73 | + ) |
| 74 | + |
| 75 | + |
| 76 | +class AsyncPresignedURLResource(AsyncAPIResource): |
| 77 | + @cached_property |
| 78 | + def with_raw_response(self) -> AsyncPresignedURLResourceWithRawResponse: |
| 79 | + return AsyncPresignedURLResourceWithRawResponse(self) |
| 80 | + |
| 81 | + @cached_property |
| 82 | + def with_streaming_response(self) -> AsyncPresignedURLResourceWithStreamingResponse: |
| 83 | + return AsyncPresignedURLResourceWithStreamingResponse(self) |
| 84 | + |
| 85 | + async def create( |
| 86 | + self, |
| 87 | + *, |
| 88 | + object_name: str, |
| 89 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 90 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 91 | + extra_headers: Headers | None = None, |
| 92 | + extra_query: Query | None = None, |
| 93 | + extra_body: Body | None = None, |
| 94 | + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, |
| 95 | + ) -> PresignedURLCreateResponse: |
| 96 | + """ |
| 97 | + Retrieve a presigned url to post storage artifacts. |
| 98 | +
|
| 99 | + Args: |
| 100 | + object_name: The name of the object. |
| 101 | +
|
| 102 | + extra_headers: Send extra headers |
| 103 | +
|
| 104 | + extra_query: Add additional query parameters to the request |
| 105 | +
|
| 106 | + extra_body: Add additional JSON properties to the request |
| 107 | +
|
| 108 | + timeout: Override the client-level default timeout for this request, in seconds |
| 109 | + """ |
| 110 | + return await self._post( |
| 111 | + "/storage/presigned-url", |
| 112 | + options=make_request_options( |
| 113 | + extra_headers=extra_headers, |
| 114 | + extra_query=extra_query, |
| 115 | + extra_body=extra_body, |
| 116 | + timeout=timeout, |
| 117 | + query=await async_maybe_transform( |
| 118 | + {"object_name": object_name}, presigned_url_create_params.PresignedURLCreateParams |
| 119 | + ), |
| 120 | + ), |
| 121 | + cast_to=PresignedURLCreateResponse, |
| 122 | + ) |
| 123 | + |
| 124 | + |
| 125 | +class PresignedURLResourceWithRawResponse: |
| 126 | + def __init__(self, presigned_url: PresignedURLResource) -> None: |
| 127 | + self._presigned_url = presigned_url |
| 128 | + |
| 129 | + self.create = to_raw_response_wrapper( |
| 130 | + presigned_url.create, |
| 131 | + ) |
| 132 | + |
| 133 | + |
| 134 | +class AsyncPresignedURLResourceWithRawResponse: |
| 135 | + def __init__(self, presigned_url: AsyncPresignedURLResource) -> None: |
| 136 | + self._presigned_url = presigned_url |
| 137 | + |
| 138 | + self.create = async_to_raw_response_wrapper( |
| 139 | + presigned_url.create, |
| 140 | + ) |
| 141 | + |
| 142 | + |
| 143 | +class PresignedURLResourceWithStreamingResponse: |
| 144 | + def __init__(self, presigned_url: PresignedURLResource) -> None: |
| 145 | + self._presigned_url = presigned_url |
| 146 | + |
| 147 | + self.create = to_streamed_response_wrapper( |
| 148 | + presigned_url.create, |
| 149 | + ) |
| 150 | + |
| 151 | + |
| 152 | +class AsyncPresignedURLResourceWithStreamingResponse: |
| 153 | + def __init__(self, presigned_url: AsyncPresignedURLResource) -> None: |
| 154 | + self._presigned_url = presigned_url |
| 155 | + |
| 156 | + self.create = async_to_streamed_response_wrapper( |
| 157 | + presigned_url.create, |
| 158 | + ) |
0 commit comments