nextmv 0.28.5__py3-none-any.whl → 0.29.0.dev0__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/__init__.py +8 -0
- nextmv/cloud/application.py +125 -13
- nextmv/cloud/client.py +28 -9
- nextmv/cloud/manifest.py +142 -14
- nextmv/cloud/package.py +1 -1
- nextmv/input.py +419 -6
- nextmv/model.py +12 -3
- nextmv/options.py +88 -0
- nextmv/output.py +535 -51
- {nextmv-0.28.5.dist-info → nextmv-0.29.0.dev0.dist-info}/METADATA +1 -1
- {nextmv-0.28.5.dist-info → nextmv-0.29.0.dev0.dist-info}/RECORD +14 -14
- {nextmv-0.28.5.dist-info → nextmv-0.29.0.dev0.dist-info}/WHEEL +0 -0
- {nextmv-0.28.5.dist-info → nextmv-0.29.0.dev0.dist-info}/licenses/LICENSE +0 -0
nextmv/options.py
CHANGED
|
@@ -215,6 +215,18 @@ class Option:
|
|
|
215
215
|
perform validation on these attributes. For example, the maximum length
|
|
216
216
|
of a string or the maximum value of an integer. These additional
|
|
217
217
|
attributes will be shown in the help message of the `Options`.
|
|
218
|
+
control_type : str, optional
|
|
219
|
+
The type of control to use for the option in the Nextmv Cloud UI. This is
|
|
220
|
+
useful for defining how the option should be presented in the Nextmv
|
|
221
|
+
Cloud UI. Current control types include "input", "select", "slider", and
|
|
222
|
+
"toggle". This attribute is not used in the local `Options` class, but '
|
|
223
|
+
it is used in the Nextmv Cloud UI to define the type of control to use for
|
|
224
|
+
the option. This will be validated by the Nextmv Cloud, and availability
|
|
225
|
+
is based on options_type.
|
|
226
|
+
hidden_from : list[str], optional
|
|
227
|
+
A list of team roles to which this option will be hidden in the UI. For
|
|
228
|
+
example, if you want to hide an option from the "operator" role, you can
|
|
229
|
+
pass `hidden_from=["operator"]`.
|
|
218
230
|
|
|
219
231
|
Examples
|
|
220
232
|
--------
|
|
@@ -256,6 +268,22 @@ class Option:
|
|
|
256
268
|
a string or the maximum value of an integer. These additional attributes
|
|
257
269
|
will be shown in the help message of the `Options`.
|
|
258
270
|
"""
|
|
271
|
+
control_type: Optional[str] = None
|
|
272
|
+
"""
|
|
273
|
+
The type of control to use for the option in the Nextmv Cloud UI. This is
|
|
274
|
+
useful for defining how the option should be presented in the Nextmv
|
|
275
|
+
Cloud UI. Current control types include "input", "select", "slider", and
|
|
276
|
+
"toggle". This attribute is not used in the local `Options` class, but it
|
|
277
|
+
is used in the Nextmv Cloud UI to define the type of control to use for
|
|
278
|
+
the option. This will be validated by the Nextmv Cloud, and availability
|
|
279
|
+
is based on options_type.
|
|
280
|
+
"""
|
|
281
|
+
hidden_from: Optional[list[str]] = None
|
|
282
|
+
"""
|
|
283
|
+
A list of team roles for which this option will be hidden in the UI. For
|
|
284
|
+
example, if you want to hide an option from the "operator" role, you can
|
|
285
|
+
pass `hidden_from=["operator"]`.
|
|
286
|
+
"""
|
|
259
287
|
|
|
260
288
|
@classmethod
|
|
261
289
|
def from_dict(cls, data: dict[str, Any]) -> "Option":
|
|
@@ -294,6 +322,8 @@ class Option:
|
|
|
294
322
|
required=data.get("required", False),
|
|
295
323
|
choices=data.get("choices"),
|
|
296
324
|
additional_attributes=data.get("additional_attributes"),
|
|
325
|
+
control_type=data.get("control_type"),
|
|
326
|
+
hidden_from=data.get("hidden_from"),
|
|
297
327
|
)
|
|
298
328
|
|
|
299
329
|
def to_dict(self) -> dict[str, Any]:
|
|
@@ -323,6 +353,8 @@ class Option:
|
|
|
323
353
|
"required": self.required,
|
|
324
354
|
"choices": self.choices,
|
|
325
355
|
"additional_attributes": self.additional_attributes,
|
|
356
|
+
"control_type": self.control_type,
|
|
357
|
+
"hidden_from": self.hidden_from,
|
|
326
358
|
}
|
|
327
359
|
|
|
328
360
|
|
|
@@ -942,6 +974,12 @@ class Options:
|
|
|
942
974
|
if isinstance(option, Option) and option.additional_attributes is not None:
|
|
943
975
|
description += f" (additional attributes: {option.additional_attributes})"
|
|
944
976
|
|
|
977
|
+
if isinstance(option, Option) and option.control_type is not None:
|
|
978
|
+
description += f" (control type: {option.control_type})"
|
|
979
|
+
|
|
980
|
+
if isinstance(option, Option) and option.hidden_from:
|
|
981
|
+
description += f" (hidden from: {', '.join(option.hidden_from)})"
|
|
982
|
+
|
|
945
983
|
if option.description is not None and option.description != "":
|
|
946
984
|
description += f": {option.description}"
|
|
947
985
|
|
|
@@ -1012,3 +1050,53 @@ class Options:
|
|
|
1012
1050
|
return option.param_type
|
|
1013
1051
|
else:
|
|
1014
1052
|
raise TypeError(f"expected an <Option> (or deprecated <Parameter>) object, but got {type(option)}")
|
|
1053
|
+
|
|
1054
|
+
class OptionsEnforcement:
|
|
1055
|
+
"""
|
|
1056
|
+
OptionsEnforcement is a class that provides rules for how the options
|
|
1057
|
+
are enforced on Nextmv Cloud.
|
|
1058
|
+
|
|
1059
|
+
This class is used to enforce options in the Nextmv Cloud. It is not used
|
|
1060
|
+
in the local `Options` class, but it is used to control validation when a run
|
|
1061
|
+
is submitted to the Nextmv Cloud.
|
|
1062
|
+
|
|
1063
|
+
Parameters
|
|
1064
|
+
----------
|
|
1065
|
+
strict: bool default = False
|
|
1066
|
+
If True, the options additional options that are configured will not
|
|
1067
|
+
pass validation. This means that only the options that are defined in the
|
|
1068
|
+
`Options` class will be allowed. If False, additional options that are
|
|
1069
|
+
not defined in the `Options` class will be allowed.
|
|
1070
|
+
validation_enforce: bool default = False
|
|
1071
|
+
If True, the options will be validated against your option configuration
|
|
1072
|
+
validation rules. If False, the options will not be validated.
|
|
1073
|
+
"""
|
|
1074
|
+
|
|
1075
|
+
strict: bool = False
|
|
1076
|
+
"""
|
|
1077
|
+
If True, the options additional options that are configured will not
|
|
1078
|
+
pass validation. This means that only the options that are defined in the
|
|
1079
|
+
`Options` class will be allowed. If False, additional options that are
|
|
1080
|
+
not defined in the `Options` class will be allowed.
|
|
1081
|
+
"""
|
|
1082
|
+
validation_enforce: bool = False
|
|
1083
|
+
"""
|
|
1084
|
+
If True, the options will be validated against your option configuration
|
|
1085
|
+
validation rules. If False, the options will not be validated.
|
|
1086
|
+
"""
|
|
1087
|
+
|
|
1088
|
+
def __init__(self, strict: bool = False, validation_enforce: bool = False):
|
|
1089
|
+
"""
|
|
1090
|
+
Initialize an OptionsEnforcement instance with the provided rules.
|
|
1091
|
+
|
|
1092
|
+
Parameters
|
|
1093
|
+
----------
|
|
1094
|
+
strict : bool, optional
|
|
1095
|
+
If True, only options defined in the `Options` class will be allowed.
|
|
1096
|
+
Defaults to False.
|
|
1097
|
+
validation_enforced : bool, optional
|
|
1098
|
+
If True, options will be validated against the configuration rules.
|
|
1099
|
+
Defaults to False.
|
|
1100
|
+
"""
|
|
1101
|
+
self.strict = strict
|
|
1102
|
+
self.validation_enforce = validation_enforce
|