Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package azure-cli-core for openSUSE:Factory checked in at 2022-11-10 14:23:16 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/azure-cli-core (Old) and /work/SRC/openSUSE:Factory/.azure-cli-core.new.1597 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "azure-cli-core" Thu Nov 10 14:23:16 2022 rev:45 rq:1034800 version:2.42.0 Changes: -------- --- /work/SRC/openSUSE:Factory/azure-cli-core/azure-cli-core.changes 2022-10-19 13:17:46.261233793 +0200 +++ /work/SRC/openSUSE:Factory/.azure-cli-core.new.1597/azure-cli-core.changes 2022-11-10 14:24:24.079068552 +0100 @@ -1,0 +2,8 @@ +Tue Nov 1 09:35:52 UTC 2022 - John Paul Adrian Glaubitz <[email protected]> + +- New upstream release + + Version 2.42.0 + + For detailed information about changes see the + HISTORY.rst file provided with this package + +------------------------------------------------------------------- Old: ---- azure-cli-core-2.41.0.tar.gz New: ---- azure-cli-core-2.42.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ azure-cli-core.spec ++++++ --- /var/tmp/diff_new_pack.Tm4sv0/_old 2022-11-10 14:24:24.507070975 +0100 +++ /var/tmp/diff_new_pack.Tm4sv0/_new 2022-11-10 14:24:24.511070997 +0100 @@ -17,7 +17,7 @@ Name: azure-cli-core -Version: 2.41.0 +Version: 2.42.0 Release: 0 Summary: Microsoft Azure CLI Core Module License: MIT ++++++ azure-cli-core-2.41.0.tar.gz -> azure-cli-core-2.42.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/HISTORY.rst new/azure-cli-core-2.42.0/HISTORY.rst --- old/azure-cli-core-2.41.0/HISTORY.rst 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/HISTORY.rst 2022-10-28 05:24:17.000000000 +0200 @@ -3,6 +3,11 @@ Release History =============== +2.42.0 +++++++ +* `aaz`: Support `FreeFormDictType` and `FreeFormDictArg` (#24183) +* `aaz`: Support `configured_default` property in arguments (#24411) + 2.41.0 ++++++ * Support Continuous Access Evaluation (#23635) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/PKG-INFO new/azure-cli-core-2.42.0/PKG-INFO --- old/azure-cli-core-2.41.0/PKG-INFO 2022-10-10 05:01:57.753471900 +0200 +++ new/azure-cli-core-2.42.0/PKG-INFO 2022-10-28 05:24:43.010562700 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: azure-cli-core -Version: 2.41.0 +Version: 2.42.0 Summary: Microsoft Azure Command-Line Tools Core Module Home-page: https://github.com/Azure/azure-cli Author: Microsoft Corporation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/__init__.py new/azure-cli-core-2.42.0/azure/cli/core/__init__.py --- old/azure-cli-core-2.41.0/azure/cli/core/__init__.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/__init__.py 2022-10-28 05:24:17.000000000 +0200 @@ -4,7 +4,7 @@ # -------------------------------------------------------------------------------------------- # pylint: disable=line-too-long -__version__ = "2.41.0" +__version__ = "2.42.0" import os import sys diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/_profile.py new/azure-cli-core-2.42.0/azure/cli/core/_profile.py --- old/azure-cli-core-2.41.0/azure/cli/core/_profile.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/_profile.py 2022-10-28 05:24:17.000000000 +0200 @@ -858,6 +858,8 @@ # PREVIEW: On Windows, use core.allow_broker=true to use broker (WAM) for authentication. allow_broker = cli_ctx.config.getboolean('core', 'allow_broker', fallback=False) + from .telemetry import set_broker_info + set_broker_info(allow_broker=allow_broker) return Identity(*args, encrypt=encrypt, use_msal_http_cache=use_msal_http_cache, allow_broker=allow_broker, **kwargs) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/aaz/__init__.py new/azure-cli-core-2.42.0/azure/cli/core/aaz/__init__.py --- old/azure-cli-core-2.41.0/azure/cli/core/aaz/__init__.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/aaz/__init__.py 2022-10-28 05:24:17.000000000 +0200 @@ -10,13 +10,16 @@ """ from ._arg import has_value, AAZArgumentsSchema, AAZArgEnum, AAZStrArg, AAZIntArg, AAZObjectArg, AAZDictArg, \ - AAZFloatArg, AAZBaseArg, AAZBoolArg, AAZListArg, AAZResourceGroupNameArg, AAZResourceLocationArg, \ - AAZResourceIdArg, AAZSubscriptionIdArg, AAZUuidArg, AAZDateArg, AAZTimeArg, AAZDateTimeArg, AAZDurationArg + AAZFreeFormDictArg, AAZFloatArg, AAZBaseArg, AAZBoolArg, AAZListArg, AAZResourceGroupNameArg, \ + AAZResourceLocationArg, AAZResourceIdArg, AAZSubscriptionIdArg, AAZUuidArg, AAZDateArg, AAZTimeArg, \ + AAZDateTimeArg, AAZDurationArg from ._arg_fmt import AAZStrArgFormat, AAZIntArgFormat, AAZFloatArgFormat, AAZBoolArgFormat, AAZObjectArgFormat, \ - AAZDictArgFormat, AAZListArgFormat, AAZResourceLocationArgFormat, AAZResourceIdArgFormat, \ - AAZSubscriptionIdArgFormat, AAZUuidFormat, AAZDateFormat, AAZTimeFormat, AAZDateTimeFormat, AAZDurationFormat + AAZDictArgFormat, AAZFreeFormDictArgFormat, AAZListArgFormat, AAZResourceLocationArgFormat, \ + AAZResourceIdArgFormat, AAZSubscriptionIdArgFormat, AAZUuidFormat, AAZDateFormat, AAZTimeFormat, \ + AAZDateTimeFormat, AAZDurationFormat from ._base import AAZValuePatch, AAZUndefined from ._command import AAZCommand, AAZWaitCommand, AAZCommandGroup, \ register_callback, register_command, register_command_group, load_aaz_command_table -from ._field_type import AAZIntType, AAZFloatType, AAZStrType, AAZBoolType, AAZDictType, AAZListType, AAZObjectType +from ._field_type import AAZIntType, AAZFloatType, AAZStrType, AAZBoolType, AAZDictType, AAZFreeFormDictType, \ + AAZListType, AAZObjectType from ._operation import AAZHttpOperation, AAZJsonInstanceUpdateOperation, AAZGenericInstanceUpdateOperation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/aaz/_arg.py new/azure-cli-core-2.42.0/azure/cli/core/aaz/_arg.py --- old/azure-cli-core-2.41.0/azure/cli/core/aaz/_arg.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/aaz/_arg.py 2022-10-28 05:24:17.000000000 +0200 @@ -8,15 +8,15 @@ from azure.cli.core import azclierror from knack.arguments import CLICommandArgument, CaseInsensitiveList -from ._arg_action import AAZSimpleTypeArgAction, AAZObjectArgAction, AAZDictArgAction, AAZListArgAction, \ - AAZGenericUpdateAction, AAZGenericUpdateForceStringAction +from ._arg_action import AAZSimpleTypeArgAction, AAZObjectArgAction, AAZDictArgAction, AAZFreeFormDictArgAction, \ + AAZListArgAction, AAZGenericUpdateAction, AAZGenericUpdateForceStringAction from ._base import AAZBaseType, AAZUndefined from ._field_type import AAZObjectType, AAZStrType, AAZIntType, AAZBoolType, AAZFloatType, AAZListType, AAZDictType, \ - AAZSimpleType + AAZSimpleType, AAZFreeFormDictType from ._field_value import AAZObject -from ._arg_fmt import AAZObjectArgFormat, AAZListArgFormat, AAZDictArgFormat, AAZSubscriptionIdArgFormat, \ - AAZResourceLocationArgFormat, AAZResourceIdArgFormat, AAZUuidFormat, AAZDateFormat, AAZTimeFormat, \ - AAZDateTimeFormat, AAZDurationFormat +from ._arg_fmt import AAZObjectArgFormat, AAZListArgFormat, AAZDictArgFormat, AAZFreeFormDictArgFormat, \ + AAZSubscriptionIdArgFormat, AAZResourceLocationArgFormat, AAZResourceIdArgFormat, AAZUuidFormat, AAZDateFormat, \ + AAZTimeFormat, AAZDateTimeFormat, AAZDurationFormat # pylint: disable=redefined-builtin, protected-access, too-few-public-methods @@ -325,6 +325,33 @@ return f"Dict<String,{self.Element._type_in_help}>" +class AAZFreeFormDictArg(AAZBaseArg, AAZFreeFormDictType): + + def __init__(self, fmt=None, **kwargs): + fmt = fmt or AAZFreeFormDictArgFormat() + super().__init__(fmt=fmt, **kwargs) + + def to_cmd_arg(self, name): + arg = super().to_cmd_arg(name) + + short_summary = arg.type.settings.get('help', None) or '' + if short_summary: + short_summary += ' ' + short_summary += "Support json-file and yaml-file." + arg.help = short_summary + return arg + + def _build_cmd_action(self): + class Action(AAZFreeFormDictArgAction): + _schema = self # bind action class with current schema + + return Action + + @property + def _type_in_help(self): + return "Dict<String, Any>" + + class AAZListArg(AAZCompoundTypeArg, AAZListType): def __init__(self, fmt=None, singular_options=None, **kwargs): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/aaz/_arg_action.py new/azure-cli-core-2.42.0/azure/cli/core/aaz/_arg_action.py --- old/azure-cli-core-2.41.0/azure/cli/core/aaz/_arg_action.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/aaz/_arg_action.py 2022-10-28 05:24:17.000000000 +0200 @@ -104,7 +104,7 @@ if isinstance(values, str) and len(values) > 0: try: - data = cls._str_parser(values, is_simple=True) + data = cls.decode_str(values) except AAZShowHelp as aaz_help: aaz_help.schema = cls._schema raise aaz_help @@ -114,6 +114,10 @@ dest_ops.add(data, *prefix_keys) @classmethod + def decode_str(cls, value): + return cls._str_parser(value, is_simple=True) + + @classmethod def format_data(cls, data): if data == AAZBlankArgValue: if cls._schema._blank == AAZUndefined: @@ -261,6 +265,50 @@ raise AAZInvalidValueError(f"dict type value expected, got '{data}'({type(data)})") + +class AAZFreeFormDictArgAction(AAZSimpleTypeArgAction): + + @classmethod + def decode_str(cls, value): + from azure.cli.core.util import get_file_json, shell_safe_json_parse, get_file_yaml + + if len(value) == 0: + # the express "a=" will return the blank value of schema 'a' + return AAZBlankArgValue + + path = os.path.expanduser(value) + if os.path.exists(path): + if path.endswith('.yml') or path.endswith('.yaml'): + # read from yaml file + v = get_file_yaml(path) + else: + # read from json file + v = get_file_json(path, preserve_order=True) + else: + try: + v = shell_safe_json_parse(value, True) + except Exception as ex: + logger.debug(ex) # log parse json failed expression + raise + return v + + @classmethod + def format_data(cls, data): + if data == AAZBlankArgValue: + if cls._schema._blank == AAZUndefined: + raise AAZInvalidValueError("argument value cannot be blank") + data = copy.deepcopy(cls._schema._blank) + + if isinstance(data, dict): + return data + + if data is None: + if cls._schema._nullable: + return data + raise AAZInvalidValueError("field is not nullable") + + raise AAZInvalidValueError(f"dict type value expected, got '{data}'({type(data)})") + class AAZListArgAction(AAZCompoundTypeArgAction): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/aaz/_arg_browser.py new/azure-cli-core-2.42.0/azure/cli/core/aaz/_arg_browser.py --- old/azure-cli-core-2.41.0/azure/cli/core/aaz/_arg_browser.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/aaz/_arg_browser.py 2022-10-28 05:24:17.000000000 +0200 @@ -62,6 +62,24 @@ else: raise NotImplementedError() + def get_anytype_elements(self): + """Iter over sub elements of list or dict.""" + if self._arg_data is None: + # stop iteration + return + + if isinstance(self._arg_data, dict): + for k, d in self._arg_data.items(): + v = self._arg_value[k] + if isinstance(v, AAZBaseValue): + # ignore fixed type element + continue + # build AAZBaseValue from data without schema + v = AAZBaseValue(None, d) + yield k, AAZArgBrowser(v, d, parent=None) + else: + raise NotImplementedError() + @property def data(self): return self._arg_data diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/aaz/_arg_fmt.py new/azure-cli-core-2.42.0/azure/cli/core/aaz/_arg_fmt.py --- old/azure-cli-core-2.41.0/azure/cli/core/aaz/_arg_fmt.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/aaz/_arg_fmt.py 2022-10-28 05:24:17.000000000 +0200 @@ -12,7 +12,7 @@ from ._command_ctx import AAZCommandCtx from ._field_type import AAZSimpleType -from ._field_value import AAZUndefined, AAZSimpleValue, AAZDict, AAZList, AAZObject +from ._field_value import AAZUndefined, AAZSimpleValue, AAZDict, AAZFreeFormDict, AAZList, AAZObject from .exceptions import AAZInvalidArgValueError logger = get_logger(__name__) @@ -451,6 +451,34 @@ if value._is_patch: return value + + if self._min_properties and len(value) < self._min_properties: + raise AAZInvalidArgValueError( + f"Invalid format: dict length is less than {self._min_properties}") + + if self._max_properties and len(value) > self._max_properties: + raise AAZInvalidArgValueError( + f"Invalid format: dict length is greater than {self._max_properties}") + + return value + + +class AAZFreeFormDictArgFormat(AAZBaseArgFormat): + + def __init__(self, max_properties=None, min_properties=None): + self._max_properties = max_properties + self._min_properties = min_properties + + def __call__(self, ctx, value): + assert isinstance(value, AAZFreeFormDict) + data = value._data + if data == AAZUndefined or data is None: + return value + + assert isinstance(data, dict) + + if value._is_patch: + return value if self._min_properties and len(value) < self._min_properties: raise AAZInvalidArgValueError( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/aaz/_command.py new/azure-cli-core-2.42.0/azure/cli/core/aaz/_command.py --- old/azure-cli-core-2.41.0/azure/cli/core/aaz/_command.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/aaz/_command.py 2022-10-28 05:24:17.000000000 +0200 @@ -6,6 +6,7 @@ # pylint: disable=too-few-public-methods, too-many-instance-attributes, protected-access, not-callable import importlib import os +import copy from functools import partial from knack.commands import CLICommand, PREVIEW_EXPERIMENTAL_CONFLICT_ERROR @@ -166,9 +167,10 @@ """ This function is called by core to add global arguments """ schema = self.get_arguments_schema() - # not support to overwrite arguments defined in schema - if not hasattr(schema, param_name): - super().update_argument(param_name, argtype) + if hasattr(schema, param_name): + # not support to overwrite arguments defined in schema, use arg.type as overrides + argtype = copy.deepcopy(self.arguments[param_name].type) + super().update_argument(param_name, argtype) @staticmethod def deserialize_output(value, client_flatten=True): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/aaz/_content_builder.py new/azure-cli-core-2.42.0/azure/cli/core/aaz/_content_builder.py --- old/azure-cli-core-2.41.0/azure/cli/core/aaz/_content_builder.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/aaz/_content_builder.py 2022-10-28 05:24:17.000000000 +0200 @@ -4,7 +4,7 @@ # -------------------------------------------------------------------------------------------- from ._base import AAZBaseValue, AAZUndefined -from ._field_value import AAZSimpleValue, AAZDict, AAZList, AAZObject +from ._field_value import AAZSimpleValue, AAZBaseDictValue, AAZDict, AAZFreeFormDict, AAZList, AAZObject from ._field_type import AAZObjectType from ._arg_browser import AAZArgBrowser @@ -72,7 +72,7 @@ value[prop_name] = None else: value[prop_name] = [] - elif isinstance(value[prop_name], (AAZDict, AAZObject)): + elif isinstance(value[prop_name], (AAZBaseDictValue, AAZObject)): if sub_arg.data is None: value[prop_name] = None else: @@ -98,38 +98,52 @@ schema.Element = typ(**typ_kwargs) if typ_kwargs else typ() else: assert isinstance(schema.Element, typ) - if isinstance(value, (AAZDict, AAZList)): - for key, sub_arg in arg.get_elements(): - if sub_arg is not None and sub_arg.data != AAZUndefined: - sub_arg = sub_arg.get_prop(arg_key) - - if sub_arg is not None and sub_arg.data != AAZUndefined: - if not sub_arg.is_patch and arg_key: - if isinstance(value[key], AAZSimpleValue): - value[key] = sub_arg.data - elif isinstance(value[key], AAZList): - if sub_arg.data is None: - value[key] = None - else: - value[key] = [] - elif isinstance(value[key], (AAZDict, AAZObject)): - if sub_arg.data is None: - value[key] = None - else: - value[key] = {} - else: - raise NotImplementedError() - sub_values.append(value[key]) - sub_args.append(sub_arg) - else: + if not isinstance(value, (AAZDict, AAZList)): raise NotImplementedError() + for key, sub_arg in arg.get_elements(): + if sub_arg is not None and sub_arg.data != AAZUndefined: + sub_arg = sub_arg.get_prop(arg_key) + + if sub_arg is not None and sub_arg.data != AAZUndefined: + if not sub_arg.is_patch and arg_key: + if isinstance(value[key], AAZSimpleValue): + value[key] = sub_arg.data + elif isinstance(value[key], AAZList): + if sub_arg.data is None: + value[key] = None + else: + value[key] = [] + elif isinstance(value[key], (AAZBaseDictValue, AAZObject)): + if sub_arg.data is None: + value[key] = None + else: + value[key] = {} + else: + raise NotImplementedError() + sub_values.append(value[key]) + sub_args.append(sub_arg) + if sub_values: self._sub_elements_builder = AAZContentBuilder(sub_values, sub_args) return self._sub_elements_builder return None + def set_anytype_elements(self, arg_key=None): + """Set any type elements of free from dictionary""" + for value, arg in zip(self._values, self._args): + if not isinstance(value, AAZFreeFormDict): + raise NotImplementedError() + + for key, sub_arg in arg.get_anytype_elements(): + if sub_arg is not None and sub_arg.data != AAZUndefined: + sub_arg = sub_arg.get_prop(arg_key) + + if sub_arg is not None and sub_arg.data != AAZUndefined: + if not sub_arg.is_patch and arg_key: + value[key] = sub_arg.data + def discriminate_by(self, prop_name, prop_value): """discriminate object by a specify property""" if self._discriminator_prop_name is None: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/aaz/_field_type.py new/azure-cli-core-2.42.0/azure/cli/core/aaz/_field_type.py --- old/azure-cli-core-2.41.0/azure/cli/core/aaz/_field_type.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/aaz/_field_type.py 2022-10-28 05:24:17.000000000 +0200 @@ -2,9 +2,11 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- +import abc + from collections import OrderedDict from ._base import AAZBaseType, AAZValuePatch, AAZUndefined -from ._field_value import AAZObject, AAZDict, AAZList, AAZSimpleValue +from ._field_value import AAZObject, AAZDict, AAZFreeFormDict, AAZList, AAZSimpleValue from .exceptions import AAZUnknownFieldError, AAZConflictFieldDefinitionError, AAZValuePrecisionLossError, \ AAZInvalidFieldError @@ -246,11 +248,46 @@ return None -class AAZDictType(AAZBaseType): +class AAZBaseDictType(AAZBaseType): + + _PatchDataCls = dict + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + @abc.abstractmethod + def __getitem__(self, key): + raise NotImplementedError() + + def process_data(self, data, **kwargs): + if data == None: # noqa: E711, pylint: disable=singleton-comparison + # data can be None or AAZSimpleValue == None + if self._nullable: + return None + return AAZValuePatch.build(self) + + if isinstance(data, self._ValueCls) and data._is_patch: + # use value patch + result = AAZValuePatch.build(self) + else: + result = {} + + value = self._ValueCls(schema=self, data=result) # pylint: disable=not-callable + + if isinstance(data, self._ValueCls): + for key in data._data.keys(): + value[key] = data[key] + else: + assert isinstance(data, (dict,)) + for key, sub_data in data.items(): + value[key] = sub_data + return result + + +class AAZDictType(AAZBaseDictType): """Dict value type""" _ValueCls = AAZDict - _PatchDataCls = dict def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -276,28 +313,14 @@ def __getitem__(self, key): return self.Element - def process_data(self, data, **kwargs): - if data == None: # noqa: E711, pylint: disable=singleton-comparison - # data can be None or AAZSimpleValue == None - if self._nullable: - return None - return AAZValuePatch.build(self) - if isinstance(data, AAZDict) and data._is_patch: - # use value patch - result = AAZValuePatch.build(self) - else: - result = {} - value = AAZDict(schema=self, data=result) +class AAZFreeFormDictType(AAZBaseDictType): + """Free form dict value type""" - if isinstance(data, AAZDict): - for key in data._data.keys(): - value[key] = data[key] - else: - assert isinstance(data, (dict,)) - for key, sub_data in data.items(): - value[key] = sub_data - return result + _ValueCls = AAZFreeFormDict + + def __getitem__(self, key): + return None class AAZListType(AAZBaseType): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/aaz/_field_value.py new/azure-cli-core-2.42.0/azure/cli/core/aaz/_field_value.py --- old/azure-cli-core-2.41.0/azure/cli/core/aaz/_field_value.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/aaz/_field_value.py 2022-10-28 05:24:17.000000000 +0200 @@ -2,8 +2,11 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- +import copy from ._base import AAZBaseValue, AAZValuePatch, AAZUndefined +from .exceptions import AAZInvalidValueError +import abc class AAZSimpleValue(AAZBaseValue): @@ -161,27 +164,19 @@ return attr_schema, name -class AAZDict(AAZBaseValue): +class AAZBaseDictValue(AAZBaseValue): def __init__(self, schema, data): - from ._field_type import AAZDictType - assert isinstance(schema, AAZDictType) super().__init__(schema, data) assert isinstance(self._data, dict) or self._data is None or self._data == AAZUndefined + @abc.abstractmethod def __getitem__(self, key) -> AAZBaseValue: - item_schema = self._schema.Element - if key not in self._data: - self._data[key] = AAZValuePatch.build(item_schema) - return item_schema._ValueCls(item_schema, self._data[key]) # return as AAZValue + raise NotImplementedError() + @abc.abstractmethod def __setitem__(self, key, data): - try: - item_schema = self._schema.Element - except AttributeError: - # ignore undefined element - return - self._data[key] = item_schema.process_data(data, key=key) + raise NotImplementedError() def __delitem__(self, key): del self._data[key] @@ -229,6 +224,28 @@ for key in self._data: yield key, self[key] + +class AAZDict(AAZBaseDictValue): + + def __init__(self, schema, data): + from ._field_type import AAZDictType + assert isinstance(schema, AAZDictType) + super().__init__(schema, data) + + def __getitem__(self, key) -> AAZBaseValue: + item_schema = self._schema[key] + if key not in self._data: + self._data[key] = AAZValuePatch.build(item_schema) + return item_schema._ValueCls(item_schema, self._data[key]) # return as AAZValue + + def __setitem__(self, key, data): + try: + item_schema = self._schema[key] + except AttributeError: + # ignore undefined element + return + self._data[key] = item_schema.process_data(data, key=key) + def to_serialized_data(self, processor=None, **kwargs): if self._data == AAZUndefined: result = AAZUndefined @@ -243,6 +260,61 @@ result[key] = v if not result and self._is_patch: + result = AAZUndefined + + if processor: + result = processor(self._schema, result) + return result + + +class AAZFreeFormDict(AAZBaseDictValue): + + def __init__(self, schema, data): + from ._field_type import AAZFreeFormDictType + assert isinstance(schema, AAZFreeFormDictType) + super().__init__(schema, data) + + def __getitem__(self, key) -> AAZBaseValue: + item_schema = self._schema[key] + if item_schema is None: + # free form + return self._data[key] + if key not in self._data: + self._data[key] = AAZValuePatch.build(item_schema) + return item_schema._ValueCls(item_schema, self._data[key]) # return as AAZValue + + def __setitem__(self, key, data): + item_schema = self._schema[key] + if item_schema is None: + # free form + if isinstance(data, AAZValuePatch): + raise AAZInvalidValueError("Not support value patch for Free-Form dict key") + if isinstance(data, AAZBaseValue): + if data._is_patch: + raise AAZInvalidValueError("Not support value patch for Free-Form dict key") + data = data._data + assert not isinstance(data, AAZBaseValue) + self._data[key] = copy.deepcopy(data) + return + + # For fixed key properties usage + self._data[key] = item_schema.process_data(data, key=key) + + def to_serialized_data(self, processor=None, **kwargs): + if self._data == AAZUndefined: + result = AAZUndefined + elif self._data is None: + result = None + else: + result = {} + for key, v in self.items(): + if isinstance(v, AAZBaseValue): + v = v.to_serialized_data(processor=processor, **kwargs) + if v == AAZUndefined: + continue + result[key] = v + + if not result and self._is_patch: result = AAZUndefined if processor: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/aaz/_help.py new/azure-cli-core-2.42.0/azure/cli/core/aaz/_help.py --- old/azure-cli-core-2.41.0/azure/cli/core/aaz/_help.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/aaz/_help.py 2022-10-28 05:24:17.000000000 +0200 @@ -35,7 +35,7 @@ self.schema = None def show(self): - from ._arg import AAZObjectArg, AAZDictArg, AAZListArg, AAZBaseArg + from ._arg import AAZObjectArg, AAZDictArg, AAZFreeFormDictArg, AAZListArg, AAZBaseArg assert self.schema is not None and isinstance(self.schema, AAZBaseArg) schema = self.schema schema_key = self.keys[0] @@ -49,7 +49,7 @@ # show the help of current schema break key = f'.{key}' - elif isinstance(schema, AAZDictArg): + elif isinstance(schema, (AAZDictArg, AAZFreeFormDictArg)): try: schema = schema.Element except AAZUnknownFieldError: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/aaz/_operation.py new/azure-cli-core-2.42.0/azure/cli/core/aaz/_operation.py --- old/azure-cli-core-2.41.0/azure/cli/core/aaz/_operation.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/aaz/_operation.py 2022-10-28 05:24:17.000000000 +0200 @@ -13,7 +13,7 @@ from ._arg_browser import AAZArgBrowser from ._base import AAZUndefined, AAZBaseValue, AAZBaseType from ._content_builder import AAZContentBuilder -from ._field_type import AAZSimpleType, AAZObjectType, AAZDictType, AAZListType +from ._field_type import AAZSimpleType, AAZObjectType, AAZBaseDictType, AAZListType from ._field_value import AAZSimpleValue try: @@ -170,7 +170,7 @@ _field_result = processor(_field_schema, {}) assert _field_result != AAZUndefined result[_name] = _field_result - elif isinstance(_field_schema, AAZDictType): + elif isinstance(_field_schema, AAZBaseDictType): # use an empty dict for required dict property result[_name] = {} elif isinstance(_field_schema, AAZListType): @@ -190,7 +190,7 @@ # use an empty dict as data for required object, and process it's properties data = processor(value._schema, {}) assert data != AAZUndefined - elif isinstance(value._schema, AAZDictType): + elif isinstance(value._schema, AAZBaseDictType): # use an empty dict for required dict data = {} elif isinstance(value._schema, AAZListType): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/auth/identity.py new/azure-cli-core-2.42.0/azure/cli/core/auth/identity.py --- old/azure-cli-core-2.41.0/azure/cli/core/auth/identity.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/auth/identity.py 2022-10-28 05:24:17.000000000 +0200 @@ -154,6 +154,7 @@ scopes, prompt='select_account', port=8400 if self._is_adfs else None, success_template=success_template, error_template=error_template, parent_window_handle=self._msal_app.CONSOLE_WINDOW_HANDLE, on_before_launching_ui=_prompt_launching_ui, + enable_msa_passthrough=True, **kwargs) return check_result(result) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/commands/parameters.py new/azure-cli-core-2.42.0/azure/cli/core/commands/parameters.py --- old/azure-cli-core-2.41.0/azure/cli/core/commands/parameters.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/commands/parameters.py 2022-10-28 05:24:17.000000000 +0200 @@ -248,7 +248,7 @@ name_type = CLIArgumentType(options_list=['--name', '-n'], help='the primary resource name') -edge_zone_type = CLIArgumentType(options_list='--edge-zone', help='The name of edge zone.', is_preview=True) +edge_zone_type = CLIArgumentType(options_list='--edge-zone', help='The name of edge zone.') def get_location_type(cli_ctx): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/intercept_survey.py new/azure-cli-core-2.42.0/azure/cli/core/intercept_survey.py --- old/azure-cli-core-2.41.0/azure/cli/core/intercept_survey.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/intercept_survey.py 2022-10-28 05:24:17.000000000 +0200 @@ -88,6 +88,9 @@ ]) print_styled_text((SURVEY_STYLE, NEW_LINE)) + from azure.cli.core import telemetry + telemetry.set_survey_info(show_survey_message=True) + # log prompt time next_prompt_time = datetime.utcnow() + timedelta(days=PROMPT_INTERVAL_IN_DAYS) survey_note = { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/profiles/_shared.py new/azure-cli-core-2.42.0/azure/cli/core/profiles/_shared.py --- old/azure-cli-core-2.41.0/azure/cli/core/profiles/_shared.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/profiles/_shared.py 2022-10-28 05:24:17.000000000 +0200 @@ -162,7 +162,7 @@ 'snapshots': '2022-03-02', 'galleries': '2021-10-01', 'gallery_images': '2021-10-01', - 'gallery_image_versions': '2022-01-03', + 'gallery_image_versions': '2022-03-03', 'gallery_applications': '2021-07-01', 'gallery_application_versions': '2022-01-03', 'shared_galleries': '2022-01-03', @@ -249,7 +249,7 @@ ResourceType.MGMT_ARO: '2022-04-01', ResourceType.MGMT_DATABOXEDGE: '2021-02-01-preview', ResourceType.MGMT_CUSTOMLOCATION: '2021-03-15-preview', - ResourceType.MGMT_CONTAINERSERVICE: SDKProfile('2022-07-01', { + ResourceType.MGMT_CONTAINERSERVICE: SDKProfile('2022-09-01', { 'container_services': '2017-07-01', 'open_shift_managed_clusters': '2019-09-30-preview' }), @@ -412,9 +412,20 @@ # use the version in a profile as much as possible. AD_HOC_API_VERSIONS = { ResourceType.MGMT_NETWORK: { - 'container_network': '2018-08-01', 'appservice_network': '2020-04-01', 'appservice_ensure_subnet': '2019-02-01' + }, + ResourceType.MGMT_CONTAINERREGISTRY: { + # src/azure-cli/azure/cli/command_modules/acr/_client_factory.py:8 + 'VERSION_2019_05_01_PREVIEW': "2019-05-01-preview", + 'VERSION_2019_06_01_PREVIEW': "2019-06-01-preview", + 'VERSION_2020_11_01_PREVIEW': "2020-11-01-preview", + 'VERSION_2021_08_01_PREVIEW': "2021-08-01-preview", + 'VERSION_2022_02_01_PREVIEW': "2022-02-01-preview", + }, + ResourceType.MGMT_CONTAINERSERVICE: { + # src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py:50 + 'ManagedClusterAddonProfile': '2020-03-01', } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/telemetry.py new/azure-cli-core-2.42.0/azure/cli/core/telemetry.py --- old/azure-cli-core-2.41.0/azure/cli/core/telemetry.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/telemetry.py 2022-10-28 05:24:17.000000000 +0200 @@ -50,6 +50,7 @@ self.feedback = None self.extension_management_detail = None self.raw_command = None + self.show_survey_message = False self.mode = 'default' # The AzCLIError sub-class name self.error_type = 'None' @@ -66,6 +67,7 @@ self.suppress_new_event = False self.poll_start_time = None self.poll_end_time = None + self.allow_broker = None def add_event(self, name, properties): for key in self.instrumentation_key: @@ -204,6 +206,8 @@ set_custom_properties(result, 'PollStartTime', str(self.poll_start_time)) set_custom_properties(result, 'PollEndTime', str(self.poll_end_time)) set_custom_properties(result, 'CloudName', _get_cloud_name()) + set_custom_properties(result, 'ShowSurveyMessage', str(self.show_survey_message)) + set_custom_properties(result, 'AllowBroker', str(self.allow_broker)) return result @@ -418,6 +422,18 @@ @decorators.suppress_all_exceptions() +def set_survey_info(show_survey_message): + # whether showed the intercept survey message or not + _session.show_survey_message = show_survey_message + + [email protected]_all_exceptions() +def set_broker_info(allow_broker): + # whether customer has configured `allow_broker` to enable WAM(Web Account Manager) login for authentication + _session.allow_broker = allow_broker + + [email protected]_all_exceptions() def add_dedicated_instrumentation_key(dedicated_instrumentation_key): if not dedicated_instrumentation_key: return diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure/cli/core/util.py new/azure-cli-core-2.42.0/azure/cli/core/util.py --- old/azure-cli-core-2.41.0/azure/cli/core/util.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure/cli/core/util.py 2022-10-28 05:24:17.000000000 +0200 @@ -167,7 +167,9 @@ error_msg = "The command failed with an unexpected error. Here is the traceback:" az_error = azclierror.CLIInternalError(error_msg) az_error.set_exception_trace(ex) - az_error.set_recommendation("To open an issue, please run: 'az feedback'") + az_error.set_recommendation( + "To check existing issues, please visit: https://github.com/Azure/azure-cli/issues\n" + "To open a new issue, please run `az feedback`") if isinstance(az_error, azclierror.ResourceNotFoundError): exit_code = 3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure_cli_core.egg-info/PKG-INFO new/azure-cli-core-2.42.0/azure_cli_core.egg-info/PKG-INFO --- old/azure-cli-core-2.41.0/azure_cli_core.egg-info/PKG-INFO 2022-10-10 05:01:57.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure_cli_core.egg-info/PKG-INFO 2022-10-28 05:24:42.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: azure-cli-core -Version: 2.41.0 +Version: 2.42.0 Summary: Microsoft Azure Command-Line Tools Core Module Home-page: https://github.com/Azure/azure-cli Author: Microsoft Corporation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/azure_cli_core.egg-info/requires.txt new/azure-cli-core-2.42.0/azure_cli_core.egg-info/requires.txt --- old/azure-cli-core-2.41.0/azure_cli_core.egg-info/requires.txt 2022-10-10 05:01:57.000000000 +0200 +++ new/azure-cli-core-2.42.0/azure_cli_core.egg-info/requires.txt 2022-10-28 05:24:42.000000000 +0200 @@ -6,7 +6,7 @@ jmespath knack~=0.10.0 msal-extensions~=1.0.0 -msal[broker]==1.20.0b1 +msal[broker]==1.20.0 msrestazure~=0.6.4 packaging<22.0,>=20.9 paramiko<3.0.0,>=2.0.8 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/azure-cli-core-2.41.0/setup.py new/azure-cli-core-2.42.0/setup.py --- old/azure-cli-core-2.41.0/setup.py 2022-10-10 05:01:41.000000000 +0200 +++ new/azure-cli-core-2.42.0/setup.py 2022-10-28 05:24:17.000000000 +0200 @@ -8,7 +8,7 @@ from codecs import open from setuptools import setup, find_packages -VERSION = "2.41.0" +VERSION = "2.42.0" # If we have source, validate that our version numbers match # This should prevent uploading releases with mismatched versions. @@ -51,7 +51,7 @@ 'jmespath', 'knack~=0.10.0', 'msal-extensions~=1.0.0', - 'msal[broker]==1.20.0b1', + 'msal[broker]==1.20.0', 'msrestazure~=0.6.4', 'packaging>=20.9,<22.0', 'paramiko>=2.0.8,<3.0.0',
