-
Notifications
You must be signed in to change notification settings - Fork 17
Document response classes #175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ | |
| ] | ||
|
|
||
| pygments_style = "sphinx" | ||
| pygments_dark_style = "monokai" | ||
|
|
||
| templates_path = [] | ||
| exclude_patterns = [] | ||
|
|
@@ -44,5 +45,5 @@ | |
|
|
||
| intersphinx_mapping = { | ||
| "python": ("https://docs.python.org/3", None), | ||
| "requests": ("https://docs.python-requests.org/en/master", None), | ||
| "requests": ("https://docs.python-requests.org/en/latest", None), | ||
|
Comment on lines
-47
to
+48
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a redirection in place, but |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ API Reference | |
|
|
||
| installation | ||
| nodes | ||
| responses | ||
| exceptions | ||
| logging | ||
| transport | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| Responses | ||
| ========= | ||
|
|
||
| .. py:currentmodule:: elastic_transport | ||
|
|
||
|
|
||
| Response headers | ||
| ---------------- | ||
|
|
||
| .. autoclass:: elastic_transport::HttpHeaders | ||
| :members: freeze | ||
|
|
||
| Metadata | ||
| -------- | ||
|
|
||
| .. autoclass:: ApiResponseMeta | ||
| :members: | ||
|
|
||
| Response classes | ||
| ---------------- | ||
|
|
||
| .. autoclass:: ApiResponse | ||
| :members: | ||
|
|
||
| .. autoclass:: BinaryApiResponse | ||
| :members: | ||
| :show-inheritance: | ||
|
|
||
| .. autoclass:: HeadApiResponse | ||
| :members: | ||
| :show-inheritance: | ||
|
|
||
| .. autoclass:: ListApiResponse | ||
| :members: | ||
| :show-inheritance: | ||
|
|
||
| .. autoclass:: ObjectApiResponse | ||
| :members: | ||
| :show-inheritance: | ||
|
|
||
| .. autoclass:: TextApiResponse | ||
| :members: | ||
| :show-inheritance: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,7 +68,15 @@ def __str__(self) -> str: | |
|
|
||
|
|
||
| class HttpHeaders(MutableMapping[str, str]): | ||
| """HTTP headers""" | ||
| """HTTP headers | ||
|
|
||
| Behaves like a Python dictionary. Can be used like this:: | ||
|
|
||
| headers = HttpHeaders() | ||
| headers["foo"] = "bar" | ||
| headers["foo"] = "baz" | ||
| print(headers["foo"]) # prints "baz" | ||
| """ | ||
|
|
||
| __slots__ = ("_internal", "_frozen") | ||
|
|
||
|
|
@@ -180,26 +188,24 @@ def hide_auth(val: str) -> str: | |
|
|
||
| @dataclass | ||
| class ApiResponseMeta: | ||
| """Metadata that is returned from Transport.perform_request()""" | ||
| """Metadata that is returned from Transport.perform_request() | ||
|
|
||
| :ivar int status: HTTP status code | ||
| :ivar str http_version: HTTP version being used | ||
| :ivar HttpHeaders headers: HTTP headers | ||
| :ivar float duration: Number of seconds from start of request to start of response | ||
| :ivar NodeConfig node: Node which handled the request | ||
| :ivar typing.Optional[str] mimetype: Mimetype to be used by the serializer to decode the raw response bytes. | ||
|
Comment on lines
+193
to
+198
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't able to get Sphinx to show the |
||
| """ | ||
|
|
||
| #: HTTP status code | ||
| status: int | ||
|
|
||
| #: HTTP version being used | ||
| http_version: str | ||
|
|
||
| #: HTTP headers | ||
| headers: HttpHeaders | ||
|
|
||
| #: Number of seconds from start of request to start of response | ||
| duration: float | ||
|
|
||
| #: Node which handled the request | ||
| node: "NodeConfig" | ||
|
|
||
| @property | ||
| def mimetype(self) -> Optional[str]: | ||
| """Mimetype to be used by the serializer to decode the raw response bytes.""" | ||
| try: | ||
| content_type = self.headers["content-type"] | ||
| return content_type.partition(";")[0] or None | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required to make sure code blocks such as the one in HttpHeaders are visible in dark mode.