-
Notifications
You must be signed in to change notification settings - Fork 1.5k
List instances and List revision should use ST Id not name #9643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ebdc33b
cf07a53
9e85d13
62b8b53
94c1821
82cb3e5
2845dd8
9630b19
dafc862
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| # flake8: noqa | ||
|
|
||
| from azure.cli.core.aaz import * | ||
| from ._target_helper import TargetHelper | ||
|
|
||
|
|
||
| @register_command( | ||
|
|
@@ -89,6 +90,14 @@ class SolutionInstancesList(AAZHttpOperation): | |
| CLIENT_TYPE = "MgmtClient" | ||
|
|
||
| def __call__(self, *args, **kwargs): | ||
| # Resolve solution template name to its uniqueIdentifier | ||
| self.unique_identifier = TargetHelper.get_solution_template_unique_identifier( | ||
| self.ctx.subscription_id, | ||
| self.ctx.args.resource_group, | ||
| self.ctx.args.solution_name, | ||
| self.client | ||
| ) | ||
|
|
||
| request = self.make_request() | ||
|
Comment on lines
92
to
101
|
||
| session = self.client.send_request(request=request, stream=False, **kwargs) | ||
| if session.http_response.status_code in [200]: | ||
|
|
@@ -127,7 +136,7 @@ def url_parameters(self): | |
| required=True, | ||
| ), | ||
| **self.serialize_url_param( | ||
| "solutionName", self.ctx.args.solution_name, | ||
| "solutionName", self.unique_identifier, | ||
| required=True, | ||
| ), | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| # flake8: noqa | ||
|
|
||
| from azure.cli.core.aaz import * | ||
| from ._target_helper import TargetHelper | ||
|
|
||
|
|
||
| @register_command( | ||
|
|
@@ -92,6 +93,14 @@ class TargetSolutionRevisionsList(AAZHttpOperation): | |
| CLIENT_TYPE = "MgmtClient" | ||
|
|
||
| def __call__(self, *args, **kwargs): | ||
| # Resolve solution template name to its uniqueIdentifier | ||
| self.unique_identifier = TargetHelper.get_solution_template_unique_identifier( | ||
| self.ctx.subscription_id, | ||
| self.ctx.args.resource_group, | ||
| self.ctx.args.solution_name, | ||
| self.client | ||
| ) | ||
|
|
||
| request = self.make_request() | ||
| session = self.client.send_request(request=request, stream=False, **kwargs) | ||
|
Comment on lines
95
to
105
|
||
| if session.http_response.status_code in [200]: | ||
|
|
@@ -122,7 +131,7 @@ def url_parameters(self): | |
| required=True, | ||
| ), | ||
| **self.serialize_url_param( | ||
| "solutionName", self.ctx.args.solution_name, | ||
| "solutionName", self.unique_identifier, | ||
| required=True, | ||
| ), | ||
| **self.serialize_url_param( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
Avisiktapatra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Code generated by aaz-dev-tools. DO NOT EDIT. | ||
|
|
||
| # pylint: skip-file | ||
| # flake8: noqa | ||
|
|
||
|
|
||
| class TargetHelper: | ||
| """Shared helper for target commands.""" | ||
|
|
||
| @staticmethod | ||
| def get_solution_template_unique_identifier(subscription_id, resource_group_name, template_name, client): | ||
| """Fetch the solution template and return its uniqueIdentifier from properties. | ||
|
|
||
| Args: | ||
| subscription_id: The subscription ID | ||
| resource_group_name: The resource group name | ||
| template_name: The solution template name | ||
| client: HTTP client for making the request | ||
|
|
||
| Returns: | ||
| str: The uniqueIdentifier from template properties, or template_name as fallback | ||
|
|
||
| Raises: | ||
| CLIInternalError: If the template does not exist or the request fails | ||
| """ | ||
| from azure.cli.core.azclierror import CLIInternalError | ||
| import json | ||
|
|
||
| template_url = client.format_url( | ||
| "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/solutionTemplates/{solutionTemplateName}", | ||
| subscriptionId=subscription_id, | ||
| resourceGroupName=resource_group_name, | ||
| solutionTemplateName=template_name | ||
| ) | ||
| request = client._request("GET", template_url, { | ||
| "api-version": "2025-08-01" | ||
| }, { | ||
| "Accept": "application/json" | ||
| }, None, {}, None) | ||
|
|
||
| try: | ||
| response = client.send_request(request=request, stream=False) | ||
|
|
||
| if response.http_response.status_code == 404: | ||
| raise CLIInternalError( | ||
| f"Solution template '{template_name}' not found in resource group '{resource_group_name}'." | ||
| ) | ||
| if response.http_response.status_code != 200: | ||
| raise CLIInternalError( | ||
| f"Failed to get solution template '{template_name}': HTTP {response.http_response.status_code}" | ||
| ) | ||
|
|
||
| data = json.loads(response.http_response.text()) | ||
| unique_identifier = data.get("properties", {}).get("uniqueIdentifier") | ||
|
|
||
| if unique_identifier and unique_identifier.strip(): | ||
| return unique_identifier | ||
| return template_name | ||
| except CLIInternalError: | ||
| # Propagate explicitly raised CLIInternalError instances unchanged. | ||
| raise | ||
| except Exception as exc: | ||
| # Wrap unexpected errors (e.g., network issues, JSON parsing failures) | ||
| # in CLIInternalError to match the documented behavior. | ||
| raise CLIInternalError( | ||
| f"Failed to get solution template '{template_name}': {exc}" | ||
| ) from exc | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you run these CLI cmds locally and attach results that they are working e2e