From 16c0f63b820d4c02fb355b1a5e6f9ac1b52d1cb2 Mon Sep 17 00:00:00 2001 From: Alexis Matuk Date: Thu, 29 Jun 2023 01:07:58 -0600 Subject: [PATCH 1/6] Add graphservices cli module and integration tests --- .../command_modules/graphservices/__init__.py | 44 ++ .../command_modules/graphservices/_help.py | 11 + .../command_modules/graphservices/_params.py | 13 + .../graphservices/aaz/__init__.py | 6 + .../graphservices/aaz/latest/__init__.py | 6 + .../aaz/latest/graph_services/__cmd_group.py | 25 ++ .../aaz/latest/graph_services/__init__.py | 11 + .../graph_services/account/__cmd_group.py | 23 + .../latest/graph_services/account/__init__.py | 17 + .../latest/graph_services/account/_create.py | 287 ++++++++++++ .../latest/graph_services/account/_delete.py | 140 ++++++ .../latest/graph_services/account/_list.py | 352 +++++++++++++++ .../latest/graph_services/account/_show.py | 214 +++++++++ .../latest/graph_services/account/_update.py | 419 ++++++++++++++++++ .../latest/graph_services/account/_wait.py | 210 +++++++++ .../command_modules/graphservices/commands.py | 16 + .../command_modules/graphservices/custom.py | 14 + .../graphservices/tests/__init__.py | 6 + .../graphservices/tests/latest/__init__.py | 6 + .../tests/latest/test_graphservices.py | 46 ++ 20 files changed, 1866 insertions(+) create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/__init__.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/_help.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/_params.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/__init__.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/__init__.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__cmd_group.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__init__.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__cmd_group.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__init__.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_create.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_delete.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_list.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_show.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_update.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_wait.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/commands.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/custom.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/tests/__init__.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/__init__.py create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/test_graphservices.py diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/__init__.py b/src/azure-cli/azure/cli/command_modules/graphservices/__init__.py new file mode 100644 index 00000000000..53d29b1443a --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/__init__.py @@ -0,0 +1,44 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader +from azure.cli.command_modules.graphservices._help import helps # pylint: disable=unused-import +# from azure.cli.core.profiles import ResourceType # required when using python sdk + + +class GraphservicesCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + custom_command_type = CliCommandType( + operations_tmpl='azure.cli.command_modules.graphservices.custom#{}') + super().__init__(cli_ctx=cli_ctx, + # resource_type=ResourceType.XXX # required when using python sdk + custom_command_type=custom_command_type) + + def load_command_table(self, args): + from azure.cli.command_modules.graphservices.commands import load_command_table + from azure.cli.core.aaz import load_aaz_command_table + try: + from . import aaz + except ImportError: + aaz = None + if aaz: + load_aaz_command_table( + loader=self, + aaz_pkg_name=aaz.__name__, + args=args + ) + load_command_table(self, args) + return self.command_table + + def load_arguments(self, command): + from azure.cli.command_modules.graphservices._params import load_arguments + load_arguments(self, command) + + +COMMAND_LOADER_CLS = GraphservicesCommandsLoader diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/_help.py b/src/azure-cli/azure/cli/command_modules/graphservices/_help.py new file mode 100644 index 00000000000..126d5d00714 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/_help.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# 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: disable=line-too-long +# pylint: disable=too-many-lines + +from knack.help_files import helps # pylint: disable=unused-import diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/_params.py b/src/azure-cli/azure/cli/command_modules/graphservices/_params.py new file mode 100644 index 00000000000..cfcec717c9c --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/_params.py @@ -0,0 +1,13 @@ +# -------------------------------------------------------------------------------------------- +# 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: disable=too-many-lines +# pylint: disable=too-many-statements + + +def load_arguments(self, _): # pylint: disable=unused-argument + pass diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/__init__.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/__init__.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__cmd_group.py new file mode 100644 index 00000000000..4fdc79685fe --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__cmd_group.py @@ -0,0 +1,25 @@ +# -------------------------------------------------------------------------------------------- +# 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_group( + "graph-services", +) +class __CMDGroup(AAZCommandGroup): + """Make operations on Microsoft.GraphServices resource types + + This module enables you to use the Azure CLI to manage Microsoft.GraphServices/Accounts resources in Azure, which is the resource that contains the billing configuration of the Graph app associated with it. + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__init__.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__init__.py new file mode 100644 index 00000000000..5a9d61963d6 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__init__.py @@ -0,0 +1,11 @@ +# -------------------------------------------------------------------------------------------- +# 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 .__cmd_group import * diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__cmd_group.py new file mode 100644 index 00000000000..2f575c09afc --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__cmd_group.py @@ -0,0 +1,23 @@ +# -------------------------------------------------------------------------------------------- +# 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_group( + "graph-services account", +) +class __CMDGroup(AAZCommandGroup): + """Make operations on Microsoft.GraphServices/Accounts + """ + pass + + +__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__init__.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__init__.py new file mode 100644 index 00000000000..db73033039b --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__init__.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------------------------- +# 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 .__cmd_group import * +from ._create import * +from ._delete import * +from ._list import * +from ._show import * +from ._update import * +from ._wait import * diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_create.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_create.py new file mode 100644 index 00000000000..8d4ab739e43 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_create.py @@ -0,0 +1,287 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "graph-services account create", +) +class Create(AAZCommand): + """Create account resource. + + :example: Create Account + az graph-services account create --resource-group myRG --resource-name myGraphAppBilling --subscription mySubscriptionGUID --location global --tags "foo=bar" "baz=qux" --app-id myAppGUID + """ + + _aaz_info = { + "version": "2023-04-13", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.graphservices/accounts/{}", "2023-04-13"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(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( + help="Name of an Azure resource group in your subscription", + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The name of the resource.", + required=True, + ) + + # define Arg Group "AccountResource" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + arg_group="AccountResource", + help="Location of the resource.", + default="global", + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="AccountResource", + help="Resource tags", + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg() + + # define Arg Group "Properties" + + _args_schema = cls._args_schema + _args_schema.app_id = AAZStrArg( + options=["--app-id"], + arg_group="Properties", + help="Customer owned application ID", + required=True, + fmt=AAZStrArgFormat( + pattern="(^[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}?)$", + ), + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + yield self.AccountsCreateAndUpdate(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) + return result + + class AccountsCreateAndUpdate(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 [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices/accounts/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @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( + "resourceName", self.ctx.args.resource_name, + 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", "2023-04-13", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} + ) + _builder.set_prop("location", AAZStrType, ".location") + _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}}) + _builder.set_prop("tags", AAZDictType, ".tags") + + properties = _builder.get(".properties") + if properties is not None: + properties.set_prop("appId", AAZStrType, ".app_id", typ_kwargs={"flags": {"required": True}}) + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + + _schema_on_200_201 = cls._schema_on_200_201 + _schema_on_200_201.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.location = AAZStrType() + _schema_on_200_201.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200_201.properties = AAZObjectType( + flags={"required": True}, + ) + _schema_on_200_201.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _schema_on_200_201.tags = AAZDictType() + _schema_on_200_201.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200_201.properties + properties.app_id = AAZStrType( + serialized_name="appId", + flags={"required": True}, + ) + properties.billing_plan_id = AAZStrType( + serialized_name="billingPlanId", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200_201.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200_201.tags + tags.Element = AAZStrType() + + return cls._schema_on_200_201 + + +class _CreateHelper: + """Helper class for Create""" + + +__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_delete.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_delete.py new file mode 100644 index 00000000000..8bc6feca7be --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_delete.py @@ -0,0 +1,140 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "graph-services account delete", + confirmation="Are you sure you want to perform this operation?", +) +class Delete(AAZCommand): + """Delete a account resource. + + :example: Delete account + az graph-services account delete --subscription mySubscriptionGUID --resource-group myRG --resource-name myGraphAppBilling + """ + + _aaz_info = { + "version": "2023-04-13", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.graphservices/accounts/{}", "2023-04-13"], + ] + } + + def _handler(self, command_args): + super()._handler(command_args) + self._execute_operations() + return None + + _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( + help="Name of an Azure resource group in your subscription", + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The name of the resource.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AccountsDelete(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + class AccountsDelete(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) + if session.http_response.status_code in [204]: + return self.on_204(session) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices/accounts/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "DELETE" + + @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( + "resourceName", self.ctx.args.resource_name, + 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", "2023-04-13", + required=True, + ), + } + return parameters + + def on_200(self, session): + pass + + def on_204(self, session): + pass + + +class _DeleteHelper: + """Helper class for Delete""" + + +__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_list.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_list.py new file mode 100644 index 00000000000..7e3dc16bc9c --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_list.py @@ -0,0 +1,352 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "graph-services account list", +) +class List(AAZCommand): + """List list of accounts belonging to a subscription. + + :example: List resources in subscription + az graph-services account list --subscription mySubscriptionGUID --resource-group myRg + """ + + _aaz_info = { + "version": "2023-04-13", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/providers/microsoft.graphservices/accounts", "2023-04-13"], + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.graphservices/accounts", "2023-04-13"], + ] + } + + 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( + help="Name of an Azure resource group in your subscription", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + condition_0 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) + condition_1 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True + if condition_0: + self.AccountsListByResourceGroup(ctx=self.ctx)() + if condition_1: + self.AccountsListBySubscription(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 AccountsListByResourceGroup(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.GraphServices/accounts", + **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, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-04-13", + 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() + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType() + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"required": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.app_id = AAZStrType( + serialized_name="appId", + flags={"required": True}, + ) + properties.billing_plan_id = AAZStrType( + serialized_name="billingPlanId", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + class AccountsListBySubscription(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}/providers/Microsoft.GraphServices/accounts", + **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( + "subscriptionId", self.ctx.subscription_id, + required=True, + ), + } + return parameters + + @property + def query_parameters(self): + parameters = { + **self.serialize_query_param( + "api-version", "2023-04-13", + 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() + + value = cls._schema_on_200.value + value.Element = AAZObjectType() + + _element = cls._schema_on_200.value.Element + _element.id = AAZStrType( + flags={"read_only": True}, + ) + _element.location = AAZStrType() + _element.name = AAZStrType( + flags={"read_only": True}, + ) + _element.properties = AAZObjectType( + flags={"required": True}, + ) + _element.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + _element.tags = AAZDictType() + _element.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = cls._schema_on_200.value.Element.properties + properties.app_id = AAZStrType( + serialized_name="appId", + flags={"required": True}, + ) + properties.billing_plan_id = AAZStrType( + serialized_name="billingPlanId", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.value.Element.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.value.Element.tags + tags.Element = AAZStrType() + + return cls._schema_on_200 + + +class _ListHelper: + """Helper class for List""" + + +__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_show.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_show.py new file mode 100644 index 00000000000..50c05e7e93c --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_show.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( + "graph-services account show", +) +class Show(AAZCommand): + """Get account resource for a given name. + + :example: Get account + az --subscription mySubscriptionGUID --resource-group myRG --resource-name myGraphAppBilling + """ + + _aaz_info = { + "version": "2023-04-13", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.graphservices/accounts/{}", "2023-04-13"], + ] + } + + 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.resource_group = AAZResourceGroupNameArg( + help="Name of an Azure resource group in your subscription", + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The name of the resource.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AccountsGet(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) + return result + + class AccountsGet(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.GraphServices/accounts/{resourceName}", + **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( + "resourceName", self.ctx.args.resource_name, + 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", "2023-04-13", + 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.location = AAZStrType() + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"required": True}, + ) + _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}, + ) + + properties = cls._schema_on_200.properties + properties.app_id = AAZStrType( + serialized_name="appId", + flags={"required": True}, + ) + properties.billing_plan_id = AAZStrType( + serialized_name="billingPlanId", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + 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""" + + +__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_update.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_update.py new file mode 100644 index 00000000000..49273e4c7ec --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_update.py @@ -0,0 +1,419 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "graph-services account update", +) +class Update(AAZCommand): + """Update account resource. + + The only supported updated on a resource is the tags property + + :example: Update account + az graph-services account update --resource-group myRG --resource-name myGraphAppBilling --subscription mySubscriptionGUID --location global --tags "foo1=bar1" "baz1=qux1" + """ + + _aaz_info = { + "version": "2023-04-13", + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.graphservices/accounts/{}", "2023-04-13"], + ] + } + + AZ_SUPPORT_NO_WAIT = True + + AZ_SUPPORT_GENERIC_UPDATE = True + + def _handler(self, command_args): + super()._handler(command_args) + return self.build_lro_poller(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( + help="Name of an Azure resource group in your subscription", + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The name of the resource.", + required=True, + id_part="name", + ) + + # define Arg Group "AccountResource" + + _args_schema = cls._args_schema + _args_schema.location = AAZResourceLocationArg( + arg_group="AccountResource", + help="Location of the resource.", + nullable=True, + fmt=AAZResourceLocationArgFormat( + resource_group_arg="resource_group", + ), + ) + _args_schema.tags = AAZDictArg( + options=["--tags"], + arg_group="AccountResource", + help="Resource tags", + nullable=True, + ) + + tags = cls._args_schema.tags + tags.Element = AAZStrArg( + nullable=True, + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AccountsGet(ctx=self.ctx)() + self.pre_instance_update(self.ctx.vars.instance) + self.InstanceUpdateByJson(ctx=self.ctx)() + self.InstanceUpdateByGeneric(ctx=self.ctx)() + self.post_instance_update(self.ctx.vars.instance) + yield self.AccountsCreateAndUpdate(ctx=self.ctx)() + self.post_operations() + + @register_callback + def pre_operations(self): + pass + + @register_callback + def post_operations(self): + pass + + @register_callback + def pre_instance_update(self, instance): + pass + + @register_callback + def post_instance_update(self, instance): + pass + + def _output(self, *args, **kwargs): + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) + return result + + class AccountsGet(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.GraphServices/accounts/{resourceName}", + **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( + "resourceName", self.ctx.args.resource_name, + 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", "2023-04-13", + 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() + _UpdateHelper._build_schema_account_resource_read(cls._schema_on_200) + + return cls._schema_on_200 + + class AccountsCreateAndUpdate(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 [202]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + if session.http_response.status_code in [200, 201]: + return self.client.build_lro_polling( + self.ctx.args.no_wait, + session, + self.on_200_201, + self.on_error, + lro_options={"final-state-via": "azure-async-operation"}, + path_format_arguments=self.url_parameters, + ) + + return self.on_error(session.http_response) + + @property + def url(self): + return self.client.format_url( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices/accounts/{resourceName}", + **self.url_parameters + ) + + @property + def method(self): + return "PUT" + + @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( + "resourceName", self.ctx.args.resource_name, + 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", "2023-04-13", + required=True, + ), + } + return parameters + + @property + def header_parameters(self): + parameters = { + **self.serialize_header_param( + "Content-Type", "application/json", + ), + **self.serialize_header_param( + "Accept", "application/json", + ), + } + return parameters + + @property + def content(self): + _content_value, _builder = self.new_content_builder( + self.ctx.args, + value=self.ctx.vars.instance, + ) + + return self.serialize_content(_content_value) + + def on_200_201(self, session): + data = self.deserialize_http_content(session) + self.ctx.set_var( + "instance", + data, + schema_builder=self._build_schema_on_200_201 + ) + + _schema_on_200_201 = None + + @classmethod + def _build_schema_on_200_201(cls): + if cls._schema_on_200_201 is not None: + return cls._schema_on_200_201 + + cls._schema_on_200_201 = AAZObjectType() + _UpdateHelper._build_schema_account_resource_read(cls._schema_on_200_201) + + return cls._schema_on_200_201 + + class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance(self.ctx.vars.instance) + + def _update_instance(self, instance): + _instance_value, _builder = self.new_content_builder( + self.ctx.args, + value=instance, + typ=AAZObjectType + ) + _builder.set_prop("location", AAZStrType, ".location") + _builder.set_prop("tags", AAZDictType, ".tags") + + tags = _builder.get(".tags") + if tags is not None: + tags.set_elements(AAZStrType, ".") + + return _instance_value + + class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + + def __call__(self, *args, **kwargs): + self._update_instance_by_generic( + self.ctx.vars.instance, + self.ctx.generic_update_args + ) + + +class _UpdateHelper: + """Helper class for Update""" + + _schema_account_resource_read = None + + @classmethod + def _build_schema_account_resource_read(cls, _schema): + if cls._schema_account_resource_read is not None: + _schema.id = cls._schema_account_resource_read.id + _schema.location = cls._schema_account_resource_read.location + _schema.name = cls._schema_account_resource_read.name + _schema.properties = cls._schema_account_resource_read.properties + _schema.system_data = cls._schema_account_resource_read.system_data + _schema.tags = cls._schema_account_resource_read.tags + _schema.type = cls._schema_account_resource_read.type + return + + cls._schema_account_resource_read = _schema_account_resource_read = AAZObjectType() + + account_resource_read = _schema_account_resource_read + account_resource_read.id = AAZStrType( + flags={"read_only": True}, + ) + account_resource_read.location = AAZStrType() + account_resource_read.name = AAZStrType( + flags={"read_only": True}, + ) + account_resource_read.properties = AAZObjectType( + flags={"required": True}, + ) + account_resource_read.system_data = AAZObjectType( + serialized_name="systemData", + flags={"read_only": True}, + ) + account_resource_read.tags = AAZDictType() + account_resource_read.type = AAZStrType( + flags={"read_only": True}, + ) + + properties = _schema_account_resource_read.properties + properties.app_id = AAZStrType( + serialized_name="appId", + flags={"required": True}, + ) + properties.billing_plan_id = AAZStrType( + serialized_name="billingPlanId", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + system_data = _schema_account_resource_read.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = _schema_account_resource_read.tags + tags.Element = AAZStrType() + + _schema.id = cls._schema_account_resource_read.id + _schema.location = cls._schema_account_resource_read.location + _schema.name = cls._schema_account_resource_read.name + _schema.properties = cls._schema_account_resource_read.properties + _schema.system_data = cls._schema_account_resource_read.system_data + _schema.tags = cls._schema_account_resource_read.tags + _schema.type = cls._schema_account_resource_read.type + + +__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_wait.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_wait.py new file mode 100644 index 00000000000..35cfae092bc --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_wait.py @@ -0,0 +1,210 @@ +# -------------------------------------------------------------------------------------------- +# 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( + "graph-services account wait", +) +class Wait(AAZWaitCommand): + """Place the CLI in a waiting state until a condition is met. + """ + + _aaz_info = { + "resources": [ + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.graphservices/accounts/{}", "2023-04-13"], + ] + } + + 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.resource_group = AAZResourceGroupNameArg( + help="Name of an Azure resource group in your subscription", + required=True, + ) + _args_schema.resource_name = AAZStrArg( + options=["-n", "--name", "--resource-name"], + help="The name of the resource.", + required=True, + id_part="name", + ) + return cls._args_schema + + def _execute_operations(self): + self.pre_operations() + self.AccountsGet(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=False) + return result + + class AccountsGet(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.GraphServices/accounts/{resourceName}", + **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( + "resourceName", self.ctx.args.resource_name, + 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", "2023-04-13", + 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.location = AAZStrType() + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"required": True}, + ) + _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}, + ) + + properties = cls._schema_on_200.properties + properties.app_id = AAZStrType( + serialized_name="appId", + flags={"required": True}, + ) + properties.billing_plan_id = AAZStrType( + serialized_name="billingPlanId", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) + + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + 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 _WaitHelper: + """Helper class for Wait""" + + +__all__ = ["Wait"] diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/commands.py b/src/azure-cli/azure/cli/command_modules/graphservices/commands.py new file mode 100644 index 00000000000..30b4e29e7ca --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/commands.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# 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: disable=too-many-lines +# pylint: disable=too-many-statements + +# from azure.cli.core.commands import CliCommandType +# from azure.cli.core.profiles import ResourceType + + +def load_command_table(self, _): # pylint: disable=unused-argument + pass diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/custom.py b/src/azure-cli/azure/cli/command_modules/graphservices/custom.py new file mode 100644 index 00000000000..86df1e48ef5 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/custom.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# 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: disable=too-many-lines +# pylint: disable=too-many-statements + +from knack.log import get_logger + + +logger = get_logger(__name__) diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/tests/__init__.py b/src/azure-cli/azure/cli/command_modules/graphservices/tests/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/tests/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/__init__.py b/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/__init__.py new file mode 100644 index 00000000000..5757aea3175 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/__init__.py @@ -0,0 +1,6 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/test_graphservices.py b/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/test_graphservices.py new file mode 100644 index 00000000000..b0fa0f25e7f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/test_graphservices.py @@ -0,0 +1,46 @@ +# -------------------------------------------------------------------------------------------- +# 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 +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import * +import time + +class GraphservicesScenario(ScenarioTest): + + @ResourceGroupPreparer(random_name_length=20) + def test_billing_flow(self, resource_group): + self.kwargs.update({ + 'accountName' : self.create_random_name(prefix="azcliacc", length=20), + 'aad_app_display_name' : self.create_random_name(prefix="azcliapp", length=20) + }) + + #Create aad app for which billing will be enabled + result = self.cmd('ad app create --display-name {aad_app_display_name}').get_output_in_json() + self.kwargs['app_id'] = result['appId'] + + #Wait for application to finish creating + time.sleep(120) + + #Create resource (enable billing on aad app) + self.cmd('az graph-services account create --resource-group {rg} --name {accountName} --app-id {app_id} --tags key1=value1', checks=[ + self.check('name', '{accountName}'), + self.check('tags.key1', 'value1'), + self.check('properties.provisioningState', 'Succeeded') + ]) + + #Read created resource + self.cmd('az graph-services account show --resource-group {rg} --name {accountName}', checks=[ + self.check('name', '{accountName}'), + self.check('properties.provisioningState', 'Succeeded'), + self.check('properties.appId', '{app_id}'), + ]) + + #Update resource + self.cmd('az graph-services account update --resource-group {rg} --name {accountName} --tags updatedKey1=updatedValue1 --location global', checks=[ + self.check('name', '{accountName}'), + self.check('tags.updatedKey1', 'updatedValue1'), + self.check('properties.provisioningState', 'Succeeded') + ]) \ No newline at end of file From f5676269fa31d00d82dad16fffe77a3ac41b0cfb Mon Sep 17 00:00:00 2001 From: Alexis Matuk Date: Thu, 29 Jun 2023 02:12:39 -0600 Subject: [PATCH 2/6] Add recording --- .../latest/recordings/test_billing_flow.yaml | 334 ++++++++++++++++++ .../tests/latest/test_graphservices.py | 1 - 2 files changed, 334 insertions(+), 1 deletion(-) create mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/recordings/test_billing_flow.yaml diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/recordings/test_billing_flow.yaml b/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/recordings/test_billing_flow.yaml new file mode 100644 index 00000000000..ab7febfdb70 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/recordings/test_billing_flow.yaml @@ -0,0 +1,334 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - ad app create + Connection: + - keep-alive + ParameterSetName: + - --display-name + User-Agent: + - python/3.10.0 (Windows-10-10.0.22621-SP0) AZURECLI/2.49.0 + method: GET + uri: https://graph.microsoft.com/v1.0/applications?$filter=startswith%28displayName%2C%27azcliapp000003%27%29 + response: + body: + string: '{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#applications","value":[]}' + headers: + cache-control: + - no-cache + content-length: + - '87' + content-type: + - application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8 + date: + - Thu, 29 Jun 2023 08:02:02 GMT + odata-version: + - '4.0' + request-id: + - 375ebdb0-6e31-4ee4-aadf-e11cb54559b7 + strict-transport-security: + - max-age=31536000 + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-ms-ags-diagnostic: + - '{"ServerInfo":{"DataCenter":"South Central US","Slice":"E","Ring":"5","ScaleUnit":"002","RoleInstance":"SN1PEPF00020FE4"}}' + x-ms-resource-unit: + - '2' + status: + code: 200 + message: OK +- request: + body: '{"displayName": "azcliapp000003", "keyCredentials": []}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - ad app create + Connection: + - keep-alive + Content-Length: + - '55' + Content-Type: + - application/json + ParameterSetName: + - --display-name + User-Agent: + - python/3.10.0 (Windows-10-10.0.22621-SP0) AZURECLI/2.49.0 + method: POST + uri: https://graph.microsoft.com/v1.0/applications + response: + body: + string: '{"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#applications/$entity", + "id": "7e4c7904-7542-4acf-9b34-a1d3e0f484c1", "deletedDateTime": null, "appId": + "0536fb07-8182-4d18-bfb3-b3248e88d630", "applicationTemplateId": null, "disabledByMicrosoftStatus": + null, "createdDateTime": "2023-06-29T08:02:03.9106084Z", "displayName": "azcliapp000003", + "description": null, "groupMembershipClaims": null, "identifierUris": [], + "isDeviceOnlyAuthSupported": null, "isFallbackPublicClient": null, "notes": + null, "publisherDomain": "growthandmonetization.onmicrosoft.com", "serviceManagementReference": + null, "signInAudience": "AzureADandPersonalMicrosoftAccount", "tags": [], + "tokenEncryptionKeyId": null, "samlMetadataUrl": null, "defaultRedirectUri": + null, "certification": null, "optionalClaims": null, "servicePrincipalLockConfiguration": + null, "requestSignatureVerification": null, "addIns": [], "api": {"acceptMappedClaims": + null, "knownClientApplications": [], "requestedAccessTokenVersion": 2, "oauth2PermissionScopes": + [], "preAuthorizedApplications": []}, "appRoles": [], "info": {"logoUrl": + null, "marketingUrl": null, "privacyStatementUrl": null, "supportUrl": null, + "termsOfServiceUrl": null}, "keyCredentials": [], "parentalControlSettings": + {"countriesBlockedForMinors": [], "legalAgeGroupRule": "Allow"}, "passwordCredentials": + [], "publicClient": {"redirectUris": []}, "requiredResourceAccess": [], "verifiedPublisher": + {"displayName": null, "verifiedPublisherId": null, "addedDateTime": null}, + "web": {"homePageUrl": null, "logoutUrl": null, "redirectUris": [], "implicitGrantSettings": + {"enableAccessTokenIssuance": false, "enableIdTokenIssuance": false}, "redirectUriSettings": + []}, "spa": {"redirectUris": []}}' + headers: + cache-control: + - no-cache + content-length: + - '1731' + content-type: + - application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8 + date: + - Thu, 29 Jun 2023 08:02:15 GMT + location: + - https://graph.microsoft.com/v2/67419183-f612-47fe-9b45-48fa5b880dc6/directoryObjects/7e4c7904-7542-4acf-9b34-a1d3e0f484c1/Microsoft.DirectoryServices.Application + odata-version: + - '4.0' + request-id: + - 5f0aef50-83f7-4a7e-9e91-47c09f887d62 + strict-transport-security: + - max-age=31536000 + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-ms-ags-diagnostic: + - '{"ServerInfo":{"DataCenter":"South Central US","Slice":"E","Ring":"5","ScaleUnit":"002","RoleInstance":"SN1PEPF00006482"}}' + x-ms-resource-unit: + - '1' + status: + code: 201 + message: Created +- request: + body: '{"location": "global", "properties": {"appId": "0536fb07-8182-4d18-bfb3-b3248e88d630"}, + "tags": {"key1": "value1"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - graph-services account create + Connection: + - keep-alive + Content-Length: + - '115' + Content-Type: + - application/json + ParameterSetName: + - --resource-group --name --app-id --tags + User-Agent: + - AZURECLI/2.49.0 (AAZ) azsdk-python-core/1.26.0 Python/3.10.0 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002?api-version=2023-04-13 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002","name":"azcliacc000002","type":"microsoft.graphservices/accounts","location":"global","tags":{"key1":"value1"},"systemData":{"createdByType":"User","createdAt":"2023-06-29T08:04:16.9596398Z","lastModifiedByType":"User","lastModifiedAt":"2023-06-29T08:04:16.9596398Z"},"properties":{"appId":"0536fb07-8182-4d18-bfb3-b3248e88d630","billingPlanId":"50df83c8-736a-4601-8865-b768dcfc5bad","provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '567' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 29 Jun 2023 08:04:21 GMT + etag: + - '"00002bfa-0000-0500-0000-649d3b040000"' + expires: + - '-1' + mise-correlation-id: + - 49d5509d-2831-4c01-b4f6-e7634d7148c7 + ms-cv: + - tQHNN9KzHkKId4sLgyaFfg.0 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - graph-services account show + Connection: + - keep-alive + ParameterSetName: + - --resource-group --name + User-Agent: + - AZURECLI/2.49.0 (AAZ) azsdk-python-core/1.26.0 Python/3.10.0 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002?api-version=2023-04-13 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002","name":"azcliacc000002","type":"microsoft.graphservices/accounts","location":"global","tags":{"key1":"value1"},"systemData":{"createdByType":"User","createdAt":"2023-06-29T08:04:16.9596398Z","lastModifiedByType":"User","lastModifiedAt":"2023-06-29T08:04:16.9596398Z"},"properties":{"appId":"0536fb07-8182-4d18-bfb3-b3248e88d630","billingPlanId":"50df83c8-736a-4601-8865-b768dcfc5bad","provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '567' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 29 Jun 2023 08:04:22 GMT + etag: + - '"00002bfa-0000-0500-0000-649d3b040000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - graph-services account update + Connection: + - keep-alive + ParameterSetName: + - --resource-group --name --tags --location + User-Agent: + - AZURECLI/2.49.0 (AAZ) azsdk-python-core/1.26.0 Python/3.10.0 (Windows-10-10.0.22621-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002?api-version=2023-04-13 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002","name":"azcliacc000002","type":"microsoft.graphservices/accounts","location":"global","tags":{"key1":"value1"},"systemData":{"createdByType":"User","createdAt":"2023-06-29T08:04:16.9596398Z","lastModifiedByType":"User","lastModifiedAt":"2023-06-29T08:04:16.9596398Z"},"properties":{"appId":"0536fb07-8182-4d18-bfb3-b3248e88d630","billingPlanId":"50df83c8-736a-4601-8865-b768dcfc5bad","provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '567' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 29 Jun 2023 08:04:22 GMT + etag: + - '"00002bfa-0000-0500-0000-649d3b040000"' + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + status: + code: 200 + message: OK +- request: + body: '{"location": "global", "properties": {"appId": "0536fb07-8182-4d18-bfb3-b3248e88d630"}, + "tags": {"key1": "value1", "updatedKey1": "updatedValue1"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - graph-services account update + Connection: + - keep-alive + Content-Length: + - '147' + Content-Type: + - application/json + ParameterSetName: + - --resource-group --name --tags --location + User-Agent: + - AZURECLI/2.49.0 (AAZ) azsdk-python-core/1.26.0 Python/3.10.0 (Windows-10-10.0.22621-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002?api-version=2023-04-13 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002","name":"azcliacc000002","type":"microsoft.graphservices/accounts","location":"global","tags":{"key1":"value1","updatedKey1":"updatedValue1"},"systemData":{"createdByType":"User","createdAt":"2023-06-29T08:04:16.9596398Z","lastModifiedByType":"User","lastModifiedAt":"2023-06-29T08:04:22.951096Z"},"properties":{"appId":"0536fb07-8182-4d18-bfb3-b3248e88d630","billingPlanId":"50df83c8-736a-4601-8865-b768dcfc5bad","provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '596' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 29 Jun 2023 08:04:29 GMT + etag: + - '"000031fa-0000-0500-0000-649d3b0a0000"' + expires: + - '-1' + mise-correlation-id: + - f34a2cab-5578-4b31-8abd-11066a1f70a4 + ms-cv: + - eQz2/MDQiUKlLRhFTYCgNw.0 + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-providerhub-traffic: + - 'True' + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/test_graphservices.py b/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/test_graphservices.py index b0fa0f25e7f..0f075d03fbf 100644 --- a/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/test_graphservices.py +++ b/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/test_graphservices.py @@ -9,7 +9,6 @@ import time class GraphservicesScenario(ScenarioTest): - @ResourceGroupPreparer(random_name_length=20) def test_billing_flow(self, resource_group): self.kwargs.update({ From 89ab3e853bfacdbdc8e12fca719668eb6bec7258 Mon Sep 17 00:00:00 2001 From: kairu Date: Wed, 5 Jul 2023 20:04:40 +0800 Subject: [PATCH 3/6] comment out commands --- .../tests/latest/test_graphservices.py | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/test_graphservices.py b/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/test_graphservices.py index 0f075d03fbf..9b19b8228de 100644 --- a/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/test_graphservices.py +++ b/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/test_graphservices.py @@ -8,38 +8,38 @@ from azure.cli.testsdk import * import time -class GraphservicesScenario(ScenarioTest): - @ResourceGroupPreparer(random_name_length=20) - def test_billing_flow(self, resource_group): - self.kwargs.update({ - 'accountName' : self.create_random_name(prefix="azcliacc", length=20), - 'aad_app_display_name' : self.create_random_name(prefix="azcliapp", length=20) - }) - - #Create aad app for which billing will be enabled - result = self.cmd('ad app create --display-name {aad_app_display_name}').get_output_in_json() - self.kwargs['app_id'] = result['appId'] - - #Wait for application to finish creating - time.sleep(120) - - #Create resource (enable billing on aad app) - self.cmd('az graph-services account create --resource-group {rg} --name {accountName} --app-id {app_id} --tags key1=value1', checks=[ - self.check('name', '{accountName}'), - self.check('tags.key1', 'value1'), - self.check('properties.provisioningState', 'Succeeded') - ]) - - #Read created resource - self.cmd('az graph-services account show --resource-group {rg} --name {accountName}', checks=[ - self.check('name', '{accountName}'), - self.check('properties.provisioningState', 'Succeeded'), - self.check('properties.appId', '{app_id}'), - ]) - - #Update resource - self.cmd('az graph-services account update --resource-group {rg} --name {accountName} --tags updatedKey1=updatedValue1 --location global', checks=[ - self.check('name', '{accountName}'), - self.check('tags.updatedKey1', 'updatedValue1'), - self.check('properties.provisioningState', 'Succeeded') - ]) \ No newline at end of file +# class GraphservicesScenario(ScenarioTest): +# @ResourceGroupPreparer(random_name_length=20) +# def test_billing_flow(self, resource_group): +# self.kwargs.update({ +# 'accountName' : self.create_random_name(prefix="azcliacc", length=20), +# 'aad_app_display_name' : self.create_random_name(prefix="azcliapp", length=20) +# }) +# +# #Create aad app for which billing will be enabled +# result = self.cmd('ad app create --display-name {aad_app_display_name}').get_output_in_json() +# self.kwargs['app_id'] = result['appId'] +# +# #Wait for application to finish creating +# time.sleep(120) +# +# #Create resource (enable billing on aad app) +# self.cmd('az graph-services account create --resource-group {rg} --name {accountName} --app-id {app_id} --tags key1=value1', checks=[ +# self.check('name', '{accountName}'), +# self.check('tags.key1', 'value1'), +# self.check('properties.provisioningState', 'Succeeded') +# ]) +# +# #Read created resource +# self.cmd('az graph-services account show --resource-group {rg} --name {accountName}', checks=[ +# self.check('name', '{accountName}'), +# self.check('properties.provisioningState', 'Succeeded'), +# self.check('properties.appId', '{app_id}'), +# ]) +# +# #Update resource +# self.cmd('az graph-services account update --resource-group {rg} --name {accountName} --tags updatedKey1=updatedValue1 --location global', checks=[ +# self.check('name', '{accountName}'), +# self.check('tags.updatedKey1', 'updatedValue1'), +# self.check('properties.provisioningState', 'Succeeded') +# ]) \ No newline at end of file From 488754cba833e39bc4fb15a6366d4258419bd39b Mon Sep 17 00:00:00 2001 From: kairu Date: Wed, 5 Jul 2023 20:30:08 +0800 Subject: [PATCH 4/6] hide aaz commands --- .../command_modules/graphservices/__init__.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/__init__.py b/src/azure-cli/azure/cli/command_modules/graphservices/__init__.py index 53d29b1443a..211e7f89bce 100644 --- a/src/azure-cli/azure/cli/command_modules/graphservices/__init__.py +++ b/src/azure-cli/azure/cli/command_modules/graphservices/__init__.py @@ -23,16 +23,16 @@ def __init__(self, cli_ctx=None): def load_command_table(self, args): from azure.cli.command_modules.graphservices.commands import load_command_table from azure.cli.core.aaz import load_aaz_command_table - try: - from . import aaz - except ImportError: - aaz = None - if aaz: - load_aaz_command_table( - loader=self, - aaz_pkg_name=aaz.__name__, - args=args - ) + # try: + # from . import aaz + # except ImportError: + # aaz = None + # if aaz: + # load_aaz_command_table( + # loader=self, + # aaz_pkg_name=aaz.__name__, + # args=args + # ) load_command_table(self, args) return self.command_table From 8050315a45d611b7ed39097edd64b54ac9ed061e Mon Sep 17 00:00:00 2001 From: kairu Date: Wed, 5 Jul 2023 20:57:06 +0800 Subject: [PATCH 5/6] remove aaz commands --- .../aaz/latest/graph_services/__cmd_group.py | 25 -- .../aaz/latest/graph_services/__init__.py | 11 - .../graph_services/account/__cmd_group.py | 23 - .../latest/graph_services/account/__init__.py | 17 - .../latest/graph_services/account/_create.py | 287 ------------ .../latest/graph_services/account/_delete.py | 140 ------ .../latest/graph_services/account/_list.py | 352 --------------- .../latest/graph_services/account/_show.py | 214 --------- .../latest/graph_services/account/_update.py | 419 ------------------ .../latest/graph_services/account/_wait.py | 210 --------- 10 files changed, 1698 deletions(-) delete mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__cmd_group.py delete mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__init__.py delete mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__cmd_group.py delete mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__init__.py delete mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_create.py delete mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_delete.py delete mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_list.py delete mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_show.py delete mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_update.py delete mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_wait.py diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__cmd_group.py deleted file mode 100644 index 4fdc79685fe..00000000000 --- a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__cmd_group.py +++ /dev/null @@ -1,25 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# 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_group( - "graph-services", -) -class __CMDGroup(AAZCommandGroup): - """Make operations on Microsoft.GraphServices resource types - - This module enables you to use the Azure CLI to manage Microsoft.GraphServices/Accounts resources in Azure, which is the resource that contains the billing configuration of the Graph app associated with it. - """ - pass - - -__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__init__.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__init__.py deleted file mode 100644 index 5a9d61963d6..00000000000 --- a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# 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 .__cmd_group import * diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__cmd_group.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__cmd_group.py deleted file mode 100644 index 2f575c09afc..00000000000 --- a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__cmd_group.py +++ /dev/null @@ -1,23 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# 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_group( - "graph-services account", -) -class __CMDGroup(AAZCommandGroup): - """Make operations on Microsoft.GraphServices/Accounts - """ - pass - - -__all__ = ["__CMDGroup"] diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__init__.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__init__.py deleted file mode 100644 index db73033039b..00000000000 --- a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# 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 .__cmd_group import * -from ._create import * -from ._delete import * -from ._list import * -from ._show import * -from ._update import * -from ._wait import * diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_create.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_create.py deleted file mode 100644 index 8d4ab739e43..00000000000 --- a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_create.py +++ /dev/null @@ -1,287 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# 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( - "graph-services account create", -) -class Create(AAZCommand): - """Create account resource. - - :example: Create Account - az graph-services account create --resource-group myRG --resource-name myGraphAppBilling --subscription mySubscriptionGUID --location global --tags "foo=bar" "baz=qux" --app-id myAppGUID - """ - - _aaz_info = { - "version": "2023-04-13", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.graphservices/accounts/{}", "2023-04-13"], - ] - } - - AZ_SUPPORT_NO_WAIT = True - - def _handler(self, command_args): - super()._handler(command_args) - return self.build_lro_poller(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( - help="Name of an Azure resource group in your subscription", - required=True, - ) - _args_schema.resource_name = AAZStrArg( - options=["-n", "--name", "--resource-name"], - help="The name of the resource.", - required=True, - ) - - # define Arg Group "AccountResource" - - _args_schema = cls._args_schema - _args_schema.location = AAZResourceLocationArg( - arg_group="AccountResource", - help="Location of the resource.", - default="global", - fmt=AAZResourceLocationArgFormat( - resource_group_arg="resource_group", - ), - ) - _args_schema.tags = AAZDictArg( - options=["--tags"], - arg_group="AccountResource", - help="Resource tags", - ) - - tags = cls._args_schema.tags - tags.Element = AAZStrArg() - - # define Arg Group "Properties" - - _args_schema = cls._args_schema - _args_schema.app_id = AAZStrArg( - options=["--app-id"], - arg_group="Properties", - help="Customer owned application ID", - required=True, - fmt=AAZStrArgFormat( - pattern="(^[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}?)$", - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - yield self.AccountsCreateAndUpdate(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) - return result - - class AccountsCreateAndUpdate(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 [202]: - return self.client.build_lro_polling( - self.ctx.args.no_wait, - session, - self.on_200_201, - self.on_error, - lro_options={"final-state-via": "azure-async-operation"}, - path_format_arguments=self.url_parameters, - ) - if session.http_response.status_code in [200, 201]: - return self.client.build_lro_polling( - self.ctx.args.no_wait, - session, - self.on_200_201, - self.on_error, - lro_options={"final-state-via": "azure-async-operation"}, - path_format_arguments=self.url_parameters, - ) - - return self.on_error(session.http_response) - - @property - def url(self): - return self.client.format_url( - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices/accounts/{resourceName}", - **self.url_parameters - ) - - @property - def method(self): - return "PUT" - - @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( - "resourceName", self.ctx.args.resource_name, - 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", "2023-04-13", - required=True, - ), - } - return parameters - - @property - def header_parameters(self): - parameters = { - **self.serialize_header_param( - "Content-Type", "application/json", - ), - **self.serialize_header_param( - "Accept", "application/json", - ), - } - return parameters - - @property - def content(self): - _content_value, _builder = self.new_content_builder( - self.ctx.args, - typ=AAZObjectType, - typ_kwargs={"flags": {"required": True, "client_flatten": True}} - ) - _builder.set_prop("location", AAZStrType, ".location") - _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True}}) - _builder.set_prop("tags", AAZDictType, ".tags") - - properties = _builder.get(".properties") - if properties is not None: - properties.set_prop("appId", AAZStrType, ".app_id", typ_kwargs={"flags": {"required": True}}) - - tags = _builder.get(".tags") - if tags is not None: - tags.set_elements(AAZStrType, ".") - - return self.serialize_content(_content_value) - - def on_200_201(self, session): - data = self.deserialize_http_content(session) - self.ctx.set_var( - "instance", - data, - schema_builder=self._build_schema_on_200_201 - ) - - _schema_on_200_201 = None - - @classmethod - def _build_schema_on_200_201(cls): - if cls._schema_on_200_201 is not None: - return cls._schema_on_200_201 - - cls._schema_on_200_201 = AAZObjectType() - - _schema_on_200_201 = cls._schema_on_200_201 - _schema_on_200_201.id = AAZStrType( - flags={"read_only": True}, - ) - _schema_on_200_201.location = AAZStrType() - _schema_on_200_201.name = AAZStrType( - flags={"read_only": True}, - ) - _schema_on_200_201.properties = AAZObjectType( - flags={"required": True}, - ) - _schema_on_200_201.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - _schema_on_200_201.tags = AAZDictType() - _schema_on_200_201.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = cls._schema_on_200_201.properties - properties.app_id = AAZStrType( - serialized_name="appId", - flags={"required": True}, - ) - properties.billing_plan_id = AAZStrType( - serialized_name="billingPlanId", - flags={"read_only": True}, - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - - system_data = cls._schema_on_200_201.system_data - system_data.created_at = AAZStrType( - serialized_name="createdAt", - ) - system_data.created_by_type = AAZStrType( - serialized_name="createdByType", - ) - system_data.last_modified_at = AAZStrType( - serialized_name="lastModifiedAt", - ) - system_data.last_modified_by_type = AAZStrType( - serialized_name="lastModifiedByType", - ) - - tags = cls._schema_on_200_201.tags - tags.Element = AAZStrType() - - return cls._schema_on_200_201 - - -class _CreateHelper: - """Helper class for Create""" - - -__all__ = ["Create"] diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_delete.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_delete.py deleted file mode 100644 index 8bc6feca7be..00000000000 --- a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_delete.py +++ /dev/null @@ -1,140 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# 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( - "graph-services account delete", - confirmation="Are you sure you want to perform this operation?", -) -class Delete(AAZCommand): - """Delete a account resource. - - :example: Delete account - az graph-services account delete --subscription mySubscriptionGUID --resource-group myRG --resource-name myGraphAppBilling - """ - - _aaz_info = { - "version": "2023-04-13", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.graphservices/accounts/{}", "2023-04-13"], - ] - } - - def _handler(self, command_args): - super()._handler(command_args) - self._execute_operations() - return None - - _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( - help="Name of an Azure resource group in your subscription", - required=True, - ) - _args_schema.resource_name = AAZStrArg( - options=["-n", "--name", "--resource-name"], - help="The name of the resource.", - required=True, - id_part="name", - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.AccountsDelete(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - class AccountsDelete(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) - if session.http_response.status_code in [204]: - return self.on_204(session) - - return self.on_error(session.http_response) - - @property - def url(self): - return self.client.format_url( - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices/accounts/{resourceName}", - **self.url_parameters - ) - - @property - def method(self): - return "DELETE" - - @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( - "resourceName", self.ctx.args.resource_name, - 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", "2023-04-13", - required=True, - ), - } - return parameters - - def on_200(self, session): - pass - - def on_204(self, session): - pass - - -class _DeleteHelper: - """Helper class for Delete""" - - -__all__ = ["Delete"] diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_list.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_list.py deleted file mode 100644 index 7e3dc16bc9c..00000000000 --- a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_list.py +++ /dev/null @@ -1,352 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# 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( - "graph-services account list", -) -class List(AAZCommand): - """List list of accounts belonging to a subscription. - - :example: List resources in subscription - az graph-services account list --subscription mySubscriptionGUID --resource-group myRg - """ - - _aaz_info = { - "version": "2023-04-13", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/providers/microsoft.graphservices/accounts", "2023-04-13"], - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.graphservices/accounts", "2023-04-13"], - ] - } - - 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( - help="Name of an Azure resource group in your subscription", - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - condition_0 = has_value(self.ctx.args.resource_group) and has_value(self.ctx.subscription_id) - condition_1 = has_value(self.ctx.subscription_id) and has_value(self.ctx.args.resource_group) is not True - if condition_0: - self.AccountsListByResourceGroup(ctx=self.ctx)() - if condition_1: - self.AccountsListBySubscription(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 AccountsListByResourceGroup(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.GraphServices/accounts", - **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, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2023-04-13", - 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() - - value = cls._schema_on_200.value - value.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element - _element.id = AAZStrType( - flags={"read_only": True}, - ) - _element.location = AAZStrType() - _element.name = AAZStrType( - flags={"read_only": True}, - ) - _element.properties = AAZObjectType( - flags={"required": True}, - ) - _element.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - _element.tags = AAZDictType() - _element.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = cls._schema_on_200.value.Element.properties - properties.app_id = AAZStrType( - serialized_name="appId", - flags={"required": True}, - ) - properties.billing_plan_id = AAZStrType( - serialized_name="billingPlanId", - flags={"read_only": True}, - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - - system_data = cls._schema_on_200.value.Element.system_data - system_data.created_at = AAZStrType( - serialized_name="createdAt", - ) - system_data.created_by_type = AAZStrType( - serialized_name="createdByType", - ) - system_data.last_modified_at = AAZStrType( - serialized_name="lastModifiedAt", - ) - system_data.last_modified_by_type = AAZStrType( - serialized_name="lastModifiedByType", - ) - - tags = cls._schema_on_200.value.Element.tags - tags.Element = AAZStrType() - - return cls._schema_on_200 - - class AccountsListBySubscription(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}/providers/Microsoft.GraphServices/accounts", - **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( - "subscriptionId", self.ctx.subscription_id, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2023-04-13", - 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() - - value = cls._schema_on_200.value - value.Element = AAZObjectType() - - _element = cls._schema_on_200.value.Element - _element.id = AAZStrType( - flags={"read_only": True}, - ) - _element.location = AAZStrType() - _element.name = AAZStrType( - flags={"read_only": True}, - ) - _element.properties = AAZObjectType( - flags={"required": True}, - ) - _element.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - _element.tags = AAZDictType() - _element.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = cls._schema_on_200.value.Element.properties - properties.app_id = AAZStrType( - serialized_name="appId", - flags={"required": True}, - ) - properties.billing_plan_id = AAZStrType( - serialized_name="billingPlanId", - flags={"read_only": True}, - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - - system_data = cls._schema_on_200.value.Element.system_data - system_data.created_at = AAZStrType( - serialized_name="createdAt", - ) - system_data.created_by_type = AAZStrType( - serialized_name="createdByType", - ) - system_data.last_modified_at = AAZStrType( - serialized_name="lastModifiedAt", - ) - system_data.last_modified_by_type = AAZStrType( - serialized_name="lastModifiedByType", - ) - - tags = cls._schema_on_200.value.Element.tags - tags.Element = AAZStrType() - - return cls._schema_on_200 - - -class _ListHelper: - """Helper class for List""" - - -__all__ = ["List"] diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_show.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_show.py deleted file mode 100644 index 50c05e7e93c..00000000000 --- a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_show.py +++ /dev/null @@ -1,214 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# 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( - "graph-services account show", -) -class Show(AAZCommand): - """Get account resource for a given name. - - :example: Get account - az --subscription mySubscriptionGUID --resource-group myRG --resource-name myGraphAppBilling - """ - - _aaz_info = { - "version": "2023-04-13", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.graphservices/accounts/{}", "2023-04-13"], - ] - } - - 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.resource_group = AAZResourceGroupNameArg( - help="Name of an Azure resource group in your subscription", - required=True, - ) - _args_schema.resource_name = AAZStrArg( - options=["-n", "--name", "--resource-name"], - help="The name of the resource.", - required=True, - id_part="name", - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.AccountsGet(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) - return result - - class AccountsGet(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.GraphServices/accounts/{resourceName}", - **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( - "resourceName", self.ctx.args.resource_name, - 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", "2023-04-13", - 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.location = AAZStrType() - _schema_on_200.name = AAZStrType( - flags={"read_only": True}, - ) - _schema_on_200.properties = AAZObjectType( - flags={"required": True}, - ) - _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}, - ) - - properties = cls._schema_on_200.properties - properties.app_id = AAZStrType( - serialized_name="appId", - flags={"required": True}, - ) - properties.billing_plan_id = AAZStrType( - serialized_name="billingPlanId", - flags={"read_only": True}, - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - - system_data = cls._schema_on_200.system_data - system_data.created_at = AAZStrType( - serialized_name="createdAt", - ) - system_data.created_by_type = AAZStrType( - serialized_name="createdByType", - ) - system_data.last_modified_at = AAZStrType( - serialized_name="lastModifiedAt", - ) - 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""" - - -__all__ = ["Show"] diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_update.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_update.py deleted file mode 100644 index 49273e4c7ec..00000000000 --- a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_update.py +++ /dev/null @@ -1,419 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# 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( - "graph-services account update", -) -class Update(AAZCommand): - """Update account resource. - - The only supported updated on a resource is the tags property - - :example: Update account - az graph-services account update --resource-group myRG --resource-name myGraphAppBilling --subscription mySubscriptionGUID --location global --tags "foo1=bar1" "baz1=qux1" - """ - - _aaz_info = { - "version": "2023-04-13", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.graphservices/accounts/{}", "2023-04-13"], - ] - } - - AZ_SUPPORT_NO_WAIT = True - - AZ_SUPPORT_GENERIC_UPDATE = True - - def _handler(self, command_args): - super()._handler(command_args) - return self.build_lro_poller(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( - help="Name of an Azure resource group in your subscription", - required=True, - ) - _args_schema.resource_name = AAZStrArg( - options=["-n", "--name", "--resource-name"], - help="The name of the resource.", - required=True, - id_part="name", - ) - - # define Arg Group "AccountResource" - - _args_schema = cls._args_schema - _args_schema.location = AAZResourceLocationArg( - arg_group="AccountResource", - help="Location of the resource.", - nullable=True, - fmt=AAZResourceLocationArgFormat( - resource_group_arg="resource_group", - ), - ) - _args_schema.tags = AAZDictArg( - options=["--tags"], - arg_group="AccountResource", - help="Resource tags", - nullable=True, - ) - - tags = cls._args_schema.tags - tags.Element = AAZStrArg( - nullable=True, - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.AccountsGet(ctx=self.ctx)() - self.pre_instance_update(self.ctx.vars.instance) - self.InstanceUpdateByJson(ctx=self.ctx)() - self.InstanceUpdateByGeneric(ctx=self.ctx)() - self.post_instance_update(self.ctx.vars.instance) - yield self.AccountsCreateAndUpdate(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - @register_callback - def pre_instance_update(self, instance): - pass - - @register_callback - def post_instance_update(self, instance): - pass - - def _output(self, *args, **kwargs): - result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) - return result - - class AccountsGet(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.GraphServices/accounts/{resourceName}", - **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( - "resourceName", self.ctx.args.resource_name, - 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", "2023-04-13", - 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() - _UpdateHelper._build_schema_account_resource_read(cls._schema_on_200) - - return cls._schema_on_200 - - class AccountsCreateAndUpdate(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 [202]: - return self.client.build_lro_polling( - self.ctx.args.no_wait, - session, - self.on_200_201, - self.on_error, - lro_options={"final-state-via": "azure-async-operation"}, - path_format_arguments=self.url_parameters, - ) - if session.http_response.status_code in [200, 201]: - return self.client.build_lro_polling( - self.ctx.args.no_wait, - session, - self.on_200_201, - self.on_error, - lro_options={"final-state-via": "azure-async-operation"}, - path_format_arguments=self.url_parameters, - ) - - return self.on_error(session.http_response) - - @property - def url(self): - return self.client.format_url( - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.GraphServices/accounts/{resourceName}", - **self.url_parameters - ) - - @property - def method(self): - return "PUT" - - @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( - "resourceName", self.ctx.args.resource_name, - 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", "2023-04-13", - required=True, - ), - } - return parameters - - @property - def header_parameters(self): - parameters = { - **self.serialize_header_param( - "Content-Type", "application/json", - ), - **self.serialize_header_param( - "Accept", "application/json", - ), - } - return parameters - - @property - def content(self): - _content_value, _builder = self.new_content_builder( - self.ctx.args, - value=self.ctx.vars.instance, - ) - - return self.serialize_content(_content_value) - - def on_200_201(self, session): - data = self.deserialize_http_content(session) - self.ctx.set_var( - "instance", - data, - schema_builder=self._build_schema_on_200_201 - ) - - _schema_on_200_201 = None - - @classmethod - def _build_schema_on_200_201(cls): - if cls._schema_on_200_201 is not None: - return cls._schema_on_200_201 - - cls._schema_on_200_201 = AAZObjectType() - _UpdateHelper._build_schema_account_resource_read(cls._schema_on_200_201) - - return cls._schema_on_200_201 - - class InstanceUpdateByJson(AAZJsonInstanceUpdateOperation): - - def __call__(self, *args, **kwargs): - self._update_instance(self.ctx.vars.instance) - - def _update_instance(self, instance): - _instance_value, _builder = self.new_content_builder( - self.ctx.args, - value=instance, - typ=AAZObjectType - ) - _builder.set_prop("location", AAZStrType, ".location") - _builder.set_prop("tags", AAZDictType, ".tags") - - tags = _builder.get(".tags") - if tags is not None: - tags.set_elements(AAZStrType, ".") - - return _instance_value - - class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): - - def __call__(self, *args, **kwargs): - self._update_instance_by_generic( - self.ctx.vars.instance, - self.ctx.generic_update_args - ) - - -class _UpdateHelper: - """Helper class for Update""" - - _schema_account_resource_read = None - - @classmethod - def _build_schema_account_resource_read(cls, _schema): - if cls._schema_account_resource_read is not None: - _schema.id = cls._schema_account_resource_read.id - _schema.location = cls._schema_account_resource_read.location - _schema.name = cls._schema_account_resource_read.name - _schema.properties = cls._schema_account_resource_read.properties - _schema.system_data = cls._schema_account_resource_read.system_data - _schema.tags = cls._schema_account_resource_read.tags - _schema.type = cls._schema_account_resource_read.type - return - - cls._schema_account_resource_read = _schema_account_resource_read = AAZObjectType() - - account_resource_read = _schema_account_resource_read - account_resource_read.id = AAZStrType( - flags={"read_only": True}, - ) - account_resource_read.location = AAZStrType() - account_resource_read.name = AAZStrType( - flags={"read_only": True}, - ) - account_resource_read.properties = AAZObjectType( - flags={"required": True}, - ) - account_resource_read.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - account_resource_read.tags = AAZDictType() - account_resource_read.type = AAZStrType( - flags={"read_only": True}, - ) - - properties = _schema_account_resource_read.properties - properties.app_id = AAZStrType( - serialized_name="appId", - flags={"required": True}, - ) - properties.billing_plan_id = AAZStrType( - serialized_name="billingPlanId", - flags={"read_only": True}, - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - - system_data = _schema_account_resource_read.system_data - system_data.created_at = AAZStrType( - serialized_name="createdAt", - ) - system_data.created_by_type = AAZStrType( - serialized_name="createdByType", - ) - system_data.last_modified_at = AAZStrType( - serialized_name="lastModifiedAt", - ) - system_data.last_modified_by_type = AAZStrType( - serialized_name="lastModifiedByType", - ) - - tags = _schema_account_resource_read.tags - tags.Element = AAZStrType() - - _schema.id = cls._schema_account_resource_read.id - _schema.location = cls._schema_account_resource_read.location - _schema.name = cls._schema_account_resource_read.name - _schema.properties = cls._schema_account_resource_read.properties - _schema.system_data = cls._schema_account_resource_read.system_data - _schema.tags = cls._schema_account_resource_read.tags - _schema.type = cls._schema_account_resource_read.type - - -__all__ = ["Update"] diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_wait.py b/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_wait.py deleted file mode 100644 index 35cfae092bc..00000000000 --- a/src/azure-cli/azure/cli/command_modules/graphservices/aaz/latest/graph_services/account/_wait.py +++ /dev/null @@ -1,210 +0,0 @@ -# -------------------------------------------------------------------------------------------- -# 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( - "graph-services account wait", -) -class Wait(AAZWaitCommand): - """Place the CLI in a waiting state until a condition is met. - """ - - _aaz_info = { - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.graphservices/accounts/{}", "2023-04-13"], - ] - } - - 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.resource_group = AAZResourceGroupNameArg( - help="Name of an Azure resource group in your subscription", - required=True, - ) - _args_schema.resource_name = AAZStrArg( - options=["-n", "--name", "--resource-name"], - help="The name of the resource.", - required=True, - id_part="name", - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.AccountsGet(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=False) - return result - - class AccountsGet(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.GraphServices/accounts/{resourceName}", - **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( - "resourceName", self.ctx.args.resource_name, - 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", "2023-04-13", - 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.location = AAZStrType() - _schema_on_200.name = AAZStrType( - flags={"read_only": True}, - ) - _schema_on_200.properties = AAZObjectType( - flags={"required": True}, - ) - _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}, - ) - - properties = cls._schema_on_200.properties - properties.app_id = AAZStrType( - serialized_name="appId", - flags={"required": True}, - ) - properties.billing_plan_id = AAZStrType( - serialized_name="billingPlanId", - flags={"read_only": True}, - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) - - system_data = cls._schema_on_200.system_data - system_data.created_at = AAZStrType( - serialized_name="createdAt", - ) - system_data.created_by_type = AAZStrType( - serialized_name="createdByType", - ) - system_data.last_modified_at = AAZStrType( - serialized_name="lastModifiedAt", - ) - 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 _WaitHelper: - """Helper class for Wait""" - - -__all__ = ["Wait"] From 22753acede10cad6c71c01717d3788eac504f228 Mon Sep 17 00:00:00 2001 From: kairu Date: Wed, 5 Jul 2023 21:42:11 +0800 Subject: [PATCH 6/6] remove recording file --- .../latest/recordings/test_billing_flow.yaml | 334 ------------------ 1 file changed, 334 deletions(-) delete mode 100644 src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/recordings/test_billing_flow.yaml diff --git a/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/recordings/test_billing_flow.yaml b/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/recordings/test_billing_flow.yaml deleted file mode 100644 index ab7febfdb70..00000000000 --- a/src/azure-cli/azure/cli/command_modules/graphservices/tests/latest/recordings/test_billing_flow.yaml +++ /dev/null @@ -1,334 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - CommandName: - - ad app create - Connection: - - keep-alive - ParameterSetName: - - --display-name - User-Agent: - - python/3.10.0 (Windows-10-10.0.22621-SP0) AZURECLI/2.49.0 - method: GET - uri: https://graph.microsoft.com/v1.0/applications?$filter=startswith%28displayName%2C%27azcliapp000003%27%29 - response: - body: - string: '{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#applications","value":[]}' - headers: - cache-control: - - no-cache - content-length: - - '87' - content-type: - - application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8 - date: - - Thu, 29 Jun 2023 08:02:02 GMT - odata-version: - - '4.0' - request-id: - - 375ebdb0-6e31-4ee4-aadf-e11cb54559b7 - strict-transport-security: - - max-age=31536000 - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-ms-ags-diagnostic: - - '{"ServerInfo":{"DataCenter":"South Central US","Slice":"E","Ring":"5","ScaleUnit":"002","RoleInstance":"SN1PEPF00020FE4"}}' - x-ms-resource-unit: - - '2' - status: - code: 200 - message: OK -- request: - body: '{"displayName": "azcliapp000003", "keyCredentials": []}' - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - CommandName: - - ad app create - Connection: - - keep-alive - Content-Length: - - '55' - Content-Type: - - application/json - ParameterSetName: - - --display-name - User-Agent: - - python/3.10.0 (Windows-10-10.0.22621-SP0) AZURECLI/2.49.0 - method: POST - uri: https://graph.microsoft.com/v1.0/applications - response: - body: - string: '{"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#applications/$entity", - "id": "7e4c7904-7542-4acf-9b34-a1d3e0f484c1", "deletedDateTime": null, "appId": - "0536fb07-8182-4d18-bfb3-b3248e88d630", "applicationTemplateId": null, "disabledByMicrosoftStatus": - null, "createdDateTime": "2023-06-29T08:02:03.9106084Z", "displayName": "azcliapp000003", - "description": null, "groupMembershipClaims": null, "identifierUris": [], - "isDeviceOnlyAuthSupported": null, "isFallbackPublicClient": null, "notes": - null, "publisherDomain": "growthandmonetization.onmicrosoft.com", "serviceManagementReference": - null, "signInAudience": "AzureADandPersonalMicrosoftAccount", "tags": [], - "tokenEncryptionKeyId": null, "samlMetadataUrl": null, "defaultRedirectUri": - null, "certification": null, "optionalClaims": null, "servicePrincipalLockConfiguration": - null, "requestSignatureVerification": null, "addIns": [], "api": {"acceptMappedClaims": - null, "knownClientApplications": [], "requestedAccessTokenVersion": 2, "oauth2PermissionScopes": - [], "preAuthorizedApplications": []}, "appRoles": [], "info": {"logoUrl": - null, "marketingUrl": null, "privacyStatementUrl": null, "supportUrl": null, - "termsOfServiceUrl": null}, "keyCredentials": [], "parentalControlSettings": - {"countriesBlockedForMinors": [], "legalAgeGroupRule": "Allow"}, "passwordCredentials": - [], "publicClient": {"redirectUris": []}, "requiredResourceAccess": [], "verifiedPublisher": - {"displayName": null, "verifiedPublisherId": null, "addedDateTime": null}, - "web": {"homePageUrl": null, "logoutUrl": null, "redirectUris": [], "implicitGrantSettings": - {"enableAccessTokenIssuance": false, "enableIdTokenIssuance": false}, "redirectUriSettings": - []}, "spa": {"redirectUris": []}}' - headers: - cache-control: - - no-cache - content-length: - - '1731' - content-type: - - application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8 - date: - - Thu, 29 Jun 2023 08:02:15 GMT - location: - - https://graph.microsoft.com/v2/67419183-f612-47fe-9b45-48fa5b880dc6/directoryObjects/7e4c7904-7542-4acf-9b34-a1d3e0f484c1/Microsoft.DirectoryServices.Application - odata-version: - - '4.0' - request-id: - - 5f0aef50-83f7-4a7e-9e91-47c09f887d62 - strict-transport-security: - - max-age=31536000 - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-ms-ags-diagnostic: - - '{"ServerInfo":{"DataCenter":"South Central US","Slice":"E","Ring":"5","ScaleUnit":"002","RoleInstance":"SN1PEPF00006482"}}' - x-ms-resource-unit: - - '1' - status: - code: 201 - message: Created -- request: - body: '{"location": "global", "properties": {"appId": "0536fb07-8182-4d18-bfb3-b3248e88d630"}, - "tags": {"key1": "value1"}}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - graph-services account create - Connection: - - keep-alive - Content-Length: - - '115' - Content-Type: - - application/json - ParameterSetName: - - --resource-group --name --app-id --tags - User-Agent: - - AZURECLI/2.49.0 (AAZ) azsdk-python-core/1.26.0 Python/3.10.0 (Windows-10-10.0.22621-SP0) - method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002?api-version=2023-04-13 - response: - body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002","name":"azcliacc000002","type":"microsoft.graphservices/accounts","location":"global","tags":{"key1":"value1"},"systemData":{"createdByType":"User","createdAt":"2023-06-29T08:04:16.9596398Z","lastModifiedByType":"User","lastModifiedAt":"2023-06-29T08:04:16.9596398Z"},"properties":{"appId":"0536fb07-8182-4d18-bfb3-b3248e88d630","billingPlanId":"50df83c8-736a-4601-8865-b768dcfc5bad","provisioningState":"Succeeded"}}' - headers: - cache-control: - - no-cache - content-length: - - '567' - content-type: - - application/json; charset=utf-8 - date: - - Thu, 29 Jun 2023 08:04:21 GMT - etag: - - '"00002bfa-0000-0500-0000-649d3b040000"' - expires: - - '-1' - mise-correlation-id: - - 49d5509d-2831-4c01-b4f6-e7634d7148c7 - ms-cv: - - tQHNN9KzHkKId4sLgyaFfg.0 - pragma: - - no-cache - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-content-type-options: - - nosniff - x-ms-providerhub-traffic: - - 'True' - x-ms-ratelimit-remaining-subscription-writes: - - '1199' - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - graph-services account show - Connection: - - keep-alive - ParameterSetName: - - --resource-group --name - User-Agent: - - AZURECLI/2.49.0 (AAZ) azsdk-python-core/1.26.0 Python/3.10.0 (Windows-10-10.0.22621-SP0) - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002?api-version=2023-04-13 - response: - body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002","name":"azcliacc000002","type":"microsoft.graphservices/accounts","location":"global","tags":{"key1":"value1"},"systemData":{"createdByType":"User","createdAt":"2023-06-29T08:04:16.9596398Z","lastModifiedByType":"User","lastModifiedAt":"2023-06-29T08:04:16.9596398Z"},"properties":{"appId":"0536fb07-8182-4d18-bfb3-b3248e88d630","billingPlanId":"50df83c8-736a-4601-8865-b768dcfc5bad","provisioningState":"Succeeded"}}' - headers: - cache-control: - - no-cache - content-length: - - '567' - content-type: - - application/json; charset=utf-8 - date: - - Thu, 29 Jun 2023 08:04:22 GMT - etag: - - '"00002bfa-0000-0500-0000-649d3b040000"' - expires: - - '-1' - pragma: - - no-cache - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-content-type-options: - - nosniff - x-ms-providerhub-traffic: - - 'True' - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - graph-services account update - Connection: - - keep-alive - ParameterSetName: - - --resource-group --name --tags --location - User-Agent: - - AZURECLI/2.49.0 (AAZ) azsdk-python-core/1.26.0 Python/3.10.0 (Windows-10-10.0.22621-SP0) - method: GET - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002?api-version=2023-04-13 - response: - body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002","name":"azcliacc000002","type":"microsoft.graphservices/accounts","location":"global","tags":{"key1":"value1"},"systemData":{"createdByType":"User","createdAt":"2023-06-29T08:04:16.9596398Z","lastModifiedByType":"User","lastModifiedAt":"2023-06-29T08:04:16.9596398Z"},"properties":{"appId":"0536fb07-8182-4d18-bfb3-b3248e88d630","billingPlanId":"50df83c8-736a-4601-8865-b768dcfc5bad","provisioningState":"Succeeded"}}' - headers: - cache-control: - - no-cache - content-length: - - '567' - content-type: - - application/json; charset=utf-8 - date: - - Thu, 29 Jun 2023 08:04:22 GMT - etag: - - '"00002bfa-0000-0500-0000-649d3b040000"' - expires: - - '-1' - pragma: - - no-cache - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-content-type-options: - - nosniff - x-ms-providerhub-traffic: - - 'True' - status: - code: 200 - message: OK -- request: - body: '{"location": "global", "properties": {"appId": "0536fb07-8182-4d18-bfb3-b3248e88d630"}, - "tags": {"key1": "value1", "updatedKey1": "updatedValue1"}}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - CommandName: - - graph-services account update - Connection: - - keep-alive - Content-Length: - - '147' - Content-Type: - - application/json - ParameterSetName: - - --resource-group --name --tags --location - User-Agent: - - AZURECLI/2.49.0 (AAZ) azsdk-python-core/1.26.0 Python/3.10.0 (Windows-10-10.0.22621-SP0) - method: PUT - uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002?api-version=2023-04-13 - response: - body: - string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.GraphServices/accounts/azcliacc000002","name":"azcliacc000002","type":"microsoft.graphservices/accounts","location":"global","tags":{"key1":"value1","updatedKey1":"updatedValue1"},"systemData":{"createdByType":"User","createdAt":"2023-06-29T08:04:16.9596398Z","lastModifiedByType":"User","lastModifiedAt":"2023-06-29T08:04:22.951096Z"},"properties":{"appId":"0536fb07-8182-4d18-bfb3-b3248e88d630","billingPlanId":"50df83c8-736a-4601-8865-b768dcfc5bad","provisioningState":"Succeeded"}}' - headers: - cache-control: - - no-cache - content-length: - - '596' - content-type: - - application/json; charset=utf-8 - date: - - Thu, 29 Jun 2023 08:04:29 GMT - etag: - - '"000031fa-0000-0500-0000-649d3b0a0000"' - expires: - - '-1' - mise-correlation-id: - - f34a2cab-5578-4b31-8abd-11066a1f70a4 - ms-cv: - - eQz2/MDQiUKlLRhFTYCgNw.0 - pragma: - - no-cache - strict-transport-security: - - max-age=31536000; includeSubDomains - transfer-encoding: - - chunked - vary: - - Accept-Encoding - x-content-type-options: - - nosniff - x-ms-providerhub-traffic: - - 'True' - x-ms-ratelimit-remaining-subscription-writes: - - '1199' - status: - code: 200 - message: OK -version: 1