Skip to content

Commit d17aed6

Browse files
author
Alan Zhang
committed
Update API spec to 2024-11-01 and remove SKU tier from create
1 parent 21199ad commit d17aed6

32 files changed

+12438
-12349
lines changed

src/amg/HISTORY.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,9 @@ Release History
151151
* `az grafana folder create`: support parent folder argument for nested folder creation
152152
* `az grafana folder list`: support nested folders
153153
* `az grafana folder show`: support nested folders
154-
* `az grafana backup`: include corresponding nested folders when individual folders are specified
154+
* `az grafana backup`: include corresponding nested folders when individual folders are specified
155+
156+
2.8.1
157+
++++++
158+
* `az grafana create`: remove SKU tier argument and API key argument
159+
* `az grafana update`: remove API key argument

src/amg/azext_amg/aaz/latest/grafana/__cmd_group.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
)
1717
class __CMDGroup(AAZCommandGroup):
1818
"""Commands to manage Azure Managed Grafana resources.
19-
20-
For optimized experience, not all data plane APIs, documented at `https://grafana.com/docs/grafana/latest/http_api/`, are exposed. On coverage gap, please reach out to [email protected]
2119
"""
2220
pass
2321

src/amg/azext_amg/aaz/latest/grafana/_create.py

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
class Create(AAZCommand):
1818
"""Create a workspace for Grafana resource. This API is idempotent, so user can either create a new grafana or update an existing grafana.
1919
20-
:example: create Azure Managed Grafana resource with Standard Sku and public network access enabled
21-
az grafana create --resource-group myResourceGroup --workspace-name myWorkspace --sku-tier Standard --public-network-access Enabled
20+
:example: create Azure Managed Grafana resource with public network access enabled
21+
az grafana create --resource-group myResourceGroup --workspace-name myWorkspace --public-network-access Enabled
2222
"""
2323

2424
_aaz_info = {
25-
"version": "2023-09-01",
25+
"version": "2024-11-01-preview",
2626
"resources": [
27-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.dashboard/grafana/{}", "2023-09-01"],
27+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.dashboard/grafana/{}", "2024-11-01-preview"],
2828
]
2929
}
3030

@@ -52,6 +52,9 @@ def _build_arguments_schema(cls, *args, **kwargs):
5252
options=["-n", "--name", "--workspace-name"],
5353
help="The workspace name of Azure Managed Grafana.",
5454
required=True,
55+
fmt=AAZStrArgFormat(
56+
pattern="^[a-zA-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]$",
57+
),
5558
)
5659
_args_schema.identity = AAZObjectArg(
5760
options=["--identity"],
@@ -69,17 +72,30 @@ def _build_arguments_schema(cls, *args, **kwargs):
6972
)
7073

7174
identity = cls._args_schema.identity
75+
identity.mi_system_assigned = AAZStrArg(
76+
options=["system-assigned", "mi-system-assigned"],
77+
help="Set the system managed identity.",
78+
blank="True",
79+
)
7280
identity.type = AAZStrArg(
7381
options=["type"],
7482
help="Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).",
7583
required=True,
7684
enum={"None": "None", "SystemAssigned": "SystemAssigned", "SystemAssigned,UserAssigned": "SystemAssigned,UserAssigned", "UserAssigned": "UserAssigned"},
7785
)
86+
identity.mi_user_assigned = AAZListArg(
87+
options=["user-assigned", "mi-user-assigned"],
88+
help="Set the user managed identities.",
89+
blank=[],
90+
)
7891
identity.user_assigned_identities = AAZDictArg(
7992
options=["user-assigned-identities"],
8093
help="The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.",
8194
)
8295

96+
mi_user_assigned = cls._args_schema.identity.mi_user_assigned
97+
mi_user_assigned.Element = AAZStrArg()
98+
8399
user_assigned_identities = cls._args_schema.identity.user_assigned_identities
84100
user_assigned_identities.Element = AAZObjectArg(
85101
blank={},
@@ -92,7 +108,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
92108

93109
_args_schema = cls._args_schema
94110
_args_schema.service_account = AAZStrArg(
95-
options=["--api-key", "--service-account"],
111+
options=["--service-account"],
96112
arg_group="Properties",
97113
help="The api key setting of the Grafana instance.",
98114
default="Disabled",
@@ -124,12 +140,6 @@ def _build_arguments_schema(cls, *args, **kwargs):
124140
default="Disabled",
125141
enum={"Disabled": "Disabled", "Enabled": "Enabled"},
126142
)
127-
_args_schema.sku_tier = AAZStrArg(
128-
options=["--sku-tier"],
129-
arg_group="Properties",
130-
help="The Sku of the grafana resource.",
131-
default="Standard",
132-
)
133143
return cls._args_schema
134144

135145
def _execute_operations(self):
@@ -213,7 +223,7 @@ def url_parameters(self):
213223
def query_parameters(self):
214224
parameters = {
215225
**self.serialize_query_param(
216-
"api-version", "2023-09-01",
226+
"api-version", "2024-11-01-preview",
217227
required=True,
218228
),
219229
}
@@ -238,7 +248,7 @@ def content(self):
238248
typ=AAZObjectType,
239249
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
240250
)
241-
_builder.set_prop("identity", AAZObjectType, ".identity")
251+
_builder.set_prop("identity", AAZIdentityObjectType, ".identity")
242252
_builder.set_prop("location", AAZStrType, ".location")
243253
_builder.set_prop("properties", AAZObjectType)
244254
_builder.set_prop("sku", AAZObjectType)
@@ -248,11 +258,17 @@ def content(self):
248258
if identity is not None:
249259
identity.set_prop("type", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}})
250260
identity.set_prop("userAssignedIdentities", AAZDictType, ".user_assigned_identities")
261+
identity.set_prop("userAssigned", AAZListType, ".mi_user_assigned", typ_kwargs={"flags": {"action": "create"}})
262+
identity.set_prop("systemAssigned", AAZStrType, ".mi_system_assigned", typ_kwargs={"flags": {"action": "create"}})
251263

252264
user_assigned_identities = _builder.get(".identity.userAssignedIdentities")
253265
if user_assigned_identities is not None:
254266
user_assigned_identities.set_elements(AAZObjectType, ".")
255267

268+
user_assigned = _builder.get(".identity.userAssigned")
269+
if user_assigned is not None:
270+
user_assigned.set_elements(AAZStrType, ".")
271+
256272
properties = _builder.get(".properties")
257273
if properties is not None:
258274
properties.set_prop("apiKey", AAZStrType, ".service_account")
@@ -261,10 +277,6 @@ def content(self):
261277
properties.set_prop("publicNetworkAccess", AAZStrType, ".public_network_access")
262278
properties.set_prop("zoneRedundancy", AAZStrType, ".zone_redundancy")
263279

264-
sku = _builder.get(".sku")
265-
if sku is not None:
266-
sku.set_prop("name", AAZStrType, ".sku_tier", typ_kwargs={"flags": {"required": True}})
267-
268280
tags = _builder.get(".tags")
269281
if tags is not None:
270282
tags.set_elements(AAZStrType, ".")
@@ -292,7 +304,7 @@ def _build_schema_on_200_201(cls):
292304
_schema_on_200_201.id = AAZStrType(
293305
flags={"read_only": True},
294306
)
295-
_schema_on_200_201.identity = AAZObjectType()
307+
_schema_on_200_201.identity = AAZIdentityObjectType()
296308
_schema_on_200_201.location = AAZStrType()
297309
_schema_on_200_201.name = AAZStrType(
298310
flags={"read_only": True},
@@ -398,7 +410,18 @@ def _build_schema_on_200_201(cls):
398410
)
399411

400412
grafana_configurations = cls._schema_on_200_201.properties.grafana_configurations
413+
grafana_configurations.security = AAZObjectType()
401414
grafana_configurations.smtp = AAZObjectType()
415+
grafana_configurations.snapshots = AAZObjectType()
416+
grafana_configurations.unified_alerting_screenshots = AAZObjectType(
417+
serialized_name="unifiedAlertingScreenshots",
418+
)
419+
grafana_configurations.users = AAZObjectType()
420+
421+
security = cls._schema_on_200_201.properties.grafana_configurations.security
422+
security.csrf_always_check = AAZBoolType(
423+
serialized_name="csrfAlwaysCheck",
424+
)
402425

403426
smtp = cls._schema_on_200_201.properties.grafana_configurations.smtp
404427
smtp.enabled = AAZBoolType()
@@ -420,6 +443,24 @@ def _build_schema_on_200_201(cls):
420443
)
421444
smtp.user = AAZStrType()
422445

446+
snapshots = cls._schema_on_200_201.properties.grafana_configurations.snapshots
447+
snapshots.external_enabled = AAZBoolType(
448+
serialized_name="externalEnabled",
449+
)
450+
451+
unified_alerting_screenshots = cls._schema_on_200_201.properties.grafana_configurations.unified_alerting_screenshots
452+
unified_alerting_screenshots.capture_enabled = AAZBoolType(
453+
serialized_name="captureEnabled",
454+
)
455+
456+
users = cls._schema_on_200_201.properties.grafana_configurations.users
457+
users.editors_can_admin = AAZBoolType(
458+
serialized_name="editorsCanAdmin",
459+
)
460+
users.viewers_can_edit = AAZBoolType(
461+
serialized_name="viewersCanEdit",
462+
)
463+
423464
grafana_integrations = cls._schema_on_200_201.properties.grafana_integrations
424465
grafana_integrations.azure_monitor_workspace_integrations = AAZListType(
425466
serialized_name="azureMonitorWorkspaceIntegrations",

src/amg/azext_amg/aaz/latest/grafana/_delete.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class Delete(AAZCommand):
2020
"""
2121

2222
_aaz_info = {
23-
"version": "2023-09-01",
23+
"version": "2024-11-01-preview",
2424
"resources": [
25-
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.dashboard/grafana/{}", "2023-09-01"],
25+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.dashboard/grafana/{}", "2024-11-01-preview"],
2626
]
2727
}
2828

@@ -51,6 +51,9 @@ def _build_arguments_schema(cls, *args, **kwargs):
5151
help="The workspace name of Azure Managed Grafana.",
5252
required=True,
5353
id_part="name",
54+
fmt=AAZStrArgFormat(
55+
pattern="^[a-zA-Z][a-z0-9A-Z-]{0,28}[a-z0-9A-Z]$",
56+
),
5457
)
5558
return cls._args_schema
5659

@@ -140,7 +143,7 @@ def url_parameters(self):
140143
def query_parameters(self):
141144
parameters = {
142145
**self.serialize_query_param(
143-
"api-version", "2023-09-01",
146+
"api-version", "2024-11-01-preview",
144147
required=True,
145148
),
146149
}

0 commit comments

Comments
 (0)