databricks-sdk 0.25.1__py3-none-any.whl → 0.27.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.

Potentially problematic release.


This version of databricks-sdk might be problematic. Click here for more details.

@@ -98,106 +98,190 @@ class AnthropicConfig:
98
98
 
99
99
 
100
100
  @dataclass
101
- class AppEvents:
102
- event_name: Optional[str] = None
101
+ class App:
102
+ name: str
103
+ """The name of the app. The name must contain only lowercase alphanumeric characters and hyphens
104
+ and be between 2 and 30 characters long. It must be unique within the workspace."""
103
105
 
104
- event_time: Optional[str] = None
106
+ active_deployment: Optional[AppDeployment] = None
107
+ """The active deployment of the app."""
105
108
 
106
- event_type: Optional[str] = None
109
+ create_time: Optional[str] = None
110
+ """The creation time of the app. Formatted timestamp in ISO 6801."""
107
111
 
108
- message: Optional[str] = None
112
+ creator: Optional[str] = None
113
+ """The email of the user that created the app."""
114
+
115
+ description: Optional[str] = None
116
+ """The description of the app."""
109
117
 
110
- service_name: Optional[str] = None
118
+ pending_deployment: Optional[AppDeployment] = None
119
+ """The pending deployment of the app."""
120
+
121
+ status: Optional[AppStatus] = None
122
+
123
+ update_time: Optional[str] = None
124
+ """The update time of the app. Formatted timestamp in ISO 6801."""
125
+
126
+ updater: Optional[str] = None
127
+ """The email of the user that last updated the app."""
128
+
129
+ url: Optional[str] = None
130
+ """The URL of the app once it is deployed."""
111
131
 
112
132
  def as_dict(self) -> dict:
113
- """Serializes the AppEvents into a dictionary suitable for use as a JSON request body."""
133
+ """Serializes the App into a dictionary suitable for use as a JSON request body."""
114
134
  body = {}
115
- if self.event_name is not None: body['event_name'] = self.event_name
116
- if self.event_time is not None: body['event_time'] = self.event_time
117
- if self.event_type is not None: body['event_type'] = self.event_type
118
- if self.message is not None: body['message'] = self.message
119
- if self.service_name is not None: body['service_name'] = self.service_name
135
+ if self.active_deployment: body['active_deployment'] = self.active_deployment.as_dict()
136
+ if self.create_time is not None: body['create_time'] = self.create_time
137
+ if self.creator is not None: body['creator'] = self.creator
138
+ if self.description is not None: body['description'] = self.description
139
+ if self.name is not None: body['name'] = self.name
140
+ if self.pending_deployment: body['pending_deployment'] = self.pending_deployment.as_dict()
141
+ if self.status: body['status'] = self.status.as_dict()
142
+ if self.update_time is not None: body['update_time'] = self.update_time
143
+ if self.updater is not None: body['updater'] = self.updater
144
+ if self.url is not None: body['url'] = self.url
120
145
  return body
121
146
 
122
147
  @classmethod
123
- def from_dict(cls, d: Dict[str, any]) -> AppEvents:
124
- """Deserializes the AppEvents from a dictionary."""
125
- return cls(event_name=d.get('event_name', None),
126
- event_time=d.get('event_time', None),
127
- event_type=d.get('event_type', None),
128
- message=d.get('message', None),
129
- service_name=d.get('service_name', None))
148
+ def from_dict(cls, d: Dict[str, any]) -> App:
149
+ """Deserializes the App from a dictionary."""
150
+ return cls(active_deployment=_from_dict(d, 'active_deployment', AppDeployment),
151
+ create_time=d.get('create_time', None),
152
+ creator=d.get('creator', None),
153
+ description=d.get('description', None),
154
+ name=d.get('name', None),
155
+ pending_deployment=_from_dict(d, 'pending_deployment', AppDeployment),
156
+ status=_from_dict(d, 'status', AppStatus),
157
+ update_time=d.get('update_time', None),
158
+ updater=d.get('updater', None),
159
+ url=d.get('url', None))
130
160
 
131
161
 
132
162
  @dataclass
133
- class AppManifest:
134
- dependencies: Optional[List[Any]] = None
135
- """Workspace dependencies."""
163
+ class AppDeployment:
164
+ source_code_path: str
165
+ """The source code path of the deployment."""
136
166
 
137
- description: Optional[str] = None
138
- """application description"""
167
+ create_time: Optional[str] = None
168
+ """The creation time of the deployment. Formatted timestamp in ISO 6801."""
139
169
 
140
- ingress: Optional[Any] = None
141
- """Ingress rules for app public endpoints"""
170
+ creator: Optional[str] = None
171
+ """The email of the user creates the deployment."""
142
172
 
143
- name: Optional[str] = None
144
- """Only a-z and dashes (-). Max length of 30."""
173
+ deployment_id: Optional[str] = None
174
+ """The unique id of the deployment."""
175
+
176
+ status: Optional[AppDeploymentStatus] = None
177
+ """Status and status message of the deployment"""
178
+
179
+ update_time: Optional[str] = None
180
+ """The update time of the deployment. Formatted timestamp in ISO 6801."""
181
+
182
+ def as_dict(self) -> dict:
183
+ """Serializes the AppDeployment into a dictionary suitable for use as a JSON request body."""
184
+ body = {}
185
+ if self.create_time is not None: body['create_time'] = self.create_time
186
+ if self.creator is not None: body['creator'] = self.creator
187
+ if self.deployment_id is not None: body['deployment_id'] = self.deployment_id
188
+ if self.source_code_path is not None: body['source_code_path'] = self.source_code_path
189
+ if self.status: body['status'] = self.status.as_dict()
190
+ if self.update_time is not None: body['update_time'] = self.update_time
191
+ return body
192
+
193
+ @classmethod
194
+ def from_dict(cls, d: Dict[str, any]) -> AppDeployment:
195
+ """Deserializes the AppDeployment from a dictionary."""
196
+ return cls(create_time=d.get('create_time', None),
197
+ creator=d.get('creator', None),
198
+ deployment_id=d.get('deployment_id', None),
199
+ source_code_path=d.get('source_code_path', None),
200
+ status=_from_dict(d, 'status', AppDeploymentStatus),
201
+ update_time=d.get('update_time', None))
145
202
 
146
- registry: Optional[Any] = None
147
- """Container private registry"""
148
203
 
149
- services: Optional[Any] = None
150
- """list of app services. Restricted to one for now."""
204
+ class AppDeploymentState(Enum):
205
+
206
+ CANCELLED = 'CANCELLED'
207
+ FAILED = 'FAILED'
208
+ IN_PROGRESS = 'IN_PROGRESS'
209
+ STATE_UNSPECIFIED = 'STATE_UNSPECIFIED'
210
+ SUCCEEDED = 'SUCCEEDED'
151
211
 
152
- version: Optional[Any] = None
153
- """The manifest format version. Must be set to 1."""
212
+
213
+ @dataclass
214
+ class AppDeploymentStatus:
215
+ message: Optional[str] = None
216
+ """Message corresponding with the deployment state."""
217
+
218
+ state: Optional[AppDeploymentState] = None
219
+ """State of the deployment."""
154
220
 
155
221
  def as_dict(self) -> dict:
156
- """Serializes the AppManifest into a dictionary suitable for use as a JSON request body."""
222
+ """Serializes the AppDeploymentStatus into a dictionary suitable for use as a JSON request body."""
157
223
  body = {}
158
- if self.dependencies: body['dependencies'] = [v for v in self.dependencies]
159
- if self.description is not None: body['description'] = self.description
160
- if self.ingress: body['ingress'] = self.ingress
161
- if self.name is not None: body['name'] = self.name
162
- if self.registry: body['registry'] = self.registry
163
- if self.services: body['services'] = self.services
164
- if self.version: body['version'] = self.version
224
+ if self.message is not None: body['message'] = self.message
225
+ if self.state is not None: body['state'] = self.state.value
165
226
  return body
166
227
 
167
228
  @classmethod
168
- def from_dict(cls, d: Dict[str, any]) -> AppManifest:
169
- """Deserializes the AppManifest from a dictionary."""
170
- return cls(dependencies=d.get('dependencies', None),
171
- description=d.get('description', None),
172
- ingress=d.get('ingress', None),
173
- name=d.get('name', None),
174
- registry=d.get('registry', None),
175
- services=d.get('services', None),
176
- version=d.get('version', None))
229
+ def from_dict(cls, d: Dict[str, any]) -> AppDeploymentStatus:
230
+ """Deserializes the AppDeploymentStatus from a dictionary."""
231
+ return cls(message=d.get('message', None), state=_enum(d, 'state', AppDeploymentState))
177
232
 
178
233
 
179
234
  @dataclass
180
- class AppServiceStatus:
181
- deployment: Optional[Any] = None
235
+ class AppEnvironment:
236
+ env: Optional[List[EnvVariable]] = None
182
237
 
183
- name: Optional[str] = None
238
+ def as_dict(self) -> dict:
239
+ """Serializes the AppEnvironment into a dictionary suitable for use as a JSON request body."""
240
+ body = {}
241
+ if self.env: body['env'] = [v.as_dict() for v in self.env]
242
+ return body
243
+
244
+ @classmethod
245
+ def from_dict(cls, d: Dict[str, any]) -> AppEnvironment:
246
+ """Deserializes the AppEnvironment from a dictionary."""
247
+ return cls(env=_repeated_dict(d, 'env', EnvVariable))
248
+
249
+
250
+ class AppState(Enum):
251
+
252
+ CREATING = 'CREATING'
253
+ DELETED = 'DELETED'
254
+ DELETING = 'DELETING'
255
+ DEPLOYED = 'DEPLOYED'
256
+ DEPLOYING = 'DEPLOYING'
257
+ ERROR = 'ERROR'
258
+ IDLE = 'IDLE'
259
+ READY = 'READY'
260
+ RUNNING = 'RUNNING'
261
+ STARTING = 'STARTING'
262
+ STATE_UNSPECIFIED = 'STATE_UNSPECIFIED'
263
+ UPDATING = 'UPDATING'
184
264
 
185
- template: Optional[Any] = None
265
+
266
+ @dataclass
267
+ class AppStatus:
268
+ message: Optional[str] = None
269
+ """Message corresponding with the app state."""
270
+
271
+ state: Optional[AppState] = None
272
+ """State of the app."""
186
273
 
187
274
  def as_dict(self) -> dict:
188
- """Serializes the AppServiceStatus into a dictionary suitable for use as a JSON request body."""
275
+ """Serializes the AppStatus into a dictionary suitable for use as a JSON request body."""
189
276
  body = {}
190
- if self.deployment: body['deployment'] = self.deployment
191
- if self.name is not None: body['name'] = self.name
192
- if self.template: body['template'] = self.template
277
+ if self.message is not None: body['message'] = self.message
278
+ if self.state is not None: body['state'] = self.state.value
193
279
  return body
194
280
 
195
281
  @classmethod
196
- def from_dict(cls, d: Dict[str, any]) -> AppServiceStatus:
197
- """Deserializes the AppServiceStatus from a dictionary."""
198
- return cls(deployment=d.get('deployment', None),
199
- name=d.get('name', None),
200
- template=d.get('template', None))
282
+ def from_dict(cls, d: Dict[str, any]) -> AppStatus:
283
+ """Deserializes the AppStatus from a dictionary."""
284
+ return cls(message=d.get('message', None), state=_enum(d, 'state', AppState))
201
285
 
202
286
 
203
287
  @dataclass
@@ -351,6 +435,49 @@ class CohereConfig:
351
435
  return cls(cohere_api_key=d.get('cohere_api_key', None))
352
436
 
353
437
 
438
+ @dataclass
439
+ class CreateAppDeploymentRequest:
440
+ source_code_path: str
441
+ """The source code path of the deployment."""
442
+
443
+ app_name: Optional[str] = None
444
+ """The name of the app."""
445
+
446
+ def as_dict(self) -> dict:
447
+ """Serializes the CreateAppDeploymentRequest into a dictionary suitable for use as a JSON request body."""
448
+ body = {}
449
+ if self.app_name is not None: body['app_name'] = self.app_name
450
+ if self.source_code_path is not None: body['source_code_path'] = self.source_code_path
451
+ return body
452
+
453
+ @classmethod
454
+ def from_dict(cls, d: Dict[str, any]) -> CreateAppDeploymentRequest:
455
+ """Deserializes the CreateAppDeploymentRequest from a dictionary."""
456
+ return cls(app_name=d.get('app_name', None), source_code_path=d.get('source_code_path', None))
457
+
458
+
459
+ @dataclass
460
+ class CreateAppRequest:
461
+ name: str
462
+ """The name of the app. The name must contain only lowercase alphanumeric characters and hyphens
463
+ and be between 2 and 30 characters long. It must be unique within the workspace."""
464
+
465
+ description: Optional[str] = None
466
+ """The description of the app."""
467
+
468
+ def as_dict(self) -> dict:
469
+ """Serializes the CreateAppRequest into a dictionary suitable for use as a JSON request body."""
470
+ body = {}
471
+ if self.description is not None: body['description'] = self.description
472
+ if self.name is not None: body['name'] = self.name
473
+ return body
474
+
475
+ @classmethod
476
+ def from_dict(cls, d: Dict[str, any]) -> CreateAppRequest:
477
+ """Deserializes the CreateAppRequest from a dictionary."""
478
+ return cls(description=d.get('description', None), name=d.get('name', None))
479
+
480
+
354
481
  @dataclass
355
482
  class CreateServingEndpoint:
356
483
  name: str
@@ -433,22 +560,6 @@ class DataframeSplitInput:
433
560
  return cls(columns=d.get('columns', None), data=d.get('data', None), index=d.get('index', None))
434
561
 
435
562
 
436
- @dataclass
437
- class DeleteAppResponse:
438
- name: Optional[str] = None
439
-
440
- def as_dict(self) -> dict:
441
- """Serializes the DeleteAppResponse into a dictionary suitable for use as a JSON request body."""
442
- body = {}
443
- if self.name is not None: body['name'] = self.name
444
- return body
445
-
446
- @classmethod
447
- def from_dict(cls, d: Dict[str, any]) -> DeleteAppResponse:
448
- """Deserializes the DeleteAppResponse from a dictionary."""
449
- return cls(name=d.get('name', None))
450
-
451
-
452
563
  @dataclass
453
564
  class DeleteResponse:
454
565
 
@@ -463,68 +574,6 @@ class DeleteResponse:
463
574
  return cls()
464
575
 
465
576
 
466
- @dataclass
467
- class DeployAppRequest:
468
- manifest: AppManifest
469
- """Manifest that specifies the application requirements"""
470
-
471
- resources: Optional[Any] = None
472
- """Information passed at app deployment time to fulfill app dependencies"""
473
-
474
- def as_dict(self) -> dict:
475
- """Serializes the DeployAppRequest into a dictionary suitable for use as a JSON request body."""
476
- body = {}
477
- if self.manifest: body['manifest'] = self.manifest.as_dict()
478
- if self.resources: body['resources'] = self.resources
479
- return body
480
-
481
- @classmethod
482
- def from_dict(cls, d: Dict[str, any]) -> DeployAppRequest:
483
- """Deserializes the DeployAppRequest from a dictionary."""
484
- return cls(manifest=_from_dict(d, 'manifest', AppManifest), resources=d.get('resources', None))
485
-
486
-
487
- @dataclass
488
- class DeploymentStatus:
489
- container_logs: Optional[List[Any]] = None
490
- """Container logs."""
491
-
492
- deployment_id: Optional[str] = None
493
- """description"""
494
-
495
- extra_info: Optional[str] = None
496
- """Supplementary information about pod"""
497
-
498
- state: Optional[DeploymentStatusState] = None
499
- """State: one of DEPLOYING,SUCCESS, FAILURE, DEPLOYMENT_STATE_UNSPECIFIED"""
500
-
501
- def as_dict(self) -> dict:
502
- """Serializes the DeploymentStatus into a dictionary suitable for use as a JSON request body."""
503
- body = {}
504
- if self.container_logs: body['container_logs'] = [v for v in self.container_logs]
505
- if self.deployment_id is not None: body['deployment_id'] = self.deployment_id
506
- if self.extra_info is not None: body['extra_info'] = self.extra_info
507
- if self.state is not None: body['state'] = self.state.value
508
- return body
509
-
510
- @classmethod
511
- def from_dict(cls, d: Dict[str, any]) -> DeploymentStatus:
512
- """Deserializes the DeploymentStatus from a dictionary."""
513
- return cls(container_logs=d.get('container_logs', None),
514
- deployment_id=d.get('deployment_id', None),
515
- extra_info=d.get('extra_info', None),
516
- state=_enum(d, 'state', DeploymentStatusState))
517
-
518
-
519
- class DeploymentStatusState(Enum):
520
- """State: one of DEPLOYING,SUCCESS, FAILURE, DEPLOYMENT_STATE_UNSPECIFIED"""
521
-
522
- DEPLOYING = 'DEPLOYING'
523
- DEPLOYMENT_STATE_UNSPECIFIED = 'DEPLOYMENT_STATE_UNSPECIFIED'
524
- FAILURE = 'FAILURE'
525
- SUCCESS = 'SUCCESS'
526
-
527
-
528
577
  @dataclass
529
578
  class EmbeddingsV1ResponseEmbeddingElement:
530
579
  embedding: Optional[List[float]] = None
@@ -771,6 +820,28 @@ class EndpointTag:
771
820
  return cls(key=d.get('key', None), value=d.get('value', None))
772
821
 
773
822
 
823
+ @dataclass
824
+ class EnvVariable:
825
+ name: Optional[str] = None
826
+
827
+ value: Optional[str] = None
828
+
829
+ value_from: Optional[str] = None
830
+
831
+ def as_dict(self) -> dict:
832
+ """Serializes the EnvVariable into a dictionary suitable for use as a JSON request body."""
833
+ body = {}
834
+ if self.name is not None: body['name'] = self.name
835
+ if self.value is not None: body['value'] = self.value
836
+ if self.value_from is not None: body['value_from'] = self.value_from
837
+ return body
838
+
839
+ @classmethod
840
+ def from_dict(cls, d: Dict[str, any]) -> EnvVariable:
841
+ """Deserializes the EnvVariable from a dictionary."""
842
+ return cls(name=d.get('name', None), value=d.get('value', None), value_from=d.get('value_from', None))
843
+
844
+
774
845
  @dataclass
775
846
  class ExportMetricsResponse:
776
847
 
@@ -925,31 +996,19 @@ class FoundationModel:
925
996
 
926
997
 
927
998
  @dataclass
928
- class GetAppResponse:
929
- current_services: Optional[List[AppServiceStatus]] = None
930
-
931
- name: Optional[str] = None
932
-
933
- pending_services: Optional[List[AppServiceStatus]] = None
934
-
935
- url: Optional[str] = None
999
+ class GetOpenApiResponse:
1000
+ """The response is an OpenAPI spec in JSON format that typically includes fields like openapi,
1001
+ info, servers and paths, etc."""
936
1002
 
937
1003
  def as_dict(self) -> dict:
938
- """Serializes the GetAppResponse into a dictionary suitable for use as a JSON request body."""
1004
+ """Serializes the GetOpenApiResponse into a dictionary suitable for use as a JSON request body."""
939
1005
  body = {}
940
- if self.current_services: body['current_services'] = [v.as_dict() for v in self.current_services]
941
- if self.name is not None: body['name'] = self.name
942
- if self.pending_services: body['pending_services'] = [v.as_dict() for v in self.pending_services]
943
- if self.url is not None: body['url'] = self.url
944
1006
  return body
945
1007
 
946
1008
  @classmethod
947
- def from_dict(cls, d: Dict[str, any]) -> GetAppResponse:
948
- """Deserializes the GetAppResponse from a dictionary."""
949
- return cls(current_services=_repeated_dict(d, 'current_services', AppServiceStatus),
950
- name=d.get('name', None),
951
- pending_services=_repeated_dict(d, 'pending_services', AppServiceStatus),
952
- url=d.get('url', None))
1009
+ def from_dict(cls, d: Dict[str, any]) -> GetOpenApiResponse:
1010
+ """Deserializes the GetOpenApiResponse from a dictionary."""
1011
+ return cls()
953
1012
 
954
1013
 
955
1014
  @dataclass
@@ -971,40 +1030,45 @@ class GetServingEndpointPermissionLevelsResponse:
971
1030
 
972
1031
 
973
1032
  @dataclass
974
- class ListAppEventsResponse:
975
- events: Optional[List[AppEvents]] = None
976
- """App events"""
1033
+ class ListAppDeploymentsResponse:
1034
+ app_deployments: Optional[List[AppDeployment]] = None
1035
+ """Deployment history of the app."""
1036
+
1037
+ next_page_token: Optional[str] = None
1038
+ """Pagination token to request the next page of apps."""
977
1039
 
978
1040
  def as_dict(self) -> dict:
979
- """Serializes the ListAppEventsResponse into a dictionary suitable for use as a JSON request body."""
1041
+ """Serializes the ListAppDeploymentsResponse into a dictionary suitable for use as a JSON request body."""
980
1042
  body = {}
981
- if self.events: body['events'] = [v.as_dict() for v in self.events]
1043
+ if self.app_deployments: body['app_deployments'] = [v.as_dict() for v in self.app_deployments]
1044
+ if self.next_page_token is not None: body['next_page_token'] = self.next_page_token
982
1045
  return body
983
1046
 
984
1047
  @classmethod
985
- def from_dict(cls, d: Dict[str, any]) -> ListAppEventsResponse:
986
- """Deserializes the ListAppEventsResponse from a dictionary."""
987
- return cls(events=_repeated_dict(d, 'events', AppEvents))
1048
+ def from_dict(cls, d: Dict[str, any]) -> ListAppDeploymentsResponse:
1049
+ """Deserializes the ListAppDeploymentsResponse from a dictionary."""
1050
+ return cls(app_deployments=_repeated_dict(d, 'app_deployments', AppDeployment),
1051
+ next_page_token=d.get('next_page_token', None))
988
1052
 
989
1053
 
990
1054
  @dataclass
991
1055
  class ListAppsResponse:
992
- apps: Optional[List[Any]] = None
993
- """Available apps."""
1056
+ apps: Optional[List[App]] = None
994
1057
 
995
1058
  next_page_token: Optional[str] = None
1059
+ """Pagination token to request the next page of apps."""
996
1060
 
997
1061
  def as_dict(self) -> dict:
998
1062
  """Serializes the ListAppsResponse into a dictionary suitable for use as a JSON request body."""
999
1063
  body = {}
1000
- if self.apps: body['apps'] = [v for v in self.apps]
1064
+ if self.apps: body['apps'] = [v.as_dict() for v in self.apps]
1001
1065
  if self.next_page_token is not None: body['next_page_token'] = self.next_page_token
1002
1066
  return body
1003
1067
 
1004
1068
  @classmethod
1005
1069
  def from_dict(cls, d: Dict[str, any]) -> ListAppsResponse:
1006
1070
  """Deserializes the ListAppsResponse from a dictionary."""
1007
- return cls(apps=d.get('apps', None), next_page_token=d.get('next_page_token', None))
1071
+ return cls(apps=_repeated_dict(d, 'apps', App), next_page_token=d.get('next_page_token', None))
1008
1072
 
1009
1073
 
1010
1074
  @dataclass
@@ -2228,6 +2292,26 @@ class ServingEndpointPermissionsRequest:
2228
2292
  serving_endpoint_id=d.get('serving_endpoint_id', None))
2229
2293
 
2230
2294
 
2295
+ @dataclass
2296
+ class StopAppRequest:
2297
+ name: Optional[str] = None
2298
+ """The name of the app."""
2299
+
2300
+
2301
+ @dataclass
2302
+ class StopAppResponse:
2303
+
2304
+ def as_dict(self) -> dict:
2305
+ """Serializes the StopAppResponse into a dictionary suitable for use as a JSON request body."""
2306
+ body = {}
2307
+ return body
2308
+
2309
+ @classmethod
2310
+ def from_dict(cls, d: Dict[str, any]) -> StopAppResponse:
2311
+ """Deserializes the StopAppResponse from a dictionary."""
2312
+ return cls()
2313
+
2314
+
2231
2315
  @dataclass
2232
2316
  class TrafficConfig:
2233
2317
  routes: Optional[List[Route]] = None
@@ -2245,6 +2329,28 @@ class TrafficConfig:
2245
2329
  return cls(routes=_repeated_dict(d, 'routes', Route))
2246
2330
 
2247
2331
 
2332
+ @dataclass
2333
+ class UpdateAppRequest:
2334
+ name: str
2335
+ """The name of the app. The name must contain only lowercase alphanumeric characters and hyphens
2336
+ and be between 2 and 30 characters long. It must be unique within the workspace."""
2337
+
2338
+ description: Optional[str] = None
2339
+ """The description of the app."""
2340
+
2341
+ def as_dict(self) -> dict:
2342
+ """Serializes the UpdateAppRequest into a dictionary suitable for use as a JSON request body."""
2343
+ body = {}
2344
+ if self.description is not None: body['description'] = self.description
2345
+ if self.name is not None: body['name'] = self.name
2346
+ return body
2347
+
2348
+ @classmethod
2349
+ def from_dict(cls, d: Dict[str, any]) -> UpdateAppRequest:
2350
+ """Deserializes the UpdateAppRequest from a dictionary."""
2351
+ return cls(description=d.get('description', None), name=d.get('name', None))
2352
+
2353
+
2248
2354
  @dataclass
2249
2355
  class V1ResponseChoiceElement:
2250
2356
  finish_reason: Optional[str] = None
@@ -2283,118 +2389,304 @@ class V1ResponseChoiceElement:
2283
2389
 
2284
2390
 
2285
2391
  class AppsAPI:
2286
- """Lakehouse Apps run directly on a customer’s Databricks instance, integrate with their data, use and
2287
- extend Databricks services, and enable users to interact through single sign-on."""
2392
+ """Apps run directly on a customer’s Databricks instance, integrate with their data, use and extend
2393
+ Databricks services, and enable users to interact through single sign-on."""
2288
2394
 
2289
2395
  def __init__(self, api_client):
2290
2396
  self._api = api_client
2291
2397
 
2292
- def create(self, manifest: AppManifest, *, resources: Optional[Any] = None) -> DeploymentStatus:
2293
- """Create and deploy an application.
2398
+ def wait_get_app_idle(self,
2399
+ name: str,
2400
+ timeout=timedelta(minutes=20),
2401
+ callback: Optional[Callable[[App], None]] = None) -> App:
2402
+ deadline = time.time() + timeout.total_seconds()
2403
+ target_states = (AppState.IDLE, )
2404
+ failure_states = (AppState.ERROR, )
2405
+ status_message = 'polling...'
2406
+ attempt = 1
2407
+ while time.time() < deadline:
2408
+ poll = self.get(name=name)
2409
+ status = poll.status.state
2410
+ status_message = f'current status: {status}'
2411
+ if poll.status:
2412
+ status_message = poll.status.message
2413
+ if status in target_states:
2414
+ return poll
2415
+ if callback:
2416
+ callback(poll)
2417
+ if status in failure_states:
2418
+ msg = f'failed to reach IDLE, got {status}: {status_message}'
2419
+ raise OperationFailed(msg)
2420
+ prefix = f"name={name}"
2421
+ sleep = attempt
2422
+ if sleep > 10:
2423
+ # sleep 10s max per attempt
2424
+ sleep = 10
2425
+ _LOG.debug(f'{prefix}: ({status}) {status_message} (sleeping ~{sleep}s)')
2426
+ time.sleep(sleep + random.random())
2427
+ attempt += 1
2428
+ raise TimeoutError(f'timed out after {timeout}: {status_message}')
2429
+
2430
+ def wait_get_deployment_app_succeeded(
2431
+ self,
2432
+ app_name: str,
2433
+ deployment_id: str,
2434
+ timeout=timedelta(minutes=20),
2435
+ callback: Optional[Callable[[AppDeployment], None]] = None) -> AppDeployment:
2436
+ deadline = time.time() + timeout.total_seconds()
2437
+ target_states = (AppDeploymentState.SUCCEEDED, )
2438
+ failure_states = (AppDeploymentState.FAILED, )
2439
+ status_message = 'polling...'
2440
+ attempt = 1
2441
+ while time.time() < deadline:
2442
+ poll = self.get_deployment(app_name=app_name, deployment_id=deployment_id)
2443
+ status = poll.status.state
2444
+ status_message = f'current status: {status}'
2445
+ if poll.status:
2446
+ status_message = poll.status.message
2447
+ if status in target_states:
2448
+ return poll
2449
+ if callback:
2450
+ callback(poll)
2451
+ if status in failure_states:
2452
+ msg = f'failed to reach SUCCEEDED, got {status}: {status_message}'
2453
+ raise OperationFailed(msg)
2454
+ prefix = f"app_name={app_name}, deployment_id={deployment_id}"
2455
+ sleep = attempt
2456
+ if sleep > 10:
2457
+ # sleep 10s max per attempt
2458
+ sleep = 10
2459
+ _LOG.debug(f'{prefix}: ({status}) {status_message} (sleeping ~{sleep}s)')
2460
+ time.sleep(sleep + random.random())
2461
+ attempt += 1
2462
+ raise TimeoutError(f'timed out after {timeout}: {status_message}')
2463
+
2464
+ def create(self, name: str, *, description: Optional[str] = None) -> Wait[App]:
2465
+ """Create an App.
2466
+
2467
+ Creates a new app.
2468
+
2469
+ :param name: str
2470
+ The name of the app. The name must contain only lowercase alphanumeric characters and hyphens and be
2471
+ between 2 and 30 characters long. It must be unique within the workspace.
2472
+ :param description: str (optional)
2473
+ The description of the app.
2474
+
2475
+ :returns:
2476
+ Long-running operation waiter for :class:`App`.
2477
+ See :method:wait_get_app_idle for more details.
2478
+ """
2479
+ body = {}
2480
+ if description is not None: body['description'] = description
2481
+ if name is not None: body['name'] = name
2482
+ headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
2483
+
2484
+ op_response = self._api.do('POST', '/api/2.0/preview/apps', body=body, headers=headers)
2485
+ return Wait(self.wait_get_app_idle, response=App.from_dict(op_response), name=op_response['name'])
2486
+
2487
+ def create_and_wait(self,
2488
+ name: str,
2489
+ *,
2490
+ description: Optional[str] = None,
2491
+ timeout=timedelta(minutes=20)) -> App:
2492
+ return self.create(description=description, name=name).result(timeout=timeout)
2493
+
2494
+ def create_deployment(self, app_name: str, source_code_path: str) -> Wait[AppDeployment]:
2495
+ """Create an App Deployment.
2294
2496
 
2295
- Creates and deploys an application.
2497
+ Creates an app deployment for the app with the supplied name.
2296
2498
 
2297
- :param manifest: :class:`AppManifest`
2298
- Manifest that specifies the application requirements
2299
- :param resources: Any (optional)
2300
- Information passed at app deployment time to fulfill app dependencies
2499
+ :param app_name: str
2500
+ The name of the app.
2501
+ :param source_code_path: str
2502
+ The source code path of the deployment.
2301
2503
 
2302
- :returns: :class:`DeploymentStatus`
2504
+ :returns:
2505
+ Long-running operation waiter for :class:`AppDeployment`.
2506
+ See :method:wait_get_deployment_app_succeeded for more details.
2303
2507
  """
2304
2508
  body = {}
2305
- if manifest is not None: body['manifest'] = manifest.as_dict()
2306
- if resources is not None: body['resources'] = resources
2509
+ if source_code_path is not None: body['source_code_path'] = source_code_path
2307
2510
  headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
2308
2511
 
2309
- res = self._api.do('POST', '/api/2.0/preview/apps/deployments', body=body, headers=headers)
2310
- return DeploymentStatus.from_dict(res)
2512
+ op_response = self._api.do('POST',
2513
+ f'/api/2.0/preview/apps/{app_name}/deployments',
2514
+ body=body,
2515
+ headers=headers)
2516
+ return Wait(self.wait_get_deployment_app_succeeded,
2517
+ response=AppDeployment.from_dict(op_response),
2518
+ app_name=app_name,
2519
+ deployment_id=op_response['deployment_id'])
2520
+
2521
+ def create_deployment_and_wait(self, app_name: str, source_code_path: str,
2522
+ timeout=timedelta(minutes=20)) -> AppDeployment:
2523
+ return self.create_deployment(app_name=app_name,
2524
+ source_code_path=source_code_path).result(timeout=timeout)
2311
2525
 
2312
- def delete_app(self, name: str) -> DeleteAppResponse:
2313
- """Delete an application.
2526
+ def delete(self, name: str):
2527
+ """Delete an App.
2314
2528
 
2315
- Delete an application definition
2529
+ Deletes an app.
2316
2530
 
2317
2531
  :param name: str
2318
- The name of an application. This field is required.
2532
+ The name of the app.
2533
+
2319
2534
 
2320
- :returns: :class:`DeleteAppResponse`
2321
2535
  """
2322
2536
 
2323
2537
  headers = {'Accept': 'application/json', }
2324
2538
 
2325
- res = self._api.do('DELETE', f'/api/2.0/preview/apps/instances/{name}', headers=headers)
2326
- return DeleteAppResponse.from_dict(res)
2539
+ self._api.do('DELETE', f'/api/2.0/preview/apps/{name}', headers=headers)
2327
2540
 
2328
- def get_app(self, name: str) -> GetAppResponse:
2329
- """Get definition for an application.
2541
+ def get(self, name: str) -> App:
2542
+ """Get an App.
2330
2543
 
2331
- Get an application definition
2544
+ Retrieves information for the app with the supplied name.
2332
2545
 
2333
2546
  :param name: str
2334
- The name of an application. This field is required.
2547
+ The name of the app.
2335
2548
 
2336
- :returns: :class:`GetAppResponse`
2549
+ :returns: :class:`App`
2337
2550
  """
2338
2551
 
2339
2552
  headers = {'Accept': 'application/json', }
2340
2553
 
2341
- res = self._api.do('GET', f'/api/2.0/preview/apps/instances/{name}', headers=headers)
2342
- return GetAppResponse.from_dict(res)
2554
+ res = self._api.do('GET', f'/api/2.0/preview/apps/{name}', headers=headers)
2555
+ return App.from_dict(res)
2343
2556
 
2344
- def get_app_deployment_status(self,
2345
- deployment_id: str,
2346
- *,
2347
- include_app_log: Optional[str] = None) -> DeploymentStatus:
2348
- """Get deployment status for an application.
2557
+ def get_deployment(self, app_name: str, deployment_id: str) -> AppDeployment:
2558
+ """Get an App Deployment.
2349
2559
 
2350
- Get deployment status for an application
2560
+ Retrieves information for the app deployment with the supplied name and deployment id.
2351
2561
 
2562
+ :param app_name: str
2563
+ The name of the app.
2352
2564
  :param deployment_id: str
2353
- The deployment id for an application. This field is required.
2354
- :param include_app_log: str (optional)
2355
- Boolean flag to include application logs
2565
+ The unique id of the deployment.
2356
2566
 
2357
- :returns: :class:`DeploymentStatus`
2567
+ :returns: :class:`AppDeployment`
2358
2568
  """
2359
2569
 
2360
- query = {}
2361
- if include_app_log is not None: query['include_app_log'] = include_app_log
2362
2570
  headers = {'Accept': 'application/json', }
2363
2571
 
2364
2572
  res = self._api.do('GET',
2365
- f'/api/2.0/preview/apps/deployments/{deployment_id}',
2366
- query=query,
2573
+ f'/api/2.0/preview/apps/{app_name}/deployments/{deployment_id}',
2367
2574
  headers=headers)
2368
- return DeploymentStatus.from_dict(res)
2575
+ return AppDeployment.from_dict(res)
2369
2576
 
2370
- def get_apps(self) -> ListAppsResponse:
2371
- """List all applications.
2577
+ def get_environment(self, name: str) -> AppEnvironment:
2578
+ """Get App Environment.
2372
2579
 
2373
- List all available applications
2580
+ Retrieves app environment.
2374
2581
 
2375
- :returns: :class:`ListAppsResponse`
2582
+ :param name: str
2583
+ The name of the app.
2584
+
2585
+ :returns: :class:`AppEnvironment`
2376
2586
  """
2377
2587
 
2378
2588
  headers = {'Accept': 'application/json', }
2379
2589
 
2380
- res = self._api.do('GET', '/api/2.0/preview/apps/instances', headers=headers)
2381
- return ListAppsResponse.from_dict(res)
2590
+ res = self._api.do('GET', f'/api/2.0/preview/apps/{name}/environment', headers=headers)
2591
+ return AppEnvironment.from_dict(res)
2382
2592
 
2383
- def get_events(self, name: str) -> ListAppEventsResponse:
2384
- """Get deployment events for an application.
2593
+ def list(self, *, page_size: Optional[int] = None, page_token: Optional[str] = None) -> Iterator[App]:
2594
+ """List Apps.
2385
2595
 
2386
- Get deployment events for an application
2596
+ Lists all apps in the workspace.
2387
2597
 
2388
- :param name: str
2389
- The name of an application. This field is required.
2598
+ :param page_size: int (optional)
2599
+ Upper bound for items returned.
2600
+ :param page_token: str (optional)
2601
+ Pagination token to go to the next page of apps. Requests first page if absent.
2602
+
2603
+ :returns: Iterator over :class:`App`
2604
+ """
2605
+
2606
+ query = {}
2607
+ if page_size is not None: query['page_size'] = page_size
2608
+ if page_token is not None: query['page_token'] = page_token
2609
+ headers = {'Accept': 'application/json', }
2610
+
2611
+ while True:
2612
+ json = self._api.do('GET', '/api/2.0/preview/apps', query=query, headers=headers)
2613
+ if 'apps' in json:
2614
+ for v in json['apps']:
2615
+ yield App.from_dict(v)
2616
+ if 'next_page_token' not in json or not json['next_page_token']:
2617
+ return
2618
+ query['page_token'] = json['next_page_token']
2619
+
2620
+ def list_deployments(self,
2621
+ app_name: str,
2622
+ *,
2623
+ page_size: Optional[int] = None,
2624
+ page_token: Optional[str] = None) -> Iterator[AppDeployment]:
2625
+ """List App Deployments.
2626
+
2627
+ Lists all app deployments for the app with the supplied name.
2390
2628
 
2391
- :returns: :class:`ListAppEventsResponse`
2629
+ :param app_name: str
2630
+ The name of the app.
2631
+ :param page_size: int (optional)
2632
+ Upper bound for items returned.
2633
+ :param page_token: str (optional)
2634
+ Pagination token to go to the next page of apps. Requests first page if absent.
2635
+
2636
+ :returns: Iterator over :class:`AppDeployment`
2392
2637
  """
2393
2638
 
2639
+ query = {}
2640
+ if page_size is not None: query['page_size'] = page_size
2641
+ if page_token is not None: query['page_token'] = page_token
2394
2642
  headers = {'Accept': 'application/json', }
2395
2643
 
2396
- res = self._api.do('GET', f'/api/2.0/preview/apps/{name}/events', headers=headers)
2397
- return ListAppEventsResponse.from_dict(res)
2644
+ while True:
2645
+ json = self._api.do('GET',
2646
+ f'/api/2.0/preview/apps/{app_name}/deployments',
2647
+ query=query,
2648
+ headers=headers)
2649
+ if 'app_deployments' in json:
2650
+ for v in json['app_deployments']:
2651
+ yield AppDeployment.from_dict(v)
2652
+ if 'next_page_token' not in json or not json['next_page_token']:
2653
+ return
2654
+ query['page_token'] = json['next_page_token']
2655
+
2656
+ def stop(self, name: str):
2657
+ """Stop an App.
2658
+
2659
+ Stops the active deployment of the app in the workspace.
2660
+
2661
+ :param name: str
2662
+ The name of the app.
2663
+
2664
+
2665
+ """
2666
+
2667
+ headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
2668
+
2669
+ self._api.do('POST', f'/api/2.0/preview/apps/{name}/stop', headers=headers)
2670
+
2671
+ def update(self, name: str, *, description: Optional[str] = None) -> App:
2672
+ """Update an App.
2673
+
2674
+ Updates the app with the supplied name.
2675
+
2676
+ :param name: str
2677
+ The name of the app. The name must contain only lowercase alphanumeric characters and hyphens and be
2678
+ between 2 and 30 characters long. It must be unique within the workspace.
2679
+ :param description: str (optional)
2680
+ The description of the app.
2681
+
2682
+ :returns: :class:`App`
2683
+ """
2684
+ body = {}
2685
+ if description is not None: body['description'] = description
2686
+ headers = {'Accept': 'application/json', 'Content-Type': 'application/json', }
2687
+
2688
+ res = self._api.do('PATCH', f'/api/2.0/preview/apps/{name}', body=body, headers=headers)
2689
+ return App.from_dict(res)
2398
2690
 
2399
2691
 
2400
2692
  class ServingEndpointsAPI:
@@ -2554,6 +2846,22 @@ class ServingEndpointsAPI:
2554
2846
  res = self._api.do('GET', f'/api/2.0/serving-endpoints/{name}', headers=headers)
2555
2847
  return ServingEndpointDetailed.from_dict(res)
2556
2848
 
2849
+ def get_open_api(self, name: str):
2850
+ """Get the schema for a serving endpoint.
2851
+
2852
+ Get the query schema of the serving endpoint in OpenAPI format. The schema contains information for
2853
+ the supported paths, input and output format and datatypes.
2854
+
2855
+ :param name: str
2856
+ The name of the serving endpoint that the served model belongs to. This field is required.
2857
+
2858
+
2859
+ """
2860
+
2861
+ headers = {'Accept': 'application/json', }
2862
+
2863
+ self._api.do('GET', f'/api/2.0/serving-endpoints/{name}/openapi', headers=headers)
2864
+
2557
2865
  def get_permission_levels(self, serving_endpoint_id: str) -> GetServingEndpointPermissionLevelsResponse:
2558
2866
  """Get serving endpoint permission levels.
2559
2867