-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.py
More file actions
357 lines (278 loc) · 12.6 KB
/
client.py
File metadata and controls
357 lines (278 loc) · 12.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# This file was auto-generated by Fern from our API Definition.
from __future__ import annotations
import typing
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from .raw_client import AsyncRawInternalClient, RawInternalClient
if typing.TYPE_CHECKING:
from .ai_gateway.client import AiGatewayClient, AsyncAiGatewayClient
from .applications.client import ApplicationsClient, AsyncApplicationsClient
from .artifact_versions.client import ArtifactVersionsClient, AsyncArtifactVersionsClient
from .build_logs.client import AsyncBuildLogsClient, BuildLogsClient
from .clusters.client import AsyncClustersClient, ClustersClient
from .deployments.client import AsyncDeploymentsClient, DeploymentsClient
from .docker_registries.client import AsyncDockerRegistriesClient, DockerRegistriesClient
from .metrics.client import AsyncMetricsClient, MetricsClient
from .ml.client import AsyncMlClient, MlClient
from .users.client import AsyncUsersClient, UsersClient
from .vcs.client import AsyncVcsClient, VcsClient
from .workflows.client import AsyncWorkflowsClient, WorkflowsClient
class InternalClient:
def __init__(self, *, client_wrapper: SyncClientWrapper):
self._raw_client = RawInternalClient(client_wrapper=client_wrapper)
self._client_wrapper = client_wrapper
self._users: typing.Optional[UsersClient] = None
self._ai_gateway: typing.Optional[AiGatewayClient] = None
self._clusters: typing.Optional[ClustersClient] = None
self._deployments: typing.Optional[DeploymentsClient] = None
self._applications: typing.Optional[ApplicationsClient] = None
self._metrics: typing.Optional[MetricsClient] = None
self._vcs: typing.Optional[VcsClient] = None
self._docker_registries: typing.Optional[DockerRegistriesClient] = None
self._workflows: typing.Optional[WorkflowsClient] = None
self._build_logs: typing.Optional[BuildLogsClient] = None
self._artifact_versions: typing.Optional[ArtifactVersionsClient] = None
self._ml: typing.Optional[MlClient] = None
@property
def with_raw_response(self) -> RawInternalClient:
"""
Retrieves a raw implementation of this client that returns raw responses.
Returns
-------
RawInternalClient
"""
return self._raw_client
def get_id_from_fqn(
self, type: str, *, fqn: str, request_options: typing.Optional[RequestOptions] = None
) -> typing.Dict[str, typing.Any]:
"""
Get IDs associated with the FQN for various entity types, such as deployment, application, workspace, or cluster.
Parameters
----------
type : str
Entity Type
fqn : str
Entity FQN
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
typing.Dict[str, typing.Any]
Returns the IDs for the specified entity type based on the provided FQN. For example, deploymentId, applicationId, and workspaceId for type deployment, or applicationId and workspaceId for type app.
Examples
--------
from truefoundry_sdk import TrueFoundry
client = TrueFoundry(
api_key="YOUR_API_KEY",
base_url="https://yourhost.com/path/to/api",
)
client.internal.get_id_from_fqn(
type="type",
fqn="fqn",
)
"""
_response = self._raw_client.get_id_from_fqn(type, fqn=fqn, request_options=request_options)
return _response.data
@property
def users(self):
if self._users is None:
from .users.client import UsersClient # noqa: E402
self._users = UsersClient(client_wrapper=self._client_wrapper)
return self._users
@property
def ai_gateway(self):
if self._ai_gateway is None:
from .ai_gateway.client import AiGatewayClient # noqa: E402
self._ai_gateway = AiGatewayClient(client_wrapper=self._client_wrapper)
return self._ai_gateway
@property
def clusters(self):
if self._clusters is None:
from .clusters.client import ClustersClient # noqa: E402
self._clusters = ClustersClient(client_wrapper=self._client_wrapper)
return self._clusters
@property
def deployments(self):
if self._deployments is None:
from .deployments.client import DeploymentsClient # noqa: E402
self._deployments = DeploymentsClient(client_wrapper=self._client_wrapper)
return self._deployments
@property
def applications(self):
if self._applications is None:
from .applications.client import ApplicationsClient # noqa: E402
self._applications = ApplicationsClient(client_wrapper=self._client_wrapper)
return self._applications
@property
def metrics(self):
if self._metrics is None:
from .metrics.client import MetricsClient # noqa: E402
self._metrics = MetricsClient(client_wrapper=self._client_wrapper)
return self._metrics
@property
def vcs(self):
if self._vcs is None:
from .vcs.client import VcsClient # noqa: E402
self._vcs = VcsClient(client_wrapper=self._client_wrapper)
return self._vcs
@property
def docker_registries(self):
if self._docker_registries is None:
from .docker_registries.client import DockerRegistriesClient # noqa: E402
self._docker_registries = DockerRegistriesClient(client_wrapper=self._client_wrapper)
return self._docker_registries
@property
def workflows(self):
if self._workflows is None:
from .workflows.client import WorkflowsClient # noqa: E402
self._workflows = WorkflowsClient(client_wrapper=self._client_wrapper)
return self._workflows
@property
def build_logs(self):
if self._build_logs is None:
from .build_logs.client import BuildLogsClient # noqa: E402
self._build_logs = BuildLogsClient(client_wrapper=self._client_wrapper)
return self._build_logs
@property
def artifact_versions(self):
if self._artifact_versions is None:
from .artifact_versions.client import ArtifactVersionsClient # noqa: E402
self._artifact_versions = ArtifactVersionsClient(client_wrapper=self._client_wrapper)
return self._artifact_versions
@property
def ml(self):
if self._ml is None:
from .ml.client import MlClient # noqa: E402
self._ml = MlClient(client_wrapper=self._client_wrapper)
return self._ml
class AsyncInternalClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper):
self._raw_client = AsyncRawInternalClient(client_wrapper=client_wrapper)
self._client_wrapper = client_wrapper
self._users: typing.Optional[AsyncUsersClient] = None
self._ai_gateway: typing.Optional[AsyncAiGatewayClient] = None
self._clusters: typing.Optional[AsyncClustersClient] = None
self._deployments: typing.Optional[AsyncDeploymentsClient] = None
self._applications: typing.Optional[AsyncApplicationsClient] = None
self._metrics: typing.Optional[AsyncMetricsClient] = None
self._vcs: typing.Optional[AsyncVcsClient] = None
self._docker_registries: typing.Optional[AsyncDockerRegistriesClient] = None
self._workflows: typing.Optional[AsyncWorkflowsClient] = None
self._build_logs: typing.Optional[AsyncBuildLogsClient] = None
self._artifact_versions: typing.Optional[AsyncArtifactVersionsClient] = None
self._ml: typing.Optional[AsyncMlClient] = None
@property
def with_raw_response(self) -> AsyncRawInternalClient:
"""
Retrieves a raw implementation of this client that returns raw responses.
Returns
-------
AsyncRawInternalClient
"""
return self._raw_client
async def get_id_from_fqn(
self, type: str, *, fqn: str, request_options: typing.Optional[RequestOptions] = None
) -> typing.Dict[str, typing.Any]:
"""
Get IDs associated with the FQN for various entity types, such as deployment, application, workspace, or cluster.
Parameters
----------
type : str
Entity Type
fqn : str
Entity FQN
request_options : typing.Optional[RequestOptions]
Request-specific configuration.
Returns
-------
typing.Dict[str, typing.Any]
Returns the IDs for the specified entity type based on the provided FQN. For example, deploymentId, applicationId, and workspaceId for type deployment, or applicationId and workspaceId for type app.
Examples
--------
import asyncio
from truefoundry_sdk import AsyncTrueFoundry
client = AsyncTrueFoundry(
api_key="YOUR_API_KEY",
base_url="https://yourhost.com/path/to/api",
)
async def main() -> None:
await client.internal.get_id_from_fqn(
type="type",
fqn="fqn",
)
asyncio.run(main())
"""
_response = await self._raw_client.get_id_from_fqn(type, fqn=fqn, request_options=request_options)
return _response.data
@property
def users(self):
if self._users is None:
from .users.client import AsyncUsersClient # noqa: E402
self._users = AsyncUsersClient(client_wrapper=self._client_wrapper)
return self._users
@property
def ai_gateway(self):
if self._ai_gateway is None:
from .ai_gateway.client import AsyncAiGatewayClient # noqa: E402
self._ai_gateway = AsyncAiGatewayClient(client_wrapper=self._client_wrapper)
return self._ai_gateway
@property
def clusters(self):
if self._clusters is None:
from .clusters.client import AsyncClustersClient # noqa: E402
self._clusters = AsyncClustersClient(client_wrapper=self._client_wrapper)
return self._clusters
@property
def deployments(self):
if self._deployments is None:
from .deployments.client import AsyncDeploymentsClient # noqa: E402
self._deployments = AsyncDeploymentsClient(client_wrapper=self._client_wrapper)
return self._deployments
@property
def applications(self):
if self._applications is None:
from .applications.client import AsyncApplicationsClient # noqa: E402
self._applications = AsyncApplicationsClient(client_wrapper=self._client_wrapper)
return self._applications
@property
def metrics(self):
if self._metrics is None:
from .metrics.client import AsyncMetricsClient # noqa: E402
self._metrics = AsyncMetricsClient(client_wrapper=self._client_wrapper)
return self._metrics
@property
def vcs(self):
if self._vcs is None:
from .vcs.client import AsyncVcsClient # noqa: E402
self._vcs = AsyncVcsClient(client_wrapper=self._client_wrapper)
return self._vcs
@property
def docker_registries(self):
if self._docker_registries is None:
from .docker_registries.client import AsyncDockerRegistriesClient # noqa: E402
self._docker_registries = AsyncDockerRegistriesClient(client_wrapper=self._client_wrapper)
return self._docker_registries
@property
def workflows(self):
if self._workflows is None:
from .workflows.client import AsyncWorkflowsClient # noqa: E402
self._workflows = AsyncWorkflowsClient(client_wrapper=self._client_wrapper)
return self._workflows
@property
def build_logs(self):
if self._build_logs is None:
from .build_logs.client import AsyncBuildLogsClient # noqa: E402
self._build_logs = AsyncBuildLogsClient(client_wrapper=self._client_wrapper)
return self._build_logs
@property
def artifact_versions(self):
if self._artifact_versions is None:
from .artifact_versions.client import AsyncArtifactVersionsClient # noqa: E402
self._artifact_versions = AsyncArtifactVersionsClient(client_wrapper=self._client_wrapper)
return self._artifact_versions
@property
def ml(self):
if self._ml is None:
from .ml.client import AsyncMlClient # noqa: E402
self._ml = AsyncMlClient(client_wrapper=self._client_wrapper)
return self._ml