|
| 1 | +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from typing_extensions import Literal |
| 6 | + |
| 7 | +import httpx |
| 8 | + |
| 9 | +from ..types import feedback_submit_params |
| 10 | +from .._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given |
| 11 | +from .._utils import maybe_transform, async_maybe_transform |
| 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.feedback_submit_response import FeedbackSubmitResponse |
| 22 | + |
| 23 | +__all__ = ["FeedbackResource", "AsyncFeedbackResource"] |
| 24 | + |
| 25 | + |
| 26 | +class FeedbackResource(SyncAPIResource): |
| 27 | + """Report bugs, docs mismatches, and friction with any Context.dev API. |
| 28 | +
|
| 29 | + Submissions cost no credits and use a separate rate limit. |
| 30 | + """ |
| 31 | + |
| 32 | + @cached_property |
| 33 | + def with_raw_response(self) -> FeedbackResourceWithRawResponse: |
| 34 | + """ |
| 35 | + This property can be used as a prefix for any HTTP method call to return |
| 36 | + the raw response object instead of the parsed content. |
| 37 | +
|
| 38 | + For more information, see https://www.github.com/context-dot-dev/context-python-sdk#accessing-raw-response-data-eg-headers |
| 39 | + """ |
| 40 | + return FeedbackResourceWithRawResponse(self) |
| 41 | + |
| 42 | + @cached_property |
| 43 | + def with_streaming_response(self) -> FeedbackResourceWithStreamingResponse: |
| 44 | + """ |
| 45 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 46 | +
|
| 47 | + For more information, see https://www.github.com/context-dot-dev/context-python-sdk#with_streaming_response |
| 48 | + """ |
| 49 | + return FeedbackResourceWithStreamingResponse(self) |
| 50 | + |
| 51 | + def submit( |
| 52 | + self, |
| 53 | + *, |
| 54 | + category: Literal["bug", "docs_mismatch", "friction", "feature_gap", "quality_degradation", "other"], |
| 55 | + note: str, |
| 56 | + request_id: str | Omit = omit, |
| 57 | + tags: SequenceNotStr[str] | Omit = omit, |
| 58 | + url: str | Omit = omit, |
| 59 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 60 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 61 | + extra_headers: Headers | None = None, |
| 62 | + extra_query: Query | None = None, |
| 63 | + extra_body: Body | None = None, |
| 64 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 65 | + ) -> FeedbackSubmitResponse: |
| 66 | + """Report a problem with a Context.dev API call, docs page, SDK, or CLI. |
| 67 | +
|
| 68 | + Include |
| 69 | + request_id, url, or both. |
| 70 | +
|
| 71 | + Args: |
| 72 | + category: Kind of issue. |
| 73 | +
|
| 74 | + note: What went wrong and what you expected instead. |
| 75 | +
|
| 76 | + request_id: The request_id of the API call the feedback is about, from its response body or |
| 77 | + X-Request-Id header. |
| 78 | +
|
| 79 | + tags: Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters. |
| 80 | +
|
| 81 | + url: The page the feedback is about, such as one page of a crawl or a docs page. |
| 82 | +
|
| 83 | + extra_headers: Send extra headers |
| 84 | +
|
| 85 | + extra_query: Add additional query parameters to the request |
| 86 | +
|
| 87 | + extra_body: Add additional JSON properties to the request |
| 88 | +
|
| 89 | + timeout: Override the client-level default timeout for this request, in seconds |
| 90 | + """ |
| 91 | + return self._post( |
| 92 | + "/feedback", |
| 93 | + body=maybe_transform( |
| 94 | + { |
| 95 | + "category": category, |
| 96 | + "note": note, |
| 97 | + "request_id": request_id, |
| 98 | + "tags": tags, |
| 99 | + "url": url, |
| 100 | + }, |
| 101 | + feedback_submit_params.FeedbackSubmitParams, |
| 102 | + ), |
| 103 | + options=make_request_options( |
| 104 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 105 | + ), |
| 106 | + cast_to=FeedbackSubmitResponse, |
| 107 | + ) |
| 108 | + |
| 109 | + |
| 110 | +class AsyncFeedbackResource(AsyncAPIResource): |
| 111 | + """Report bugs, docs mismatches, and friction with any Context.dev API. |
| 112 | +
|
| 113 | + Submissions cost no credits and use a separate rate limit. |
| 114 | + """ |
| 115 | + |
| 116 | + @cached_property |
| 117 | + def with_raw_response(self) -> AsyncFeedbackResourceWithRawResponse: |
| 118 | + """ |
| 119 | + This property can be used as a prefix for any HTTP method call to return |
| 120 | + the raw response object instead of the parsed content. |
| 121 | +
|
| 122 | + For more information, see https://www.github.com/context-dot-dev/context-python-sdk#accessing-raw-response-data-eg-headers |
| 123 | + """ |
| 124 | + return AsyncFeedbackResourceWithRawResponse(self) |
| 125 | + |
| 126 | + @cached_property |
| 127 | + def with_streaming_response(self) -> AsyncFeedbackResourceWithStreamingResponse: |
| 128 | + """ |
| 129 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 130 | +
|
| 131 | + For more information, see https://www.github.com/context-dot-dev/context-python-sdk#with_streaming_response |
| 132 | + """ |
| 133 | + return AsyncFeedbackResourceWithStreamingResponse(self) |
| 134 | + |
| 135 | + async def submit( |
| 136 | + self, |
| 137 | + *, |
| 138 | + category: Literal["bug", "docs_mismatch", "friction", "feature_gap", "quality_degradation", "other"], |
| 139 | + note: str, |
| 140 | + request_id: str | Omit = omit, |
| 141 | + tags: SequenceNotStr[str] | Omit = omit, |
| 142 | + url: str | Omit = omit, |
| 143 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 144 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 145 | + extra_headers: Headers | None = None, |
| 146 | + extra_query: Query | None = None, |
| 147 | + extra_body: Body | None = None, |
| 148 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 149 | + ) -> FeedbackSubmitResponse: |
| 150 | + """Report a problem with a Context.dev API call, docs page, SDK, or CLI. |
| 151 | +
|
| 152 | + Include |
| 153 | + request_id, url, or both. |
| 154 | +
|
| 155 | + Args: |
| 156 | + category: Kind of issue. |
| 157 | +
|
| 158 | + note: What went wrong and what you expected instead. |
| 159 | +
|
| 160 | + request_id: The request_id of the API call the feedback is about, from its response body or |
| 161 | + X-Request-Id header. |
| 162 | +
|
| 163 | + tags: Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters. |
| 164 | +
|
| 165 | + url: The page the feedback is about, such as one page of a crawl or a docs page. |
| 166 | +
|
| 167 | + extra_headers: Send extra headers |
| 168 | +
|
| 169 | + extra_query: Add additional query parameters to the request |
| 170 | +
|
| 171 | + extra_body: Add additional JSON properties to the request |
| 172 | +
|
| 173 | + timeout: Override the client-level default timeout for this request, in seconds |
| 174 | + """ |
| 175 | + return await self._post( |
| 176 | + "/feedback", |
| 177 | + body=await async_maybe_transform( |
| 178 | + { |
| 179 | + "category": category, |
| 180 | + "note": note, |
| 181 | + "request_id": request_id, |
| 182 | + "tags": tags, |
| 183 | + "url": url, |
| 184 | + }, |
| 185 | + feedback_submit_params.FeedbackSubmitParams, |
| 186 | + ), |
| 187 | + options=make_request_options( |
| 188 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 189 | + ), |
| 190 | + cast_to=FeedbackSubmitResponse, |
| 191 | + ) |
| 192 | + |
| 193 | + |
| 194 | +class FeedbackResourceWithRawResponse: |
| 195 | + def __init__(self, feedback: FeedbackResource) -> None: |
| 196 | + self._feedback = feedback |
| 197 | + |
| 198 | + self.submit = to_raw_response_wrapper( |
| 199 | + feedback.submit, |
| 200 | + ) |
| 201 | + |
| 202 | + |
| 203 | +class AsyncFeedbackResourceWithRawResponse: |
| 204 | + def __init__(self, feedback: AsyncFeedbackResource) -> None: |
| 205 | + self._feedback = feedback |
| 206 | + |
| 207 | + self.submit = async_to_raw_response_wrapper( |
| 208 | + feedback.submit, |
| 209 | + ) |
| 210 | + |
| 211 | + |
| 212 | +class FeedbackResourceWithStreamingResponse: |
| 213 | + def __init__(self, feedback: FeedbackResource) -> None: |
| 214 | + self._feedback = feedback |
| 215 | + |
| 216 | + self.submit = to_streamed_response_wrapper( |
| 217 | + feedback.submit, |
| 218 | + ) |
| 219 | + |
| 220 | + |
| 221 | +class AsyncFeedbackResourceWithStreamingResponse: |
| 222 | + def __init__(self, feedback: AsyncFeedbackResource) -> None: |
| 223 | + self._feedback = feedback |
| 224 | + |
| 225 | + self.submit = async_to_streamed_response_wrapper( |
| 226 | + feedback.submit, |
| 227 | + ) |
0 commit comments