|
| 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 Body, Query, Headers, NotGiven, not_given |
| 8 | +from .._compat import cached_property |
| 9 | +from .._resource import SyncAPIResource, AsyncAPIResource |
| 10 | +from .._response import ( |
| 11 | + to_raw_response_wrapper, |
| 12 | + to_streamed_response_wrapper, |
| 13 | + async_to_raw_response_wrapper, |
| 14 | + async_to_streamed_response_wrapper, |
| 15 | +) |
| 16 | +from .._base_client import make_request_options |
| 17 | +from ..types.capabilities import Capabilities |
| 18 | + |
| 19 | +__all__ = ["CapabilitiesResource", "AsyncCapabilitiesResource"] |
| 20 | + |
| 21 | + |
| 22 | +class CapabilitiesResource(SyncAPIResource): |
| 23 | + @cached_property |
| 24 | + def with_raw_response(self) -> CapabilitiesResourceWithRawResponse: |
| 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/kernel/hypeman-python#accessing-raw-response-data-eg-headers |
| 30 | + """ |
| 31 | + return CapabilitiesResourceWithRawResponse(self) |
| 32 | + |
| 33 | + @cached_property |
| 34 | + def with_streaming_response(self) -> CapabilitiesResourceWithStreamingResponse: |
| 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/kernel/hypeman-python#with_streaming_response |
| 39 | + """ |
| 40 | + return CapabilitiesResourceWithStreamingResponse(self) |
| 41 | + |
| 42 | + def get( |
| 43 | + self, |
| 44 | + *, |
| 45 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 46 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 47 | + extra_headers: Headers | None = None, |
| 48 | + extra_query: Query | None = None, |
| 49 | + extra_body: Body | None = None, |
| 50 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 51 | + ) -> Capabilities: |
| 52 | + """ |
| 53 | + Returns machine-readable host capabilities: server and API version, host |
| 54 | + OS/architecture, every runtime available on this host with its per-runtime |
| 55 | + feature IDs, the configured default runtime and whether it is available, guest |
| 56 | + networking model and host gateway, supported image platforms, and stable |
| 57 | + server-level feature IDs. |
| 58 | +
|
| 59 | + Runtime-derived values reflect the actual host (for example, snapshot and |
| 60 | + standby support on macOS is gated on the host OS version), so clients can gate |
| 61 | + behavior on capabilities without hard-coding hypervisor knowledge. |
| 62 | + """ |
| 63 | + return self._get( |
| 64 | + "/capabilities", |
| 65 | + options=make_request_options( |
| 66 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 67 | + ), |
| 68 | + cast_to=Capabilities, |
| 69 | + ) |
| 70 | + |
| 71 | + |
| 72 | +class AsyncCapabilitiesResource(AsyncAPIResource): |
| 73 | + @cached_property |
| 74 | + def with_raw_response(self) -> AsyncCapabilitiesResourceWithRawResponse: |
| 75 | + """ |
| 76 | + This property can be used as a prefix for any HTTP method call to return |
| 77 | + the raw response object instead of the parsed content. |
| 78 | +
|
| 79 | + For more information, see https://www.github.com/kernel/hypeman-python#accessing-raw-response-data-eg-headers |
| 80 | + """ |
| 81 | + return AsyncCapabilitiesResourceWithRawResponse(self) |
| 82 | + |
| 83 | + @cached_property |
| 84 | + def with_streaming_response(self) -> AsyncCapabilitiesResourceWithStreamingResponse: |
| 85 | + """ |
| 86 | + An alternative to `.with_raw_response` that doesn't eagerly read the response body. |
| 87 | +
|
| 88 | + For more information, see https://www.github.com/kernel/hypeman-python#with_streaming_response |
| 89 | + """ |
| 90 | + return AsyncCapabilitiesResourceWithStreamingResponse(self) |
| 91 | + |
| 92 | + async def get( |
| 93 | + self, |
| 94 | + *, |
| 95 | + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. |
| 96 | + # The extra values given here take precedence over values defined on the client or passed to this method. |
| 97 | + extra_headers: Headers | None = None, |
| 98 | + extra_query: Query | None = None, |
| 99 | + extra_body: Body | None = None, |
| 100 | + timeout: float | httpx.Timeout | None | NotGiven = not_given, |
| 101 | + ) -> Capabilities: |
| 102 | + """ |
| 103 | + Returns machine-readable host capabilities: server and API version, host |
| 104 | + OS/architecture, every runtime available on this host with its per-runtime |
| 105 | + feature IDs, the configured default runtime and whether it is available, guest |
| 106 | + networking model and host gateway, supported image platforms, and stable |
| 107 | + server-level feature IDs. |
| 108 | +
|
| 109 | + Runtime-derived values reflect the actual host (for example, snapshot and |
| 110 | + standby support on macOS is gated on the host OS version), so clients can gate |
| 111 | + behavior on capabilities without hard-coding hypervisor knowledge. |
| 112 | + """ |
| 113 | + return await self._get( |
| 114 | + "/capabilities", |
| 115 | + options=make_request_options( |
| 116 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 117 | + ), |
| 118 | + cast_to=Capabilities, |
| 119 | + ) |
| 120 | + |
| 121 | + |
| 122 | +class CapabilitiesResourceWithRawResponse: |
| 123 | + def __init__(self, capabilities: CapabilitiesResource) -> None: |
| 124 | + self._capabilities = capabilities |
| 125 | + |
| 126 | + self.get = to_raw_response_wrapper( |
| 127 | + capabilities.get, |
| 128 | + ) |
| 129 | + |
| 130 | + |
| 131 | +class AsyncCapabilitiesResourceWithRawResponse: |
| 132 | + def __init__(self, capabilities: AsyncCapabilitiesResource) -> None: |
| 133 | + self._capabilities = capabilities |
| 134 | + |
| 135 | + self.get = async_to_raw_response_wrapper( |
| 136 | + capabilities.get, |
| 137 | + ) |
| 138 | + |
| 139 | + |
| 140 | +class CapabilitiesResourceWithStreamingResponse: |
| 141 | + def __init__(self, capabilities: CapabilitiesResource) -> None: |
| 142 | + self._capabilities = capabilities |
| 143 | + |
| 144 | + self.get = to_streamed_response_wrapper( |
| 145 | + capabilities.get, |
| 146 | + ) |
| 147 | + |
| 148 | + |
| 149 | +class AsyncCapabilitiesResourceWithStreamingResponse: |
| 150 | + def __init__(self, capabilities: AsyncCapabilitiesResource) -> None: |
| 151 | + self._capabilities = capabilities |
| 152 | + |
| 153 | + self.get = async_to_streamed_response_wrapper( |
| 154 | + capabilities.get, |
| 155 | + ) |
0 commit comments