Skip to content

Commit 29820bf

Browse files
committed
[Consumption] Add --name/-n aliases, flatten --time-period, add examples
- Expose --budget-name also as --name and -n on budget show/delete/create/update. - Flatten --time-period on budget create/update so users pass --start-date and --end-date directly. - Add a manual example for 'budget create' and a swagger-generated example for 'budget show'.
1 parent 8218165 commit 29820bf

5 files changed

Lines changed: 34 additions & 27 deletions

File tree

src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/budget/_create.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
)
1717
class Create(AAZCommand):
1818
"""Create operation to create or update a budget. You can optionally provide an eTag if desired as a form of concurrency control. To obtain the latest eTag for a given budget, perform a get operation prior to your put operation.
19+
20+
:example: Create a monthly cost budget
21+
az consumption budget create -n my-budget --amount 100 --category Cost --time-grain Monthly --start-date 2025-01-01T00:00:00Z --end-date 2025-12-31T00:00:00Z --scope subscriptions/00000000-0000-0000-0000-000000000000
1922
"""
2023

2124
_aaz_info = {
@@ -42,7 +45,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
4245

4346
_args_schema = cls._args_schema
4447
_args_schema.budget_name = AAZStrArg(
45-
options=["--budget-name"],
48+
options=["-n", "--name", "--budget-name"],
4649
help="Budget Name.",
4750
required=True,
4851
)
@@ -91,11 +94,6 @@ def _build_arguments_schema(cls, *args, **kwargs):
9194
help="The time covered by a budget. Tracking of the amount will be reset based on the time grain. BillingMonth, BillingQuarter, and BillingAnnual are only supported by WD customers",
9295
enum={"Annually": "Annually", "BillingAnnual": "BillingAnnual", "BillingMonth": "BillingMonth", "BillingQuarter": "BillingQuarter", "Monthly": "Monthly", "Quarterly": "Quarterly"},
9396
)
94-
_args_schema.time_period = AAZObjectArg(
95-
options=["--time-period"],
96-
arg_group="Properties",
97-
help="Has start and end date of the budget. The start date must be first of the month and should be less than the end date. Budget start date must be on or after June 1, 2017. Future start date should not be more than twelve months. Past start date should be selected within the timegrain period. There are no restrictions on the end date.",
98-
)
9997

10098
filter = cls._args_schema.filter
10199
filter.and_ = AAZListArg(
@@ -193,18 +191,21 @@ def _build_arguments_schema(cls, *args, **kwargs):
193191
contact_roles = cls._args_schema.notifications.Element.contact_roles
194192
contact_roles.Element = AAZStrArg()
195193

196-
time_period = cls._args_schema.time_period
197-
time_period.end_date = AAZDateTimeArg(
198-
options=["end-date"],
194+
# define Arg Group "TimePeriod"
195+
196+
_args_schema = cls._args_schema
197+
_args_schema.end_date = AAZDateTimeArg(
198+
options=["--end-date"],
199+
arg_group="TimePeriod",
199200
help="The end date for the budget. If not provided, we default this to 10 years from the start date.",
200201
fmt=AAZDateTimeFormat(
201202
protocol="iso",
202203
),
203204
)
204-
time_period.start_date = AAZDateTimeArg(
205-
options=["start-date"],
205+
_args_schema.start_date = AAZDateTimeArg(
206+
options=["--start-date"],
207+
arg_group="TimePeriod",
206208
help="The start date for the budget.",
207-
required=True,
208209
fmt=AAZDateTimeFormat(
209210
protocol="iso",
210211
),
@@ -348,7 +349,7 @@ def content(self):
348349
properties.set_prop("filter", AAZObjectType, ".filter")
349350
properties.set_prop("notifications", AAZDictType, ".notifications")
350351
properties.set_prop("timeGrain", AAZStrType, ".time_grain", typ_kwargs={"flags": {"required": True}})
351-
properties.set_prop("timePeriod", AAZObjectType, ".time_period", typ_kwargs={"flags": {"required": True}})
352+
properties.set_prop("timePeriod", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}})
352353

353354
filter = _builder.get(".properties.filter")
354355
if filter is not None:

src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/budget/_delete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
4343

4444
_args_schema = cls._args_schema
4545
_args_schema.budget_name = AAZStrArg(
46-
options=["--budget-name"],
46+
options=["-n", "--name", "--budget-name"],
4747
help="Budget Name.",
4848
required=True,
4949
)

src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/budget/_show.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
)
1717
class Show(AAZCommand):
1818
"""Get the budget for the scope by budget name.
19+
20+
:example: Budget
21+
az consumption budget show --scope subscriptions/00000000-0000-0000-0000-000000000000 --budget-name TestBudget
1922
"""
2023

2124
_aaz_info = {
@@ -42,7 +45,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
4245

4346
_args_schema = cls._args_schema
4447
_args_schema.budget_name = AAZStrArg(
45-
options=["--budget-name"],
48+
options=["-n", "--name", "--budget-name"],
4649
help="Budget Name.",
4750
required=True,
4851
)

src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/budget/_update.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
4444

4545
_args_schema = cls._args_schema
4646
_args_schema.budget_name = AAZStrArg(
47-
options=["--budget-name"],
47+
options=["-n", "--name", "--budget-name"],
4848
help="Budget Name.",
4949
required=True,
5050
)
@@ -96,11 +96,6 @@ def _build_arguments_schema(cls, *args, **kwargs):
9696
help="The time covered by a budget. Tracking of the amount will be reset based on the time grain. BillingMonth, BillingQuarter, and BillingAnnual are only supported by WD customers",
9797
enum={"Annually": "Annually", "BillingAnnual": "BillingAnnual", "BillingMonth": "BillingMonth", "BillingQuarter": "BillingQuarter", "Monthly": "Monthly", "Quarterly": "Quarterly"},
9898
)
99-
_args_schema.time_period = AAZObjectArg(
100-
options=["--time-period"],
101-
arg_group="Properties",
102-
help="Has start and end date of the budget. The start date must be first of the month and should be less than the end date. Budget start date must be on or after June 1, 2017. Future start date should not be more than twelve months. Past start date should be selected within the timegrain period. There are no restrictions on the end date.",
103-
)
10499

105100
filter = cls._args_schema.filter
106101
filter.and_ = AAZListArg(
@@ -212,17 +207,21 @@ def _build_arguments_schema(cls, *args, **kwargs):
212207
nullable=True,
213208
)
214209

215-
time_period = cls._args_schema.time_period
216-
time_period.end_date = AAZDateTimeArg(
217-
options=["end-date"],
210+
# define Arg Group "TimePeriod"
211+
212+
_args_schema = cls._args_schema
213+
_args_schema.end_date = AAZDateTimeArg(
214+
options=["--end-date"],
215+
arg_group="TimePeriod",
218216
help="The end date for the budget. If not provided, we default this to 10 years from the start date.",
219217
nullable=True,
220218
fmt=AAZDateTimeFormat(
221219
protocol="iso",
222220
),
223221
)
224-
time_period.start_date = AAZDateTimeArg(
225-
options=["start-date"],
222+
_args_schema.start_date = AAZDateTimeArg(
223+
options=["--start-date"],
224+
arg_group="TimePeriod",
226225
help="The start date for the budget.",
227226
fmt=AAZDateTimeFormat(
228227
protocol="iso",
@@ -494,7 +493,7 @@ def _update_instance(self, instance):
494493
properties.set_prop("filter", AAZObjectType, ".filter")
495494
properties.set_prop("notifications", AAZDictType, ".notifications")
496495
properties.set_prop("timeGrain", AAZStrType, ".time_grain", typ_kwargs={"flags": {"required": True}})
497-
properties.set_prop("timePeriod", AAZObjectType, ".time_period", typ_kwargs={"flags": {"required": True}})
496+
properties.set_prop("timePeriod", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}})
498497

499498
filter = _builder.get(".properties.filter")
500499
if filter is not None:

src/azure-cli/azure/cli/command_modules/consumption/aaz/latest/consumption/usage/_list.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
class List(AAZCommand):
1818
"""List the usage details for the defined scope. Usage details are available via this API only for May 1, 2014 or later.
1919
20+
**Note:Microsoft will be retiring the Consumption Usage Details API at some point in the future. We do not recommend that you take a new dependency on this API. Please use the Cost Details API instead. We will notify customers once a date for retirement has been determined.For Learn more,see [Generate Cost Details Report - Create Operation](https://learn.microsoft.com/en-us/rest/api/cost-management/generate-cost-details-report/create-operation?tabs=HTTP)**
21+
22+
**Note:Microsoft will be retiring the Consumption Usage Details API at some point in the future. We do not recommend that you take a new dependency on this API. Please use the Cost Details API instead. We will notify customers once a date for retirement has been determined.For Learn more,see [Generate Cost Details Report - Create Operation](https://learn.microsoft.com/en-us/rest/api/cost-management/generate-cost-details-report/create-operation?tabs=HTTP)**
23+
2024
**Note:Microsoft will be retiring the Consumption Usage Details API at some point in the future. We do not recommend that you take a new dependency on this API. Please use the Cost Details API instead. We will notify customers once a date for retirement has been determined.For Learn more,see [Generate Cost Details Report - Create Operation](https://learn.microsoft.com/en-us/rest/api/cost-management/generate-cost-details-report/create-operation?tabs=HTTP)**
2125
"""
2226

0 commit comments

Comments
 (0)