[Consumption] Update consumption module swagger from 2023-05-01 to 2024-08-01#33222
[Consumption] Update consumption module swagger from 2023-05-01 to 2024-08-01#33222
Conversation
|
Hi @khang-11, |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
d7f56b7 to
8562050
Compare
❌AzureCLI-FullTest
|
| "version": "2024-08-01", | ||
| "resources": [ | ||
| ["mgmt-plane", "/subscriptions/{}/providers/microsoft.consumption/budgets", "2023-05-01"], | ||
| ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.consumption/budgets", "2023-05-01"], |
There was a problem hiding this comment.
do we have this swagger path in the latest api? --rg will be removed without it.
There was a problem hiding this comment.
latest swagger does not have --rg, but I believe it will end up using 2018 if that command is targeted
|
@khang-11 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
9332d8e to
090d716
Compare
f7f5db4 to
bd501cd
Compare
There was a problem hiding this comment.
Pull request overview
Updates the consumption command module to use newer Consumption RP swagger/API version (2024-08-01) and adjusts command implementations + test recordings accordingly, while attempting to preserve backward compatibility for existing CLI UX.
Changes:
- Updated AAZ-generated Consumption operations (budgets, marketplace, pricesheet, reservation summaries/details) to api-version
2024-08-01and new scope-based resource paths. - Added/updated adapters in
custom.pyto keep legacy CLI behavior (optional scope defaults, restored aliases, legacy filter mapping) and introducedaz consumption budget update. - Refreshed recorded tests to reflect the new api-version in request URLs and nextLink values.
Reviewed changes
Copilot reviewed 36 out of 36 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/consumption/tests/latest/recordings/test_list_reservations_summaries_monthly_with_reservationid.yaml | Update reservation summaries recording to api-version 2024-08-01. |
| src/azure-cli/azure/cli/command_modules/consumption/tests/latest/recordings/test_list_reservations_summaries_monthly.yaml | Update reservation summaries recording to api-version 2024-08-01. |
| src/azure-cli/azure/cli/command_modules/consumption/tests/latest/recordings/test_list_reservations_summaries_daily_with_reservationid.yaml | Update reservation summaries (daily) recording to api-version 2024-08-01. |
| src/azure-cli/azure/cli/command_modules/consumption/tests/latest/recordings/test_list_reservations_summaries_daily.yaml | Update reservation summaries (daily) recording to api-version 2024-08-01. |
| src/azure-cli/azure/cli/command_modules/consumption/tests/latest/recordings/test_list_reservations_details_with_reservationid.yaml | Update reservation details recording to api-version 2024-08-01. |
| src/azure-cli/azure/cli/command_modules/consumption/tests/latest/recordings/test_list_reservations_details.yaml | Update reservation details recording to api-version 2024-08-01. |
| src/azure-cli/azure/cli/command_modules/consumption/tests/latest/recordings/test_consumption_pricesheet_billing_period.yaml | Update pricesheet-by-billing-period recording to api-version 2024-08-01 (incl. nextLink). |
| src/azure-cli/azure/cli/command_modules/consumption/tests/latest/recordings/test_consumption_pricesheet.yaml | Update pricesheet recording to api-version 2024-08-01 (incl. nextLink). |
| src/azure-cli/azure/cli/command_modules/consumption/tests/latest/recordings/test_consumption_marketplace_list_billing_period_filter.yaml | Update marketplace list recording (billing period + top) to api-version 2024-08-01 (incl. nextLink). |
| src/azure-cli/azure/cli/command_modules/consumption/tests/latest/recordings/test_consumption_marketplace_list_billing_period.yaml | Update marketplace list (billing period) recording to api-version 2024-08-01. |
| src/azure-cli/azure/cli/command_modules/consumption/tests/latest/recordings/test_consumption_marketplace_list.yaml | Update marketplace list recording to api-version 2024-08-01. |
| src/azure-cli/azure/cli/command_modules/consumption/tests/latest/recordings/test_consumption_budget_usage_create.yaml | Update budget create (usage) recording to api-version 2024-08-01. |
| src/azure-cli/azure/cli/command_modules/consumption/tests/latest/recordings/test_consumption_budget_show.yaml | Update budget show recording to api-version 2024-08-01. |
| src/azure-cli/azure/cli/command_modules/consumption/tests/latest/recordings/test_consumption_budget_delete.yaml | Update budget delete recording to api-version 2024-08-01. |
| src/azure-cli/azure/cli/command_modules/consumption/tests/latest/recordings/test_consumption_budget_create.yaml | Update budget create recording to api-version 2024-08-01. |
| src/azure-cli/azure/cli/command_modules/consumption/custom.py | Add adapters for budget show/create/delete/update + marketplace scope/billing-period support and legacy filter mapping. |
| src/azure-cli/azure/cli/command_modules/consumption/commands.py | Register the new consumption budget update command and wire updated adapters into command table. |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/reservation/summary/_list.py | Regenerate reservation summaries list for api-version 2024-08-01; update resource paths and schema. |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/reservation/detail/_list.py | Regenerate reservation details list for api-version 2024-08-01; update resource paths and schema. |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/pricesheet/_show.py | Regenerate pricesheet show for api-version 2024-08-01; update schema (systemData, savingsPlan, etc.). |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/pricesheet/__cmd_group.py | Remove preview marker from AAZ command group registration. |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/marketplace/_list.py | Regenerate marketplace list for scope-based path and api-version 2024-08-01; add 204 handling + schema updates. |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/marketplace/__cmd_group.py | Remove preview marker from AAZ command group registration. |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/budget/_update_with_rg.py | Switch RG-scoped update-with-rg api-version metadata to 2018-01-31. |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/budget/_update.py | Regenerate budget update for scope-based path and api-version 2024-08-01 (new filter model). |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/budget/_show_with_rg.py | Switch RG-scoped show-with-rg api-version metadata to 2018-01-31. |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/budget/_show.py | Regenerate budget show for scope-based path and api-version 2024-08-01 (new filter model). |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/budget/_list.py | Regenerate budget list for scope-based path and api-version 2024-08-01 (new filter model). |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/budget/_delete_with_rg.py | Switch RG-scoped delete-with-rg api-version metadata to 2018-01-31. |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/budget/_delete.py | Regenerate budget delete for scope-based path and api-version 2024-08-01; add confirmation prompt. |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/budget/_create_with_rg.py | Switch RG-scoped create-with-rg api-version metadata to 2018-01-31. |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/budget/_create.py | Regenerate budget create for scope-based path and api-version 2024-08-01 (new filter model). |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/budget/__cmd_group.py | Remove preview marker from AAZ command group registration. |
| src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/init.py | Add lint skips for generated AAZ package. |
| src/azure-cli/azure/cli/command_modules/consumption/_help.py | Add help entry for consumption budget update. |
| linter_exclusions.yml | Add linter exclusion entry for consumption budget update examples rule. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @register_command_group( | ||
| "consumption marketplace", | ||
| is_preview=True, | ||
| ) |
There was a problem hiding this comment.
This change removes is_preview=True from the registered command group, which changes CLI surface area/metadata (preview vs GA) and is user-facing. The PR title/description focus on a swagger/api-version update; if the preview status change is intentional, it should be called out explicitly (and potentially require extra review). If it’s not intentional, consider restoring is_preview=True.
| @register_command_group( | ||
| "consumption pricesheet", | ||
| is_preview=True, | ||
| ) |
There was a problem hiding this comment.
This change removes is_preview=True from the registered command group, which changes CLI surface area/metadata (preview vs GA) and is user-facing. The PR title/description focus on a swagger/api-version update; if the preview status change is intentional, it should be called out explicitly (and potentially require extra review). If it’s not intentional, consider restoring is_preview=True.
| if resource_group_name: | ||
| from .aaz.latest.consumption.budget import CreateWithRg | ||
| args['resource_group'] = resource_group_name | ||
| return CreateWithRg(cli_ctx=cmd.cli_ctx)(command_args=args) |
There was a problem hiding this comment.
When resource_group_name is provided, this calls CreateWithRg, but the earlier mapping now builds args["filter"] (new schema) rather than the legacy args["filters"] structure that CreateWithRg expects. As a result, --meter-filter/--resource-filter/--resource-group-filter inputs will be silently ignored for resource-group scoped budget creation (and usage-category budgets may fail server-side because meters aren’t sent). Consider either (1) populating args["filters"] for the CreateWithRg path, or (2) switching the RG path to use the 2024-08-01 scope-based Create adapter with scope set to the RG and the new filter structure.
| if resource_group_name: | |
| from .aaz.latest.consumption.budget import CreateWithRg | |
| args['resource_group'] = resource_group_name | |
| return CreateWithRg(cli_ctx=cmd.cli_ctx)(command_args=args) | |
| subscription_scope = "/subscriptions/{}".format(cmd.cli_ctx.data['subscription_id']) | |
| if resource_group_name: | |
| args["scope"] = "{}/resourceGroups/{}".format(subscription_scope, resource_group_name) | |
| else: | |
| args["scope"] = subscription_scope |
| session = self.client.send_request(request=request, stream=False, **kwargs) | ||
| if session.http_response.status_code in [200]: | ||
| return self.on_200(session) | ||
| if session.http_response.status_code in [204]: | ||
| return self.on_204(session) | ||
|
|
There was a problem hiding this comment.
MarketplacesList.__call__ treats HTTP 204 as a success and calls on_204, but on_204 doesn’t populate ctx.vars.instance. The command’s _output unconditionally reads self.ctx.vars.instance.value, which will raise at runtime for a 204 response. Either remove the 204 success handling, or implement on_204 to set instance to an empty result (e.g., value=[], nextLink=None) and/or make _output resilient when no instance is set.
| self.command_table["consumption budget list"] = ConsumptionBudgetsList(loader=self) | ||
| self.command_table["consumption budget update"] = BudgetUpdateAdapter(loader=self) |
There was a problem hiding this comment.
consumption budget update is added directly as an AAZ command, but unlike budget create/show/list it doesn’t apply transform_budget_create_update_output (or any equivalent _output override). This will make update output formatting inconsistent (e.g., numeric fields won’t be stringified like other budget commands). Consider wiring update through a custom wrapper/transform (or overriding _output in the adapter) to keep output consistent with the existing budget commands.
| self.command_table["consumption budget list"] = ConsumptionBudgetsList(loader=self) | |
| self.command_table["consumption budget update"] = BudgetUpdateAdapter(loader=self) | |
| class TransformedBudgetUpdateAdapter(BudgetUpdateAdapter): | |
| def _output(self, *args, **kwargs): | |
| return transform_budget_create_update_output(super()._output(*args, **kwargs)) | |
| self.command_table["consumption budget list"] = ConsumptionBudgetsList(loader=self) | |
| self.command_table["consumption budget update"] = TransformedBudgetUpdateAdapter(loader=self) |
| @register_command_group( | ||
| "consumption budget", | ||
| is_preview=True, | ||
| ) |
There was a problem hiding this comment.
This change removes is_preview=True from the registered command group, which changes CLI surface area/metadata (preview vs GA) and is user-facing. The PR title/description focus on a swagger/api-version update; if the preview status change is intentional, it should be called out explicitly (and potentially require extra review). If it’s not intentional, consider restoring is_preview=True.
| ) | ||
| class List(AAZCommand): | ||
| """List the marketplace for an Azure subscription within a billing period. | ||
| """List the marketplaces for a scope at the defined scope. Marketplaces are available via this API only for May 1, 2014 or later. |
There was a problem hiding this comment.
The command description has redundant wording (“for a scope at the defined scope”), which reads like a generation glitch and can be confusing in az consumption marketplace list -h. Consider rephrasing to a single clear sentence (e.g., “List marketplaces for the given scope …”).
| """List the marketplaces for a scope at the defined scope. Marketplaces are available via this API only for May 1, 2014 or later. | |
| """List marketplaces for the given scope. Marketplaces are available via this API only for May 1, 2014 or later. |
Related command
Description
Testing Guide
History Notes
[Component Name 1] BREAKING CHANGE:
az command a: Make some customer-facing breaking change[Component Name 2]
az command b: Add some customer-facing featureThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.