diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/config_template/_create.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/config_template/_create.py index f62083b3f40..70ae22677f8 100644 --- a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/config_template/_create.py +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/config_template/_create.py @@ -101,7 +101,8 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema.configurations = AAZFileArg( options=["--config-template-file","--configuration-template-file"], - help="Link to File containing Config expressions for this config version" + help="Link to File containing Config expressions for this config version", + required=True ) return cls._args_schema diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/configuration/_config_show.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/configuration/_config_show.py index 8c4a83d2fa9..18b973d70c5 100644 --- a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/configuration/_config_show.py +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/configuration/_config_show.py @@ -77,17 +77,25 @@ def _build_arguments_schema(cls, *args, **kwargs): # help="The resource-specific properties for this resource.", # nullable=True, # ) + _args_schema.version = AAZStrArg( + options=["--version"], + help="The version of the solution to show configuration for. Defaults to 'version1' if not specified." + ) return cls._args_schema def _execute_operations(self): self.pre_operations() - config_name = str(self.ctx.args.level_name) - if len(config_name) > 18: - config_name = config_name[:18] + "Config" + version = self.ctx.args.version + if version is not None and str(version).lower() != "undefined": + self.SolutionRevisionGet(ctx=self.ctx)() else: - config_name = config_name + "Config" - self.ctx.args.level_name = config_name - self.SolutionsGet(ctx=self.ctx)() + config_name = str(self.ctx.args.level_name) + if len(config_name) > 18: + config_name = config_name[:18] + "Config" + else: + config_name = config_name + "Config" + self.ctx.args.level_name = config_name + self.SolutionsGet(ctx=self.ctx)() self.post_operations() @register_callback @@ -101,7 +109,6 @@ def post_operations(self): def _output(self, *args, **kwargs): result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) print(result["properties"]["values"]) - pass class SolutionsGet(AAZHttpOperation): CLIENT_TYPE = "MgmtClient" @@ -259,7 +266,153 @@ def _build_schema_on_200(cls): tags.Element = AAZStrType() return cls._schema_on_200 + + class SolutionRevisionGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + config = dict() + config["properties"] = dict() + config["properties"]["values"] = "{}" + if session.http_response.status_code in [404]: + self.ctx.set_var( + "instance", + config, + schema_builder=self._build_schema_on_404 + ) + else: + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/targets/{targetName}/solutions/{solutionName}/versions/{version}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "targetName", self.ctx.args.level_name if not str(self.ctx.args.level_name).endswith('Config') else str(self.ctx.args.level_name)[:-6], + required=True, + ), + **self.serialize_url_param( + "solutionName", self.ctx.args.solution_name, + required=True, + ), + **self.serialize_url_param( + "version", self.ctx.args.version, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + config = dict() + config["properties"] = dict() + config["properties"]["values"] = data.get("properties", {}).get("configuration", "") + self.ctx.set_var( + "instance", + config, + schema_builder=self._build_schema_on_200 + ) + + @classmethod + def _build_schema_on_404(cls): + cls._schema_on_200 = AAZObjectType() + _schema_on_200 = cls._schema_on_200 + _schema_on_200.properties = AAZFreeFormDictType() + return cls._schema_on_200 + + @classmethod + def _build_schema_on_200(cls): + cls._schema_on_200 = AAZObjectType() + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.location = AAZStrType( + flags={"required": False}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType() + _schema_on_200.properties.values = AAZStrType() + _schema_on_200.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200.tags = AAZDictType() + _schema_on_200.type = AAZStrType( + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 class _ShowHelper: """Helper class for Show""" diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/__init__.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/__init__.py index 97c8485d1f0..0e2e5182419 100644 --- a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/__init__.py +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/__init__.py @@ -20,3 +20,6 @@ from ._show import * # from ._update import * from ._wait import * +from ._use_context import * +from ._set_context import * +from ._current_context import * \ No newline at end of file diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_create.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_create.py index 338261e603d..5c3f2c6f810 100644 --- a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_create.py +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_create.py @@ -65,11 +65,13 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["--capabilities"], arg_group="Properties", help="List of Capabilities", + required=True ) _args_schema.hierarchies = AAZListArg( options=["--hierarchies"], arg_group="Properties", help="List of Hierarchies", + required=True ) capabilities = cls._args_schema.capabilities diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_current_context.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_current_context.py new file mode 100644 index 00000000000..cac0a25e88d --- /dev/null +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_current_context.py @@ -0,0 +1,68 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + +@register_command( + "workload-orchestration context current", +) +class CurrentContext(AAZCommand): + """Show current context information + :example: Show current context + az workload-orchestration context current + """ + + _aaz_info = { + "version": "2025-06-01" + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + # No operations needed - just reading config + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + context_id = self.ctx.cli_ctx.config.get('workload_orchestration', 'context_id', None) + context_name = self.ctx.cli_ctx.config.get('workload_orchestration', 'context_name', None) + resource_group = self.ctx.cli_ctx.config.get('workload_orchestration', 'resource_group', None) + + if not context_id or not context_name or not resource_group: + return "No current context is set" + + return { + "contextId": context_id, + "name": context_name, + "resourceGroup": resource_group + } + +class _CurrentContextHelper: + """Helper class for CurrentContext""" + +__all__ = ["CurrentContext"] diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_set_context.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_set_context.py new file mode 100644 index 00000000000..4dd4a8ae82a --- /dev/null +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_set_context.py @@ -0,0 +1,82 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + +@register_command( + "workload-orchestration context set", +) +class SetContext(AAZCommand): + """Set current context using context ID + :example: Set a Context using ID + az workload-orchestration context set --id /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Edge/contexts/myContext + """ + + _aaz_info = { + "version": "2025-06-01" + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + _args_schema = cls._args_schema + _args_schema.context_id = AAZStrArg( + options=["--id"], + help="The full resource ID of the Context.", + required=True + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + # Extract context name and resource group from ID + # ID format: /subscriptions/{sub}/resourceGroups/{rg}/providers/Microsoft.Edge/contexts/{name} + context_id = self.ctx.args.context_id.to_serialized_data() + parts = context_id.split('/') + if len(parts) != 9 or parts[6] != 'Microsoft.Edge' or parts[7] != 'contexts': + raise CLIInternalError("Invalid context ID format") + + context_name = parts[8] + resource_group = parts[4] + + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + context_id = self.ctx.args.context_id.to_serialized_data() + parts = context_id.split('/') + context_name = parts[8] + resource_group = parts[4] + + self.ctx.cli_ctx.config.set_value('workload_orchestration', 'context_id', context_id) + self.ctx.cli_ctx.config.set_value('workload_orchestration', 'context_name', context_name) + self.ctx.cli_ctx.config.set_value('workload_orchestration', 'resource_group', resource_group) + + return f"Successfully set current context using ID '{self.ctx.args.context_id}'" + +class _SetContextHelper: + """Helper class for SetContext""" + +__all__ = ["SetContext"] diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_show.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_show.py index 086a6576a77..f12c52f0d93 100644 --- a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_show.py +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_show.py @@ -61,6 +61,7 @@ def _build_arguments_schema(cls, *args, **kwargs): def _execute_operations(self): self.pre_operations() + self.ContextsGet(ctx=self.ctx)() self.post_operations() diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_use_context.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_use_context.py new file mode 100644 index 00000000000..4238d9fdf32 --- /dev/null +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/context/_use_context.py @@ -0,0 +1,183 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + +from azure.cli.core.azclierror import CLIInternalError + +@register_command( + "workload-orchestration context use", +) +class UseContext(AAZCommand): + """Use Context by name + :example: Use a Context + az workload-orchestration context use -n myContext -g myResourceGroup + """ + + _aaz_info = { + "version": "2025-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.edge/contexts/{}", "2025-06-01"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return self._output() + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.context_name = AAZStrArg( + options=["-n", "--name"], + help="The name of the Context.", + required=True, + id_part="name", + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?)*$", + max_length=61, + min_length=3, + ), + ) + _args_schema.resource_group = AAZResourceGroupNameArg( + options=["-g", "--resource-group"], + help="Name of resource group.", + required=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.ContextsGet(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + current_context_id = result.get('id') + if current_context_id: + self.ctx.cli_ctx.config.set_value( + 'workload_orchestration', 'context_id', current_context_id) + self.ctx.cli_ctx.config.set_value( + 'workload_orchestration', 'context_name', self.ctx.args.context_name.to_serialized_data()) + self.ctx.cli_ctx.config.set_value( + 'workload_orchestration', 'resource_group', self.ctx.args.resource_group.to_serialized_data()) + return f"Successfully set current context to '{self.ctx.args.context_name}'" + + class ContextsGet(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/contexts/{contextName}", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "contextName", self.ctx.args.context_name, + required=True, + ), + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group or "default", + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + + return cls._schema_on_200 + +class _UseContextHelper: + """Helper class for UseContext""" + +__all__ = ["UseContext"] diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/schema/_create.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/schema/_create.py index ec7a14382ef..57c594773f2 100644 --- a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/schema/_create.py +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/schema/_create.py @@ -91,6 +91,7 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema.value = AAZFileArg( options=["--schema-file","-f"], help="Path to the schema file", + required=True ) tags = cls._args_schema.tags diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/solution_template/_create.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/solution_template/_create.py index 528572999a0..612b8e73b9e 100644 --- a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/solution_template/_create.py +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/solution_template/_create.py @@ -67,6 +67,7 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["--capabilities"], arg_group="Properties", help="List of capabilities", + required=True, ) _args_schema.description = AAZStrArg( options=["--description"], @@ -92,11 +93,13 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema.configurations = AAZFileArg( options=["--config-template-file","--configuration-template-file","-f"], help="Link to File containing Config expressions for this solution version", + required=True, ) _args_schema.specification = AAZFreeFormDictArg( options=["--specification"], help="App components spec, use @ to load from file", + required=True, ) _args_schema.enable_external_validation = AAZBoolArg( diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/__init__.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/__init__.py index d37a346d059..13c2517b178 100644 --- a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/__init__.py +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/__init__.py @@ -21,4 +21,6 @@ from ._show import * from ._uninstall import * from ._update import * -from ._wait import * \ No newline at end of file +from ._wait import * +from ._solution_instance_list import * +from ._solution_revision_list import * \ No newline at end of file diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_create.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_create.py index aa1dd32ad04..fa4da1477d6 100644 --- a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_create.py +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_create.py @@ -9,6 +9,7 @@ # flake8: noqa from azure.cli.core.aaz import * +from azure.cli.core.azclierror import CLIInternalError @register_command( @@ -66,27 +67,33 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["--capabilities"], arg_group="Properties", help="List of capabilities", + required=True ) _args_schema.context_id = AAZResourceIdArg( options=["--context-id"], arg_group="Properties", help="ArmId of Context", - required=True, ) _args_schema.description = AAZStrArg( options=["--description"], arg_group="Properties", help="Description of target", + required=True, + ) _args_schema.display_name = AAZStrArg( options=["--display-name"], arg_group="Properties", help="Display name of target", + required=True, + ) _args_schema.hierarchy_level = AAZStrArg( options=["--hierarchy-level"], arg_group="Properties", help="Hierarchy Level", + required=True, + ) _args_schema.solution_scope = AAZStrArg( options=["--solution-scope"], @@ -107,6 +114,8 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["--target-specification"], arg_group="Properties", help="Specifies that we are using Helm charts for the k8s deployment", + required=True, + ) capabilities = cls._args_schema.capabilities @@ -158,7 +167,13 @@ def _execute_operations(self): @register_callback def pre_operations(self): - pass + # If context_id is not provided, try to get it from config + if not self.ctx.args.context_id: + context_id = self.ctx.cli_ctx.config.get('workload_orchestration', 'context_id') + if context_id: + self.ctx.args.context_id = context_id + else: + raise CLIInternalError("No context-id provided and no default context found. Please provide --context-id or use 'az workload-orchestration context use' to set a default context.") @register_callback def post_operations(self): diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_solution_instance_list.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_solution_instance_list.py new file mode 100644 index 00000000000..1691a8e94bc --- /dev/null +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_solution_instance_list.py @@ -0,0 +1,214 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "workload-orchestration target solution-instance-list", +) +class ListSolutionInstances(AAZCommand): + """List all solution instances of a solution deployed on a target + :example: + az workload-orchestration solution-instance list -g MyResourceGroup --solution-name MySolution + """ + + _aaz_info = { + "version": "2025-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.edge/targets/{}/solutions/{}/instances", "2025-06-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.target_name = AAZStrArg( + options=["--target-name", "--name", "-n"], + help="Name of the target", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?)*$", + max_length=61, + min_length=3, + ), + ) + _args_schema.solution_name = AAZStrArg( + options=["--solution-template-name", "--solution"], + help="Name of the solution", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?)*$", + max_length=61, + min_length=3, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.SolutionInstancesList(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class SolutionInstancesList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/targets/{targetName}/solutions/{solutionName}/instances", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "targetName", self.ctx.args.target_name, + required=True, + ), + **self.serialize_url_param( + "solutionName", self.ctx.args.solution_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + + properties = cls._schema_on_200.value.Element.properties + properties.state = AAZStrType() + properties.display_name = AAZStrType( + serialized_name="displayName", + ) + properties.created_at = AAZStrType( + serialized_name="createdAt", + ) + properties.updated_at = AAZStrType( + serialized_name="updatedAt", + ) + + return cls._schema_on_200 + + +class _ListSolutionInstancesHelper: + """Helper class for ListSolutionInstances""" + + +__all__ = ["ListSolutionInstances"] diff --git a/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_solution_revision_list.py b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_solution_revision_list.py new file mode 100644 index 00000000000..a7540dc5594 --- /dev/null +++ b/src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_solution_revision_list.py @@ -0,0 +1,288 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# +# Code generated by aaz-dev-tools +# -------------------------------------------------------------------------------------------- + +# pylint: skip-file +# flake8: noqa + +from azure.cli.core.aaz import * + + +@register_command( + "workload-orchestration target solution-revision-list", +) +class ListRevisions(AAZCommand): + """List all revisions of a solution deployed on a target + :example: + List all revisions of a solution on a target + az workload-orchestration target solution-revision-list -g MyResourceGroup --target-name MyTarget --solution-name MySolution + """ + + _aaz_info = { + "version": "2025-06-01", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.edge/targets/{}/solutions/{}/versions", "2025-06-01"], + ] + } + + AZ_SUPPORT_PAGINATION = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_paging(self._execute_operations, self._output) + + _args_schema = None + + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + if cls._args_schema is not None: + return cls._args_schema + cls._args_schema = super()._build_arguments_schema(*args, **kwargs) + + # define Arg Group "" + + _args_schema = cls._args_schema + _args_schema.resource_group = AAZResourceGroupNameArg( + required=True, + ) + _args_schema.target_name = AAZStrArg( + options=["--target-name", "--name", "-n"], + help="Name of the target", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?)*$", + max_length=61, + min_length=3, + ), + ) + + # define Arg Group "Body" + + _args_schema.solution_name = AAZStrArg( + options=["--solution-template-name", "--solution"], + help="Name of the solution", + required=True, + fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([-a-zA-Z0-9]*[a-zA-Z0-9])?)*$", + max_length=61, + min_length=3, + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.TargetSolutionRevisionsList(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance.value, client_flatten=True) + next_link = self.deserialize_output(self.ctx.vars.instance.next_link) + return result, next_link + + class TargetSolutionRevisionsList(AAZHttpOperation): + CLIENT_TYPE = "MgmtClient" + + def __call__(self, *args, **kwargs): + request = self.make_request() + session = self.client.send_request(request=request, stream=False, **kwargs) + if session.http_response.status_code in [200]: + return self.on_200(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/targets/{targetName}/solutions/{solutionName}/versions", + **self.url_parameters + ) + + @property + def method(self): + return "GET" + + @property + def error_format(self): + return "MgmtErrorFormat" + + @property + def url_parameters(self): + parameters = { + **self.serialize_url_param( + "resourceGroupName", self.ctx.args.resource_group, + required=True, + ), + **self.serialize_url_param( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + **self.serialize_url_param( + "targetName", self.ctx.args.target_name, + required=True, + ), + **self.serialize_url_param( + "solutionName", self.ctx.args.solution_name, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2025-06-01", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + def on_200(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200 + ) + + _schema_on_200 = None + + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 + + cls._schema_on_200 = AAZObjectType() + + _schema_on_200 = cls._schema_on_200 + _schema_on_200.next_link = AAZStrType( + serialized_name="nextLink", + ) + _schema_on_200.value = AAZListType( + flags={"required": True}, + ) + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.extended_location = AAZObjectType( + serialized_name="extendedLocation", + ) + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType() + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + extended_location = cls._schema_on_200.value.Element.extended_location + extended_location.name = AAZStrType() + extended_location.type = AAZStrType() + + properties = cls._schema_on_200.value.Element.properties + properties.configuration = AAZStrType() + properties.external_validation_id = AAZStrType( + serialized_name="externalValidationId", + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + properties.review_id = AAZStrType( + serialized_name="reviewId", + ) + properties.revision = AAZIntType() + properties.solution_dependencies = AAZListType( + serialized_name="solutionDependencies", + ) + properties.solution_instance_name = AAZStrType( + serialized_name="solutionInstanceName", + ) + properties.solution_template_version_id = AAZStrType( + serialized_name="solutionTemplateVersionId", + ) + properties.specification = AAZFreeFormDictType() + properties.state = AAZStrType() + properties.target_display_name = AAZStrType( + serialized_name="targetDisplayName", + ) + + solution_dependencies = cls._schema_on_200.value.Element.properties.solution_dependencies + solution_dependencies.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element.properties.solution_dependencies.Element + _element.dependencies = AAZListType() + _element.solution_instance_name = AAZStrType( + serialized_name="solutionInstanceName", + ) + _element.solution_template_version_id = AAZStrType( + serialized_name="solutionTemplateVersionId", + ) + _element.solution_version_id = AAZStrType( + serialized_name="solutionVersionId", + ) + _element.target_id = AAZStrType( + serialized_name="targetId", + ) + + dependencies = cls._schema_on_200.value.Element.properties.solution_dependencies.Element.dependencies + dependencies.Element = AAZObjectType() + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + return cls._schema_on_200 + + +class _ListRevisionsHelper: + """Helper class for ListRevisions""" + + +__all__ = ["ListRevisions"]