azure-cli-core 2.85.0__tar.gz → 2.86.0__tar.gz
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.
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/HISTORY.rst +6 -0
- {azure_cli_core-2.85.0/azure_cli_core.egg-info → azure_cli_core-2.86.0}/PKG-INFO +2 -2
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/__init__.py +1 -1
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/_help.py +1 -11
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/_profile.py +75 -13
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/__init__.py +2 -1
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_command.py +175 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/azclierror.py +11 -8
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/breaking_change.py +2 -2
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/cloud.py +1 -4
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/commandIndex.latest.json +1 -1
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/command_recommender.py +4 -205
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/helpIndex.latest.json +1 -1
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/parser.py +2 -2
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0/azure_cli_core.egg-info}/PKG-INFO +2 -2
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure_cli_core.egg-info/requires.txt +1 -1
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/setup.py +2 -2
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/LICENSE.txt +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/MANIFEST.in +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/README.rst +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/__init__.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/__init__.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/_breaking_change.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/_completers.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/_config.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/_debug.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/_environment.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/_help_loaders.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/_output.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/_session.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_arg.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_arg_action.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_arg_browser.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_arg_fmt.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_base.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_client.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_command_ctx.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_content_builder.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_error_format.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_field_type.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_field_value.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_help.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_http_policy.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_operation.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_paging.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_poller.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_prompt.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_selector.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/_utils.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/exceptions.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/aaz/utils.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/api.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/auth/__init__.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/auth/binary_cache.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/auth/constants.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/auth/credential_adaptor.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/auth/identity.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/auth/landing_pages/error.html +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/auth/landing_pages/success.html +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/auth/msal_credentials.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/auth/persistence.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/auth/util.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/azlogging.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/commands/__init__.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/commands/arm.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/commands/client_factory.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/commands/command_operation.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/commands/constants.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/commands/events.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/commands/parameters.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/commands/progress.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/commands/sensitive.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/commands/template_create.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/commands/transform.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/commands/validators.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/credential_helper.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/decorators.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/extension/__init__.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/extension/_homebrew_patch.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/extension/_index.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/extension/_resolve.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/extension/dynamic_install.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/extension/operations.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/file_util.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/intercept_survey.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/keys.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/local_context.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/mock.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/profiles/__init__.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/profiles/_shared.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/sdk/__init__.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/sdk/policies.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/style.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/telemetry.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/util.py +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure_cli_core.egg-info/SOURCES.txt +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure_cli_core.egg-info/dependency_links.txt +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure_cli_core.egg-info/not-zip-safe +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure_cli_core.egg-info/top_level.txt +0 -0
- {azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: azure-cli-core
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.86.0
|
|
4
4
|
Summary: Microsoft Azure Command-Line Tools Core Module
|
|
5
5
|
Home-page: https://github.com/Azure/azure-cli
|
|
6
6
|
Author: Microsoft Corporation
|
|
@@ -28,7 +28,7 @@ Requires-Dist: humanfriendly~=10.0
|
|
|
28
28
|
Requires-Dist: jmespath
|
|
29
29
|
Requires-Dist: knack~=0.11.0
|
|
30
30
|
Requires-Dist: microsoft-security-utilities-secret-masker~=1.0.0b4
|
|
31
|
-
Requires-Dist: msal-extensions==1.
|
|
31
|
+
Requires-Dist: msal-extensions==1.3.1
|
|
32
32
|
Requires-Dist: msal[broker]==1.35.1; sys_platform == "win32"
|
|
33
33
|
Requires-Dist: msal==1.35.1; sys_platform != "win32"
|
|
34
34
|
Requires-Dist: packaging>=20.9
|
|
@@ -129,7 +129,6 @@ class CLIPrintMixin(CLIHelp):
|
|
|
129
129
|
def _print_detailed_help(self, cli_name, help_file):
|
|
130
130
|
CLIPrintMixin._print_extensions_msg(help_file)
|
|
131
131
|
super()._print_detailed_help(cli_name, help_file)
|
|
132
|
-
self._print_az_find_message(help_file.command)
|
|
133
132
|
|
|
134
133
|
@staticmethod
|
|
135
134
|
def _get_choices_defaults_sources_str(p):
|
|
@@ -154,12 +153,6 @@ class CLIPrintMixin(CLIHelp):
|
|
|
154
153
|
_print_indent('{0}'.format(e.command), indent)
|
|
155
154
|
print('')
|
|
156
155
|
|
|
157
|
-
@staticmethod
|
|
158
|
-
def _print_az_find_message(command):
|
|
159
|
-
indent = 0
|
|
160
|
-
message = 'To search AI knowledge base for examples, use: az find "az {}"'.format(command)
|
|
161
|
-
_print_indent(message + '\n', indent)
|
|
162
|
-
|
|
163
156
|
@staticmethod
|
|
164
157
|
def _process_value_sources(p):
|
|
165
158
|
commands, strings, urls = [], [], []
|
|
@@ -401,10 +394,7 @@ class AzCliHelp(CLIPrintMixin, CLIHelp):
|
|
|
401
394
|
|
|
402
395
|
self._print_cached_help_section(groups_items, "Subgroups:", max_line_len)
|
|
403
396
|
self._print_cached_help_section(commands_items, "Commands:", max_line_len)
|
|
404
|
-
|
|
405
|
-
# Use same az find message as non-cached path
|
|
406
|
-
print() # Blank line before the message
|
|
407
|
-
self._print_az_find_message('')
|
|
397
|
+
print()
|
|
408
398
|
|
|
409
399
|
from azure.cli.core.util import show_updates_available
|
|
410
400
|
show_updates_available(new_line_after=True)
|
|
@@ -152,7 +152,9 @@ class Profile:
|
|
|
152
152
|
allow_no_subscriptions=False,
|
|
153
153
|
use_cert_sn_issuer=None,
|
|
154
154
|
show_progress=False,
|
|
155
|
-
claims_challenge=None
|
|
155
|
+
claims_challenge=None,
|
|
156
|
+
skip_subscription_discovery=False,
|
|
157
|
+
subscription=None):
|
|
156
158
|
"""
|
|
157
159
|
For service principal, `password` is a dict returned by ServicePrincipalAuth.build_credential
|
|
158
160
|
"""
|
|
@@ -198,15 +200,31 @@ class Profile:
|
|
|
198
200
|
else:
|
|
199
201
|
credential = identity.get_service_principal_credential(username)
|
|
200
202
|
|
|
201
|
-
|
|
203
|
+
is_bare_mode = skip_subscription_discovery and not subscription
|
|
204
|
+
|
|
205
|
+
if skip_subscription_discovery and subscription:
|
|
206
|
+
# Fast path: fetch only the specified subscription (1 API call)
|
|
207
|
+
subscriptions = subscription_finder.find_specific_subscriptions(
|
|
208
|
+
tenant, credential, [subscription])
|
|
209
|
+
elif is_bare_mode:
|
|
210
|
+
# Bare mode: no ARM subscription calls. Tenant-level account will be created below
|
|
211
|
+
subscriptions = []
|
|
212
|
+
subscription_finder.tenants.append(tenant)
|
|
213
|
+
elif tenant:
|
|
202
214
|
subscriptions = subscription_finder.find_using_specific_tenant(tenant, credential)
|
|
203
215
|
else:
|
|
204
216
|
subscriptions = subscription_finder.find_using_common_tenant(username, credential)
|
|
205
217
|
|
|
206
218
|
if not subscriptions and not allow_no_subscriptions:
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
219
|
+
if skip_subscription_discovery and subscription:
|
|
220
|
+
raise CLIError(
|
|
221
|
+
"The subscription '{}' could not be retrieved for '{}'. "
|
|
222
|
+
"Ensure the subscription exists and that you have access to it.".format(
|
|
223
|
+
subscription, username))
|
|
224
|
+
if not is_bare_mode:
|
|
225
|
+
raise CLIError("No subscriptions found for {}.".format(username))
|
|
226
|
+
|
|
227
|
+
if allow_no_subscriptions or is_bare_mode:
|
|
210
228
|
t_list = [s.tenant_id for s in subscriptions]
|
|
211
229
|
bare_tenants = [t for t in subscription_finder.tenants if t not in t_list]
|
|
212
230
|
tenant_accounts = self._build_tenant_level_accounts(bare_tenants)
|
|
@@ -216,8 +234,24 @@ class Profile:
|
|
|
216
234
|
|
|
217
235
|
consolidated = self._normalize_properties(username, subscriptions,
|
|
218
236
|
is_service_principal, bool(use_cert_sn_issuer))
|
|
237
|
+
self._set_subscriptions(consolidated, preferred_subscription=subscription)
|
|
238
|
+
|
|
239
|
+
if subscription:
|
|
240
|
+
matches = [s for s in consolidated
|
|
241
|
+
if s[_SUBSCRIPTION_ID].lower() == subscription.lower() or
|
|
242
|
+
s.get(_SUBSCRIPTION_NAME, '').lower() == subscription.lower()]
|
|
243
|
+
if matches:
|
|
244
|
+
return deepcopy(matches)
|
|
245
|
+
if skip_subscription_discovery:
|
|
246
|
+
# --skip-subscription-discovery + --subscription S, but S is inaccessible.
|
|
247
|
+
# without --allow-no-subscriptions → already errored above
|
|
248
|
+
# with --allow-no-subscriptions → tenant-level account only (we reach here)
|
|
249
|
+
logger.warning("Subscription '%s' not found. Profile has tenant-level account only.",
|
|
250
|
+
subscription)
|
|
251
|
+
else:
|
|
252
|
+
raise CLIError("Subscription '{}' not found. Check the ID or name and try again."
|
|
253
|
+
.format(subscription))
|
|
219
254
|
|
|
220
|
-
self._set_subscriptions(consolidated)
|
|
221
255
|
return deepcopy(consolidated)
|
|
222
256
|
|
|
223
257
|
def login_with_managed_identity(self, client_id=None, object_id=None, resource_id=None,
|
|
@@ -463,7 +497,8 @@ class Profile:
|
|
|
463
497
|
s.state = 'Enabled'
|
|
464
498
|
return s
|
|
465
499
|
|
|
466
|
-
def _set_subscriptions(self, new_subscriptions, merge=True, secondary_key_name=None
|
|
500
|
+
def _set_subscriptions(self, new_subscriptions, merge=True, secondary_key_name=None,
|
|
501
|
+
preferred_subscription=None):
|
|
467
502
|
|
|
468
503
|
def _get_key_name(account, secondary_key_name):
|
|
469
504
|
return (account[_SUBSCRIPTION_ID] if secondary_key_name is None
|
|
@@ -489,17 +524,26 @@ class Profile:
|
|
|
489
524
|
dic.update((_get_key_name(x, secondary_key_name), x) for x in new_subscriptions)
|
|
490
525
|
subscriptions = list(dic.values())
|
|
491
526
|
if subscriptions:
|
|
492
|
-
|
|
527
|
+
new_active_one = None
|
|
528
|
+
|
|
529
|
+
# If a preferred subscription is specified, try to use it as default
|
|
530
|
+
if preferred_subscription:
|
|
531
|
+
preferred_lower = preferred_subscription.lower()
|
|
532
|
+
new_active_one = next(
|
|
533
|
+
(x for x in new_subscriptions
|
|
534
|
+
if x[_SUBSCRIPTION_ID].lower() == preferred_lower or
|
|
535
|
+
x.get(_SUBSCRIPTION_NAME, '').lower() == preferred_lower), None)
|
|
536
|
+
|
|
537
|
+
# Fall back to previously active subscription if still present
|
|
538
|
+
if not new_active_one and active_one:
|
|
493
539
|
new_active_one = next(
|
|
494
540
|
(x for x in new_subscriptions if _match_account(x, active_subscription_id, secondary_key_name,
|
|
495
541
|
active_secondary_key_val)), None)
|
|
496
542
|
|
|
497
|
-
|
|
498
|
-
|
|
543
|
+
for s in subscriptions:
|
|
544
|
+
s[_IS_DEFAULT_SUBSCRIPTION] = False
|
|
499
545
|
|
|
500
|
-
|
|
501
|
-
new_active_one = Profile._pick_working_subscription(new_subscriptions)
|
|
502
|
-
else:
|
|
546
|
+
if not new_active_one:
|
|
503
547
|
new_active_one = Profile._pick_working_subscription(new_subscriptions)
|
|
504
548
|
|
|
505
549
|
new_active_one[_IS_DEFAULT_SUBSCRIPTION] = True
|
|
@@ -507,6 +551,7 @@ class Profile:
|
|
|
507
551
|
|
|
508
552
|
set_cloud_subscription(self.cli_ctx, active_cloud.name, default_sub_id)
|
|
509
553
|
self._storage[_SUBSCRIPTIONS] = subscriptions
|
|
554
|
+
return subscriptions
|
|
510
555
|
|
|
511
556
|
@staticmethod
|
|
512
557
|
def _pick_working_subscription(subscriptions):
|
|
@@ -856,6 +901,23 @@ class SubscriptionFinder:
|
|
|
856
901
|
self.tenants.append(tenant)
|
|
857
902
|
return all_subscriptions
|
|
858
903
|
|
|
904
|
+
def find_specific_subscriptions(self, tenant, credential, subscription_ids):
|
|
905
|
+
"""Fetch specific subscriptions by ID using GET /subscriptions/{id}
|
|
906
|
+
instead of listing all subscriptions.
|
|
907
|
+
https://learn.microsoft.com/en-us/rest/api/resources/subscriptions/get
|
|
908
|
+
"""
|
|
909
|
+
client = self._create_subscription_client(credential)
|
|
910
|
+
all_subscriptions = []
|
|
911
|
+
for sub_id in subscription_ids:
|
|
912
|
+
try:
|
|
913
|
+
s = client.subscriptions.get(sub_id)
|
|
914
|
+
_attach_token_tenant(s, tenant)
|
|
915
|
+
all_subscriptions.append(s)
|
|
916
|
+
except Exception as ex: # pylint: disable=broad-except
|
|
917
|
+
logger.warning("Failed to retrieve subscription %s: %s", sub_id, ex)
|
|
918
|
+
self.tenants.append(tenant)
|
|
919
|
+
return all_subscriptions
|
|
920
|
+
|
|
859
921
|
def _create_subscription_client(self, credential):
|
|
860
922
|
from azure.cli.core.profiles import ResourceType, get_api_version
|
|
861
923
|
from azure.cli.core.profiles._shared import get_client_class
|
|
@@ -21,7 +21,8 @@ from ._arg_fmt import AAZStrArgFormat, AAZIntArgFormat, AAZFloatArgFormat, AAZBo
|
|
|
21
21
|
AAZPaginationTokenArgFormat
|
|
22
22
|
from ._base import has_value, AAZValuePatch, AAZUndefined
|
|
23
23
|
from ._command import AAZCommand, AAZWaitCommand, AAZCommandGroup, \
|
|
24
|
-
register_callback, register_command, register_command_group, load_aaz_command_table,
|
|
24
|
+
register_callback, register_command, register_command_group, load_aaz_command_table, \
|
|
25
|
+
load_aaz_command_table_args_guided, link_helper
|
|
25
26
|
from ._field_type import AAZIntType, AAZFloatType, AAZStrType, AAZBoolType, AAZDictType, AAZFreeFormDictType, \
|
|
26
27
|
AAZListType, AAZObjectType, AAZIdentityObjectType, AAZAnyType
|
|
27
28
|
from ._operation import AAZHttpOperation, AAZJsonInstanceUpdateOperation, AAZGenericInstanceUpdateOperation, \
|
|
@@ -387,6 +387,181 @@ def register_command(
|
|
|
387
387
|
AAZ_PACKAGE_FULL_LOAD_ENV_NAME = 'AZURE_AAZ_FULL_LOAD'
|
|
388
388
|
|
|
389
389
|
|
|
390
|
+
def load_aaz_command_table_args_guided(loader, aaz_pkg_name, args):
|
|
391
|
+
"""Args-guided AAZ command tree loader.
|
|
392
|
+
|
|
393
|
+
Instead of importing the entire AAZ package tree (all __init__.py files which eagerly
|
|
394
|
+
import all command classes), this function navigates only to the relevant subtree based
|
|
395
|
+
on CLI args. For example, ``az monitor log-analytics workspace create --help`` only loads
|
|
396
|
+
the ``workspace`` sub-package and the ``_create`` module, skipping all other commands.
|
|
397
|
+
|
|
398
|
+
This requires that AAZ ``__init__.py`` files do NOT contain wildcard imports
|
|
399
|
+
(``from ._create import *`` etc.) -- they should be empty (just the license header).
|
|
400
|
+
"""
|
|
401
|
+
profile_pkg = _get_profile_pkg(aaz_pkg_name, loader.cli_ctx.cloud)
|
|
402
|
+
|
|
403
|
+
command_table = {}
|
|
404
|
+
command_group_table = {}
|
|
405
|
+
if args is None or os.environ.get(AAZ_PACKAGE_FULL_LOAD_ENV_NAME, 'False').lower() == 'true':
|
|
406
|
+
effective_args = None # fully load
|
|
407
|
+
else:
|
|
408
|
+
effective_args = list(args)
|
|
409
|
+
if profile_pkg is not None:
|
|
410
|
+
_load_aaz_by_pkg(loader, profile_pkg, effective_args,
|
|
411
|
+
command_table, command_group_table)
|
|
412
|
+
|
|
413
|
+
for group_name, command_group in command_group_table.items():
|
|
414
|
+
loader.command_group_table[group_name] = command_group
|
|
415
|
+
for command_name, command in command_table.items():
|
|
416
|
+
loader.command_table[command_name] = command
|
|
417
|
+
return command_table, command_group_table
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
def _try_import_module(relative_name, package):
|
|
421
|
+
"""Try to import a module by relative name, return None on failure."""
|
|
422
|
+
try:
|
|
423
|
+
return importlib.import_module(relative_name, package)
|
|
424
|
+
except ModuleNotFoundError as ex:
|
|
425
|
+
# Only treat "module not found" for the requested module as a benign miss.
|
|
426
|
+
target_mod_name = f"{package}.{relative_name.lstrip('.')}"
|
|
427
|
+
if ex.name == target_mod_name:
|
|
428
|
+
return None
|
|
429
|
+
# Different module is missing; propagate so the real error surfaces.
|
|
430
|
+
raise
|
|
431
|
+
except ImportError:
|
|
432
|
+
logger.error("Error importing module %r from package %r", relative_name, package)
|
|
433
|
+
raise
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
def _register_from_module(loader, mod, command_table, command_group_table):
|
|
437
|
+
"""Scan a module's namespace for AAZCommand/AAZCommandGroup classes and register them."""
|
|
438
|
+
for value in mod.__dict__.values():
|
|
439
|
+
if not isinstance(value, type):
|
|
440
|
+
continue
|
|
441
|
+
if value.__module__ != mod.__name__: # skip imported classes
|
|
442
|
+
continue
|
|
443
|
+
if issubclass(value, AAZCommandGroup) and value.AZ_NAME:
|
|
444
|
+
command_group_table[value.AZ_NAME] = value(cli_ctx=loader.cli_ctx)
|
|
445
|
+
elif issubclass(value, AAZCommand) and value.AZ_NAME:
|
|
446
|
+
command_table[value.AZ_NAME] = value(loader=loader)
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
def _get_pkg_children(pkg):
|
|
450
|
+
"""List child entries of a package using pkgutil.
|
|
451
|
+
|
|
452
|
+
Returns two sets: (file_stems, subdir_names).
|
|
453
|
+
- file_stems: module-like stems, e.g. {'_create', '_list', '__cmd_group'}
|
|
454
|
+
- subdir_names: sub-package directory names, e.g. {'namespace', 'eventhub'}
|
|
455
|
+
"""
|
|
456
|
+
import pkgutil
|
|
457
|
+
file_stems = set()
|
|
458
|
+
subdir_names = set()
|
|
459
|
+
|
|
460
|
+
pkg_path = getattr(pkg, '__path__', None)
|
|
461
|
+
if not pkg_path:
|
|
462
|
+
return file_stems, subdir_names
|
|
463
|
+
|
|
464
|
+
for _importer, name, ispkg in pkgutil.iter_modules(pkg_path):
|
|
465
|
+
if ispkg:
|
|
466
|
+
if not name.startswith('_'):
|
|
467
|
+
subdir_names.add(name)
|
|
468
|
+
else:
|
|
469
|
+
file_stems.add(name)
|
|
470
|
+
|
|
471
|
+
return file_stems, subdir_names
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
def _load_aaz_by_pkg(loader, pkg, args, command_table, command_group_table):
|
|
475
|
+
"""Recursively navigate the AAZ package tree guided by CLI args.
|
|
476
|
+
|
|
477
|
+
- args is None -> full recursive load of all commands under this package.
|
|
478
|
+
- args is empty list -> args exhausted; load current level's commands and sub-group headers.
|
|
479
|
+
- args has items -> try to match first arg as a command module or sub-package,
|
|
480
|
+
recurse with remaining args on match.
|
|
481
|
+
- no match on first arg -> load current level's commands and sub-group headers.
|
|
482
|
+
"""
|
|
483
|
+
base_module = pkg.__name__
|
|
484
|
+
file_stems, subdir_names = _get_pkg_children(pkg)
|
|
485
|
+
|
|
486
|
+
if args is not None and args and not args[0].startswith('-'):
|
|
487
|
+
first_arg = args[0].lower().replace('-', '_')
|
|
488
|
+
|
|
489
|
+
# First arg matches a command module (e.g. "create" -> "_create")
|
|
490
|
+
if f"_{first_arg}" in file_stems:
|
|
491
|
+
mod = _try_import_module(f"._{first_arg}", base_module)
|
|
492
|
+
if mod:
|
|
493
|
+
_register_from_module(loader, mod, command_table, command_group_table)
|
|
494
|
+
return
|
|
495
|
+
|
|
496
|
+
# First arg matches a sub-package (command group)
|
|
497
|
+
if first_arg in subdir_names:
|
|
498
|
+
sub_module = f"{base_module}.{first_arg}"
|
|
499
|
+
mod = _try_import_module('.__cmd_group', sub_module)
|
|
500
|
+
if mod:
|
|
501
|
+
_register_from_module(loader, mod, command_table, command_group_table)
|
|
502
|
+
sub_pkg = _try_import_module(f'.{first_arg}', base_module)
|
|
503
|
+
if sub_pkg:
|
|
504
|
+
_load_aaz_by_pkg(loader, sub_pkg, args[1:], command_table, command_group_table)
|
|
505
|
+
return
|
|
506
|
+
|
|
507
|
+
# Load __cmd_group + all command modules at this level
|
|
508
|
+
mod = _try_import_module('.__cmd_group', base_module)
|
|
509
|
+
if mod:
|
|
510
|
+
_register_from_module(loader, mod, command_table, command_group_table)
|
|
511
|
+
|
|
512
|
+
for stem in file_stems:
|
|
513
|
+
if stem.startswith('_') and not stem.startswith('__'):
|
|
514
|
+
mod = _try_import_module(f'.{stem}', base_module)
|
|
515
|
+
if mod:
|
|
516
|
+
_register_from_module(loader, mod, command_table, command_group_table)
|
|
517
|
+
|
|
518
|
+
for subdir in subdir_names:
|
|
519
|
+
sub_module = f"{base_module}.{subdir}"
|
|
520
|
+
if args is None:
|
|
521
|
+
# Full load -> recurse into every sub-package
|
|
522
|
+
sub_pkg = _try_import_module(f'.{subdir}', base_module)
|
|
523
|
+
if sub_pkg:
|
|
524
|
+
_load_aaz_by_pkg(loader, sub_pkg, None, command_table, command_group_table)
|
|
525
|
+
else:
|
|
526
|
+
# Args exhausted / not matched -> load sub-group header and the first
|
|
527
|
+
# command so the group is non-empty and the parser creates a subparser
|
|
528
|
+
# for it (required for help output).
|
|
529
|
+
# TODO: After optimized loading is applied to the whole CLI, revisit
|
|
530
|
+
# this and consider a lighter approach (e.g. parser-level fix) to
|
|
531
|
+
# avoid importing one command per trimmed sub-group.
|
|
532
|
+
mod = _try_import_module('.__cmd_group', sub_module)
|
|
533
|
+
if mod:
|
|
534
|
+
_register_from_module(loader, mod, command_table, command_group_table)
|
|
535
|
+
sub_pkg = _try_import_module(f'.{subdir}', base_module)
|
|
536
|
+
if sub_pkg:
|
|
537
|
+
_load_first_command(loader, sub_pkg, command_table)
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
def _load_first_command(loader, pkg, command_table):
|
|
541
|
+
"""Load the first available command module from a package.
|
|
542
|
+
|
|
543
|
+
This ensures the command group is non-empty so the parser creates a subparser
|
|
544
|
+
for it, which is required for it to appear in help output.
|
|
545
|
+
"""
|
|
546
|
+
file_stems, subdir_names = _get_pkg_children(pkg)
|
|
547
|
+
base_module = pkg.__name__
|
|
548
|
+
|
|
549
|
+
# Try to load a command module at this level first
|
|
550
|
+
for stem in sorted(file_stems):
|
|
551
|
+
if stem.startswith('_') and not stem.startswith('__'):
|
|
552
|
+
mod = _try_import_module(f'.{stem}', base_module)
|
|
553
|
+
if mod:
|
|
554
|
+
_register_from_module(loader, mod, command_table, {})
|
|
555
|
+
return
|
|
556
|
+
|
|
557
|
+
# No command at this level, recurse into the first sub-package
|
|
558
|
+
for subdir in sorted(subdir_names):
|
|
559
|
+
sub_pkg = _try_import_module(f'.{subdir}', base_module)
|
|
560
|
+
if sub_pkg:
|
|
561
|
+
_load_first_command(loader, sub_pkg, command_table)
|
|
562
|
+
return
|
|
563
|
+
|
|
564
|
+
|
|
390
565
|
def load_aaz_command_table(loader, aaz_pkg_name, args):
|
|
391
566
|
""" This function is used in AzCommandsLoader.load_command_table.
|
|
392
567
|
It will load commands in module's aaz package.
|
|
@@ -33,8 +33,8 @@ class AzCLIError(CLIError):
|
|
|
33
33
|
self.recommendations = []
|
|
34
34
|
self.set_recommendation(recommendation)
|
|
35
35
|
|
|
36
|
-
#
|
|
37
|
-
self.
|
|
36
|
+
# example recommendations with tuple form: (recommendation, description)
|
|
37
|
+
self.example_recommendations = []
|
|
38
38
|
|
|
39
39
|
# exception trace for the error
|
|
40
40
|
self.exception_trace = None
|
|
@@ -50,11 +50,11 @@ class AzCLIError(CLIError):
|
|
|
50
50
|
elif isinstance(recommendation, list):
|
|
51
51
|
self.recommendations.extend(recommendation)
|
|
52
52
|
|
|
53
|
-
def
|
|
54
|
-
""" Set
|
|
53
|
+
def set_example_recommendation(self, recommendations):
|
|
54
|
+
""" Set example recommendations for the error.
|
|
55
55
|
One item should be a tuple with the form: (recommendation, description)
|
|
56
56
|
"""
|
|
57
|
-
self.
|
|
57
|
+
self.example_recommendations.extend(recommendations)
|
|
58
58
|
|
|
59
59
|
def set_exception_trace(self, exception_trace):
|
|
60
60
|
self.exception_trace = exception_trace
|
|
@@ -80,9 +80,12 @@ class AzCLIError(CLIError):
|
|
|
80
80
|
for recommendation in self.recommendations:
|
|
81
81
|
print(recommendation, file=sys.stderr)
|
|
82
82
|
|
|
83
|
-
if self.
|
|
84
|
-
print(
|
|
85
|
-
|
|
83
|
+
if self.example_recommendations:
|
|
84
|
+
print(file=sys.stderr)
|
|
85
|
+
if len(self.example_recommendations) > 1: # contains help examples
|
|
86
|
+
print("Examples from command's help:", file=sys.stderr)
|
|
87
|
+
|
|
88
|
+
for recommendation, description in self.example_recommendations:
|
|
86
89
|
print_styled_text(recommendation, file=sys.stderr)
|
|
87
90
|
print_styled_text(description, file=sys.stderr)
|
|
88
91
|
|
|
@@ -15,8 +15,8 @@ from knack.util import StatusTag, color_map
|
|
|
15
15
|
|
|
16
16
|
logger = get_logger()
|
|
17
17
|
|
|
18
|
-
NEXT_BREAKING_CHANGE_RELEASE = '2.
|
|
19
|
-
NEXT_BREAKING_CHANGE_DATE = '
|
|
18
|
+
NEXT_BREAKING_CHANGE_RELEASE = '2.87.0'
|
|
19
|
+
NEXT_BREAKING_CHANGE_DATE = 'June 2026'
|
|
20
20
|
DEFAULT_BREAKING_CHANGE_TAG = '[Breaking Change]'
|
|
21
21
|
|
|
22
22
|
|
|
@@ -23,9 +23,6 @@ CLOUD_CONFIG_FILE = os.path.join(GLOBAL_CONFIG_DIR, 'clouds.config')
|
|
|
23
23
|
# Add names of clouds that don't allow telemetry data collection here such as some air-gapped clouds.
|
|
24
24
|
CLOUDS_FORBIDDING_TELEMETRY = ['USSec', 'USNat']
|
|
25
25
|
|
|
26
|
-
# Add names of clouds that don't allow Aladdin requests for command recommendations here
|
|
27
|
-
CLOUDS_FORBIDDING_ALADDIN_REQUEST = ['USSec', 'USNat']
|
|
28
|
-
|
|
29
26
|
|
|
30
27
|
class CloudNotRegisteredException(Exception):
|
|
31
28
|
def __init__(self, cloud_name):
|
|
@@ -501,7 +498,7 @@ AZURE_BLEU_CLOUD = Cloud(
|
|
|
501
498
|
sql_management='https://management.database.sovcloud-api.fr:8443/',
|
|
502
499
|
batch_resource_id='https://batch.sovcloud-api.fr/',
|
|
503
500
|
gallery='https://gallery.sovcloud-api.fr/',
|
|
504
|
-
active_directory='https://login.sovcloud-
|
|
501
|
+
active_directory='https://login.sovcloud-identity.fr',
|
|
505
502
|
active_directory_resource_id='https://management.sovcloud-api.fr/',
|
|
506
503
|
active_directory_graph_resource_id='https://graph.svc.sovcloud.fr/',
|
|
507
504
|
microsoft_graph_resource_id='https://graph.svc.sovcloud.fr',
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
# Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
4
|
# --------------------------------------------------------------------------------------------
|
|
5
5
|
|
|
6
|
-
from enum import Enum
|
|
7
|
-
|
|
8
6
|
from azure.cli.core import telemetry
|
|
9
7
|
from knack.log import get_logger
|
|
10
8
|
|
|
@@ -12,80 +10,9 @@ from knack.log import get_logger
|
|
|
12
10
|
logger = get_logger(__name__)
|
|
13
11
|
|
|
14
12
|
|
|
15
|
-
class AladdinUserFaultType(Enum):
|
|
16
|
-
"""Define the userfault types required by aladdin service
|
|
17
|
-
to get the command recommendations"""
|
|
18
|
-
|
|
19
|
-
ExpectedArgument = 'ExpectedArgument'
|
|
20
|
-
UnrecognizedArguments = 'UnrecognizedArguments'
|
|
21
|
-
ValidationError = 'ValidationError'
|
|
22
|
-
UnknownSubcommand = 'UnknownSubcommand'
|
|
23
|
-
MissingRequiredParameters = 'MissingRequiredParameters'
|
|
24
|
-
MissingRequiredSubcommand = 'MissingRequiredSubcommand'
|
|
25
|
-
StorageAccountNotFound = 'StorageAccountNotFound'
|
|
26
|
-
Unknown = 'Unknown'
|
|
27
|
-
InvalidJMESPathQuery = 'InvalidJMESPathQuery'
|
|
28
|
-
InvalidOutputType = 'InvalidOutputType'
|
|
29
|
-
InvalidParameterValue = 'InvalidParameterValue'
|
|
30
|
-
UnableToParseCommandInput = 'UnableToParseCommandInput'
|
|
31
|
-
ResourceGroupNotFound = 'ResourceGroupNotFound'
|
|
32
|
-
InvalidDateTimeArgumentValue = 'InvalidDateTimeArgumentValue'
|
|
33
|
-
InvalidResourceGroupName = 'InvalidResourceGroupName'
|
|
34
|
-
AzureResourceNotFound = 'AzureResourceNotFound'
|
|
35
|
-
InvalidAccountName = 'InvalidAccountName'
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def get_error_type(error_msg):
|
|
39
|
-
"""The the error type of the failed command from the error message.
|
|
40
|
-
The error types are only consumed by aladdin service for better recommendations.
|
|
41
|
-
"""
|
|
42
|
-
|
|
43
|
-
error_type = AladdinUserFaultType.Unknown
|
|
44
|
-
if not error_msg:
|
|
45
|
-
return error_type.value
|
|
46
|
-
|
|
47
|
-
error_msg = error_msg.lower()
|
|
48
|
-
if 'unrecognized' in error_msg:
|
|
49
|
-
error_type = AladdinUserFaultType.UnrecognizedArguments
|
|
50
|
-
elif 'expected one argument' in error_msg or 'expected at least one argument' in error_msg \
|
|
51
|
-
or 'value required' in error_msg:
|
|
52
|
-
error_type = AladdinUserFaultType.ExpectedArgument
|
|
53
|
-
elif 'misspelled' in error_msg:
|
|
54
|
-
error_type = AladdinUserFaultType.UnknownSubcommand
|
|
55
|
-
elif 'arguments are required' in error_msg or 'argument required' in error_msg:
|
|
56
|
-
error_type = AladdinUserFaultType.MissingRequiredParameters
|
|
57
|
-
if '_subcommand' in error_msg:
|
|
58
|
-
error_type = AladdinUserFaultType.MissingRequiredSubcommand
|
|
59
|
-
elif '_command_package' in error_msg:
|
|
60
|
-
error_type = AladdinUserFaultType.UnableToParseCommandInput
|
|
61
|
-
elif 'not found' in error_msg or 'could not be found' in error_msg \
|
|
62
|
-
or 'resource not found' in error_msg:
|
|
63
|
-
error_type = AladdinUserFaultType.AzureResourceNotFound
|
|
64
|
-
if 'storage_account' in error_msg or 'storage account' in error_msg:
|
|
65
|
-
error_type = AladdinUserFaultType.StorageAccountNotFound
|
|
66
|
-
elif 'resource_group' in error_msg or 'resource group' in error_msg:
|
|
67
|
-
error_type = AladdinUserFaultType.ResourceGroupNotFound
|
|
68
|
-
elif 'pattern' in error_msg or 'is not a valid value' in error_msg or 'invalid' in error_msg:
|
|
69
|
-
error_type = AladdinUserFaultType.InvalidParameterValue
|
|
70
|
-
if 'jmespath_type' in error_msg:
|
|
71
|
-
error_type = AladdinUserFaultType.InvalidJMESPathQuery
|
|
72
|
-
elif 'datetime_type' in error_msg:
|
|
73
|
-
error_type = AladdinUserFaultType.InvalidDateTimeArgumentValue
|
|
74
|
-
elif '--output' in error_msg:
|
|
75
|
-
error_type = AladdinUserFaultType.InvalidOutputType
|
|
76
|
-
elif 'resource_group' in error_msg:
|
|
77
|
-
error_type = AladdinUserFaultType.InvalidResourceGroupName
|
|
78
|
-
elif 'storage_account' in error_msg:
|
|
79
|
-
error_type = AladdinUserFaultType.InvalidAccountName
|
|
80
|
-
elif "validation error" in error_msg:
|
|
81
|
-
error_type = AladdinUserFaultType.ValidationError
|
|
82
|
-
|
|
83
|
-
return error_type.value
|
|
84
|
-
|
|
85
|
-
|
|
86
13
|
class CommandRecommender: # pylint: disable=too-few-public-methods
|
|
87
14
|
"""Recommend a command for user when user's command fails.
|
|
88
|
-
It
|
|
15
|
+
It uses examples from help files to provide recommendations."""
|
|
89
16
|
|
|
90
17
|
def __init__(self, command, parameters, extension, error_msg, cli_ctx):
|
|
91
18
|
"""
|
|
@@ -107,8 +34,6 @@ class CommandRecommender: # pylint: disable=too-few-public-methods
|
|
|
107
34
|
self.cli_ctx = cli_ctx
|
|
108
35
|
# the item is a dict with the form {'command': #, 'description': #}
|
|
109
36
|
self.help_examples = []
|
|
110
|
-
# the item is a dict with the form {'command': #, 'description': #, 'link': #}
|
|
111
|
-
self.aladdin_recommendations = []
|
|
112
37
|
|
|
113
38
|
def set_help_examples(self, examples):
|
|
114
39
|
"""Set help examples.
|
|
@@ -119,89 +44,10 @@ class CommandRecommender: # pylint: disable=too-few-public-methods
|
|
|
119
44
|
|
|
120
45
|
self.help_examples.extend(examples)
|
|
121
46
|
|
|
122
|
-
def _set_aladdin_recommendations(self): # pylint: disable=too-many-locals
|
|
123
|
-
"""Set Aladdin recommendations.
|
|
124
|
-
Call the API, parse the response and set aladdin_recommendations.
|
|
125
|
-
"""
|
|
126
|
-
|
|
127
|
-
import hashlib
|
|
128
|
-
import json
|
|
129
|
-
import requests
|
|
130
|
-
from requests import RequestException
|
|
131
|
-
from http import HTTPStatus
|
|
132
|
-
from azure.cli.core import __version__ as version
|
|
133
|
-
|
|
134
|
-
api_url = 'https://app.aladdin.microsoft.com/api/v1.0/suggestions'
|
|
135
|
-
correlation_id = telemetry._session.correlation_id # pylint: disable=protected-access
|
|
136
|
-
subscription_id = telemetry._get_azure_subscription_id() # pylint: disable=protected-access
|
|
137
|
-
event_id = telemetry._session.event_id # pylint: disable=protected-access
|
|
138
|
-
# Used for DDOS protection and rate limiting
|
|
139
|
-
user_id = telemetry._get_user_azure_id() # pylint: disable=protected-access
|
|
140
|
-
hashed_user_id = hashlib.sha256(user_id.encode('utf-8')).hexdigest()
|
|
141
|
-
|
|
142
|
-
headers = {
|
|
143
|
-
'Content-Type': 'application/json',
|
|
144
|
-
'X-UserId': hashed_user_id
|
|
145
|
-
}
|
|
146
|
-
context = {
|
|
147
|
-
'versionNumber': version,
|
|
148
|
-
'errorType': get_error_type(self.error_msg)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if telemetry.is_telemetry_enabled():
|
|
152
|
-
if correlation_id:
|
|
153
|
-
context['correlationId'] = correlation_id
|
|
154
|
-
if subscription_id:
|
|
155
|
-
context['subscriptionId'] = subscription_id
|
|
156
|
-
if event_id:
|
|
157
|
-
context['eventId'] = event_id
|
|
158
|
-
|
|
159
|
-
parameters = self._normalize_parameters(self.parameters)
|
|
160
|
-
parameters = [item for item in set(parameters) if item not in ['--debug', '--verbose', '--only-show-errors']]
|
|
161
|
-
query = {
|
|
162
|
-
"command": self.command,
|
|
163
|
-
"parameters": ','.join(parameters)
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
response = None
|
|
167
|
-
try:
|
|
168
|
-
response = requests.get(
|
|
169
|
-
api_url,
|
|
170
|
-
params={
|
|
171
|
-
'query': json.dumps(query),
|
|
172
|
-
'clientType': 'AzureCli',
|
|
173
|
-
'context': json.dumps(context)
|
|
174
|
-
},
|
|
175
|
-
headers=headers,
|
|
176
|
-
timeout=1)
|
|
177
|
-
telemetry.set_debug_info('AladdinResponseTime', response.elapsed.total_seconds())
|
|
178
|
-
|
|
179
|
-
except RequestException as ex:
|
|
180
|
-
logger.debug('Recommendation requests.get() exception: %s', ex)
|
|
181
|
-
telemetry.set_debug_info('AladdinException', ex.__class__.__name__)
|
|
182
|
-
|
|
183
|
-
recommendations = []
|
|
184
|
-
if response and response.status_code == HTTPStatus.OK:
|
|
185
|
-
for result in response.json():
|
|
186
|
-
# parse the response to get the raw command
|
|
187
|
-
raw_command = 'az {} '.format(result['command'])
|
|
188
|
-
for parameter, placeholder in zip(result['parameters'].split(','), result['placeholders'].split('♠')):
|
|
189
|
-
raw_command += '{} {}{}'.format(parameter, placeholder, ' ' if placeholder else '')
|
|
190
|
-
|
|
191
|
-
# format the recommendation
|
|
192
|
-
recommendation = {
|
|
193
|
-
'command': raw_command.strip(),
|
|
194
|
-
'description': result['description'],
|
|
195
|
-
'link': result['link']
|
|
196
|
-
}
|
|
197
|
-
recommendations.append(recommendation)
|
|
198
|
-
|
|
199
|
-
self.aladdin_recommendations.extend(recommendations)
|
|
200
|
-
|
|
201
47
|
def provide_recommendations(self):
|
|
202
48
|
"""Provide recommendations when a command fails.
|
|
203
49
|
|
|
204
|
-
The recommendations are
|
|
50
|
+
The recommendations are from CLI help examples,
|
|
205
51
|
which include both commands and reference links along with their descriptions.
|
|
206
52
|
|
|
207
53
|
:return: The decorated recommendations
|
|
@@ -273,14 +119,7 @@ class CommandRecommender: # pylint: disable=too-few-public-methods
|
|
|
273
119
|
if self.cli_ctx and self.cli_ctx.config.get('core', 'error_recommendation', 'on').upper() == 'OFF':
|
|
274
120
|
return []
|
|
275
121
|
|
|
276
|
-
|
|
277
|
-
if not self._disable_aladdin_service():
|
|
278
|
-
self._set_aladdin_recommendations()
|
|
279
|
-
|
|
280
|
-
# recommendations are either all from Aladdin or all from help examples
|
|
281
|
-
recommendations = self.aladdin_recommendations
|
|
282
|
-
if not recommendations:
|
|
283
|
-
recommendations = self.help_examples
|
|
122
|
+
recommendations = self.help_examples
|
|
284
123
|
|
|
285
124
|
# sort the recommendations by parameter matching, get the top 3 recommended commands
|
|
286
125
|
recommendations = sort_recommendations(recommendations)[:3]
|
|
@@ -305,8 +144,6 @@ class CommandRecommender: # pylint: disable=too-few-public-methods
|
|
|
305
144
|
|
|
306
145
|
# add reference link as a recommendation
|
|
307
146
|
decorated_link = [(Style.HYPERLINK, OVERVIEW_REFERENCE)]
|
|
308
|
-
if self.aladdin_recommendations:
|
|
309
|
-
decorated_link = [(Style.HYPERLINK, self.aladdin_recommendations[0]['link'])]
|
|
310
147
|
|
|
311
148
|
decorated_description = [(Style.SECONDARY, 'Read more about the command in reference docs')]
|
|
312
149
|
decorated_recommendations.append((decorated_link, decorated_description))
|
|
@@ -319,49 +156,11 @@ class CommandRecommender: # pylint: disable=too-few-public-methods
|
|
|
319
156
|
def _set_recommended_command_to_telemetry(self, raw_commands):
|
|
320
157
|
"""Set the recommended commands to Telemetry
|
|
321
158
|
|
|
322
|
-
Aladdin recommended commands and commands from CLI help examples are
|
|
323
|
-
set to different properties in Telemetry.
|
|
324
|
-
|
|
325
159
|
:param raw_commands: The recommended raw commands
|
|
326
160
|
:type raw_commands: list
|
|
327
161
|
"""
|
|
328
162
|
|
|
329
|
-
|
|
330
|
-
telemetry.set_debug_info('AladdinRecommendCommand', ';'.join(raw_commands))
|
|
331
|
-
else:
|
|
332
|
-
telemetry.set_debug_info('ExampleRecommendCommand', ';'.join(raw_commands))
|
|
333
|
-
|
|
334
|
-
def _disable_aladdin_service(self):
|
|
335
|
-
"""Decide whether to disable aladdin request when a command fails.
|
|
336
|
-
|
|
337
|
-
The possible cases to disable it are:
|
|
338
|
-
1. CLI context is missing
|
|
339
|
-
2. In air-gapped clouds
|
|
340
|
-
3. In testing environments
|
|
341
|
-
4. In autocomplete mode
|
|
342
|
-
|
|
343
|
-
:return: whether Aladdin service need to be disabled or not
|
|
344
|
-
:type: bool
|
|
345
|
-
"""
|
|
346
|
-
|
|
347
|
-
from azure.cli.core.cloud import CLOUDS_FORBIDDING_ALADDIN_REQUEST
|
|
348
|
-
|
|
349
|
-
# CLI is not started well
|
|
350
|
-
if not self.cli_ctx or not self.cli_ctx.cloud:
|
|
351
|
-
return True
|
|
352
|
-
|
|
353
|
-
# for air-gapped clouds
|
|
354
|
-
if self.cli_ctx.cloud.name in CLOUDS_FORBIDDING_ALADDIN_REQUEST:
|
|
355
|
-
return True
|
|
356
|
-
|
|
357
|
-
# for testing environments
|
|
358
|
-
if self.cli_ctx.__class__.__name__ == 'DummyCli':
|
|
359
|
-
return True
|
|
360
|
-
|
|
361
|
-
if self.cli_ctx.data['completer_active']:
|
|
362
|
-
return True
|
|
363
|
-
|
|
364
|
-
return False
|
|
163
|
+
telemetry.set_debug_info('ExampleRecommendCommand', ';'.join(raw_commands))
|
|
365
164
|
|
|
366
165
|
def _normalize_parameters(self, args):
|
|
367
166
|
"""Normalize a parameter list.
|
|
@@ -169,7 +169,7 @@ class AzCliCommandParser(CLICommandParser):
|
|
|
169
169
|
from azure.cli.core.util import QUERY_REFERENCE
|
|
170
170
|
az_error.set_recommendation(QUERY_REFERENCE)
|
|
171
171
|
elif recommendations:
|
|
172
|
-
az_error.
|
|
172
|
+
az_error.set_example_recommendation(recommendations)
|
|
173
173
|
az_error.print_error()
|
|
174
174
|
az_error.send_telemetry()
|
|
175
175
|
self.exit(2)
|
|
@@ -324,7 +324,7 @@ class AzCliCommandParser(CLICommandParser):
|
|
|
324
324
|
recommender.set_help_examples(self.get_examples(command_name_inferred))
|
|
325
325
|
recommendations = recommender.provide_recommendations()
|
|
326
326
|
if recommendations:
|
|
327
|
-
az_error.
|
|
327
|
+
az_error.set_example_recommendation(recommendations)
|
|
328
328
|
|
|
329
329
|
# remind user to check extensions if we can not find a command to recommend
|
|
330
330
|
if isinstance(az_error, CommandNotFoundError) \
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: azure-cli-core
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.86.0
|
|
4
4
|
Summary: Microsoft Azure Command-Line Tools Core Module
|
|
5
5
|
Home-page: https://github.com/Azure/azure-cli
|
|
6
6
|
Author: Microsoft Corporation
|
|
@@ -28,7 +28,7 @@ Requires-Dist: humanfriendly~=10.0
|
|
|
28
28
|
Requires-Dist: jmespath
|
|
29
29
|
Requires-Dist: knack~=0.11.0
|
|
30
30
|
Requires-Dist: microsoft-security-utilities-secret-masker~=1.0.0b4
|
|
31
|
-
Requires-Dist: msal-extensions==1.
|
|
31
|
+
Requires-Dist: msal-extensions==1.3.1
|
|
32
32
|
Requires-Dist: msal[broker]==1.35.1; sys_platform == "win32"
|
|
33
33
|
Requires-Dist: msal==1.35.1; sys_platform != "win32"
|
|
34
34
|
Requires-Dist: packaging>=20.9
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
from codecs import open
|
|
9
9
|
from setuptools import setup, find_packages
|
|
10
10
|
|
|
11
|
-
VERSION = "2.
|
|
11
|
+
VERSION = "2.86.0"
|
|
12
12
|
|
|
13
13
|
# If we have source, validate that our version numbers match
|
|
14
14
|
# This should prevent uploading releases with mismatched versions.
|
|
@@ -54,7 +54,7 @@ DEPENDENCIES = [
|
|
|
54
54
|
'jmespath',
|
|
55
55
|
'knack~=0.11.0',
|
|
56
56
|
'microsoft-security-utilities-secret-masker~=1.0.0b4',
|
|
57
|
-
'msal-extensions==1.
|
|
57
|
+
'msal-extensions==1.3.1',
|
|
58
58
|
'msal[broker]==1.35.1; sys_platform == "win32"',
|
|
59
59
|
'msal==1.35.1; sys_platform != "win32"',
|
|
60
60
|
'packaging>=20.9',
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/auth/landing_pages/error.html
RENAMED
|
File without changes
|
{azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/auth/landing_pages/success.html
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure/cli/core/commands/command_operation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{azure_cli_core-2.85.0 → azure_cli_core-2.86.0}/azure_cli_core.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|