def last_rt_list()

in packages/autorest.python/autorest/multiapi/models/code_model.py [0:0]


    def last_rt_list(self) -> Dict[str, str]:
        """Build the a mapping RT => API version if RT doesn't exist in latest detected API version.

        Example:
        last_rt_list = {
        'check_dns_name_availability': '2018-05-01'
        }

        There is one subtle scenario if PREVIEW mode is disabled:
        - RT1 available on 2019-05-01 and 2019-06-01-preview
        - RT2 available on 2019-06-01-preview
        - RT3 available on 2019-07-01-preview

        Then, if I put "RT2: 2019-06-01-preview" in the list, this means I have to make
        "2019-06-01-preview" the default for models loading (otherwise "RT2: 2019-06-01-preview" won't work).
        But this likely breaks RT1 default operations at "2019-05-01", with default models at "2019-06-01-preview"
        since "models" are shared for the entire set of operations groups (I wished models would be split by
        operation groups, but meh, that's not the case)

        So, until we have a smarter Autorest to deal with that, only preview RTs which do not share models with
        a stable RT can be added to this map. In this case, RT2 is out, RT3 is in.
        """

        def there_is_a_rt_that_contains_api_version(rt_dict, api_version):
            "Test in the given api_version is is one of those RT."
            for rt_api_version in rt_dict.values():
                if api_version in rt_api_version:
                    return True
            return False

        last_rt_list = {}

        # First let's map operation groups to their available APIs
        versioned_dict = {
            operation_group.name: operation_group.available_apis for operation_group in self.operation_groups
        }

        # Now let's also include mixins to their available APIs
        versioned_dict.update(
            {
                mixin_operation.name: mixin_operation.available_apis
                for mixin_operation in self.operation_mixin_group.mixin_operations
            }
        )
        for operation, api_versions_list in versioned_dict.items():
            local_default_api_version = _get_default_api_version_from_list(
                self.mod_to_api_version,
                api_versions_list,
                self.preview_mode,
                self.user_specified_default_api,
            )
            if local_default_api_version == self.default_api_version:
                continue
            # If some others RT contains "local_default_api_version", and
            # if it's greater than the future default, danger, don't profile it
            if (
                there_is_a_rt_that_contains_api_version(versioned_dict, local_default_api_version)
                and local_default_api_version > self.default_api_version
            ):
                continue
            last_rt_list[operation] = local_default_api_version
        return last_rt_list