nextmv 1.0.0.dev2__py3-none-any.whl → 1.0.0.dev4__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 (120) hide show
  1. nextmv/__about__.py +1 -1
  2. nextmv/cli/CONTRIBUTING.md +81 -29
  3. nextmv/cli/cloud/__init__.py +2 -0
  4. nextmv/cli/cloud/acceptance/create.py +20 -22
  5. nextmv/cli/cloud/acceptance/delete.py +7 -8
  6. nextmv/cli/cloud/acceptance/get.py +9 -10
  7. nextmv/cli/cloud/acceptance/list.py +3 -3
  8. nextmv/cli/cloud/acceptance/update.py +6 -6
  9. nextmv/cli/cloud/account/__init__.py +3 -3
  10. nextmv/cli/cloud/account/create.py +11 -11
  11. nextmv/cli/cloud/account/delete.py +6 -7
  12. nextmv/cli/cloud/account/get.py +3 -3
  13. nextmv/cli/cloud/account/update.py +5 -5
  14. nextmv/cli/cloud/app/create.py +25 -26
  15. nextmv/cli/cloud/app/delete.py +5 -6
  16. nextmv/cli/cloud/app/exists.py +2 -2
  17. nextmv/cli/cloud/app/get.py +2 -2
  18. nextmv/cli/cloud/app/list.py +3 -3
  19. nextmv/cli/cloud/app/push.py +269 -45
  20. nextmv/cli/cloud/app/update.py +12 -12
  21. nextmv/cli/cloud/batch/create.py +26 -28
  22. nextmv/cli/cloud/batch/delete.py +5 -6
  23. nextmv/cli/cloud/batch/get.py +8 -8
  24. nextmv/cli/cloud/batch/list.py +3 -3
  25. nextmv/cli/cloud/batch/metadata.py +4 -4
  26. nextmv/cli/cloud/batch/update.py +6 -6
  27. nextmv/cli/cloud/data/__init__.py +1 -1
  28. nextmv/cli/cloud/data/upload.py +15 -15
  29. nextmv/cli/cloud/ensemble/__init__.py +2 -0
  30. nextmv/cli/cloud/ensemble/create.py +21 -22
  31. nextmv/cli/cloud/ensemble/delete.py +5 -6
  32. nextmv/cli/cloud/ensemble/get.py +4 -4
  33. nextmv/cli/cloud/ensemble/list.py +63 -0
  34. nextmv/cli/cloud/ensemble/update.py +9 -9
  35. nextmv/cli/cloud/input_set/create.py +20 -22
  36. nextmv/cli/cloud/input_set/get.py +3 -3
  37. nextmv/cli/cloud/input_set/list.py +3 -3
  38. nextmv/cli/cloud/input_set/update.py +24 -24
  39. nextmv/cli/cloud/instance/create.py +14 -15
  40. nextmv/cli/cloud/instance/delete.py +5 -6
  41. nextmv/cli/cloud/instance/exists.py +2 -2
  42. nextmv/cli/cloud/instance/get.py +2 -2
  43. nextmv/cli/cloud/instance/list.py +3 -3
  44. nextmv/cli/cloud/instance/update.py +14 -14
  45. nextmv/cli/cloud/managed_input/create.py +14 -16
  46. nextmv/cli/cloud/managed_input/delete.py +6 -7
  47. nextmv/cli/cloud/managed_input/get.py +3 -3
  48. nextmv/cli/cloud/managed_input/list.py +3 -3
  49. nextmv/cli/cloud/managed_input/update.py +9 -9
  50. nextmv/cli/cloud/run/cancel.py +2 -2
  51. nextmv/cli/cloud/run/create.py +32 -33
  52. nextmv/cli/cloud/run/get.py +8 -8
  53. nextmv/cli/cloud/run/input.py +4 -4
  54. nextmv/cli/cloud/run/list.py +6 -6
  55. nextmv/cli/cloud/run/logs.py +9 -10
  56. nextmv/cli/cloud/run/metadata.py +4 -4
  57. nextmv/cli/cloud/run/track.py +32 -33
  58. nextmv/cli/cloud/scenario/create.py +21 -21
  59. nextmv/cli/cloud/scenario/delete.py +5 -6
  60. nextmv/cli/cloud/scenario/get.py +8 -8
  61. nextmv/cli/cloud/scenario/list.py +3 -3
  62. nextmv/cli/cloud/scenario/metadata.py +4 -4
  63. nextmv/cli/cloud/scenario/update.py +6 -6
  64. nextmv/cli/cloud/secrets/create.py +17 -17
  65. nextmv/cli/cloud/secrets/delete.py +5 -6
  66. nextmv/cli/cloud/secrets/get.py +4 -4
  67. nextmv/cli/cloud/secrets/list.py +3 -3
  68. nextmv/cli/cloud/secrets/update.py +17 -20
  69. nextmv/cli/cloud/shadow/__init__.py +1 -1
  70. nextmv/cli/cloud/shadow/create.py +32 -32
  71. nextmv/cli/cloud/shadow/delete.py +5 -6
  72. nextmv/cli/cloud/shadow/get.py +2 -2
  73. nextmv/cli/cloud/shadow/list.py +3 -3
  74. nextmv/cli/cloud/shadow/metadata.py +4 -4
  75. nextmv/cli/cloud/shadow/start.py +3 -3
  76. nextmv/cli/cloud/shadow/stop.py +8 -10
  77. nextmv/cli/cloud/shadow/update.py +7 -6
  78. nextmv/cli/cloud/switchback/__init__.py +33 -0
  79. nextmv/cli/cloud/switchback/create.py +151 -0
  80. nextmv/cli/cloud/switchback/delete.py +67 -0
  81. nextmv/cli/cloud/switchback/get.py +62 -0
  82. nextmv/cli/cloud/switchback/list.py +63 -0
  83. nextmv/cli/cloud/switchback/metadata.py +68 -0
  84. nextmv/cli/cloud/switchback/start.py +43 -0
  85. nextmv/cli/cloud/switchback/stop.py +41 -0
  86. nextmv/cli/cloud/switchback/update.py +96 -0
  87. nextmv/cli/cloud/upload/create.py +2 -2
  88. nextmv/cli/cloud/version/create.py +9 -10
  89. nextmv/cli/cloud/version/delete.py +5 -6
  90. nextmv/cli/cloud/version/exists.py +2 -2
  91. nextmv/cli/cloud/version/get.py +2 -2
  92. nextmv/cli/cloud/version/list.py +3 -3
  93. nextmv/cli/cloud/version/update.py +8 -8
  94. nextmv/cli/community/clone.py +12 -10
  95. nextmv/cli/community/list.py +9 -9
  96. nextmv/cli/configuration/config.py +43 -10
  97. nextmv/cli/configuration/create.py +3 -3
  98. nextmv/cli/configuration/delete.py +7 -7
  99. nextmv/cli/configuration/list.py +3 -3
  100. nextmv/cli/confirm.py +32 -0
  101. nextmv/cli/main.py +27 -36
  102. nextmv/cli/message.py +2 -2
  103. nextmv/cli/options.py +14 -0
  104. nextmv/cli/version.py +1 -1
  105. nextmv/cloud/__init__.py +5 -0
  106. nextmv/cloud/application/__init__.py +192 -54
  107. nextmv/cloud/application/_batch_scenario.py +2 -2
  108. nextmv/cloud/application/_instance.py +2 -2
  109. nextmv/cloud/application/_managed_input.py +1 -1
  110. nextmv/cloud/application/_shadow.py +1 -1
  111. nextmv/cloud/application/_switchback.py +323 -0
  112. nextmv/cloud/application/_version.py +3 -2
  113. nextmv/cloud/shadow.py +43 -4
  114. nextmv/cloud/switchback.py +226 -0
  115. {nextmv-1.0.0.dev2.dist-info → nextmv-1.0.0.dev4.dist-info}/METADATA +1 -1
  116. nextmv-1.0.0.dev4.dist-info/RECORD +183 -0
  117. nextmv-1.0.0.dev2.dist-info/RECORD +0 -170
  118. {nextmv-1.0.0.dev2.dist-info → nextmv-1.0.0.dev4.dist-info}/WHEEL +0 -0
  119. {nextmv-1.0.0.dev2.dist-info → nextmv-1.0.0.dev4.dist-info}/entry_points.txt +0 -0
  120. {nextmv-1.0.0.dev2.dist-info → nextmv-1.0.0.dev4.dist-info}/licenses/LICENSE +0 -0
@@ -23,15 +23,15 @@ def start(
23
23
 
24
24
  Before starting a shadow test, it must be created in draft state. You may
25
25
  use the [code]nextmv cloud shadow create[/code] command to create a new
26
- shadow test. Alternatively, define a [code]--start-time[/code] when using
27
- the [code]nextmv cloud shadow create[/code] command to have the shadow test
26
+ shadow test. Alternatively, define a --start-time when using the
27
+ [code]nextmv cloud shadow create[/code] command to have the shadow test
28
28
  start automatically at a specific time.
29
29
 
30
30
  [bold][underline]Examples[/underline][/bold]
31
31
 
32
32
  - Start the shadow test with the ID [magenta]hop-analysis[/magenta] from application
33
33
  [magenta]hare-app[/magenta].
34
- $ [green]nextmv cloud shadow start --app-id hare-app --shadow-test-id hop-analysis[/green]
34
+ $ [dim]nextmv cloud shadow start --app-id hare-app --shadow-test-id hop-analysis[/dim]
35
35
  """
36
36
 
37
37
  in_progress(msg="Starting shadow test...")
@@ -21,23 +21,21 @@ def stop(
21
21
  """
22
22
  Stops a Nextmv Cloud shadow test.
23
23
 
24
- Before stopping a shadow test, it must be in a started state. You may
25
- use the [code]nextmv cloud shadow start[/code] command to start
26
- a shadow test. Alternatively, define a [code]--start-time[/code] when using
27
- the [code]nextmv cloud shadow create[/code] command to have the shadow test
28
- start automatically at a specific time.
24
+ Before stopping a shadow test, it must be in a started state. Experiments
25
+ in a [magenta]draft[/magenta] state, that haven't started, can be deleted
26
+ with the [code]nextmv cloud shadow delete[/code] command.
29
27
 
30
28
  [bold][underline]Examples[/underline][/bold]
31
29
 
32
- - Start the shadow test with the ID [magenta]hop-analysis[/magenta] from application
30
+ - Stop the shadow test with the ID [magenta]hop-analysis[/magenta] from application
33
31
  [magenta]hare-app[/magenta].
34
- $ [green]nextmv cloud shadow start --app-id hare-app --shadow-test-id hop-analysis[/green]
32
+ $ [dim]nextmv cloud shadow stop --app-id hare-app --shadow-test-id hop-analysis[/dim]
35
33
  """
36
34
 
37
- in_progress(msg="Starting shadow test...")
35
+ in_progress(msg="Stopping shadow test...")
38
36
  cloud_app = build_app(app_id=app_id, profile=profile)
39
- cloud_app.start_shadow_test(shadow_test_id=shadow_test_id)
37
+ cloud_app.stop_shadow_test(shadow_test_id=shadow_test_id)
40
38
  success(
41
- f"Shadow test [magenta]{shadow_test_id}[/magenta] started successfully "
39
+ f"Shadow test [magenta]{shadow_test_id}[/magenta] stopped successfully "
42
40
  f"in application [magenta]{app_id}[/magenta]."
43
41
  )
@@ -57,17 +57,17 @@ def update(
57
57
  [bold][underline]Examples[/underline][/bold]
58
58
 
59
59
  - Update the name of a shadow test.
60
- $ [green]nextmv cloud shadow update --app-id hare-app --shadow-test-id carrot-feast \\
61
- --name "Spring Carrot Harvest"[/green]
60
+ $ [dim]nextmv cloud shadow update --app-id hare-app --shadow-test-id carrot-feast \\
61
+ --name "Spring Carrot Harvest"[/dim]
62
62
 
63
63
  - Update the description of a shadow test.
64
- $ [green]nextmv cloud shadow update --app-id hare-app --shadow-test-id bunny-hop-routes \\
65
- --description "Optimizing hop paths through the meadow"[/green]
64
+ $ [dim]nextmv cloud shadow update --app-id hare-app --shadow-test-id bunny-hop-routes \\
65
+ --description "Optimizing hop paths through the meadow"[/dim]
66
66
 
67
67
  - Update both name and description and save the result.
68
- $ [green]nextmv cloud shadow update --app-id hare-app --shadow-test-id lettuce-delivery \\
68
+ $ [dim]nextmv cloud shadow update --app-id hare-app --shadow-test-id lettuce-delivery \\
69
69
  --name "Warren Lettuce Express" --description "Fast lettuce delivery to all burrows" \\
70
- --output updated-shadow-test.json[/green]
70
+ --output updated-shadow-test.json[/dim]
71
71
  """
72
72
 
73
73
  cloud_app = build_app(app_id=app_id, profile=profile)
@@ -90,6 +90,7 @@ def update(
90
90
  json.dump(shadow_test_dict, f, indent=2)
91
91
 
92
92
  success(msg=f"Updated shadow test information saved to [magenta]{output}[/magenta].")
93
+
93
94
  return
94
95
 
95
96
  print_json(shadow_test_dict)
@@ -0,0 +1,33 @@
1
+ """
2
+ This module defines the cloud switchback command tree for the Nextmv CLI.
3
+ """
4
+
5
+ import typer
6
+
7
+ from nextmv.cli.cloud.switchback.create import app as create_app
8
+ from nextmv.cli.cloud.switchback.delete import app as delete_app
9
+ from nextmv.cli.cloud.switchback.get import app as get_app
10
+ from nextmv.cli.cloud.switchback.list import app as list_app
11
+ from nextmv.cli.cloud.switchback.metadata import app as metadata_app
12
+ from nextmv.cli.cloud.switchback.start import app as start_app
13
+ from nextmv.cli.cloud.switchback.stop import app as stop_app
14
+ from nextmv.cli.cloud.switchback.update import app as update_app
15
+
16
+ # Set up subcommand application.
17
+ app = typer.Typer()
18
+ app.add_typer(create_app)
19
+ app.add_typer(delete_app)
20
+ app.add_typer(get_app)
21
+ app.add_typer(list_app)
22
+ app.add_typer(metadata_app)
23
+ app.add_typer(start_app)
24
+ app.add_typer(stop_app)
25
+ app.add_typer(update_app)
26
+
27
+
28
+ @app.callback()
29
+ def callback() -> None:
30
+ """
31
+ Create and manage Nextmv Cloud switchback tests.
32
+ """
33
+ pass
@@ -0,0 +1,151 @@
1
+ """
2
+ This module defines the cloud switchback create command for the Nextmv CLI.
3
+ """
4
+
5
+ from datetime import datetime
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
12
+ from nextmv.cli.options import AppIDOption, ProfileOption
13
+ from nextmv.cloud.switchback import TestComparisonSingle
14
+
15
+ # Set up subcommand application.
16
+ app = typer.Typer()
17
+
18
+
19
+ @app.command()
20
+ def create(
21
+ app_id: AppIDOption,
22
+ baseline_instance_id: Annotated[
23
+ str,
24
+ typer.Option(
25
+ "--baseline-instance-id",
26
+ "-b",
27
+ help="ID of the baseline instance for the switchback test.",
28
+ metavar="BASELINE_INSTANCE_ID",
29
+ ),
30
+ ],
31
+ candidate_instance_id: Annotated[
32
+ str,
33
+ typer.Option(
34
+ "--candidate-instance-id",
35
+ "-c",
36
+ help="ID of the candidate instance for the switchback test.",
37
+ metavar="CANDIDATE_INSTANCE_ID",
38
+ ),
39
+ ],
40
+ unit_duration_minutes: Annotated[
41
+ float,
42
+ typer.Option(
43
+ "--unit-duration-minutes",
44
+ "-u",
45
+ help="Duration of each interval in minutes.",
46
+ metavar="UNIT_DURATION_MINUTES",
47
+ min=1,
48
+ max=10080,
49
+ ),
50
+ ],
51
+ units: Annotated[
52
+ int,
53
+ typer.Option(
54
+ "--units",
55
+ "-t",
56
+ help="Total number of intervals in the switchback test.",
57
+ metavar="UNITS",
58
+ min=1,
59
+ max=1000,
60
+ ),
61
+ ],
62
+ description: Annotated[
63
+ str | None,
64
+ typer.Option(
65
+ "--description",
66
+ "-d",
67
+ help="Description of the switchback test.",
68
+ metavar="DESCRIPTION",
69
+ ),
70
+ ] = None,
71
+ name: Annotated[
72
+ str | None,
73
+ typer.Option(
74
+ "--name",
75
+ "-n",
76
+ help="Name of the switchback test. If not provided, the ID will be used as the name.",
77
+ metavar="NAME",
78
+ ),
79
+ ] = None,
80
+ switchback_test_id: Annotated[
81
+ str | None,
82
+ typer.Option(
83
+ "--switchback-test-id",
84
+ "-s",
85
+ help="ID for the switchback test. Will be generated if not provided.",
86
+ envvar="NEXTMV_SWITCHBACK_TEST_ID",
87
+ metavar="SWITCHBACK_TEST_ID",
88
+ ),
89
+ ] = None,
90
+ start: Annotated[
91
+ datetime | None,
92
+ typer.Option(
93
+ "--start",
94
+ "-r",
95
+ formats=["%Y-%m-%dT%H:%M:%S%z"],
96
+ help="Scheduled time for switchback test start in [magenta]RFC 3339[/magenta] format. "
97
+ "Object format: [dim]'2024-01-01T00:00:00Z'[/dim]",
98
+ metavar="START",
99
+ ),
100
+ ] = None,
101
+ profile: ProfileOption = None,
102
+ ) -> None:
103
+ """
104
+ Create a new Nextmv Cloud switchback test in draft mode.
105
+
106
+ The test will alternate between the --baseline-instance-id and
107
+ --candidate-instance-id over specified time intervals.
108
+
109
+ You may specify the --start option to make the switchback test start at a
110
+ specific time. Alternatively, you may use the [code]nextmv cloud switchback
111
+ start[/code] command to start the test.
112
+
113
+ Use the [code]nextmv cloud switchback stop[/code] command to stop the test.
114
+
115
+ [bold][underline]Examples[/underline][/bold]
116
+
117
+ - Create a switchback test alternating between two bunny instances.
118
+ $ [dim]nextmv cloud switchback create --app-id hare-app --switchback-test-id bunny-switch-hop \\
119
+ --name "Bunny Switch Hop" --baseline-instance-id fluffy-bunny-baseline \\
120
+ --candidate-instance-id speedy-cottontail --unit-duration-minutes 15 --units 10[/dim]
121
+
122
+ - Create a switchback test with a scheduled start time.
123
+ $ [dim]nextmv cloud switchback create --app-id hare-app --switchback-test-id sunrise-switch \\
124
+ --name "Sunrise Switch Test" --baseline-instance-id wise-old-rabbit \\
125
+ --candidate-instance-id burrow-master --unit-duration-minutes 30 --units 8 \\
126
+ --start '2026-01-23T10:00:00Z'[/dim]
127
+
128
+ - Create a switchback test with a description.
129
+ $ [dim]nextmv cloud switchback create --app-id hare-app --switchback-test-id carrot-switch \\
130
+ --name "Carrot Switch" --baseline-instance-id fluffy-bunny-baseline \\
131
+ --candidate-instance-id hopping-candidate-ears --unit-duration-minutes 20 --units 12 \\
132
+ --description "Which bunny hops best for carrots?"[/dim]
133
+ """
134
+
135
+ cloud_app = build_app(app_id=app_id, profile=profile)
136
+
137
+ in_progress(msg="Creating switchback test in draft mode...")
138
+ switchback_test = cloud_app.new_switchback_test(
139
+ comparison=TestComparisonSingle(
140
+ baseline_instance_id=baseline_instance_id,
141
+ candidate_instance_id=candidate_instance_id,
142
+ ),
143
+ unit_duration_minutes=unit_duration_minutes,
144
+ units=units,
145
+ switchback_test_id=switchback_test_id,
146
+ name=name,
147
+ description=description,
148
+ start=start,
149
+ )
150
+
151
+ print_json(switchback_test.to_dict())
@@ -0,0 +1,67 @@
1
+ """
2
+ This module defines the cloud switchback delete 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.confirm import get_confirmation
11
+ from nextmv.cli.message import info, success
12
+ from nextmv.cli.options import AppIDOption, ProfileOption, SwitchbackTestIDOption
13
+
14
+ # Set up subcommand application.
15
+ app = typer.Typer()
16
+
17
+
18
+ @app.command()
19
+ def delete(
20
+ app_id: AppIDOption,
21
+ switchback_test_id: SwitchbackTestIDOption,
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 switchback test.
34
+
35
+ This action is permanent and cannot be undone. The switchback test and all
36
+ associated data, including runs, will be deleted. Use the --yes
37
+ flag to skip the confirmation prompt.
38
+
39
+ [bold][underline]Examples[/underline][/bold]
40
+
41
+ - Delete the switchback test with the ID [magenta]hop-analysis[/magenta] from application
42
+ [magenta]hare-app[/magenta].
43
+ $ [dim]nextmv cloud switchback delete --app-id hare-app --switchback-test-id hop-analysis[/dim]
44
+
45
+ - Delete the switchback test without confirmation prompt.
46
+ $ [dim]nextmv cloud switchback delete --app-id hare-app --switchback-test-id carrot-routes --yes[/dim]
47
+ """
48
+
49
+ if not yes:
50
+ confirm = get_confirmation(
51
+ f"Are you sure you want to delete switchback test [magenta]{switchback_test_id}[/magenta] "
52
+ f"from application [magenta]{app_id}[/magenta]? This action cannot be undone.",
53
+ )
54
+
55
+ if not confirm:
56
+ info(
57
+ msg=f"Switchback test [magenta]{switchback_test_id}[/magenta] will not be deleted.",
58
+ emoji=":bulb:",
59
+ )
60
+ return
61
+
62
+ cloud_app = build_app(app_id=app_id, profile=profile)
63
+ cloud_app.delete_switchback_test(switchback_test_id=switchback_test_id)
64
+ success(
65
+ f"Switchback test [magenta]{switchback_test_id}[/magenta] deleted successfully "
66
+ f"from application [magenta]{app_id}[/magenta]."
67
+ )
@@ -0,0 +1,62 @@
1
+ """
2
+ This module defines the cloud switchback 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, ProfileOption, SwitchbackTestIDOption
13
+
14
+ # Set up subcommand application.
15
+ app = typer.Typer()
16
+
17
+
18
+ @app.command()
19
+ def get(
20
+ app_id: AppIDOption,
21
+ switchback_test_id: SwitchbackTestIDOption,
22
+ output: Annotated[
23
+ str | None,
24
+ typer.Option(
25
+ "--output",
26
+ "-o",
27
+ help="Saves the results to this location.",
28
+ metavar="OUTPUT_PATH",
29
+ ),
30
+ ] = None,
31
+ profile: ProfileOption = None,
32
+ ) -> None:
33
+ """
34
+ Get a Nextmv Cloud switchback test, including its runs.
35
+
36
+ [bold][underline]Examples[/underline][/bold]
37
+
38
+ - Get the switchback test with ID [magenta]carrot-optimization[/magenta] from application
39
+ [magenta]hare-app[/magenta].
40
+ $ [dim]nextmv cloud switchback get --app-id hare-app --switchback-test-id carrot-optimization[/dim]
41
+
42
+ - Get the switchback test using a specific profile.
43
+ $ [dim]nextmv cloud switchback get --app-id hare-app --switchback-test-id lettuce-routes \\
44
+ --profile prod[/dim]
45
+ """
46
+
47
+ cloud_app = build_app(app_id=app_id, profile=profile)
48
+ in_progress(msg="Getting switchback test...")
49
+ switchback_test = cloud_app.switchback_test(switchback_test_id=switchback_test_id)
50
+
51
+ switchback_test_dict = switchback_test.to_dict()
52
+
53
+ # Handle output
54
+ if output is not None and output != "":
55
+ with open(output, "w") as f:
56
+ json.dump(switchback_test_dict, f, indent=2)
57
+
58
+ success(msg=f"Switchback test output saved to [magenta]{output}[/magenta].")
59
+
60
+ return
61
+
62
+ print_json(switchback_test_dict)
@@ -0,0 +1,63 @@
1
+ """
2
+ This module defines the cloud switchback 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 list of switchback tests to this location.",
27
+ metavar="OUTPUT_PATH",
28
+ ),
29
+ ] = None,
30
+ profile: ProfileOption = None,
31
+ ) -> None:
32
+ """
33
+ List all Nextmv Cloud switchback tests for an application.
34
+
35
+ This command retrieves all switchback tests associated with the specified
36
+ application.
37
+
38
+ [bold][underline]Examples[/underline][/bold]
39
+
40
+ - List all switchback tests for application [magenta]hare-app[/magenta].
41
+ $ [dim]nextmv cloud switchback list --app-id hare-app[/dim]
42
+
43
+ - List all switchback tests and save to a file.
44
+ $ [dim]nextmv cloud switchback list --app-id hare-app --output tests.json[/dim]
45
+
46
+ - List all switchback tests using a specific profile.
47
+ $ [dim]nextmv cloud switchback list --app-id hare-app --profile prod[/dim]
48
+ """
49
+
50
+ cloud_app = build_app(app_id=app_id, profile=profile)
51
+ in_progress(msg="Listing switchback tests...")
52
+ switchback_tests = cloud_app.list_switchback_tests()
53
+ switchback_tests_dict = [test.to_dict() for test in switchback_tests]
54
+
55
+ if output is not None and output != "":
56
+ with open(output, "w") as f:
57
+ json.dump(switchback_tests_dict, f, indent=2)
58
+
59
+ success(msg=f"Switchback tests list saved to [magenta]{output}[/magenta].")
60
+
61
+ return
62
+
63
+ print_json(switchback_tests_dict)
@@ -0,0 +1,68 @@
1
+ """
2
+ This module defines the cloud switchback metadata 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, SwitchbackTestIDOption
13
+
14
+ # Set up subcommand application.
15
+ app = typer.Typer()
16
+
17
+
18
+ @app.command()
19
+ def metadata(
20
+ app_id: AppIDOption,
21
+ switchback_test_id: SwitchbackTestIDOption,
22
+ output: Annotated[
23
+ str | None,
24
+ typer.Option(
25
+ "--output",
26
+ "-o",
27
+ help="Saves the switchback test metadata to this location.",
28
+ metavar="OUTPUT_PATH",
29
+ ),
30
+ ] = None,
31
+ profile: ProfileOption = None,
32
+ ) -> None:
33
+ """
34
+ Get metadata for a Nextmv Cloud switchback test.
35
+
36
+ This command retrieves metadata for a specific switchback test, including
37
+ status, creation date, and other high-level information without the full
38
+ run details.
39
+
40
+ [bold][underline]Examples[/underline][/bold]
41
+
42
+ - Get metadata for switchback test [magenta]bunny-warren-optimization[/magenta] from application
43
+ [magenta]hare-app[/magenta].
44
+ $ [dim]nextmv cloud switchback metadata --app-id hare-app \\
45
+ --switchback-test-id bunny-warren-optimization[/dim]
46
+
47
+ - Get metadata and save to a file.
48
+ $ [dim]nextmv cloud switchback metadata --app-id hare-app --switchback-test-id lettuce-delivery \\
49
+ --output metadata.json[/dim]
50
+
51
+ - Get metadata using a specific profile.
52
+ $ [dim]nextmv cloud switchback metadata --app-id hare-app --switchback-test-id hop-schedule \\
53
+ --profile prod[/dim]
54
+ """
55
+
56
+ cloud_app = build_app(app_id=app_id, profile=profile)
57
+ in_progress(msg="Getting switchback test metadata...")
58
+ switchback_metadata = cloud_app.switchback_test_metadata(switchback_test_id=switchback_test_id)
59
+ switchback_metadata_dict = switchback_metadata.to_dict()
60
+
61
+ if output is not None and output != "":
62
+ with open(output, "w") as f:
63
+ json.dump(switchback_metadata_dict, f, indent=2)
64
+
65
+ success(msg=f"Switchback test metadata saved to [magenta]{output}[/magenta].")
66
+ return
67
+
68
+ print_json(switchback_metadata_dict)
@@ -0,0 +1,43 @@
1
+ """
2
+ This module defines the cloud switchback start 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, success
9
+ from nextmv.cli.options import AppIDOption, ProfileOption, SwitchbackTestIDOption
10
+
11
+ # Set up subcommand application.
12
+ app = typer.Typer()
13
+
14
+
15
+ @app.command()
16
+ def start(
17
+ app_id: AppIDOption,
18
+ switchback_test_id: SwitchbackTestIDOption,
19
+ profile: ProfileOption = None,
20
+ ) -> None:
21
+ """
22
+ Starts a Nextmv Cloud switchback test.
23
+
24
+ Before starting a switchback test, it must be created in draft state. You
25
+ may use the [code]nextmv cloud switchback create[/code] command to create a
26
+ new switchback test. Alternatively, define a --start when using the
27
+ [code]nextmv cloud switchback create[/code] command to have the switchback
28
+ test start automatically at a specific time.
29
+
30
+ [bold][underline]Examples[/underline][/bold]
31
+
32
+ - Start the switchback test with the ID [magenta]hop-analysis[/magenta] from application
33
+ [magenta]hare-app[/magenta].
34
+ $ [dim]nextmv cloud switchback start --app-id hare-app --switchback-test-id hop-analysis[/dim]
35
+ """
36
+
37
+ in_progress(msg="Starting switchback test...")
38
+ cloud_app = build_app(app_id=app_id, profile=profile)
39
+ cloud_app.start_switchback_test(switchback_test_id=switchback_test_id)
40
+ success(
41
+ f"Switchback test [magenta]{switchback_test_id}[/magenta] started successfully "
42
+ f"in application [magenta]{app_id}[/magenta]."
43
+ )
@@ -0,0 +1,41 @@
1
+ """
2
+ This module defines the cloud switchback stop 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, success
9
+ from nextmv.cli.options import AppIDOption, ProfileOption, SwitchbackTestIDOption
10
+
11
+ # Set up subcommand application.
12
+ app = typer.Typer()
13
+
14
+
15
+ @app.command()
16
+ def stop(
17
+ app_id: AppIDOption,
18
+ switchback_test_id: SwitchbackTestIDOption,
19
+ profile: ProfileOption = None,
20
+ ) -> None:
21
+ """
22
+ Stops a Nextmv Cloud switchback test.
23
+
24
+ Before stopping a switchback test, it must be in a started state. Experiments
25
+ in a [magenta]draft[/magenta] state, that haven't started, can be deleted
26
+ with the [code]nextmv cloud switchback delete[/code] command.
27
+
28
+ [bold][underline]Examples[/underline][/bold]
29
+
30
+ - Stop the switchback test with the ID [magenta]hop-analysis[/magenta] from application
31
+ [magenta]hare-app[/magenta].
32
+ $ [dim]nextmv cloud switchback stop --app-id hare-app --switchback-test-id hop-analysis[/dim]
33
+ """
34
+
35
+ in_progress(msg="Stopping switchback test...")
36
+ cloud_app = build_app(app_id=app_id, profile=profile)
37
+ cloud_app.stop_switchback_test(switchback_test_id=switchback_test_id)
38
+ success(
39
+ f"Switchback test [magenta]{switchback_test_id}[/magenta] stopped successfully "
40
+ f"in application [magenta]{app_id}[/magenta]."
41
+ )