nextmv 1.0.0.dev3__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 (115) hide show
  1. nextmv/__about__.py +1 -1
  2. nextmv/cli/CONTRIBUTING.md +81 -29
  3. nextmv/cli/cloud/acceptance/create.py +20 -22
  4. nextmv/cli/cloud/acceptance/delete.py +7 -8
  5. nextmv/cli/cloud/acceptance/get.py +9 -10
  6. nextmv/cli/cloud/acceptance/list.py +3 -3
  7. nextmv/cli/cloud/acceptance/update.py +6 -6
  8. nextmv/cli/cloud/account/__init__.py +3 -3
  9. nextmv/cli/cloud/account/create.py +11 -11
  10. nextmv/cli/cloud/account/delete.py +6 -7
  11. nextmv/cli/cloud/account/get.py +3 -3
  12. nextmv/cli/cloud/account/update.py +5 -5
  13. nextmv/cli/cloud/app/create.py +25 -26
  14. nextmv/cli/cloud/app/delete.py +5 -6
  15. nextmv/cli/cloud/app/exists.py +2 -2
  16. nextmv/cli/cloud/app/get.py +2 -2
  17. nextmv/cli/cloud/app/list.py +3 -3
  18. nextmv/cli/cloud/app/push.py +269 -45
  19. nextmv/cli/cloud/app/update.py +12 -12
  20. nextmv/cli/cloud/batch/create.py +26 -28
  21. nextmv/cli/cloud/batch/delete.py +5 -6
  22. nextmv/cli/cloud/batch/get.py +8 -8
  23. nextmv/cli/cloud/batch/list.py +3 -3
  24. nextmv/cli/cloud/batch/metadata.py +4 -4
  25. nextmv/cli/cloud/batch/update.py +6 -6
  26. nextmv/cli/cloud/data/__init__.py +1 -1
  27. nextmv/cli/cloud/data/upload.py +15 -15
  28. nextmv/cli/cloud/ensemble/__init__.py +2 -0
  29. nextmv/cli/cloud/ensemble/create.py +21 -22
  30. nextmv/cli/cloud/ensemble/delete.py +5 -6
  31. nextmv/cli/cloud/ensemble/get.py +4 -4
  32. nextmv/cli/cloud/ensemble/list.py +63 -0
  33. nextmv/cli/cloud/ensemble/update.py +9 -9
  34. nextmv/cli/cloud/input_set/create.py +20 -22
  35. nextmv/cli/cloud/input_set/get.py +3 -3
  36. nextmv/cli/cloud/input_set/list.py +3 -3
  37. nextmv/cli/cloud/input_set/update.py +24 -24
  38. nextmv/cli/cloud/instance/create.py +14 -15
  39. nextmv/cli/cloud/instance/delete.py +5 -6
  40. nextmv/cli/cloud/instance/exists.py +2 -2
  41. nextmv/cli/cloud/instance/get.py +2 -2
  42. nextmv/cli/cloud/instance/list.py +3 -3
  43. nextmv/cli/cloud/instance/update.py +14 -14
  44. nextmv/cli/cloud/managed_input/create.py +14 -16
  45. nextmv/cli/cloud/managed_input/delete.py +6 -7
  46. nextmv/cli/cloud/managed_input/get.py +3 -3
  47. nextmv/cli/cloud/managed_input/list.py +3 -3
  48. nextmv/cli/cloud/managed_input/update.py +9 -9
  49. nextmv/cli/cloud/run/cancel.py +2 -2
  50. nextmv/cli/cloud/run/create.py +32 -33
  51. nextmv/cli/cloud/run/get.py +8 -8
  52. nextmv/cli/cloud/run/input.py +4 -4
  53. nextmv/cli/cloud/run/list.py +6 -6
  54. nextmv/cli/cloud/run/logs.py +9 -10
  55. nextmv/cli/cloud/run/metadata.py +4 -4
  56. nextmv/cli/cloud/run/track.py +32 -33
  57. nextmv/cli/cloud/scenario/create.py +21 -21
  58. nextmv/cli/cloud/scenario/delete.py +5 -6
  59. nextmv/cli/cloud/scenario/get.py +8 -8
  60. nextmv/cli/cloud/scenario/list.py +3 -3
  61. nextmv/cli/cloud/scenario/metadata.py +4 -4
  62. nextmv/cli/cloud/scenario/update.py +6 -6
  63. nextmv/cli/cloud/secrets/create.py +17 -17
  64. nextmv/cli/cloud/secrets/delete.py +5 -6
  65. nextmv/cli/cloud/secrets/get.py +4 -4
  66. nextmv/cli/cloud/secrets/list.py +3 -3
  67. nextmv/cli/cloud/secrets/update.py +17 -20
  68. nextmv/cli/cloud/shadow/create.py +31 -31
  69. nextmv/cli/cloud/shadow/delete.py +5 -6
  70. nextmv/cli/cloud/shadow/get.py +2 -2
  71. nextmv/cli/cloud/shadow/list.py +3 -3
  72. nextmv/cli/cloud/shadow/metadata.py +4 -4
  73. nextmv/cli/cloud/shadow/start.py +3 -3
  74. nextmv/cli/cloud/shadow/stop.py +4 -6
  75. nextmv/cli/cloud/shadow/update.py +6 -6
  76. nextmv/cli/cloud/switchback/create.py +19 -15
  77. nextmv/cli/cloud/switchback/delete.py +5 -6
  78. nextmv/cli/cloud/switchback/get.py +3 -3
  79. nextmv/cli/cloud/switchback/list.py +3 -3
  80. nextmv/cli/cloud/switchback/metadata.py +6 -6
  81. nextmv/cli/cloud/switchback/start.py +4 -4
  82. nextmv/cli/cloud/switchback/stop.py +4 -6
  83. nextmv/cli/cloud/switchback/update.py +6 -6
  84. nextmv/cli/cloud/upload/create.py +2 -2
  85. nextmv/cli/cloud/version/create.py +9 -10
  86. nextmv/cli/cloud/version/delete.py +5 -6
  87. nextmv/cli/cloud/version/exists.py +2 -2
  88. nextmv/cli/cloud/version/get.py +2 -2
  89. nextmv/cli/cloud/version/list.py +3 -3
  90. nextmv/cli/cloud/version/update.py +8 -8
  91. nextmv/cli/community/clone.py +12 -10
  92. nextmv/cli/community/list.py +9 -9
  93. nextmv/cli/configuration/config.py +43 -10
  94. nextmv/cli/configuration/create.py +3 -3
  95. nextmv/cli/configuration/delete.py +7 -7
  96. nextmv/cli/configuration/list.py +3 -3
  97. nextmv/cli/confirm.py +32 -0
  98. nextmv/cli/main.py +27 -36
  99. nextmv/cli/message.py +2 -2
  100. nextmv/cli/version.py +1 -1
  101. nextmv/cloud/application/__init__.py +190 -54
  102. nextmv/cloud/application/_batch_scenario.py +2 -2
  103. nextmv/cloud/application/_instance.py +2 -2
  104. nextmv/cloud/application/_managed_input.py +1 -1
  105. nextmv/cloud/application/_shadow.py +1 -1
  106. nextmv/cloud/application/_switchback.py +11 -3
  107. nextmv/cloud/application/_version.py +3 -2
  108. nextmv/cloud/shadow.py +43 -4
  109. nextmv/cloud/switchback.py +46 -9
  110. {nextmv-1.0.0.dev3.dist-info → nextmv-1.0.0.dev4.dist-info}/METADATA +1 -1
  111. nextmv-1.0.0.dev4.dist-info/RECORD +183 -0
  112. nextmv-1.0.0.dev3.dist-info/RECORD +0 -181
  113. {nextmv-1.0.0.dev3.dist-info → nextmv-1.0.0.dev4.dist-info}/WHEEL +0 -0
  114. {nextmv-1.0.0.dev3.dist-info → nextmv-1.0.0.dev4.dist-info}/entry_points.txt +0 -0
  115. {nextmv-1.0.0.dev3.dist-info → nextmv-1.0.0.dev4.dist-info}/licenses/LICENSE +0 -0
@@ -7,7 +7,8 @@ from typing import Any
7
7
 
8
8
  import yaml
9
9
 
10
- from nextmv.cli.message import error
10
+ from nextmv.cli.confirm import get_confirmation
11
+ from nextmv.cli.message import error, success, warning
11
12
  from nextmv.cloud.account import Account
12
13
  from nextmv.cloud.application import Application
13
14
  from nextmv.cloud.client import Client
@@ -59,6 +60,18 @@ def save_config(config: dict[str, Any]) -> None:
59
60
  yaml.safe_dump(config, file)
60
61
 
61
62
 
63
+ def non_profile_keys() -> set[str]:
64
+ """
65
+ Returns the set of keys that are not profile names in the configuration.
66
+
67
+ Returns
68
+ -------
69
+ set[str]
70
+ The set of non-profile keys.
71
+ """
72
+ return {API_KEY_KEY, ENDPOINT_KEY}
73
+
74
+
62
75
  def build_client(profile: str | None = None) -> Client:
63
76
  """
64
77
  Builds a `cloud.Client` using the API key and endpoint for the given
@@ -91,23 +104,35 @@ def build_client(profile: str | None = None) -> Client:
91
104
 
92
105
  if profile is not None:
93
106
  if profile not in config:
94
- error(f"Profile [magenta]{profile}[/magenta] does not exist.")
107
+ error(
108
+ f"Profile [magenta]{profile}[/magenta] does not exist. "
109
+ "Create it using [code]nextmv configuration create[/code] with the --profile option."
110
+ )
95
111
 
96
112
  api_key = config[profile].get(API_KEY_KEY)
97
113
  if api_key is None or api_key == "":
98
- error(f"API key for profile [magenta]{profile}[/magenta] is not set or is empty.")
114
+ error(
115
+ f"API key for profile [magenta]{profile}[/magenta] is not set or is empty. "
116
+ "Set it using [code]nextmv configuration create[/code] with the --profile and --api-key options."
117
+ )
99
118
 
100
119
  endpoint = config[profile].get(ENDPOINT_KEY)
101
120
  if endpoint is None or endpoint == "":
102
- error(f"Endpoint for profile [magenta]{profile}[/magenta] is not set or is empty.")
121
+ error(
122
+ f"Endpoint for profile [magenta]{profile}[/magenta] is not set or is empty. "
123
+ "Please run [code]nextmv configuration create[/code]."
124
+ )
103
125
  else:
104
126
  api_key = config.get(API_KEY_KEY)
105
127
  if api_key is None or api_key == "":
106
- error("Default API key is not set or is empty.")
128
+ error(
129
+ "Default API key is not set or is empty. "
130
+ "Please run [code]nextmv configuration create[/code] with the --api-key option."
131
+ )
107
132
 
108
133
  endpoint = config.get(ENDPOINT_KEY)
109
134
  if endpoint is None or endpoint == "":
110
- error("Default endpoint is not set or is empty.")
135
+ error("Default endpoint is not set or is empty. Please run [code]nextmv configuration create[/code].")
111
136
 
112
137
  return Client(api_key=api_key, url=f"https://{endpoint}")
113
138
 
@@ -137,13 +162,21 @@ def build_app(app_id: str, profile: str | None = None) -> Application:
137
162
  """
138
163
  client = build_client(profile)
139
164
  exists = Application.exists(client=client, id=app_id)
140
- if not exists:
165
+ if exists:
166
+ return Application(client=client, id=app_id)
167
+
168
+ warning(f"Application with ID [magenta]{app_id}[/magenta] does not exist.")
169
+ should_create = get_confirmation(f"Do you want to create a new application with ID [magenta]{app_id}[/magenta]?")
170
+ if not should_create:
141
171
  error(
142
- f"Application with ID [magenta]{app_id}[/magenta] does not exist. "
143
- "Use [code]nextmv cloud app create[/code] to create a new application."
172
+ f"Application with ID [magenta]{app_id}[/magenta] was not created and does not exist. "
173
+ "Use [code]nextmv cloud app create[/code] to create a new app."
144
174
  )
145
175
 
146
- return Application(client=client, id=app_id)
176
+ app = Application.new(client=client, id=app_id, name=app_id)
177
+ success(f"Application with ID and name [magenta]{app_id}[/magenta] created successfully.")
178
+
179
+ return app
147
180
 
148
181
 
149
182
  def build_account(account_id: str | None = None, profile: str | None = None) -> Account:
@@ -58,14 +58,14 @@ def create(
58
58
  [bold][underline]Examples[/underline][/bold]
59
59
 
60
60
  - Default configuration.
61
- $ [green]nextmv configuration create --api-key NEXTMV_API_KEY[/green]
61
+ $ [dim]nextmv configuration create --api-key NEXTMV_API_KEY[/dim]
62
62
 
63
63
  - Configure a profile named [magenta]hare[/magenta].
64
- $ [green]nextmv configuration create --api-key NEXTMV_API_KEY --profile hare[/green]
64
+ $ [dim]nextmv configuration create --api-key NEXTMV_API_KEY --profile hare[/dim]
65
65
  """
66
66
 
67
67
  if profile is not None and profile.strip().lower() == "default":
68
- error("[code]default[/code] is a reserved profile name.")
68
+ error("[magenta]default[/magenta] is a reserved profile name.")
69
69
 
70
70
  endpoint = str(endpoint)
71
71
  if endpoint.startswith("https://"):
@@ -5,9 +5,9 @@ This module defines the configuration delete command for the Nextmv CLI.
5
5
  from typing import Annotated
6
6
 
7
7
  import typer
8
- from rich.prompt import Confirm
9
8
 
10
9
  from nextmv.cli.configuration.config import load_config, save_config
10
+ from nextmv.cli.confirm import get_confirmation
11
11
  from nextmv.cli.message import error, info, success
12
12
 
13
13
  # Set up subcommand application.
@@ -36,25 +36,25 @@ def delete(
36
36
  ] = False,
37
37
  ) -> None:
38
38
  """
39
- Delete a profile from the configuration. Use the [code]--yes[/code]
40
- flag to skip the confirmation prompt.
39
+ Delete a profile from the configuration.
40
+
41
+ Use the --yes flag to skip the confirmation prompt.
41
42
 
42
43
  [bold][underline]Examples[/underline][/bold]
43
44
 
44
45
  - Delete a profile named [magenta]hare[/magenta].
45
- $ [green]nextmv configuration delete --profile hare[/green]
46
+ $ [dim]nextmv configuration delete --profile hare[/dim]
46
47
 
47
48
  - Delete a profile named [magenta]hare[/magenta] without confirmation prompt.
48
- $ [green]nextmv configuration delete --profile hare --yes[/green]
49
+ $ [dim]nextmv configuration delete --profile hare --yes[/dim]
49
50
  """
50
51
  config = load_config()
51
52
  if profile not in config:
52
53
  error(f"Profile [magenta]{profile}[/magenta] does not exist.")
53
54
 
54
55
  if not yes:
55
- confirm = Confirm.ask(
56
+ confirm = get_confirmation(
56
57
  f"Are you sure you want to delete profile [magenta]{profile}[/magenta]? This action cannot be undone.",
57
- default=False,
58
58
  )
59
59
 
60
60
  if not confirm:
@@ -6,7 +6,7 @@ import typer
6
6
  from rich.console import Console
7
7
  from rich.table import Table
8
8
 
9
- from nextmv.cli.configuration.config import API_KEY_KEY, ENDPOINT_KEY, load_config, obscure_api_key
9
+ from nextmv.cli.configuration.config import API_KEY_KEY, ENDPOINT_KEY, load_config, non_profile_keys, obscure_api_key
10
10
  from nextmv.cli.message import error
11
11
 
12
12
  # Set up subcommand application.
@@ -22,7 +22,7 @@ def list() -> None:
22
22
  [bold][underline]Examples[/underline][/bold]
23
23
 
24
24
  - Show current configuration and all profiles.
25
- $ [green]nextmv configuration list[/green]
25
+ $ [dim]nextmv configuration list[/dim]
26
26
  """
27
27
 
28
28
  config = load_config()
@@ -38,7 +38,7 @@ def list() -> None:
38
38
 
39
39
  for k, v in config.items():
40
40
  # Skip default configuration.
41
- if k in {API_KEY_KEY, ENDPOINT_KEY}:
41
+ if k in non_profile_keys():
42
42
  continue
43
43
 
44
44
  profile = {
nextmv/cli/confirm.py ADDED
@@ -0,0 +1,32 @@
1
+ import sys
2
+
3
+ from rich.prompt import Confirm
4
+
5
+
6
+ def get_confirmation(msg: str) -> bool:
7
+ """
8
+ Method to get a yes/no confirmation from the user.
9
+
10
+ Parameters
11
+ ----------
12
+ msg : str
13
+ The message to display to the user.
14
+
15
+ Returns
16
+ -------
17
+ bool
18
+ True if the user confirmed, False otherwise.
19
+ """
20
+
21
+ # If this is not an interactive terminal, do not ask for confirmation, to
22
+ # avoid hanging indefinitely waiting for a user response.
23
+ if not sys.stdin.isatty():
24
+ return False
25
+
26
+ return Confirm.ask(
27
+ msg,
28
+ default=False,
29
+ case_sensitive=False,
30
+ show_default=True,
31
+ show_choices=True,
32
+ )
nextmv/cli/main.py CHANGED
@@ -13,22 +13,25 @@ about the features used here. An example of Rich markup can be found in the
13
13
  epilog of the Typer application defined below.
14
14
  """
15
15
 
16
- import os
17
16
  import sys
18
17
  from typing import Annotated
19
18
 
20
19
  import rich
21
20
  import typer
22
- from rich.prompt import Confirm
21
+ from typer import rich_utils
23
22
 
24
23
  from nextmv.cli.cloud import app as cloud_app
25
24
  from nextmv.cli.community import app as community_app
26
25
  from nextmv.cli.configuration import app as configuration_app
27
26
  from nextmv.cli.configuration.config import CONFIG_DIR, GO_CLI_PATH, load_config
27
+ from nextmv.cli.confirm import get_confirmation
28
28
  from nextmv.cli.message import error, info, success, warning
29
29
  from nextmv.cli.version import app as version_app
30
30
  from nextmv.cli.version import version_callback
31
31
 
32
+ # Disable dim text for the extended help of commands.
33
+ rich_utils.STYLE_HELPTEXT = ""
34
+
32
35
  # Main CLI application.
33
36
  app = typer.Typer(
34
37
  help="The Nextmv Command Line Interface (CLI).",
@@ -66,6 +69,15 @@ def callback(
66
69
  environment.
67
70
  """
68
71
 
72
+ # Skip checks for help commands.
73
+ if "--help" in sys.argv or "-h" in sys.argv:
74
+ return
75
+
76
+ # Skip checks for certain commands.
77
+ ignored_commands = {"configuration", "version"}
78
+ if ctx.invoked_subcommand in ignored_commands:
79
+ return
80
+
69
81
  handle_go_cli()
70
82
  handle_config_existence(ctx)
71
83
 
@@ -80,19 +92,21 @@ def handle_go_cli() -> None:
80
92
 
81
93
  exists = go_cli_exists()
82
94
  if exists:
83
- delete = Confirm.ask(
95
+ delete = get_confirmation(
84
96
  "Do you want to delete the [italic red]deprecated[/italic red] Nextmv CLI "
85
- f"at [magenta]{GO_CLI_PATH}[/magenta] now?",
86
- default=False,
97
+ f"at [magenta]{GO_CLI_PATH}[/magenta] now?"
87
98
  )
88
99
  if delete:
89
100
  remove_go_cli()
90
- else:
91
- info(
92
- msg="You can delete the [italic red]deprecated[/italic red] Nextmv CLI later by removing "
93
- f"[magenta]{GO_CLI_PATH}[/magenta]. Make sure you also clean up your [code]PATH[/code].",
94
- emoji=":bulb:",
95
- )
101
+ return
102
+
103
+ info(
104
+ msg="You can delete the [italic red]deprecated[/italic red] Nextmv CLI later by removing "
105
+ f"[magenta]{GO_CLI_PATH}[/magenta]. "
106
+ "Make sure you also clean up your [code]PATH[/code], "
107
+ f"by removing references to [magenta]{CONFIG_DIR}[/magenta] from it.",
108
+ emoji=":bulb:",
109
+ )
96
110
 
97
111
 
98
112
  def handle_config_existence(ctx: typer.Context) -> None:
@@ -105,10 +119,6 @@ def handle_config_existence(ctx: typer.Context) -> None:
105
119
  The Typer context object.
106
120
  """
107
121
 
108
- ignored_commands = {"configuration", "version"}
109
- if ctx.invoked_subcommand in ignored_commands:
110
- return
111
-
112
122
  config = load_config()
113
123
  if config == {}:
114
124
  error("No configuration found. Please run [code]nextmv configuration create[/code].")
@@ -130,11 +140,9 @@ def go_cli_exists() -> bool:
130
140
  if exists:
131
141
  warning(
132
142
  "A [italic red]deprecated[/italic red] Nextmv CLI is installed at "
133
- f"[magenta]{GO_CLI_PATH}[/magenta]. You must delete it to avoid conflicts."
143
+ f"[magenta]{GO_CLI_PATH}[/magenta]. You should delete it to avoid conflicts."
134
144
  )
135
145
 
136
- check_config_in_path()
137
-
138
146
  return exists
139
147
 
140
148
 
@@ -145,24 +153,7 @@ def remove_go_cli() -> None:
145
153
 
146
154
  if GO_CLI_PATH.exists():
147
155
  GO_CLI_PATH.unlink()
148
- success(f"Deleted deprecated [magenta]{GO_CLI_PATH}[/magenta].")
149
-
150
- check_config_in_path()
151
-
152
-
153
- def check_config_in_path() -> None:
154
- """
155
- Check if the configuration directory is in the PATH and notify the user.
156
- """
157
-
158
- path_dirs = os.environ.get("PATH", "").split(os.pathsep)
159
- config_dir_str = str(CONFIG_DIR)
160
-
161
- if config_dir_str in path_dirs:
162
- warning(
163
- f"[magenta]{CONFIG_DIR}[/magenta] was found in your [code]PATH[/code]. "
164
- f"You should remove any entries related to [magenta]{CONFIG_DIR}[/magenta] from your [code]PATH[/code]."
165
- )
156
+ success(f"Deleted [italic red]deprecated[/italic red] [magenta]{GO_CLI_PATH}[/magenta].")
166
157
 
167
158
 
168
159
  def main() -> None:
nextmv/cli/message.py CHANGED
@@ -31,7 +31,7 @@ def error(msg: str) -> None:
31
31
  if not msg.endswith("."):
32
32
  msg += "."
33
33
 
34
- rich.print(f"[red]Error:[/red] {msg}", file=sys.stderr)
34
+ rich.print(f":x: [red]Error:[/red] {msg}", file=sys.stderr)
35
35
 
36
36
  raise typer.Exit(code=1)
37
37
 
@@ -67,7 +67,7 @@ def warning(msg: str) -> None:
67
67
  if not msg.endswith("."):
68
68
  msg += "."
69
69
 
70
- rich.print(f":construction: {msg}", file=sys.stderr)
70
+ rich.print(f":construction: [yellow] Warning:[/yellow] {msg}", file=sys.stderr)
71
71
 
72
72
 
73
73
  def info(msg: str, emoji: str | None = None) -> None:
nextmv/cli/version.py CHANGED
@@ -18,7 +18,7 @@ def version() -> None:
18
18
  [bold][underline]Examples[/underline][/bold]
19
19
 
20
20
  - Show the version.
21
- $ [green]nextmv version[/green]
21
+ $ [dim]nextmv version[/dim]
22
22
  """
23
23
 
24
24
  version_callback(True)