nextmv 0.18.0__py3-none-any.whl → 1.0.0.dev2__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.
Files changed (175) hide show
  1. nextmv/__about__.py +1 -1
  2. nextmv/__entrypoint__.py +8 -13
  3. nextmv/__init__.py +53 -0
  4. nextmv/_serialization.py +96 -0
  5. nextmv/base_model.py +54 -9
  6. nextmv/cli/CONTRIBUTING.md +511 -0
  7. nextmv/cli/__init__.py +0 -0
  8. nextmv/cli/cloud/__init__.py +47 -0
  9. nextmv/cli/cloud/acceptance/__init__.py +27 -0
  10. nextmv/cli/cloud/acceptance/create.py +393 -0
  11. nextmv/cli/cloud/acceptance/delete.py +68 -0
  12. nextmv/cli/cloud/acceptance/get.py +104 -0
  13. nextmv/cli/cloud/acceptance/list.py +62 -0
  14. nextmv/cli/cloud/acceptance/update.py +95 -0
  15. nextmv/cli/cloud/account/__init__.py +28 -0
  16. nextmv/cli/cloud/account/create.py +83 -0
  17. nextmv/cli/cloud/account/delete.py +60 -0
  18. nextmv/cli/cloud/account/get.py +66 -0
  19. nextmv/cli/cloud/account/update.py +70 -0
  20. nextmv/cli/cloud/app/__init__.py +35 -0
  21. nextmv/cli/cloud/app/create.py +141 -0
  22. nextmv/cli/cloud/app/delete.py +58 -0
  23. nextmv/cli/cloud/app/exists.py +44 -0
  24. nextmv/cli/cloud/app/get.py +66 -0
  25. nextmv/cli/cloud/app/list.py +61 -0
  26. nextmv/cli/cloud/app/push.py +137 -0
  27. nextmv/cli/cloud/app/update.py +124 -0
  28. nextmv/cli/cloud/batch/__init__.py +29 -0
  29. nextmv/cli/cloud/batch/create.py +454 -0
  30. nextmv/cli/cloud/batch/delete.py +68 -0
  31. nextmv/cli/cloud/batch/get.py +104 -0
  32. nextmv/cli/cloud/batch/list.py +63 -0
  33. nextmv/cli/cloud/batch/metadata.py +66 -0
  34. nextmv/cli/cloud/batch/update.py +95 -0
  35. nextmv/cli/cloud/data/__init__.py +26 -0
  36. nextmv/cli/cloud/data/upload.py +162 -0
  37. nextmv/cli/cloud/ensemble/__init__.py +31 -0
  38. nextmv/cli/cloud/ensemble/create.py +414 -0
  39. nextmv/cli/cloud/ensemble/delete.py +67 -0
  40. nextmv/cli/cloud/ensemble/get.py +65 -0
  41. nextmv/cli/cloud/ensemble/update.py +103 -0
  42. nextmv/cli/cloud/input_set/__init__.py +30 -0
  43. nextmv/cli/cloud/input_set/create.py +170 -0
  44. nextmv/cli/cloud/input_set/get.py +63 -0
  45. nextmv/cli/cloud/input_set/list.py +63 -0
  46. nextmv/cli/cloud/input_set/update.py +123 -0
  47. nextmv/cli/cloud/instance/__init__.py +35 -0
  48. nextmv/cli/cloud/instance/create.py +290 -0
  49. nextmv/cli/cloud/instance/delete.py +62 -0
  50. nextmv/cli/cloud/instance/exists.py +39 -0
  51. nextmv/cli/cloud/instance/get.py +62 -0
  52. nextmv/cli/cloud/instance/list.py +60 -0
  53. nextmv/cli/cloud/instance/update.py +216 -0
  54. nextmv/cli/cloud/managed_input/__init__.py +31 -0
  55. nextmv/cli/cloud/managed_input/create.py +146 -0
  56. nextmv/cli/cloud/managed_input/delete.py +65 -0
  57. nextmv/cli/cloud/managed_input/get.py +63 -0
  58. nextmv/cli/cloud/managed_input/list.py +60 -0
  59. nextmv/cli/cloud/managed_input/update.py +97 -0
  60. nextmv/cli/cloud/run/__init__.py +37 -0
  61. nextmv/cli/cloud/run/cancel.py +37 -0
  62. nextmv/cli/cloud/run/create.py +530 -0
  63. nextmv/cli/cloud/run/get.py +199 -0
  64. nextmv/cli/cloud/run/input.py +86 -0
  65. nextmv/cli/cloud/run/list.py +80 -0
  66. nextmv/cli/cloud/run/logs.py +167 -0
  67. nextmv/cli/cloud/run/metadata.py +67 -0
  68. nextmv/cli/cloud/run/track.py +501 -0
  69. nextmv/cli/cloud/scenario/__init__.py +29 -0
  70. nextmv/cli/cloud/scenario/create.py +451 -0
  71. nextmv/cli/cloud/scenario/delete.py +65 -0
  72. nextmv/cli/cloud/scenario/get.py +102 -0
  73. nextmv/cli/cloud/scenario/list.py +63 -0
  74. nextmv/cli/cloud/scenario/metadata.py +67 -0
  75. nextmv/cli/cloud/scenario/update.py +93 -0
  76. nextmv/cli/cloud/secrets/__init__.py +33 -0
  77. nextmv/cli/cloud/secrets/create.py +206 -0
  78. nextmv/cli/cloud/secrets/delete.py +67 -0
  79. nextmv/cli/cloud/secrets/get.py +66 -0
  80. nextmv/cli/cloud/secrets/list.py +60 -0
  81. nextmv/cli/cloud/secrets/update.py +147 -0
  82. nextmv/cli/cloud/shadow/__init__.py +33 -0
  83. nextmv/cli/cloud/shadow/create.py +184 -0
  84. nextmv/cli/cloud/shadow/delete.py +68 -0
  85. nextmv/cli/cloud/shadow/get.py +61 -0
  86. nextmv/cli/cloud/shadow/list.py +63 -0
  87. nextmv/cli/cloud/shadow/metadata.py +66 -0
  88. nextmv/cli/cloud/shadow/start.py +43 -0
  89. nextmv/cli/cloud/shadow/stop.py +43 -0
  90. nextmv/cli/cloud/shadow/update.py +95 -0
  91. nextmv/cli/cloud/upload/__init__.py +22 -0
  92. nextmv/cli/cloud/upload/create.py +39 -0
  93. nextmv/cli/cloud/version/__init__.py +33 -0
  94. nextmv/cli/cloud/version/create.py +97 -0
  95. nextmv/cli/cloud/version/delete.py +62 -0
  96. nextmv/cli/cloud/version/exists.py +39 -0
  97. nextmv/cli/cloud/version/get.py +62 -0
  98. nextmv/cli/cloud/version/list.py +60 -0
  99. nextmv/cli/cloud/version/update.py +92 -0
  100. nextmv/cli/community/__init__.py +24 -0
  101. nextmv/cli/community/clone.py +270 -0
  102. nextmv/cli/community/list.py +265 -0
  103. nextmv/cli/configuration/__init__.py +23 -0
  104. nextmv/cli/configuration/config.py +195 -0
  105. nextmv/cli/configuration/create.py +94 -0
  106. nextmv/cli/configuration/delete.py +67 -0
  107. nextmv/cli/configuration/list.py +77 -0
  108. nextmv/cli/main.py +188 -0
  109. nextmv/cli/message.py +153 -0
  110. nextmv/cli/options.py +206 -0
  111. nextmv/cli/version.py +38 -0
  112. nextmv/cloud/__init__.py +71 -17
  113. nextmv/cloud/acceptance_test.py +757 -51
  114. nextmv/cloud/account.py +406 -17
  115. nextmv/cloud/application/__init__.py +957 -0
  116. nextmv/cloud/application/_acceptance.py +419 -0
  117. nextmv/cloud/application/_batch_scenario.py +860 -0
  118. nextmv/cloud/application/_ensemble.py +251 -0
  119. nextmv/cloud/application/_input_set.py +227 -0
  120. nextmv/cloud/application/_instance.py +289 -0
  121. nextmv/cloud/application/_managed_input.py +227 -0
  122. nextmv/cloud/application/_run.py +1393 -0
  123. nextmv/cloud/application/_secrets.py +294 -0
  124. nextmv/cloud/application/_shadow.py +314 -0
  125. nextmv/cloud/application/_utils.py +54 -0
  126. nextmv/cloud/application/_version.py +303 -0
  127. nextmv/cloud/assets.py +48 -0
  128. nextmv/cloud/batch_experiment.py +294 -33
  129. nextmv/cloud/client.py +307 -66
  130. nextmv/cloud/ensemble.py +247 -0
  131. nextmv/cloud/input_set.py +120 -2
  132. nextmv/cloud/instance.py +133 -8
  133. nextmv/cloud/integration.py +533 -0
  134. nextmv/cloud/package.py +168 -53
  135. nextmv/cloud/scenario.py +410 -0
  136. nextmv/cloud/secrets.py +234 -0
  137. nextmv/cloud/shadow.py +190 -0
  138. nextmv/cloud/url.py +73 -0
  139. nextmv/cloud/version.py +132 -4
  140. nextmv/default_app/.gitignore +1 -0
  141. nextmv/default_app/README.md +32 -0
  142. nextmv/default_app/app.yaml +12 -0
  143. nextmv/default_app/input.json +5 -0
  144. nextmv/default_app/main.py +37 -0
  145. nextmv/default_app/requirements.txt +2 -0
  146. nextmv/default_app/src/__init__.py +0 -0
  147. nextmv/default_app/src/visuals.py +36 -0
  148. nextmv/deprecated.py +47 -0
  149. nextmv/input.py +861 -90
  150. nextmv/local/__init__.py +5 -0
  151. nextmv/local/application.py +1251 -0
  152. nextmv/local/executor.py +1042 -0
  153. nextmv/local/geojson_handler.py +323 -0
  154. nextmv/local/local.py +97 -0
  155. nextmv/local/plotly_handler.py +61 -0
  156. nextmv/local/runner.py +274 -0
  157. nextmv/logger.py +80 -9
  158. nextmv/manifest.py +1466 -0
  159. nextmv/model.py +241 -66
  160. nextmv/options.py +708 -115
  161. nextmv/output.py +1301 -274
  162. nextmv/polling.py +325 -0
  163. nextmv/run.py +1702 -0
  164. nextmv/safe.py +145 -0
  165. nextmv/status.py +122 -0
  166. nextmv-1.0.0.dev2.dist-info/METADATA +311 -0
  167. nextmv-1.0.0.dev2.dist-info/RECORD +170 -0
  168. {nextmv-0.18.0.dist-info → nextmv-1.0.0.dev2.dist-info}/WHEEL +1 -1
  169. nextmv-1.0.0.dev2.dist-info/entry_points.txt +2 -0
  170. nextmv/cloud/application.py +0 -1405
  171. nextmv/cloud/manifest.py +0 -234
  172. nextmv/cloud/status.py +0 -29
  173. nextmv-0.18.0.dist-info/METADATA +0 -770
  174. nextmv-0.18.0.dist-info/RECORD +0 -25
  175. {nextmv-0.18.0.dist-info → nextmv-1.0.0.dev2.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,290 @@
1
+ """
2
+ This module defines the cloud instance create command for the Nextmv CLI.
3
+ """
4
+
5
+ from typing import Annotated
6
+
7
+ import typer
8
+
9
+ from nextmv.cli.configuration.config import build_app
10
+ from nextmv.cli.message import enum_values, error, in_progress, print_json
11
+ from nextmv.cli.options import AppIDOption, ProfileOption, VersionIDOption
12
+ from nextmv.cloud.instance import InstanceConfiguration
13
+ from nextmv.input import InputFormat
14
+ from nextmv.run import Format, FormatInput, RunQueuing
15
+
16
+ # Set up subcommand application.
17
+ app = typer.Typer()
18
+
19
+
20
+ @app.command()
21
+ def create(
22
+ # Options for creating the instance.
23
+ app_id: AppIDOption,
24
+ version_id: VersionIDOption,
25
+ description: Annotated[
26
+ str | None,
27
+ typer.Option(
28
+ "--description",
29
+ "-d",
30
+ help="An optional description for the instance.",
31
+ metavar="DESCRIPTION",
32
+ ),
33
+ ] = None,
34
+ exist_ok: Annotated[
35
+ bool,
36
+ typer.Option(
37
+ "--exist-ok",
38
+ "-e",
39
+ help="If an instance with the given ID already exists, do not raise an error, and simply return it.",
40
+ ),
41
+ ] = False,
42
+ instance_id: Annotated[
43
+ str | None,
44
+ typer.Option(
45
+ "--instance-id",
46
+ "-i",
47
+ help="The ID to assign to the new instance. If not provided, a random ID will be generated.",
48
+ envvar="NEXTMV_INSTANCE_ID",
49
+ metavar="INSTANCE_ID",
50
+ ),
51
+ ] = None,
52
+ name: Annotated[
53
+ str | None,
54
+ typer.Option(
55
+ "--name",
56
+ "-n",
57
+ help="A name for the instance. If a name is not provided, the instance ID will be used as the name.",
58
+ metavar="NAME",
59
+ ),
60
+ ] = None,
61
+ # Options for configuring the instance.
62
+ content_format: Annotated[
63
+ InputFormat | None,
64
+ typer.Option(
65
+ "--content-format",
66
+ "-c",
67
+ help=f"The content format of the instance to create. Allowed values are: {enum_values(InputFormat)}.",
68
+ metavar="CONTENT_FORMAT",
69
+ rich_help_panel="Instance configuration",
70
+ ),
71
+ ] = None,
72
+ execution_class: Annotated[
73
+ str | None,
74
+ typer.Option(
75
+ "--execution-class",
76
+ "-x",
77
+ help="The execution class to use for the instance.",
78
+ metavar="EXECUTION_CLASS",
79
+ rich_help_panel="Instance configuration",
80
+ ),
81
+ ] = None,
82
+ integration_id: Annotated[
83
+ str | None,
84
+ typer.Option(
85
+ help="The integration ID to use for the runs of the instance, if applicable.",
86
+ metavar="INTEGRATION_ID",
87
+ rich_help_panel="Instance configuration",
88
+ ),
89
+ ] = None,
90
+ no_queuing: Annotated[
91
+ bool,
92
+ typer.Option(
93
+ "--no-queuing",
94
+ help="Do not queue when running the instance. Default is [magenta]False[/magenta], "
95
+ "meaning the instance's run [italic]will[/italic] be queued.",
96
+ rich_help_panel="Instance configuration",
97
+ ),
98
+ ] = False,
99
+ options: Annotated[
100
+ list[str] | None,
101
+ typer.Option(
102
+ "--options",
103
+ "-o",
104
+ help="Options to always use when running the instance. Format: [magenta]key=value[/magenta]. "
105
+ "Pass multiple options by repeating the flag, or separating with commas.",
106
+ metavar="KEY=VALUE",
107
+ rich_help_panel="Instance configuration",
108
+ ),
109
+ ] = None,
110
+ priority: Annotated[
111
+ int,
112
+ typer.Option(
113
+ help="The priority of the runs in the instance. "
114
+ "Priority is between 1 and 10, with 1 being the highest priority.",
115
+ metavar="PRIORITY",
116
+ rich_help_panel="Instance configuration",
117
+ ),
118
+ ] = 6,
119
+ secret_collection_id: Annotated[
120
+ str | None,
121
+ typer.Option(
122
+ "--secret-collection-id",
123
+ "-s",
124
+ help="The secret collection ID to use for the instance, if applicable.",
125
+ metavar="SECRET_COLLECTION_ID",
126
+ rich_help_panel="Instance configuration",
127
+ ),
128
+ ] = None,
129
+ profile: ProfileOption = None,
130
+ ) -> None:
131
+ """
132
+ Create a new Nextmv Cloud application instance.
133
+
134
+ Use the [code]--exist-ok[/code] flag to avoid errors when creating an
135
+ instance with an ID that already exists. This is useful for scripts that
136
+ need to ensure an instance exists without worrying about whether it was
137
+ created previously.
138
+
139
+ [bold][underline]Examples[/underline][/bold]
140
+
141
+ - Create an instance for application [magenta]hare-app[/magenta] version [magenta]v1[/magenta].
142
+ $ [green]nextmv cloud instance create --app-id hare-app --version-id v1 --instance-id prod[/green]
143
+
144
+ - Create an instance with a specific name.
145
+ $ [green]nextmv cloud instance create --app-id hare-app --version-id v1 \\
146
+ --instance-id prod --name "Production Instance"[/green]
147
+
148
+ - Create an instance with a name and description.
149
+ $ [green]nextmv cloud instance create --app-id hare-app --version-id v1 \\
150
+ --instance-id prod --name "Production Instance" \\
151
+ --description "Instance for production routing jobs"[/green]
152
+
153
+ - Create an instance, or get it if it already exists.
154
+ $ [green]nextmv cloud instance create --app-id hare-app --version-id v1 \\
155
+ --instance-id prod --exist-ok[/green]
156
+
157
+ - Create an instance with configuration options.
158
+ $ [green]nextmv cloud instance create --app-id hare-app --version-id v1 \\
159
+ --instance-id prod --execution-class 6c9500mb870s --priority 1[/green]
160
+
161
+ - Create an instance with runtime options.
162
+ $ [green]nextmv cloud instance create --app-id hare-app --version-id v1 \\
163
+ --instance-id prod --options max_duration=30 --options timeout=60[/green]
164
+ """
165
+
166
+ cloud_app = build_app(app_id=app_id, profile=profile)
167
+ if exist_ok:
168
+ in_progress(msg="Creating or getting instance...")
169
+ else:
170
+ in_progress(msg="Creating instance...")
171
+
172
+ # Build the instance options from the CLI options
173
+ instance_options = build_options(options)
174
+
175
+ # Build the instance configuration
176
+ instance_config = build_config(
177
+ priority=priority,
178
+ no_queuing=no_queuing,
179
+ content_format=content_format,
180
+ execution_class=execution_class,
181
+ integration_id=integration_id,
182
+ options=instance_options,
183
+ secret_collection_id=secret_collection_id,
184
+ )
185
+
186
+ instance = cloud_app.new_instance(
187
+ version_id=version_id,
188
+ id=instance_id,
189
+ name=name,
190
+ description=description,
191
+ configuration=instance_config,
192
+ exist_ok=exist_ok,
193
+ )
194
+ print_json(instance.to_dict())
195
+
196
+
197
+ def build_options(options: list[str] | None) -> dict[str, str] | None:
198
+ """
199
+ Builds the instance options. One can pass options by either using the flag
200
+ multiple times or by separating with commas in the same flag. A
201
+ combination of both is also possible.
202
+
203
+ Parameters
204
+ ----------
205
+ options : list[str] | None
206
+ The list of instance options as strings.
207
+
208
+ Returns
209
+ -------
210
+ dict[str, str]
211
+ The built instance options.
212
+ """
213
+
214
+ if options is None:
215
+ return None
216
+
217
+ instance_options = {}
218
+ for opt in options:
219
+ # It is possible to pass multiple options separated by commas. The
220
+ # default way though is to use the flag multiple times to specify
221
+ # different options.
222
+ sub_opts = opt.split(",")
223
+ for sub_opt in sub_opts:
224
+ key_value = sub_opt.split("=", 1)
225
+ if len(key_value) != 2:
226
+ error(f"Invalid option format: {sub_opt}. Expected format is [magenta]key=value[/magenta].")
227
+
228
+ key, value = key_value
229
+ instance_options[key] = value
230
+
231
+ return instance_options
232
+
233
+
234
+ def build_config(
235
+ priority: int,
236
+ no_queuing: bool,
237
+ content_format: InputFormat | None = None,
238
+ execution_class: str | None = None,
239
+ integration_id: str | None = None,
240
+ options: dict | None = None,
241
+ secret_collection_id: str | None = None,
242
+ ) -> InstanceConfiguration:
243
+ """
244
+ Builds the instance configuration for the new instance.
245
+
246
+ Parameters
247
+ ----------
248
+ priority : int
249
+ The priority of the instance.
250
+ no_queuing : bool
251
+ Whether to disable queuing for the instance.
252
+ content_format : InputFormat | None
253
+ The content format for the instance, if applicable.
254
+ execution_class : str | None
255
+ The execution class to use for the instance, if applicable.
256
+ integration_id : str | None
257
+ The integration ID to use for the instance, if applicable.
258
+ options : dict | None
259
+ The runtime options for the instance, if applicable.
260
+ secret_collection_id : str | None
261
+ The secret collection ID to use for the instance, if applicable.
262
+
263
+ Returns
264
+ -------
265
+ InstanceConfiguration
266
+ The built instance configuration.
267
+ """
268
+
269
+ config = InstanceConfiguration(
270
+ queuing=RunQueuing(
271
+ priority=priority,
272
+ disabled=no_queuing,
273
+ ),
274
+ )
275
+ if execution_class is not None:
276
+ config.execution_class = execution_class
277
+ if options is not None:
278
+ config.options = options
279
+ if secret_collection_id is not None:
280
+ config.secrets_collection_id = secret_collection_id
281
+ if integration_id is not None:
282
+ config.integration_id = integration_id
283
+ if content_format is not None:
284
+ config.format = Format(
285
+ format_input=FormatInput(
286
+ input_type=InputFormat(content_format),
287
+ ),
288
+ )
289
+
290
+ return config
@@ -0,0 +1,62 @@
1
+ """
2
+ This module defines the cloud instance delete command for the Nextmv CLI.
3
+ """
4
+
5
+ from typing import Annotated
6
+
7
+ import typer
8
+ from rich.prompt import Confirm
9
+
10
+ from nextmv.cli.configuration.config import build_app
11
+ from nextmv.cli.message import info, success
12
+ from nextmv.cli.options import AppIDOption, InstanceIDOption, ProfileOption
13
+
14
+ # Set up subcommand application.
15
+ app = typer.Typer()
16
+
17
+
18
+ @app.command()
19
+ def delete(
20
+ app_id: AppIDOption,
21
+ instance_id: InstanceIDOption,
22
+ yes: Annotated[
23
+ bool,
24
+ typer.Option(
25
+ "--yes",
26
+ "-y",
27
+ help="Agree to deletion confirmation prompt. Useful for non-interactive sessions.",
28
+ ),
29
+ ] = False,
30
+ profile: ProfileOption = None,
31
+ ) -> None:
32
+ """
33
+ Deletes a Nextmv Cloud application instance.
34
+
35
+ This action is permanent and cannot be undone. Use the [code]--yes[/code]
36
+ flag to skip the confirmation prompt.
37
+
38
+ [bold][underline]Examples[/underline][/bold]
39
+
40
+ - Delete the instance with the ID [magenta]prod[/magenta] from application [magenta]hare-app[/magenta].
41
+ $ [green]nextmv cloud instance delete --app-id hare-app --instance-id prod[/green]
42
+
43
+ - Delete the instance without confirmation prompt.
44
+ $ [green]nextmv cloud instance delete --app-id hare-app --instance-id prod --yes[/green]
45
+ """
46
+
47
+ if not yes:
48
+ confirm = Confirm.ask(
49
+ f"Are you sure you want to delete instance [magenta]{instance_id}[/magenta] "
50
+ f"from application [magenta]{app_id}[/magenta]? This action cannot be undone.",
51
+ default=False,
52
+ )
53
+
54
+ if not confirm:
55
+ info(msg=f"Instance [magenta]{instance_id}[/magenta] will not be deleted.", emoji=":bulb:")
56
+ return
57
+
58
+ cloud_app = build_app(app_id=app_id, profile=profile)
59
+ cloud_app.delete_instance(instance_id=instance_id)
60
+ success(
61
+ f"Instance [magenta]{instance_id}[/magenta] deleted successfully from application [magenta]{app_id}[/magenta]."
62
+ )
@@ -0,0 +1,39 @@
1
+ """
2
+ This module defines the cloud instance exists command for the Nextmv CLI.
3
+ """
4
+
5
+ import typer
6
+
7
+ from nextmv.cli.configuration.config import build_app
8
+ from nextmv.cli.message import in_progress, print_json
9
+ from nextmv.cli.options import AppIDOption, InstanceIDOption, ProfileOption
10
+
11
+ # Set up subcommand application.
12
+ app = typer.Typer()
13
+
14
+
15
+ @app.command()
16
+ def exists(
17
+ app_id: AppIDOption,
18
+ instance_id: InstanceIDOption,
19
+ profile: ProfileOption = None,
20
+ ) -> None:
21
+ """
22
+ Check if a Nextmv Cloud application instance exists.
23
+
24
+ This command is useful in scripting applications to verify the existence of
25
+ a Nextmv Cloud application instance by its ID.
26
+
27
+ [bold][underline]Examples[/underline][/bold]
28
+
29
+ - Check if the instance with the ID [magenta]prod[/magenta] exists in application [magenta]hare-app[/magenta].
30
+ $ [green]nextmv cloud instance exists --app-id hare-app --instance-id prod[/green]
31
+
32
+ - Check if the instance exists using the profile named [magenta]hare[/magenta].
33
+ $ [green]nextmv cloud instance exists --app-id hare-app --instance-id prod --profile hare[/green]
34
+ """
35
+
36
+ cloud_app = build_app(app_id=app_id, profile=profile)
37
+ in_progress(msg="Checking if instance exists...")
38
+ ok = cloud_app.instance_exists(instance_id=instance_id)
39
+ print_json({"exists": ok})
@@ -0,0 +1,62 @@
1
+ """
2
+ This module defines the cloud instance get command for the Nextmv CLI.
3
+ """
4
+
5
+ import json
6
+ from typing import Annotated
7
+
8
+ import typer
9
+
10
+ from nextmv.cli.configuration.config import build_app
11
+ from nextmv.cli.message import in_progress, print_json, success
12
+ from nextmv.cli.options import AppIDOption, InstanceIDOption, ProfileOption
13
+
14
+ # Set up subcommand application.
15
+ app = typer.Typer()
16
+
17
+
18
+ @app.command()
19
+ def get(
20
+ app_id: AppIDOption,
21
+ instance_id: InstanceIDOption,
22
+ output: Annotated[
23
+ str | None,
24
+ typer.Option(
25
+ "--output",
26
+ "-o",
27
+ help="Saves the instance information to this location.",
28
+ metavar="OUTPUT_PATH",
29
+ ),
30
+ ] = None,
31
+ profile: ProfileOption = None,
32
+ ) -> None:
33
+ """
34
+ Get a Nextmv Cloud application instance.
35
+
36
+ This command is useful to get the attributes of an existing Nextmv Cloud
37
+ application instance by its ID.
38
+
39
+ [bold][underline]Examples[/underline][/bold]
40
+
41
+ - Get the instance with the ID [magenta]prod[/magenta] from application [magenta]hare-app[/magenta].
42
+ $ [green]nextmv cloud instance get --app-id hare-app --instance-id prod[/green]
43
+
44
+ - Get the instance with the ID [magenta]prod[/magenta] and save the information to a
45
+ [magenta]instance.json[/magenta] file.
46
+ $ [green]nextmv cloud instance get --app-id hare-app --instance-id prod --output instance.json[/green]
47
+ """
48
+
49
+ cloud_app = build_app(app_id=app_id, profile=profile)
50
+ in_progress(msg="Getting instance...")
51
+ instance = cloud_app.instance(instance_id=instance_id)
52
+ instance_dict = instance.to_dict()
53
+
54
+ if output is not None and output != "":
55
+ with open(output, "w") as f:
56
+ json.dump(instance_dict, f, indent=2)
57
+
58
+ success(msg=f"Instance information saved to [magenta]{output}[/magenta].")
59
+
60
+ return
61
+
62
+ print_json(instance_dict)
@@ -0,0 +1,60 @@
1
+ """
2
+ This module defines the cloud instance list command for the Nextmv CLI.
3
+ """
4
+
5
+ import json
6
+ from typing import Annotated
7
+
8
+ import typer
9
+
10
+ from nextmv.cli.configuration.config import build_app
11
+ from nextmv.cli.message import in_progress, print_json, success
12
+ from nextmv.cli.options import AppIDOption, ProfileOption
13
+
14
+ # Set up subcommand application.
15
+ app = typer.Typer()
16
+
17
+
18
+ @app.command()
19
+ def list(
20
+ app_id: AppIDOption,
21
+ output: Annotated[
22
+ str | None,
23
+ typer.Option(
24
+ "--output",
25
+ "-o",
26
+ help="Saves the instance list information to this location.",
27
+ metavar="OUTPUT_PATH",
28
+ ),
29
+ ] = None,
30
+ profile: ProfileOption = None,
31
+ ) -> None:
32
+ """
33
+ List all instances of a Nextmv Cloud application.
34
+
35
+ [bold][underline]Examples[/underline][/bold]
36
+
37
+ - List all instances of application [magenta]hare-app[/magenta].
38
+ $ [green]nextmv cloud instance list --app-id hare-app[/green]
39
+
40
+ - List all instances using the profile named [magenta]hare[/magenta].
41
+ $ [green]nextmv cloud instance list --app-id hare-app --profile hare[/green]
42
+
43
+ - List all instances and save the information to a [magenta]instances.json[/magenta] file.
44
+ $ [green]nextmv cloud instance list --app-id hare-app --output instances.json[/green]
45
+ """
46
+
47
+ cloud_app = build_app(app_id=app_id, profile=profile)
48
+ in_progress(msg="Listing instances...")
49
+ instances = cloud_app.list_instances()
50
+ instances_dicts = [instance.to_dict() for instance in instances]
51
+
52
+ if output is not None and output != "":
53
+ with open(output, "w") as f:
54
+ json.dump(instances_dicts, f, indent=2)
55
+
56
+ success(msg=f"Instance list information saved to [magenta]{output}[/magenta].")
57
+
58
+ return
59
+
60
+ print_json(instances_dicts)