nextmv 0.40.0__py3-none-any.whl → 1.0.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.
- nextmv/__about__.py +1 -1
- nextmv/__entrypoint__.py +1 -2
- nextmv/__init__.py +2 -4
- nextmv/cli/CONTRIBUTING.md +583 -0
- nextmv/cli/cloud/__init__.py +49 -0
- nextmv/cli/cloud/acceptance/__init__.py +27 -0
- nextmv/cli/cloud/acceptance/create.py +391 -0
- nextmv/cli/cloud/acceptance/delete.py +64 -0
- nextmv/cli/cloud/acceptance/get.py +103 -0
- nextmv/cli/cloud/acceptance/list.py +62 -0
- nextmv/cli/cloud/acceptance/update.py +95 -0
- nextmv/cli/cloud/account/__init__.py +28 -0
- nextmv/cli/cloud/account/create.py +83 -0
- nextmv/cli/cloud/account/delete.py +59 -0
- nextmv/cli/cloud/account/get.py +66 -0
- nextmv/cli/cloud/account/update.py +70 -0
- nextmv/cli/cloud/app/__init__.py +35 -0
- nextmv/cli/cloud/app/create.py +140 -0
- nextmv/cli/cloud/app/delete.py +57 -0
- nextmv/cli/cloud/app/exists.py +44 -0
- nextmv/cli/cloud/app/get.py +66 -0
- nextmv/cli/cloud/app/list.py +61 -0
- nextmv/cli/cloud/app/push.py +432 -0
- nextmv/cli/cloud/app/update.py +124 -0
- nextmv/cli/cloud/batch/__init__.py +29 -0
- nextmv/cli/cloud/batch/create.py +452 -0
- nextmv/cli/cloud/batch/delete.py +64 -0
- nextmv/cli/cloud/batch/get.py +104 -0
- nextmv/cli/cloud/batch/list.py +63 -0
- nextmv/cli/cloud/batch/metadata.py +66 -0
- nextmv/cli/cloud/batch/update.py +95 -0
- nextmv/cli/cloud/data/__init__.py +26 -0
- nextmv/cli/cloud/data/upload.py +162 -0
- nextmv/cli/cloud/ensemble/__init__.py +33 -0
- nextmv/cli/cloud/ensemble/create.py +413 -0
- nextmv/cli/cloud/ensemble/delete.py +63 -0
- nextmv/cli/cloud/ensemble/get.py +65 -0
- nextmv/cli/cloud/ensemble/list.py +63 -0
- nextmv/cli/cloud/ensemble/update.py +103 -0
- nextmv/cli/cloud/input_set/__init__.py +32 -0
- nextmv/cli/cloud/input_set/create.py +168 -0
- nextmv/cli/cloud/input_set/delete.py +64 -0
- nextmv/cli/cloud/input_set/get.py +63 -0
- nextmv/cli/cloud/input_set/list.py +63 -0
- nextmv/cli/cloud/input_set/update.py +123 -0
- nextmv/cli/cloud/instance/__init__.py +35 -0
- nextmv/cli/cloud/instance/create.py +289 -0
- nextmv/cli/cloud/instance/delete.py +61 -0
- nextmv/cli/cloud/instance/exists.py +39 -0
- nextmv/cli/cloud/instance/get.py +62 -0
- nextmv/cli/cloud/instance/list.py +60 -0
- nextmv/cli/cloud/instance/update.py +216 -0
- nextmv/cli/cloud/managed_input/__init__.py +31 -0
- nextmv/cli/cloud/managed_input/create.py +144 -0
- nextmv/cli/cloud/managed_input/delete.py +64 -0
- nextmv/cli/cloud/managed_input/get.py +63 -0
- nextmv/cli/cloud/managed_input/list.py +60 -0
- nextmv/cli/cloud/managed_input/update.py +97 -0
- nextmv/cli/cloud/run/__init__.py +37 -0
- nextmv/cli/cloud/run/cancel.py +37 -0
- nextmv/cli/cloud/run/create.py +524 -0
- nextmv/cli/cloud/run/get.py +199 -0
- nextmv/cli/cloud/run/input.py +86 -0
- nextmv/cli/cloud/run/list.py +80 -0
- nextmv/cli/cloud/run/logs.py +166 -0
- nextmv/cli/cloud/run/metadata.py +67 -0
- nextmv/cli/cloud/run/track.py +500 -0
- nextmv/cli/cloud/scenario/__init__.py +29 -0
- nextmv/cli/cloud/scenario/create.py +451 -0
- nextmv/cli/cloud/scenario/delete.py +61 -0
- nextmv/cli/cloud/scenario/get.py +102 -0
- nextmv/cli/cloud/scenario/list.py +63 -0
- nextmv/cli/cloud/scenario/metadata.py +67 -0
- nextmv/cli/cloud/scenario/update.py +93 -0
- nextmv/cli/cloud/secrets/__init__.py +33 -0
- nextmv/cli/cloud/secrets/create.py +206 -0
- nextmv/cli/cloud/secrets/delete.py +63 -0
- nextmv/cli/cloud/secrets/get.py +66 -0
- nextmv/cli/cloud/secrets/list.py +60 -0
- nextmv/cli/cloud/secrets/update.py +144 -0
- nextmv/cli/cloud/shadow/__init__.py +33 -0
- nextmv/cli/cloud/shadow/create.py +184 -0
- nextmv/cli/cloud/shadow/delete.py +64 -0
- nextmv/cli/cloud/shadow/get.py +61 -0
- nextmv/cli/cloud/shadow/list.py +63 -0
- nextmv/cli/cloud/shadow/metadata.py +66 -0
- nextmv/cli/cloud/shadow/start.py +43 -0
- nextmv/cli/cloud/shadow/stop.py +53 -0
- nextmv/cli/cloud/shadow/update.py +96 -0
- nextmv/cli/cloud/switchback/__init__.py +33 -0
- nextmv/cli/cloud/switchback/create.py +151 -0
- nextmv/cli/cloud/switchback/delete.py +64 -0
- nextmv/cli/cloud/switchback/get.py +62 -0
- nextmv/cli/cloud/switchback/list.py +63 -0
- nextmv/cli/cloud/switchback/metadata.py +68 -0
- nextmv/cli/cloud/switchback/start.py +43 -0
- nextmv/cli/cloud/switchback/stop.py +53 -0
- nextmv/cli/cloud/switchback/update.py +96 -0
- nextmv/cli/cloud/upload/__init__.py +22 -0
- nextmv/cli/cloud/upload/create.py +39 -0
- nextmv/cli/cloud/version/__init__.py +33 -0
- nextmv/cli/cloud/version/create.py +96 -0
- nextmv/cli/cloud/version/delete.py +61 -0
- nextmv/cli/cloud/version/exists.py +39 -0
- nextmv/cli/cloud/version/get.py +62 -0
- nextmv/cli/cloud/version/list.py +60 -0
- nextmv/cli/cloud/version/update.py +92 -0
- nextmv/cli/community/__init__.py +24 -0
- nextmv/cli/community/clone.py +20 -204
- nextmv/cli/community/list.py +61 -126
- nextmv/cli/configuration/__init__.py +23 -0
- nextmv/cli/configuration/config.py +103 -6
- nextmv/cli/configuration/create.py +17 -18
- nextmv/cli/configuration/delete.py +25 -13
- nextmv/cli/configuration/list.py +4 -4
- nextmv/cli/confirm.py +34 -0
- nextmv/cli/main.py +68 -36
- nextmv/cli/message.py +170 -0
- nextmv/cli/options.py +196 -0
- nextmv/cli/version.py +20 -1
- nextmv/cloud/__init__.py +17 -38
- nextmv/cloud/acceptance_test.py +20 -83
- nextmv/cloud/account.py +269 -30
- nextmv/cloud/application/__init__.py +898 -0
- nextmv/cloud/application/_acceptance.py +424 -0
- nextmv/cloud/application/_batch_scenario.py +845 -0
- nextmv/cloud/application/_ensemble.py +251 -0
- nextmv/cloud/application/_input_set.py +263 -0
- nextmv/cloud/application/_instance.py +289 -0
- nextmv/cloud/application/_managed_input.py +227 -0
- nextmv/cloud/application/_run.py +1393 -0
- nextmv/cloud/application/_secrets.py +294 -0
- nextmv/cloud/application/_shadow.py +320 -0
- nextmv/cloud/application/_switchback.py +332 -0
- nextmv/cloud/application/_utils.py +54 -0
- nextmv/cloud/application/_version.py +304 -0
- nextmv/cloud/batch_experiment.py +6 -2
- nextmv/cloud/community.py +446 -0
- nextmv/cloud/instance.py +11 -1
- nextmv/cloud/integration.py +8 -5
- nextmv/cloud/package.py +50 -9
- nextmv/cloud/shadow.py +254 -0
- nextmv/cloud/switchback.py +228 -0
- nextmv/deprecated.py +5 -3
- nextmv/input.py +20 -88
- nextmv/local/application.py +3 -15
- nextmv/local/runner.py +1 -1
- nextmv/model.py +50 -11
- nextmv/options.py +11 -256
- nextmv/output.py +0 -62
- nextmv/polling.py +54 -16
- nextmv/run.py +84 -37
- nextmv/status.py +1 -51
- {nextmv-0.40.0.dist-info → nextmv-1.0.0.dist-info}/METADATA +37 -11
- nextmv-1.0.0.dist-info/RECORD +185 -0
- nextmv-1.0.0.dist-info/entry_points.txt +2 -0
- nextmv/cli/community/community.py +0 -24
- nextmv/cli/configuration/configuration.py +0 -23
- nextmv/cli/error.py +0 -22
- nextmv/cloud/application.py +0 -4204
- nextmv-0.40.0.dist-info/RECORD +0 -66
- {nextmv-0.40.0.dist-info → nextmv-1.0.0.dist-info}/WHEEL +0 -0
- {nextmv-0.40.0.dist-info → nextmv-1.0.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Application mixin for managing app instances.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, Any
|
|
6
|
+
|
|
7
|
+
import requests
|
|
8
|
+
|
|
9
|
+
from nextmv.cloud.application._utils import _is_not_exist_error
|
|
10
|
+
from nextmv.cloud.instance import Instance, InstanceConfiguration
|
|
11
|
+
from nextmv.safe import safe_id
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from . import Application
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ApplicationInstanceMixin:
|
|
18
|
+
"""
|
|
19
|
+
Mixin class for managing app instances within an application.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def delete_instance(self: "Application", instance_id: str) -> None:
|
|
23
|
+
"""
|
|
24
|
+
Delete an instance.
|
|
25
|
+
|
|
26
|
+
Permanently removes the specified instance from the application.
|
|
27
|
+
|
|
28
|
+
Parameters
|
|
29
|
+
----------
|
|
30
|
+
instance_id : str
|
|
31
|
+
ID of the instance to delete.
|
|
32
|
+
|
|
33
|
+
Raises
|
|
34
|
+
------
|
|
35
|
+
requests.HTTPError
|
|
36
|
+
If the response status code is not 2xx.
|
|
37
|
+
|
|
38
|
+
Examples
|
|
39
|
+
--------
|
|
40
|
+
>>> app.delete_instance("prod-instance") # Permanently deletes the instance
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
_ = self.client.request(
|
|
44
|
+
method="DELETE",
|
|
45
|
+
endpoint=f"{self.endpoint}/instances/{instance_id}",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
def instance(self: "Application", instance_id: str) -> Instance:
|
|
49
|
+
"""
|
|
50
|
+
Get an instance.
|
|
51
|
+
|
|
52
|
+
Parameters
|
|
53
|
+
----------
|
|
54
|
+
instance_id : str
|
|
55
|
+
ID of the instance to retrieve.
|
|
56
|
+
|
|
57
|
+
Returns
|
|
58
|
+
-------
|
|
59
|
+
Instance
|
|
60
|
+
The requested instance details.
|
|
61
|
+
|
|
62
|
+
Raises
|
|
63
|
+
------
|
|
64
|
+
requests.HTTPError
|
|
65
|
+
If the response status code is not 2xx.
|
|
66
|
+
|
|
67
|
+
Examples
|
|
68
|
+
--------
|
|
69
|
+
>>> instance = app.instance("instance-123")
|
|
70
|
+
>>> print(instance.name)
|
|
71
|
+
'Production Instance'
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
response = self.client.request(
|
|
75
|
+
method="GET",
|
|
76
|
+
endpoint=f"{self.endpoint}/instances/{instance_id}",
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
return Instance.from_dict(response.json())
|
|
80
|
+
|
|
81
|
+
def instance_exists(self: "Application", instance_id: str) -> bool:
|
|
82
|
+
"""
|
|
83
|
+
Check if an instance exists.
|
|
84
|
+
|
|
85
|
+
Parameters
|
|
86
|
+
----------
|
|
87
|
+
instance_id : str
|
|
88
|
+
ID of the instance to check.
|
|
89
|
+
|
|
90
|
+
Returns
|
|
91
|
+
-------
|
|
92
|
+
bool
|
|
93
|
+
True if the instance exists, False otherwise.
|
|
94
|
+
|
|
95
|
+
Examples
|
|
96
|
+
--------
|
|
97
|
+
>>> app.instance_exists("instance-123")
|
|
98
|
+
True
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
try:
|
|
102
|
+
self.instance(instance_id=instance_id)
|
|
103
|
+
return True
|
|
104
|
+
except requests.HTTPError as e:
|
|
105
|
+
if _is_not_exist_error(e):
|
|
106
|
+
return False
|
|
107
|
+
raise e
|
|
108
|
+
|
|
109
|
+
def list_instances(self: "Application") -> list[Instance]:
|
|
110
|
+
"""
|
|
111
|
+
List all instances.
|
|
112
|
+
|
|
113
|
+
Returns
|
|
114
|
+
-------
|
|
115
|
+
list[Instance]
|
|
116
|
+
List of all instances associated with this application.
|
|
117
|
+
|
|
118
|
+
Raises
|
|
119
|
+
------
|
|
120
|
+
requests.HTTPError
|
|
121
|
+
If the response status code is not 2xx.
|
|
122
|
+
|
|
123
|
+
Examples
|
|
124
|
+
--------
|
|
125
|
+
>>> instances = app.list_instances()
|
|
126
|
+
>>> for instance in instances:
|
|
127
|
+
... print(instance.name)
|
|
128
|
+
'Development Instance'
|
|
129
|
+
'Production Instance'
|
|
130
|
+
"""
|
|
131
|
+
|
|
132
|
+
response = self.client.request(
|
|
133
|
+
method="GET",
|
|
134
|
+
endpoint=f"{self.endpoint}/instances",
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
return [Instance.from_dict(instance) for instance in response.json()]
|
|
138
|
+
|
|
139
|
+
def new_instance(
|
|
140
|
+
self: "Application",
|
|
141
|
+
version_id: str,
|
|
142
|
+
id: str | None = None,
|
|
143
|
+
name: str | None = None,
|
|
144
|
+
description: str | None = None,
|
|
145
|
+
configuration: InstanceConfiguration | None = None,
|
|
146
|
+
exist_ok: bool = False,
|
|
147
|
+
) -> Instance:
|
|
148
|
+
"""
|
|
149
|
+
Create a new instance and associate it with a version.
|
|
150
|
+
|
|
151
|
+
This method creates a new instance associated with a specific version
|
|
152
|
+
of the application. Instances are configurations of an application
|
|
153
|
+
version that can be executed.
|
|
154
|
+
|
|
155
|
+
Parameters
|
|
156
|
+
----------
|
|
157
|
+
version_id : str
|
|
158
|
+
ID of the version to associate the instance with.
|
|
159
|
+
id : str | None, default=None
|
|
160
|
+
ID of the instance. Will be generated if not provided.
|
|
161
|
+
name : str | None, default=None
|
|
162
|
+
Name of the instance. Will be generated if not provided.
|
|
163
|
+
description : Optional[str], default=None
|
|
164
|
+
Description of the instance.
|
|
165
|
+
configuration : Optional[InstanceConfiguration], default=None
|
|
166
|
+
Configuration to use for the instance. This can include resources,
|
|
167
|
+
timeouts, and other execution parameters.
|
|
168
|
+
exist_ok : bool, default=False
|
|
169
|
+
If True and an instance with the same ID already exists,
|
|
170
|
+
return the existing instance instead of creating a new one.
|
|
171
|
+
|
|
172
|
+
Returns
|
|
173
|
+
-------
|
|
174
|
+
Instance
|
|
175
|
+
The newly created (or existing) instance.
|
|
176
|
+
|
|
177
|
+
Raises
|
|
178
|
+
------
|
|
179
|
+
requests.HTTPError
|
|
180
|
+
If the response status code is not 2xx.
|
|
181
|
+
ValueError
|
|
182
|
+
If exist_ok is True and id is None.
|
|
183
|
+
|
|
184
|
+
Examples
|
|
185
|
+
--------
|
|
186
|
+
>>> # Create a new instance for a specific version
|
|
187
|
+
>>> instance = app.new_instance(
|
|
188
|
+
... version_id="version-123",
|
|
189
|
+
... id="prod-instance",
|
|
190
|
+
... name="Production Instance",
|
|
191
|
+
... description="Instance for production use"
|
|
192
|
+
... )
|
|
193
|
+
>>> print(instance.name)
|
|
194
|
+
'Production Instance'
|
|
195
|
+
"""
|
|
196
|
+
|
|
197
|
+
if exist_ok and (id is None or id == ""):
|
|
198
|
+
raise ValueError("If exist_ok is True, id must be provided")
|
|
199
|
+
|
|
200
|
+
if exist_ok and self.instance_exists(instance_id=id):
|
|
201
|
+
return self.instance(instance_id=id)
|
|
202
|
+
|
|
203
|
+
if id is None or id == "":
|
|
204
|
+
id = safe_id(prefix="instance")
|
|
205
|
+
if name is None or name == "":
|
|
206
|
+
name = id
|
|
207
|
+
|
|
208
|
+
payload = {
|
|
209
|
+
"id": id,
|
|
210
|
+
"name": name,
|
|
211
|
+
"version_id": version_id,
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if description is not None:
|
|
215
|
+
payload["description"] = description
|
|
216
|
+
if configuration is not None:
|
|
217
|
+
payload["configuration"] = configuration.to_dict()
|
|
218
|
+
|
|
219
|
+
response = self.client.request(
|
|
220
|
+
method="POST",
|
|
221
|
+
endpoint=f"{self.endpoint}/instances",
|
|
222
|
+
payload=payload,
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
return Instance.from_dict(response.json())
|
|
226
|
+
|
|
227
|
+
def update_instance(
|
|
228
|
+
self: "Application",
|
|
229
|
+
id: str,
|
|
230
|
+
name: str | None = None,
|
|
231
|
+
version_id: str | None = None,
|
|
232
|
+
description: str | None = None,
|
|
233
|
+
configuration: InstanceConfiguration | dict[str, Any] | None = None,
|
|
234
|
+
) -> Instance:
|
|
235
|
+
"""
|
|
236
|
+
Update an instance.
|
|
237
|
+
|
|
238
|
+
Parameters
|
|
239
|
+
----------
|
|
240
|
+
id : str
|
|
241
|
+
ID of the instance to update.
|
|
242
|
+
name : Optional[str], default=None
|
|
243
|
+
Optional name of the instance.
|
|
244
|
+
version_id : Optional[str], default=None
|
|
245
|
+
Optional ID of the version to associate the instance with.
|
|
246
|
+
description : Optional[str], default=None
|
|
247
|
+
Optional description of the instance.
|
|
248
|
+
configuration : Optional[InstanceConfiguration | dict[str, Any]], default=None
|
|
249
|
+
Optional configuration to use for the instance.
|
|
250
|
+
|
|
251
|
+
Returns
|
|
252
|
+
-------
|
|
253
|
+
Instance
|
|
254
|
+
The updated instance.
|
|
255
|
+
|
|
256
|
+
Raises
|
|
257
|
+
------
|
|
258
|
+
requests.HTTPError
|
|
259
|
+
If the response status code is not 2xx.
|
|
260
|
+
"""
|
|
261
|
+
|
|
262
|
+
# Get the instance as it currently exsits.
|
|
263
|
+
instance = self.instance(id)
|
|
264
|
+
instance_dict = instance.to_dict()
|
|
265
|
+
payload = instance_dict.copy()
|
|
266
|
+
|
|
267
|
+
if name is not None:
|
|
268
|
+
payload["name"] = name
|
|
269
|
+
if version_id is not None:
|
|
270
|
+
payload["version_id"] = version_id
|
|
271
|
+
if description is not None:
|
|
272
|
+
payload["description"] = description
|
|
273
|
+
if configuration is not None:
|
|
274
|
+
if isinstance(configuration, dict):
|
|
275
|
+
config_dict = configuration
|
|
276
|
+
elif isinstance(configuration, InstanceConfiguration):
|
|
277
|
+
config_dict = configuration.to_dict()
|
|
278
|
+
else:
|
|
279
|
+
raise TypeError("configuration must be either a dict or InstanceConfiguration object")
|
|
280
|
+
|
|
281
|
+
payload["configuration"] = config_dict
|
|
282
|
+
|
|
283
|
+
response = self.client.request(
|
|
284
|
+
method="PUT",
|
|
285
|
+
endpoint=f"{self.endpoint}/instances/{id}",
|
|
286
|
+
payload=payload,
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
return Instance.from_dict(response.json())
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Application mixin for handling app managed inputs.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING, Any
|
|
6
|
+
|
|
7
|
+
from nextmv.cloud.input_set import ManagedInput
|
|
8
|
+
from nextmv.input import InputFormat
|
|
9
|
+
from nextmv.output import OutputFormat
|
|
10
|
+
from nextmv.run import Format, FormatInput, FormatOutput
|
|
11
|
+
from nextmv.safe import safe_id
|
|
12
|
+
|
|
13
|
+
if TYPE_CHECKING:
|
|
14
|
+
from . import Application
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class ApplicationManagedInputMixin:
|
|
18
|
+
"""
|
|
19
|
+
Mixin class for handling app managed inputs within an application.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def delete_managed_input(self: "Application", managed_input_id: str) -> None:
|
|
23
|
+
"""
|
|
24
|
+
Delete a managed input.
|
|
25
|
+
|
|
26
|
+
Permanently removes the specified managed input from the application.
|
|
27
|
+
|
|
28
|
+
Parameters
|
|
29
|
+
----------
|
|
30
|
+
managed_input_id : str
|
|
31
|
+
ID of the managed input to delete.
|
|
32
|
+
|
|
33
|
+
Raises
|
|
34
|
+
------
|
|
35
|
+
requests.HTTPError
|
|
36
|
+
If the response status code is not 2xx.
|
|
37
|
+
|
|
38
|
+
Examples
|
|
39
|
+
--------
|
|
40
|
+
>>> app.delete_managed_input("inp_123456789") # Permanently deletes the managed input
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
_ = self.client.request(
|
|
44
|
+
method="DELETE",
|
|
45
|
+
endpoint=f"{self.endpoint}/inputs/{managed_input_id}",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
def list_managed_inputs(self: "Application") -> list[ManagedInput]:
|
|
49
|
+
"""
|
|
50
|
+
List all managed inputs.
|
|
51
|
+
|
|
52
|
+
Returns
|
|
53
|
+
-------
|
|
54
|
+
list[ManagedInput]
|
|
55
|
+
List of managed inputs.
|
|
56
|
+
|
|
57
|
+
Raises
|
|
58
|
+
------
|
|
59
|
+
requests.HTTPError
|
|
60
|
+
If the response status code is not 2xx.
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
response = self.client.request(
|
|
64
|
+
method="GET",
|
|
65
|
+
endpoint=f"{self.endpoint}/inputs",
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
return [ManagedInput.from_dict(managed_input) for managed_input in response.json()]
|
|
69
|
+
|
|
70
|
+
def managed_input(self: "Application", managed_input_id: str) -> ManagedInput:
|
|
71
|
+
"""
|
|
72
|
+
Get a managed input.
|
|
73
|
+
|
|
74
|
+
Parameters
|
|
75
|
+
----------
|
|
76
|
+
managed_input_id: str
|
|
77
|
+
ID of the managed input.
|
|
78
|
+
|
|
79
|
+
Returns
|
|
80
|
+
-------
|
|
81
|
+
ManagedInput
|
|
82
|
+
The managed input.
|
|
83
|
+
|
|
84
|
+
Raises
|
|
85
|
+
------
|
|
86
|
+
requests.HTTPError
|
|
87
|
+
If the response status code is not 2xx.
|
|
88
|
+
"""
|
|
89
|
+
|
|
90
|
+
response = self.client.request(
|
|
91
|
+
method="GET",
|
|
92
|
+
endpoint=f"{self.endpoint}/inputs/{managed_input_id}",
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
return ManagedInput.from_dict(response.json())
|
|
96
|
+
|
|
97
|
+
def new_managed_input(
|
|
98
|
+
self: "Application",
|
|
99
|
+
id: str | None = None,
|
|
100
|
+
name: str | None = None,
|
|
101
|
+
description: str | None = None,
|
|
102
|
+
upload_id: str | None = None,
|
|
103
|
+
run_id: str | None = None,
|
|
104
|
+
format: Format | dict[str, Any] | None = None,
|
|
105
|
+
) -> ManagedInput:
|
|
106
|
+
"""
|
|
107
|
+
Create a new managed input. There are two methods for creating a
|
|
108
|
+
managed input:
|
|
109
|
+
|
|
110
|
+
1. Specifying the `upload_id` parameter. You may use the `upload_url`
|
|
111
|
+
method to obtain the upload ID and the `upload_data` method
|
|
112
|
+
to upload the data to it.
|
|
113
|
+
2. Specifying the `run_id` parameter. The managed input will be
|
|
114
|
+
created from the run specified by the `run_id` parameter.
|
|
115
|
+
|
|
116
|
+
Either the `upload_id` or the `run_id` parameter must be specified.
|
|
117
|
+
|
|
118
|
+
Parameters
|
|
119
|
+
----------
|
|
120
|
+
id: Optional[str], default=None
|
|
121
|
+
ID of the managed input. Will be generated if not provided.
|
|
122
|
+
name: Optional[str], default=None
|
|
123
|
+
Name of the managed input. Will be generated if not provided.
|
|
124
|
+
description: Optional[str], default=None
|
|
125
|
+
Optional description of the managed input.
|
|
126
|
+
upload_id: Optional[str], default=None
|
|
127
|
+
ID of the upload to use for the managed input.
|
|
128
|
+
run_id: Optional[str], default=None
|
|
129
|
+
ID of the run to use for the managed input.
|
|
130
|
+
format: Optional[Format], default=None
|
|
131
|
+
Format of the managed input. Default will be formatted as `JSON`.
|
|
132
|
+
|
|
133
|
+
Returns
|
|
134
|
+
-------
|
|
135
|
+
ManagedInput
|
|
136
|
+
The new managed input.
|
|
137
|
+
|
|
138
|
+
Raises
|
|
139
|
+
------
|
|
140
|
+
requests.HTTPError
|
|
141
|
+
If the response status code is not 2xx.
|
|
142
|
+
ValueError
|
|
143
|
+
If neither the `upload_id` nor the `run_id` parameter is
|
|
144
|
+
specified.
|
|
145
|
+
"""
|
|
146
|
+
|
|
147
|
+
if upload_id is None and run_id is None:
|
|
148
|
+
raise ValueError("Either upload_id or run_id must be specified")
|
|
149
|
+
|
|
150
|
+
if id is None or id == "":
|
|
151
|
+
id = safe_id(prefix="managed-input")
|
|
152
|
+
if name is None or name == "":
|
|
153
|
+
name = id
|
|
154
|
+
|
|
155
|
+
payload = {
|
|
156
|
+
"id": id,
|
|
157
|
+
"name": name,
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if description is not None:
|
|
161
|
+
payload["description"] = description
|
|
162
|
+
if upload_id is not None:
|
|
163
|
+
payload["upload_id"] = upload_id
|
|
164
|
+
if run_id is not None:
|
|
165
|
+
payload["run_id"] = run_id
|
|
166
|
+
|
|
167
|
+
if format is not None:
|
|
168
|
+
payload["format"] = format.to_dict() if isinstance(format, Format) else format
|
|
169
|
+
else:
|
|
170
|
+
payload["format"] = Format(
|
|
171
|
+
format_input=FormatInput(input_type=InputFormat.JSON),
|
|
172
|
+
format_output=FormatOutput(output_type=OutputFormat.JSON),
|
|
173
|
+
).to_dict()
|
|
174
|
+
|
|
175
|
+
response = self.client.request(
|
|
176
|
+
method="POST",
|
|
177
|
+
endpoint=f"{self.endpoint}/inputs",
|
|
178
|
+
payload=payload,
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
return ManagedInput.from_dict(response.json())
|
|
182
|
+
|
|
183
|
+
def update_managed_input(
|
|
184
|
+
self: "Application",
|
|
185
|
+
managed_input_id: str,
|
|
186
|
+
name: str | None = None,
|
|
187
|
+
description: str | None = None,
|
|
188
|
+
) -> ManagedInput:
|
|
189
|
+
"""
|
|
190
|
+
Update a managed input.
|
|
191
|
+
|
|
192
|
+
Parameters
|
|
193
|
+
----------
|
|
194
|
+
managed_input_id : str
|
|
195
|
+
ID of the managed input to update.
|
|
196
|
+
name : Optional[str], default=None
|
|
197
|
+
Optional new name for the managed input.
|
|
198
|
+
description : Optional[str], default=None
|
|
199
|
+
Optional new description for the managed input.
|
|
200
|
+
|
|
201
|
+
Returns
|
|
202
|
+
-------
|
|
203
|
+
ManagedInput
|
|
204
|
+
The updated managed input.
|
|
205
|
+
|
|
206
|
+
Raises
|
|
207
|
+
------
|
|
208
|
+
requests.HTTPError
|
|
209
|
+
If the response status code is not 2xx.
|
|
210
|
+
"""
|
|
211
|
+
|
|
212
|
+
managed_input = self.managed_input(managed_input_id)
|
|
213
|
+
managed_input_dict = managed_input.to_dict()
|
|
214
|
+
payload = managed_input_dict.copy()
|
|
215
|
+
|
|
216
|
+
if name is not None:
|
|
217
|
+
payload["name"] = name
|
|
218
|
+
if description is not None:
|
|
219
|
+
payload["description"] = description
|
|
220
|
+
|
|
221
|
+
response = self.client.request(
|
|
222
|
+
method="PUT",
|
|
223
|
+
endpoint=f"{self.endpoint}/inputs/{managed_input_id}",
|
|
224
|
+
payload=payload,
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
return ManagedInput.from_dict(response.json())
|