ibee 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ibee/__init__.py +157 -0
- ibee/_default_clients.py +32 -0
- ibee/client.py +290 -0
- ibee/cloud_vms/__init__.py +34 -0
- ibee/cloud_vms/client.py +1473 -0
- ibee/cloud_vms/raw_client.py +2679 -0
- ibee/cloud_vms/types/__init__.py +34 -0
- ibee/cloud_vms/types/create_cloud_vm_request_os_type.py +5 -0
- ibee/core/__init__.py +127 -0
- ibee/core/api_error.py +23 -0
- ibee/core/client_wrapper.py +144 -0
- ibee/core/datetime_utils.py +70 -0
- ibee/core/file.py +67 -0
- ibee/core/force_multipart.py +18 -0
- ibee/core/http_client.py +843 -0
- ibee/core/http_response.py +59 -0
- ibee/core/http_sse/__init__.py +42 -0
- ibee/core/http_sse/_api.py +180 -0
- ibee/core/http_sse/_decoders.py +61 -0
- ibee/core/http_sse/_exceptions.py +7 -0
- ibee/core/http_sse/_models.py +17 -0
- ibee/core/jsonable_encoder.py +120 -0
- ibee/core/logging.py +107 -0
- ibee/core/parse_error.py +36 -0
- ibee/core/pydantic_utilities.py +508 -0
- ibee/core/query_encoder.py +58 -0
- ibee/core/remove_none_from_dict.py +11 -0
- ibee/core/request_options.py +37 -0
- ibee/core/serialization.py +347 -0
- ibee/environment.py +7 -0
- ibee/errors/__init__.py +44 -0
- ibee/errors/bad_request_error.py +11 -0
- ibee/errors/conflict_error.py +11 -0
- ibee/errors/forbidden_error.py +11 -0
- ibee/errors/not_found_error.py +11 -0
- ibee/errors/unauthorized_error.py +11 -0
- ibee/gpu_vms/__init__.py +34 -0
- ibee/gpu_vms/client.py +1408 -0
- ibee/gpu_vms/raw_client.py +2534 -0
- ibee/gpu_vms/types/__init__.py +34 -0
- ibee/gpu_vms/types/create_gpu_vm_request_os_type.py +5 -0
- ibee/object_storage/__init__.py +4 -0
- ibee/object_storage/client.py +341 -0
- ibee/object_storage/raw_client.py +556 -0
- ibee/secret_store/__init__.py +4 -0
- ibee/secret_store/client.py +1143 -0
- ibee/secret_store/raw_client.py +2096 -0
- ibee/tests/conftest.py +21 -0
- ibee/tests/test_aiohttp_autodetect.py +113 -0
- ibee/types/__init__.py +116 -0
- ibee/types/attach_network_request.py +22 -0
- ibee/types/bucket.py +23 -0
- ibee/types/bucket_list.py +22 -0
- ibee/types/bucket_summary.py +21 -0
- ibee/types/cloud_vm.py +34 -0
- ibee/types/cloud_vm_status.py +7 -0
- ibee/types/delete_response.py +19 -0
- ibee/types/error.py +20 -0
- ibee/types/error_detail.py +5 -0
- ibee/types/gpu_vm.py +36 -0
- ibee/types/gpu_vm_status.py +7 -0
- ibee/types/network_interface.py +26 -0
- ibee/types/network_interface_status.py +5 -0
- ibee/types/operation_accepted.py +23 -0
- ibee/types/operation_status.py +30 -0
- ibee/types/operation_status_action.py +7 -0
- ibee/types/operation_status_status.py +5 -0
- ibee/types/power_action_request.py +22 -0
- ibee/types/secret.py +29 -0
- ibee/types/secret_list.py +23 -0
- ibee/types/secret_status.py +5 -0
- ibee/types/secret_store.py +33 -0
- ibee/types/secret_store_list.py +23 -0
- ibee/types/secret_store_status.py +5 -0
- ibee/types/secret_value.py +26 -0
- ibee/types/update_vm_request.py +27 -0
- ibee/types/vm_metrics.py +26 -0
- ibee-0.1.0.dist-info/METADATA +110 -0
- ibee-0.1.0.dist-info/RECORD +82 -0
- ibee-0.1.0.dist-info/WHEEL +5 -0
- ibee-0.1.0.dist-info/licenses/LICENSE +21 -0
- ibee-0.1.0.dist-info/top_level.txt +1 -0
ibee/__init__.py
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
# isort: skip_file
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
from importlib import import_module
|
|
7
|
+
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from .types import (
|
|
10
|
+
AttachNetworkRequest,
|
|
11
|
+
Bucket,
|
|
12
|
+
BucketList,
|
|
13
|
+
BucketSummary,
|
|
14
|
+
CloudVm,
|
|
15
|
+
CloudVmStatus,
|
|
16
|
+
DeleteResponse,
|
|
17
|
+
Error,
|
|
18
|
+
ErrorDetail,
|
|
19
|
+
GpuVm,
|
|
20
|
+
GpuVmStatus,
|
|
21
|
+
NetworkInterface,
|
|
22
|
+
NetworkInterfaceStatus,
|
|
23
|
+
OperationAccepted,
|
|
24
|
+
OperationStatus,
|
|
25
|
+
OperationStatusAction,
|
|
26
|
+
OperationStatusStatus,
|
|
27
|
+
PowerActionRequest,
|
|
28
|
+
Secret,
|
|
29
|
+
SecretList,
|
|
30
|
+
SecretStatus,
|
|
31
|
+
SecretStore,
|
|
32
|
+
SecretStoreList,
|
|
33
|
+
SecretStoreStatus,
|
|
34
|
+
SecretValue,
|
|
35
|
+
UpdateVmRequest,
|
|
36
|
+
VmMetrics,
|
|
37
|
+
)
|
|
38
|
+
from .errors import BadRequestError, ConflictError, ForbiddenError, NotFoundError, UnauthorizedError
|
|
39
|
+
from . import cloud_vms, gpu_vms, object_storage, secret_store
|
|
40
|
+
from ._default_clients import DefaultAioHttpClient, DefaultAsyncHttpxClient
|
|
41
|
+
from .client import AsyncIbee, Ibee
|
|
42
|
+
from .cloud_vms import CreateCloudVmRequestOsType
|
|
43
|
+
from .environment import IbeeEnvironment
|
|
44
|
+
from .gpu_vms import CreateGpuVmRequestOsType
|
|
45
|
+
_dynamic_imports: typing.Dict[str, str] = {
|
|
46
|
+
"AsyncIbee": ".client",
|
|
47
|
+
"AttachNetworkRequest": ".types",
|
|
48
|
+
"BadRequestError": ".errors",
|
|
49
|
+
"Bucket": ".types",
|
|
50
|
+
"BucketList": ".types",
|
|
51
|
+
"BucketSummary": ".types",
|
|
52
|
+
"CloudVm": ".types",
|
|
53
|
+
"CloudVmStatus": ".types",
|
|
54
|
+
"ConflictError": ".errors",
|
|
55
|
+
"CreateCloudVmRequestOsType": ".cloud_vms",
|
|
56
|
+
"CreateGpuVmRequestOsType": ".gpu_vms",
|
|
57
|
+
"DefaultAioHttpClient": "._default_clients",
|
|
58
|
+
"DefaultAsyncHttpxClient": "._default_clients",
|
|
59
|
+
"DeleteResponse": ".types",
|
|
60
|
+
"Error": ".types",
|
|
61
|
+
"ErrorDetail": ".types",
|
|
62
|
+
"ForbiddenError": ".errors",
|
|
63
|
+
"GpuVm": ".types",
|
|
64
|
+
"GpuVmStatus": ".types",
|
|
65
|
+
"Ibee": ".client",
|
|
66
|
+
"IbeeEnvironment": ".environment",
|
|
67
|
+
"NetworkInterface": ".types",
|
|
68
|
+
"NetworkInterfaceStatus": ".types",
|
|
69
|
+
"NotFoundError": ".errors",
|
|
70
|
+
"OperationAccepted": ".types",
|
|
71
|
+
"OperationStatus": ".types",
|
|
72
|
+
"OperationStatusAction": ".types",
|
|
73
|
+
"OperationStatusStatus": ".types",
|
|
74
|
+
"PowerActionRequest": ".types",
|
|
75
|
+
"Secret": ".types",
|
|
76
|
+
"SecretList": ".types",
|
|
77
|
+
"SecretStatus": ".types",
|
|
78
|
+
"SecretStore": ".types",
|
|
79
|
+
"SecretStoreList": ".types",
|
|
80
|
+
"SecretStoreStatus": ".types",
|
|
81
|
+
"SecretValue": ".types",
|
|
82
|
+
"UnauthorizedError": ".errors",
|
|
83
|
+
"UpdateVmRequest": ".types",
|
|
84
|
+
"VmMetrics": ".types",
|
|
85
|
+
"cloud_vms": ".cloud_vms",
|
|
86
|
+
"gpu_vms": ".gpu_vms",
|
|
87
|
+
"object_storage": ".object_storage",
|
|
88
|
+
"secret_store": ".secret_store",
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def __getattr__(attr_name: str) -> typing.Any:
|
|
93
|
+
module_name = _dynamic_imports.get(attr_name)
|
|
94
|
+
if module_name is None:
|
|
95
|
+
raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
|
|
96
|
+
try:
|
|
97
|
+
module = import_module(module_name, __package__)
|
|
98
|
+
if module_name == f".{attr_name}":
|
|
99
|
+
return module
|
|
100
|
+
else:
|
|
101
|
+
return getattr(module, attr_name)
|
|
102
|
+
except ImportError as e:
|
|
103
|
+
raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
|
|
104
|
+
except AttributeError as e:
|
|
105
|
+
raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def __dir__():
|
|
109
|
+
lazy_attrs = list(_dynamic_imports.keys())
|
|
110
|
+
return sorted(lazy_attrs)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
__all__ = [
|
|
114
|
+
"AsyncIbee",
|
|
115
|
+
"AttachNetworkRequest",
|
|
116
|
+
"BadRequestError",
|
|
117
|
+
"Bucket",
|
|
118
|
+
"BucketList",
|
|
119
|
+
"BucketSummary",
|
|
120
|
+
"CloudVm",
|
|
121
|
+
"CloudVmStatus",
|
|
122
|
+
"ConflictError",
|
|
123
|
+
"CreateCloudVmRequestOsType",
|
|
124
|
+
"CreateGpuVmRequestOsType",
|
|
125
|
+
"DefaultAioHttpClient",
|
|
126
|
+
"DefaultAsyncHttpxClient",
|
|
127
|
+
"DeleteResponse",
|
|
128
|
+
"Error",
|
|
129
|
+
"ErrorDetail",
|
|
130
|
+
"ForbiddenError",
|
|
131
|
+
"GpuVm",
|
|
132
|
+
"GpuVmStatus",
|
|
133
|
+
"Ibee",
|
|
134
|
+
"IbeeEnvironment",
|
|
135
|
+
"NetworkInterface",
|
|
136
|
+
"NetworkInterfaceStatus",
|
|
137
|
+
"NotFoundError",
|
|
138
|
+
"OperationAccepted",
|
|
139
|
+
"OperationStatus",
|
|
140
|
+
"OperationStatusAction",
|
|
141
|
+
"OperationStatusStatus",
|
|
142
|
+
"PowerActionRequest",
|
|
143
|
+
"Secret",
|
|
144
|
+
"SecretList",
|
|
145
|
+
"SecretStatus",
|
|
146
|
+
"SecretStore",
|
|
147
|
+
"SecretStoreList",
|
|
148
|
+
"SecretStoreStatus",
|
|
149
|
+
"SecretValue",
|
|
150
|
+
"UnauthorizedError",
|
|
151
|
+
"UpdateVmRequest",
|
|
152
|
+
"VmMetrics",
|
|
153
|
+
"cloud_vms",
|
|
154
|
+
"gpu_vms",
|
|
155
|
+
"object_storage",
|
|
156
|
+
"secret_store",
|
|
157
|
+
]
|
ibee/_default_clients.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
SDK_DEFAULT_TIMEOUT = 60
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
import httpx_aiohttp # type: ignore[import-not-found]
|
|
11
|
+
except ImportError:
|
|
12
|
+
|
|
13
|
+
class DefaultAioHttpClient(httpx.AsyncClient): # type: ignore
|
|
14
|
+
def __init__(self, **kwargs: typing.Any) -> None:
|
|
15
|
+
raise RuntimeError(
|
|
16
|
+
"To use the aiohttp client, install the aiohttp extra: pip install ibee[aiohttp]"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
else:
|
|
20
|
+
|
|
21
|
+
class DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
|
|
22
|
+
def __init__(self, **kwargs: typing.Any) -> None:
|
|
23
|
+
kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
|
|
24
|
+
kwargs.setdefault("follow_redirects", True)
|
|
25
|
+
super().__init__(**kwargs)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class DefaultAsyncHttpxClient(httpx.AsyncClient):
|
|
29
|
+
def __init__(self, **kwargs: typing.Any) -> None:
|
|
30
|
+
kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
|
|
31
|
+
kwargs.setdefault("follow_redirects", True)
|
|
32
|
+
super().__init__(**kwargs)
|
ibee/client.py
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
9
|
+
from .core.logging import LogConfig, Logger
|
|
10
|
+
from .environment import IbeeEnvironment
|
|
11
|
+
|
|
12
|
+
if typing.TYPE_CHECKING:
|
|
13
|
+
from .cloud_vms.client import AsyncCloudVmsClient, CloudVmsClient
|
|
14
|
+
from .gpu_vms.client import AsyncGpuVmsClient, GpuVmsClient
|
|
15
|
+
from .object_storage.client import AsyncObjectStorageClient, ObjectStorageClient
|
|
16
|
+
from .secret_store.client import AsyncSecretStoreClient, SecretStoreClient
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Ibee:
|
|
20
|
+
"""
|
|
21
|
+
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
22
|
+
|
|
23
|
+
Parameters
|
|
24
|
+
----------
|
|
25
|
+
base_url : typing.Optional[str]
|
|
26
|
+
The base url to use for requests from the client.
|
|
27
|
+
|
|
28
|
+
environment : IbeeEnvironment
|
|
29
|
+
The environment to use for requests from the client. from .environment import IbeeEnvironment
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
Defaults to IbeeEnvironment.DEFAULT
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
token : typing.Union[str, typing.Callable[[], str]]
|
|
38
|
+
headers : typing.Optional[typing.Dict[str, str]]
|
|
39
|
+
Additional headers to send with every request.
|
|
40
|
+
|
|
41
|
+
timeout : typing.Optional[float]
|
|
42
|
+
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
43
|
+
|
|
44
|
+
max_retries : typing.Optional[int]
|
|
45
|
+
The default maximum number of retries for failed requests. Defaults to 2. Per-request `max_retries` in `request_options` takes precedence over this value.
|
|
46
|
+
|
|
47
|
+
stream_reconnection_enabled : typing.Optional[bool]
|
|
48
|
+
Whether to automatically reconnect on stream disconnection for resumable streaming endpoints. Defaults to True. Per-request `stream_reconnection_enabled` in `request_options` takes precedence over this value.
|
|
49
|
+
|
|
50
|
+
max_stream_reconnection_attempts : typing.Optional[int]
|
|
51
|
+
The maximum number of reconnection attempts for resumable streaming endpoints. Defaults to no limit. Per-request `max_stream_reconnection_attempts` in `request_options` takes precedence over this value.
|
|
52
|
+
|
|
53
|
+
follow_redirects : typing.Optional[bool]
|
|
54
|
+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
55
|
+
|
|
56
|
+
httpx_client : typing.Optional[httpx.Client]
|
|
57
|
+
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
|
58
|
+
|
|
59
|
+
logging : typing.Optional[typing.Union[LogConfig, Logger]]
|
|
60
|
+
Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
|
|
61
|
+
|
|
62
|
+
Examples
|
|
63
|
+
--------
|
|
64
|
+
from ibee import Ibee
|
|
65
|
+
|
|
66
|
+
client = Ibee(
|
|
67
|
+
token="YOUR_TOKEN",
|
|
68
|
+
)
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
def __init__(
|
|
72
|
+
self,
|
|
73
|
+
*,
|
|
74
|
+
base_url: typing.Optional[str] = None,
|
|
75
|
+
environment: IbeeEnvironment = IbeeEnvironment.DEFAULT,
|
|
76
|
+
token: typing.Union[str, typing.Callable[[], str]],
|
|
77
|
+
headers: typing.Optional[typing.Dict[str, str]] = None,
|
|
78
|
+
timeout: typing.Optional[float] = None,
|
|
79
|
+
max_retries: typing.Optional[int] = None,
|
|
80
|
+
stream_reconnection_enabled: typing.Optional[bool] = None,
|
|
81
|
+
max_stream_reconnection_attempts: typing.Optional[int] = None,
|
|
82
|
+
follow_redirects: typing.Optional[bool] = True,
|
|
83
|
+
httpx_client: typing.Optional[httpx.Client] = None,
|
|
84
|
+
logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
|
|
85
|
+
):
|
|
86
|
+
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
|
|
87
|
+
_defaulted_max_retries = max_retries if max_retries is not None else 2
|
|
88
|
+
self._client_wrapper = SyncClientWrapper(
|
|
89
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
90
|
+
token=token,
|
|
91
|
+
headers=headers,
|
|
92
|
+
httpx_client=httpx_client
|
|
93
|
+
if httpx_client is not None
|
|
94
|
+
else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
|
|
95
|
+
if follow_redirects is not None
|
|
96
|
+
else httpx.Client(timeout=_defaulted_timeout),
|
|
97
|
+
timeout=_defaulted_timeout,
|
|
98
|
+
max_retries=_defaulted_max_retries,
|
|
99
|
+
stream_reconnection_enabled=stream_reconnection_enabled,
|
|
100
|
+
max_stream_reconnection_attempts=max_stream_reconnection_attempts,
|
|
101
|
+
logging=logging,
|
|
102
|
+
)
|
|
103
|
+
self._secret_store: typing.Optional[SecretStoreClient] = None
|
|
104
|
+
self._object_storage: typing.Optional[ObjectStorageClient] = None
|
|
105
|
+
self._cloud_vms: typing.Optional[CloudVmsClient] = None
|
|
106
|
+
self._gpu_vms: typing.Optional[GpuVmsClient] = None
|
|
107
|
+
|
|
108
|
+
@property
|
|
109
|
+
def secret_store(self):
|
|
110
|
+
if self._secret_store is None:
|
|
111
|
+
from .secret_store.client import SecretStoreClient # noqa: E402
|
|
112
|
+
|
|
113
|
+
self._secret_store = SecretStoreClient(client_wrapper=self._client_wrapper)
|
|
114
|
+
return self._secret_store
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def object_storage(self):
|
|
118
|
+
if self._object_storage is None:
|
|
119
|
+
from .object_storage.client import ObjectStorageClient # noqa: E402
|
|
120
|
+
|
|
121
|
+
self._object_storage = ObjectStorageClient(client_wrapper=self._client_wrapper)
|
|
122
|
+
return self._object_storage
|
|
123
|
+
|
|
124
|
+
@property
|
|
125
|
+
def cloud_vms(self):
|
|
126
|
+
if self._cloud_vms is None:
|
|
127
|
+
from .cloud_vms.client import CloudVmsClient # noqa: E402
|
|
128
|
+
|
|
129
|
+
self._cloud_vms = CloudVmsClient(client_wrapper=self._client_wrapper)
|
|
130
|
+
return self._cloud_vms
|
|
131
|
+
|
|
132
|
+
@property
|
|
133
|
+
def gpu_vms(self):
|
|
134
|
+
if self._gpu_vms is None:
|
|
135
|
+
from .gpu_vms.client import GpuVmsClient # noqa: E402
|
|
136
|
+
|
|
137
|
+
self._gpu_vms = GpuVmsClient(client_wrapper=self._client_wrapper)
|
|
138
|
+
return self._gpu_vms
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def _make_default_async_client(
|
|
142
|
+
timeout: typing.Optional[float],
|
|
143
|
+
follow_redirects: typing.Optional[bool],
|
|
144
|
+
) -> httpx.AsyncClient:
|
|
145
|
+
try:
|
|
146
|
+
import httpx_aiohttp # type: ignore[import-not-found]
|
|
147
|
+
except ImportError:
|
|
148
|
+
pass
|
|
149
|
+
else:
|
|
150
|
+
if follow_redirects is not None:
|
|
151
|
+
return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout, follow_redirects=follow_redirects)
|
|
152
|
+
return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout)
|
|
153
|
+
|
|
154
|
+
if follow_redirects is not None:
|
|
155
|
+
return httpx.AsyncClient(timeout=timeout, follow_redirects=follow_redirects)
|
|
156
|
+
return httpx.AsyncClient(timeout=timeout)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class AsyncIbee:
|
|
160
|
+
"""
|
|
161
|
+
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
162
|
+
|
|
163
|
+
Parameters
|
|
164
|
+
----------
|
|
165
|
+
base_url : typing.Optional[str]
|
|
166
|
+
The base url to use for requests from the client.
|
|
167
|
+
|
|
168
|
+
environment : IbeeEnvironment
|
|
169
|
+
The environment to use for requests from the client. from .environment import IbeeEnvironment
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
Defaults to IbeeEnvironment.DEFAULT
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
token : typing.Union[str, typing.Callable[[], str]]
|
|
178
|
+
headers : typing.Optional[typing.Dict[str, str]]
|
|
179
|
+
Additional headers to send with every request.
|
|
180
|
+
|
|
181
|
+
async_token : typing.Optional[typing.Callable[[], typing.Awaitable[str]]]
|
|
182
|
+
An async callable that returns a bearer token. Use this when token acquisition involves async I/O (e.g., refreshing tokens via an async HTTP client). When provided, this is used instead of the synchronous token for async requests.
|
|
183
|
+
|
|
184
|
+
timeout : typing.Optional[float]
|
|
185
|
+
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
186
|
+
|
|
187
|
+
max_retries : typing.Optional[int]
|
|
188
|
+
The default maximum number of retries for failed requests. Defaults to 2. Per-request `max_retries` in `request_options` takes precedence over this value.
|
|
189
|
+
|
|
190
|
+
stream_reconnection_enabled : typing.Optional[bool]
|
|
191
|
+
Whether to automatically reconnect on stream disconnection for resumable streaming endpoints. Defaults to True. Per-request `stream_reconnection_enabled` in `request_options` takes precedence over this value.
|
|
192
|
+
|
|
193
|
+
max_stream_reconnection_attempts : typing.Optional[int]
|
|
194
|
+
The maximum number of reconnection attempts for resumable streaming endpoints. Defaults to no limit. Per-request `max_stream_reconnection_attempts` in `request_options` takes precedence over this value.
|
|
195
|
+
|
|
196
|
+
follow_redirects : typing.Optional[bool]
|
|
197
|
+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
198
|
+
|
|
199
|
+
httpx_client : typing.Optional[httpx.AsyncClient]
|
|
200
|
+
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
|
201
|
+
|
|
202
|
+
logging : typing.Optional[typing.Union[LogConfig, Logger]]
|
|
203
|
+
Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
|
|
204
|
+
|
|
205
|
+
Examples
|
|
206
|
+
--------
|
|
207
|
+
from ibee import AsyncIbee
|
|
208
|
+
|
|
209
|
+
client = AsyncIbee(
|
|
210
|
+
token="YOUR_TOKEN",
|
|
211
|
+
)
|
|
212
|
+
"""
|
|
213
|
+
|
|
214
|
+
def __init__(
|
|
215
|
+
self,
|
|
216
|
+
*,
|
|
217
|
+
base_url: typing.Optional[str] = None,
|
|
218
|
+
environment: IbeeEnvironment = IbeeEnvironment.DEFAULT,
|
|
219
|
+
token: typing.Union[str, typing.Callable[[], str]],
|
|
220
|
+
headers: typing.Optional[typing.Dict[str, str]] = None,
|
|
221
|
+
async_token: typing.Optional[typing.Callable[[], typing.Awaitable[str]]] = None,
|
|
222
|
+
timeout: typing.Optional[float] = None,
|
|
223
|
+
max_retries: typing.Optional[int] = None,
|
|
224
|
+
stream_reconnection_enabled: typing.Optional[bool] = None,
|
|
225
|
+
max_stream_reconnection_attempts: typing.Optional[int] = None,
|
|
226
|
+
follow_redirects: typing.Optional[bool] = True,
|
|
227
|
+
httpx_client: typing.Optional[httpx.AsyncClient] = None,
|
|
228
|
+
logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
|
|
229
|
+
):
|
|
230
|
+
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
|
|
231
|
+
_defaulted_max_retries = max_retries if max_retries is not None else 2
|
|
232
|
+
self._client_wrapper = AsyncClientWrapper(
|
|
233
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
234
|
+
token=token,
|
|
235
|
+
headers=headers,
|
|
236
|
+
async_token=async_token,
|
|
237
|
+
httpx_client=httpx_client
|
|
238
|
+
if httpx_client is not None
|
|
239
|
+
else _make_default_async_client(timeout=_defaulted_timeout, follow_redirects=follow_redirects),
|
|
240
|
+
timeout=_defaulted_timeout,
|
|
241
|
+
max_retries=_defaulted_max_retries,
|
|
242
|
+
stream_reconnection_enabled=stream_reconnection_enabled,
|
|
243
|
+
max_stream_reconnection_attempts=max_stream_reconnection_attempts,
|
|
244
|
+
logging=logging,
|
|
245
|
+
)
|
|
246
|
+
self._secret_store: typing.Optional[AsyncSecretStoreClient] = None
|
|
247
|
+
self._object_storage: typing.Optional[AsyncObjectStorageClient] = None
|
|
248
|
+
self._cloud_vms: typing.Optional[AsyncCloudVmsClient] = None
|
|
249
|
+
self._gpu_vms: typing.Optional[AsyncGpuVmsClient] = None
|
|
250
|
+
|
|
251
|
+
@property
|
|
252
|
+
def secret_store(self):
|
|
253
|
+
if self._secret_store is None:
|
|
254
|
+
from .secret_store.client import AsyncSecretStoreClient # noqa: E402
|
|
255
|
+
|
|
256
|
+
self._secret_store = AsyncSecretStoreClient(client_wrapper=self._client_wrapper)
|
|
257
|
+
return self._secret_store
|
|
258
|
+
|
|
259
|
+
@property
|
|
260
|
+
def object_storage(self):
|
|
261
|
+
if self._object_storage is None:
|
|
262
|
+
from .object_storage.client import AsyncObjectStorageClient # noqa: E402
|
|
263
|
+
|
|
264
|
+
self._object_storage = AsyncObjectStorageClient(client_wrapper=self._client_wrapper)
|
|
265
|
+
return self._object_storage
|
|
266
|
+
|
|
267
|
+
@property
|
|
268
|
+
def cloud_vms(self):
|
|
269
|
+
if self._cloud_vms is None:
|
|
270
|
+
from .cloud_vms.client import AsyncCloudVmsClient # noqa: E402
|
|
271
|
+
|
|
272
|
+
self._cloud_vms = AsyncCloudVmsClient(client_wrapper=self._client_wrapper)
|
|
273
|
+
return self._cloud_vms
|
|
274
|
+
|
|
275
|
+
@property
|
|
276
|
+
def gpu_vms(self):
|
|
277
|
+
if self._gpu_vms is None:
|
|
278
|
+
from .gpu_vms.client import AsyncGpuVmsClient # noqa: E402
|
|
279
|
+
|
|
280
|
+
self._gpu_vms = AsyncGpuVmsClient(client_wrapper=self._client_wrapper)
|
|
281
|
+
return self._gpu_vms
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
def _get_base_url(*, base_url: typing.Optional[str] = None, environment: IbeeEnvironment) -> str:
|
|
285
|
+
if base_url is not None:
|
|
286
|
+
return base_url
|
|
287
|
+
elif environment is not None:
|
|
288
|
+
return environment.value
|
|
289
|
+
else:
|
|
290
|
+
raise Exception("Please pass in either base_url or environment to construct the client")
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
# isort: skip_file
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
from importlib import import_module
|
|
7
|
+
|
|
8
|
+
if typing.TYPE_CHECKING:
|
|
9
|
+
from .types import CreateCloudVmRequestOsType
|
|
10
|
+
_dynamic_imports: typing.Dict[str, str] = {"CreateCloudVmRequestOsType": ".types"}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def __getattr__(attr_name: str) -> typing.Any:
|
|
14
|
+
module_name = _dynamic_imports.get(attr_name)
|
|
15
|
+
if module_name is None:
|
|
16
|
+
raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
|
|
17
|
+
try:
|
|
18
|
+
module = import_module(module_name, __package__)
|
|
19
|
+
if module_name == f".{attr_name}":
|
|
20
|
+
return module
|
|
21
|
+
else:
|
|
22
|
+
return getattr(module, attr_name)
|
|
23
|
+
except ImportError as e:
|
|
24
|
+
raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
|
|
25
|
+
except AttributeError as e:
|
|
26
|
+
raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def __dir__():
|
|
30
|
+
lazy_attrs = list(_dynamic_imports.keys())
|
|
31
|
+
return sorted(lazy_attrs)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
__all__ = ["CreateCloudVmRequestOsType"]
|