diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5499e33aab6..4e5d46e877e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -14,7 +14,7 @@ /src/subscription/ @wilcobmsft -/src/apic-extension/ @arpishahmsft +/src/apic-extension/ @arpishahmsft @blackchoey @adashen /src/alias/ @Juliehzl diff --git a/src/apic-extension/HISTORY.rst b/src/apic-extension/HISTORY.rst index f66b3701476..d3ef2257d02 100644 --- a/src/apic-extension/HISTORY.rst +++ b/src/apic-extension/HISTORY.rst @@ -5,7 +5,14 @@ Release History 1.0.0b5 +++++ -* Remove: All portal commands as it should not be exposed to customers. +* Add: Support yaml file for `az apic api register` command. +* Update: Command names, parameter names, and command descriptions for better understanding. Please leverage `-h` option or refer Azure CLI reference doc to see full list of commands and parameters. +* Update: Introduction to parameter constraints to ensure that valid values are provided. +* Update: Minimum Azure CLI version requirement is updated to 2.57. +* Fix: Various bug fixes for lastest preview version. +* Remove: Portal commands as we don't support this capability any longer. +* Remove: `--workspace-name` and `--terms-of-service` parameters are removed as they are not expected to be exposed. +* Remove: `head` commands in each command group are removed. 1.0.0b4 +++++ diff --git a/src/apic-extension/README.md b/src/apic-extension/README.md index a3c17e2279e..0a50541b50c 100644 --- a/src/apic-extension/README.md +++ b/src/apic-extension/README.md @@ -35,11 +35,6 @@ az apic service delete --resource-group api-center-test --service-name contosoeu az apic service delete --resource-group arpi-test-rg1 -s apictestcli3 ``` -Show Workspace Example -``` -Az apic workspace show -g api-center-test -s contosoeuap --name devdiv -``` - Create API Examples ``` az apic api create -g api-center-test -s contosoeuap --name echo-api --title "Echo API" --kind "rest" @@ -50,10 +45,10 @@ az apic api create --resource-group api-center-test --service-name contosoeuap - Update API Examples ``` -az apic api update -g api-center-test -s contosoeuap --name echo-api --summary "Basic REST API service" -w default +az apic api update -g api-center-test -s contosoeuap --name echo-api --summary "Basic REST API service" ``` ``` -az apic api update --resource-group api-center-test -s contosoeuap --name echo-api --summary "Basic REST API service" --workspace-name default +az apic api update --resource-group api-center-test -s contosoeuap --name echo-api --summary "Basic REST API service" ``` LIST Api Example @@ -90,10 +85,10 @@ az apic api version create --resource-group api-center-test --service-name conto UPDATE Api Version Examples ``` -Az apic api version update -g api-center-test -s contosoeuap --api-name echo-api --name 2023-01-01 --title "2023-01-01" -w default +Az apic api version update -g api-center-test -s contosoeuap --api-name echo-api --name 2023-01-01 --title "2023-01-01" ``` ``` -az apic api version update --resource-group api-center-test --service-name contosoeuap --api-name echo-api --name 2023-01-01 --title "2023-01-01" --workspace-name default +az apic api version update --resource-group api-center-test --service-name contosoeuap --api-name echo-api --name 2023-01-01 --title "2023-01-01" ``` LIST Api Version Examples @@ -127,7 +122,7 @@ az apic api definition create -g api-center-test -s contosoeuap --api-name echo- UPDATE API Definition Example ``` -az apic api definition update -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 --name "openapi" --title "OpenAPI" -w default +az apic api definition update -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 --name "openapi" --title "OpenAPI" ``` SHOW API Definition Example @@ -209,7 +204,7 @@ Where envcreate1.json contains UPDATE Environment ``` -az apic environment update -g api-center-test -s contosoeuap --name public --title "Public cloud" -w default +az apic environment update -g api-center-test -s contosoeuap --name public --title "Public cloud" ``` LIST Environment @@ -283,4 +278,5 @@ az apic metadata-schema export-metadata-schema -g api-center-test -s contosoeuap Register API or Quick Add ``` az apic api register -g api-center-test -s contosoeuap --api-location "C:/Users/arpishah/examples/cli-examples/spec-examples/openai.json" --environment-name public +az apic api register -g api-center-test -s contosoeuap --api-location "C:/Users/arpishah/examples/cli-examples/spec-examples/openai.yml" --environment-name public ``` \ No newline at end of file diff --git a/src/apic-extension/azext_apic_extension/__init__.py b/src/apic-extension/azext_apic_extension/__init__.py index 487554e612a..1b79ceba8ec 100644 --- a/src/apic-extension/azext_apic_extension/__init__.py +++ b/src/apic-extension/azext_apic_extension/__init__.py @@ -4,8 +4,10 @@ # # Code generated by aaz-dev-tools # -------------------------------------------------------------------------------------------- +from typing import Type from azure.cli.core import AzCommandsLoader +from azure.cli.core.aaz import AAZCommand from azext_apic_extension._help import helps # pylint: disable=unused-import @@ -19,7 +21,7 @@ def __init__(self, cli_ctx=None): custom_command_type=custom_command_type) def load_command_table(self, args): - from azext_apic_extension.commands import load_command_table + from azext_apic_extension.commands import load_custom_commands from azure.cli.core.aaz import load_aaz_command_table try: from . import aaz @@ -31,7 +33,8 @@ def load_command_table(self, args): aaz_pkg_name=aaz.__name__, args=args ) - load_command_table(self, args) + load_command_patches(self) + load_custom_commands(self, args) return self.command_table def load_arguments(self, command): @@ -39,4 +42,19 @@ def load_arguments(self, command): load_arguments(self, command) +def is_aaz_command_subclass(value: Type) -> bool: + return isinstance(value, type) and issubclass(value, AAZCommand) + + +def load_command_patches(loader: AzCommandsLoader) -> None: + import inspect + from azext_apic_extension import command_patches + + for _, value in inspect.getmembers(command_patches): + # Only load custom commands from the command_patches module + if is_aaz_command_subclass(value) and value.__module__ == command_patches.__name__: + if value.AZ_NAME: + loader.command_table[value.AZ_NAME] = value(loader=loader) + + COMMAND_LOADER_CLS = ApicExtensionCommandsLoader diff --git a/src/apic-extension/azext_apic_extension/_help.py b/src/apic-extension/azext_apic_extension/_help.py index b6bd068b769..a738f149549 100644 --- a/src/apic-extension/azext_apic_extension/_help.py +++ b/src/apic-extension/azext_apic_extension/_help.py @@ -12,11 +12,11 @@ helps['apic api register'] = """ type: command - short-summary: Single Command for registering api, api version, api definition, import spec, create deployment provided a spec file. + short-summary: Registers a new API with version, definition, and associated deployments using the specification file as the source of truth. parameters: - name: --api-location -l type: string - short-summary: Location of spec file . + short-summary: Location of spec file. - name: --resource-group -g type: string short-summary: Resource group name. @@ -30,4 +30,5 @@ - name: Register api by providing spec file. text: | az apic api register -g api-center-test -s contosoeuap --api-location "examples/cli-examples/spec-examples/openai.json" --environment-name public + az apic api register -g api-center-test -s contosoeuap --api-location "examples/cli-examples/spec-examples/openai.yml" --environment-name public """ diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/__init__.py index a6ed8b6688f..c401f439385 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/__init__.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/__init__.py @@ -11,7 +11,6 @@ from .__cmd_group import * from ._create import * from ._delete import * -from ._head import * from ._list import * from ._show import * from ._update import * diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_create.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_create.py index 71e6bb7741a..e44d3bceed6 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_create.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_create.py @@ -15,10 +15,13 @@ "apic api create", ) class Create(AAZCommand): - """Create new or updates existing API. + """Register a new API or update an existing API. :example: Create API - az apic api create -g contoso-resources -s contoso --name echo-api --title "Echo API" + az apic api create -g contoso-resources -s contoso --api-id echo-api --title "Echo API" --type REST + + :example: Create API with custom properties + az apic api create -g contoso-resources -s contoso --api-id echo-api --title "Echo API" --type REST --custom-properties '{\"public-facing\":true}' """ _aaz_info = { @@ -44,11 +47,12 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--name", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -61,6 +65,7 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The name of the API Center service.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -71,6 +76,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -84,7 +90,7 @@ def _build_arguments_schema(cls, *args, **kwargs): arg_group="Properties", help="The contact information for the API.", ) - _args_schema.custom_properties = AAZObjectArg( + _args_schema.custom_properties = AAZFreeFormDictArg( options=["--custom-properties"], arg_group="Properties", help="The custom metadata defined for API catalog entities.", @@ -103,10 +109,11 @@ def _build_arguments_schema(cls, *args, **kwargs): arg_group="Properties", help="Additional, external documentation for the API.", ) - _args_schema.kind = AAZStrArg( - options=["--kind"], + _args_schema.type = AAZStrArg( + options=["--type"], arg_group="Properties", - help="Kind of API. For example, REST or GraphQL.", + help="Type of API.", + required=True, enum={"graphql": "graphql", "grpc": "grpc", "rest": "rest", "soap": "soap", "webhook": "webhook", "websocket": "websocket"}, ) _args_schema.license = AAZObjectArg( @@ -122,15 +129,11 @@ def _build_arguments_schema(cls, *args, **kwargs): max_length=200, ), ) - _args_schema.terms_of_service = AAZObjectArg( - options=["--terms-of-service"], - arg_group="Properties", - help="Terms of service for the API.", - ) _args_schema.title = AAZStrArg( options=["--title"], arg_group="Properties", help="API title.", + required=True, fmt=AAZStrArgFormat( max_length=50, min_length=1, @@ -212,16 +215,6 @@ def _build_arguments_schema(cls, *args, **kwargs): max_length=200, ), ) - - terms_of_service = cls._args_schema.terms_of_service - terms_of_service.url = AAZStrArg( - options=["url"], - help="URL pointing to the terms of service.", - required=True, - fmt=AAZStrArgFormat( - max_length=200, - ), - ) return cls._args_schema def _execute_operations(self): @@ -271,7 +264,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( @@ -322,18 +315,17 @@ def content(self): typ=AAZObjectType, typ_kwargs={"flags": {"required": True, "client_flatten": True}} ) - _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True, "client_flatten": True}}) properties = _builder.get(".properties") if properties is not None: properties.set_prop("contacts", AAZListType, ".contacts") - properties.set_prop("customProperties", AAZObjectType, ".custom_properties") + properties.set_prop("customProperties", AAZFreeFormDictType, ".custom_properties") properties.set_prop("description", AAZStrType, ".description") properties.set_prop("externalDocumentation", AAZListType, ".external_documentation") - properties.set_prop("kind", AAZStrType, ".kind", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("kind", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) properties.set_prop("license", AAZObjectType, ".license") properties.set_prop("summary", AAZStrType, ".summary") - properties.set_prop("termsOfService", AAZObjectType, ".terms_of_service") properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) contacts = _builder.get(".properties.contacts") @@ -346,6 +338,10 @@ def content(self): _elements.set_prop("name", AAZStrType, ".name") _elements.set_prop("url", AAZStrType, ".url") + custom_properties = _builder.get(".properties.customProperties") + if custom_properties is not None: + custom_properties.set_anytype_elements(".") + external_documentation = _builder.get(".properties.externalDocumentation") if external_documentation is not None: external_documentation.set_elements(AAZObjectType, ".") @@ -362,10 +358,6 @@ def content(self): license.set_prop("name", AAZStrType, ".name") license.set_prop("url", AAZStrType, ".url") - terms_of_service = _builder.get(".properties.termsOfService") - if terms_of_service is not None: - terms_of_service.set_prop("url", AAZStrType, ".url", typ_kwargs={"flags": {"required": True}}) - return self.serialize_content(_content_value) def on_200_201(self, session): @@ -393,7 +385,7 @@ def _build_schema_on_200_201(cls): flags={"read_only": True}, ) _schema_on_200_201.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) _schema_on_200_201.system_data = AAZObjectType( serialized_name="systemData", @@ -405,7 +397,7 @@ def _build_schema_on_200_201(cls): properties = cls._schema_on_200_201.properties properties.contacts = AAZListType() - properties.custom_properties = AAZObjectType( + properties.custom_properties = AAZFreeFormDictType( serialized_name="customProperties", ) properties.description = AAZStrType() @@ -418,6 +410,7 @@ def _build_schema_on_200_201(cls): properties.license = AAZObjectType() properties.lifecycle_stage = AAZStrType( serialized_name="lifecycleStage", + flags={"read_only": True}, ) properties.summary = AAZStrType() properties.terms_of_service = AAZObjectType( diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_delete.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_delete.py index 9ffe5f1ceac..6bbbb8897b7 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_delete.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_delete.py @@ -19,7 +19,7 @@ class Delete(AAZCommand): """Delete specified API. :example: Delete API - az apic api delete -g contoso-resources -s contoso --name echo-api + az apic api delete -g contoso-resources -s contoso --api-id echo-api """ _aaz_info = { @@ -45,12 +45,13 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--name", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -64,6 +65,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -75,6 +77,7 @@ def _build_arguments_schema(cls, *args, **kwargs): id_part="child_name_1", default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -126,7 +129,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_head.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_head.py deleted file mode 100644 index 2f5ea67d21a..00000000000 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_head.py +++ /dev/null @@ -1,163 +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( - "apic api head", -) -class Head(AAZCommand): - """Checks if specified API exists. - """ - - _aaz_info = { - "version": "2024-03-01", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}", "2024-03-01"], - ] - } - - 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.api_name = AAZStrArg( - options=["--api", "--name", "--api-name"], - help="The name of the API.", - required=True, - id_part="child_name_2", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - _args_schema.resource_group = AAZResourceGroupNameArg( - required=True, - ) - _args_schema.service_name = AAZStrArg( - options=["-s", "--service", "--service-name"], - help="The name of the API Center service.", - required=True, - id_part="name", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - _args_schema.workspace_name = AAZStrArg( - options=["-w", "--workspace", "--workspace-name"], - help="The name of the workspace.", - required=True, - id_part="child_name_1", - default="default", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.ApisHead(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - class ApisHead(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.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}", - **self.url_parameters - ) - - @property - def method(self): - return "HEAD" - - @property - def error_format(self): - return "MgmtErrorFormat" - - @property - def url_parameters(self): - parameters = { - **self.serialize_url_param( - "apiName", self.ctx.args.api_name, - required=True, - ), - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), - **self.serialize_url_param( - "serviceName", self.ctx.args.service_name, - required=True, - ), - **self.serialize_url_param( - "subscriptionId", self.ctx.subscription_id, - required=True, - ), - **self.serialize_url_param( - "workspaceName", self.ctx.args.workspace_name, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2024-03-01", - required=True, - ), - } - return parameters - - def on_200(self, session): - pass - - -class _HeadHelper: - """Helper class for Head""" - - -__all__ = ["Head"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_list.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_list.py index ad82509e6d5..78ad3818b04 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_list.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_list.py @@ -53,6 +53,7 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The name of the API Center service.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -63,6 +64,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -184,7 +186,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _schema_on_200.value = AAZListType( - flags={"read_only": True}, + flags={"required": True, "read_only": True}, ) value = cls._schema_on_200.value @@ -198,7 +200,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _element.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) _element.system_data = AAZObjectType( serialized_name="systemData", @@ -210,7 +212,7 @@ def _build_schema_on_200(cls): properties = cls._schema_on_200.value.Element.properties properties.contacts = AAZListType() - properties.custom_properties = AAZObjectType( + properties.custom_properties = AAZFreeFormDictType( serialized_name="customProperties", ) properties.description = AAZStrType() @@ -223,6 +225,7 @@ def _build_schema_on_200(cls): properties.license = AAZObjectType() properties.lifecycle_stage = AAZStrType( serialized_name="lifecycleStage", + flags={"read_only": True}, ) properties.summary = AAZStrType() properties.terms_of_service = AAZObjectType( diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_show.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_show.py index bfccf1bb126..b354d5307a0 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_show.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_show.py @@ -18,7 +18,7 @@ class Show(AAZCommand): """Get details of the API. :example: Show API details - az apic api show -g contoso-resources -s contoso --name echo-api + az apic api show -g contoso-resources -s contoso --api-id echo-api """ _aaz_info = { @@ -44,12 +44,13 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--name", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -63,6 +64,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -74,6 +76,7 @@ def _build_arguments_schema(cls, *args, **kwargs): id_part="child_name_1", default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -127,7 +130,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( @@ -193,7 +196,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _schema_on_200.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) _schema_on_200.system_data = AAZObjectType( serialized_name="systemData", @@ -205,7 +208,7 @@ def _build_schema_on_200(cls): properties = cls._schema_on_200.properties properties.contacts = AAZListType() - properties.custom_properties = AAZObjectType( + properties.custom_properties = AAZFreeFormDictType( serialized_name="customProperties", ) properties.description = AAZStrType() @@ -218,6 +221,7 @@ def _build_schema_on_200(cls): properties.license = AAZObjectType() properties.lifecycle_stage = AAZStrType( serialized_name="lifecycleStage", + flags={"read_only": True}, ) properties.summary = AAZStrType() properties.terms_of_service = AAZObjectType( diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_update.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_update.py index bec77541160..8fcc68796aa 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_update.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_update.py @@ -15,10 +15,13 @@ "apic api update", ) class Update(AAZCommand): - """Update new or updates existing API. + """Update existing API. :example: Update API - az apic api update -g contoso-resources -s contoso --name echo-api --summary "Basic REST API service" + az apic api update -g contoso-resources -s contoso --api-id echo-api --summary "Basic REST API service" + + :example: Update custom properties + az apic api update -g contoso-resources -s contoso --api-id echo-api --custom-properties '{\"public-facing\":true}' """ _aaz_info = { @@ -46,12 +49,13 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--name", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -65,6 +69,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -75,6 +80,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="child_name_1", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -89,7 +95,7 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The contact information for the API.", nullable=True, ) - _args_schema.custom_properties = AAZObjectArg( + _args_schema.custom_properties = AAZFreeFormDictArg( options=["--custom-properties"], arg_group="Properties", help="The custom metadata defined for API catalog entities.", @@ -111,10 +117,10 @@ def _build_arguments_schema(cls, *args, **kwargs): help="Additional, external documentation for the API.", nullable=True, ) - _args_schema.kind = AAZStrArg( - options=["--kind"], + _args_schema.type = AAZStrArg( + options=["--type"], arg_group="Properties", - help="Kind of API. For example, REST or GraphQL.", + help="Type of API.", enum={"graphql": "graphql", "grpc": "grpc", "rest": "rest", "soap": "soap", "webhook": "webhook", "websocket": "websocket"}, ) _args_schema.license = AAZObjectArg( @@ -132,12 +138,6 @@ def _build_arguments_schema(cls, *args, **kwargs): max_length=200, ), ) - _args_schema.terms_of_service = AAZObjectArg( - options=["--terms-of-service"], - arg_group="Properties", - help="Terms of service for the API.", - nullable=True, - ) _args_schema.title = AAZStrArg( options=["--title"], arg_group="Properties", @@ -234,15 +234,6 @@ def _build_arguments_schema(cls, *args, **kwargs): max_length=200, ), ) - - terms_of_service = cls._args_schema.terms_of_service - terms_of_service.url = AAZStrArg( - options=["url"], - help="URL pointing to the terms of service.", - fmt=AAZStrArgFormat( - max_length=200, - ), - ) return cls._args_schema def _execute_operations(self): @@ -305,7 +296,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( @@ -396,7 +387,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( @@ -480,18 +471,17 @@ def _update_instance(self, instance): value=instance, typ=AAZObjectType ) - _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True, "client_flatten": True}}) properties = _builder.get(".properties") if properties is not None: properties.set_prop("contacts", AAZListType, ".contacts") - properties.set_prop("customProperties", AAZObjectType, ".custom_properties") + properties.set_prop("customProperties", AAZFreeFormDictType, ".custom_properties") properties.set_prop("description", AAZStrType, ".description") properties.set_prop("externalDocumentation", AAZListType, ".external_documentation") - properties.set_prop("kind", AAZStrType, ".kind", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("kind", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) properties.set_prop("license", AAZObjectType, ".license") properties.set_prop("summary", AAZStrType, ".summary") - properties.set_prop("termsOfService", AAZObjectType, ".terms_of_service") properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) contacts = _builder.get(".properties.contacts") @@ -504,6 +494,10 @@ def _update_instance(self, instance): _elements.set_prop("name", AAZStrType, ".name") _elements.set_prop("url", AAZStrType, ".url") + custom_properties = _builder.get(".properties.customProperties") + if custom_properties is not None: + custom_properties.set_anytype_elements(".") + external_documentation = _builder.get(".properties.externalDocumentation") if external_documentation is not None: external_documentation.set_elements(AAZObjectType, ".") @@ -520,10 +514,6 @@ def _update_instance(self, instance): license.set_prop("name", AAZStrType, ".name") license.set_prop("url", AAZStrType, ".url") - terms_of_service = _builder.get(".properties.termsOfService") - if terms_of_service is not None: - terms_of_service.set_prop("url", AAZStrType, ".url", typ_kwargs={"flags": {"required": True}}) - return _instance_value class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): @@ -560,7 +550,7 @@ def _build_schema_api_read(cls, _schema): flags={"read_only": True}, ) api_read.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) api_read.system_data = AAZObjectType( serialized_name="systemData", @@ -572,7 +562,7 @@ def _build_schema_api_read(cls, _schema): properties = _schema_api_read.properties properties.contacts = AAZListType() - properties.custom_properties = AAZObjectType( + properties.custom_properties = AAZFreeFormDictType( serialized_name="customProperties", ) properties.description = AAZStrType() @@ -585,6 +575,7 @@ def _build_schema_api_read(cls, _schema): properties.license = AAZObjectType() properties.lifecycle_stage = AAZStrType( serialized_name="lifecycleStage", + flags={"read_only": True}, ) properties.summary = AAZStrType() properties.terms_of_service = AAZObjectType( diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__cmd_group.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__cmd_group.py index 55d7e8acc2c..4d328367bf4 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__cmd_group.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__cmd_group.py @@ -15,7 +15,7 @@ "apic api definition", ) class __CMDGroup(AAZCommandGroup): - """Commands to manage API Definitions in API Center + """Commands to manage API definitions in API Center """ pass diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__init__.py index 831005a1398..e88cb10d06d 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__init__.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/__init__.py @@ -12,7 +12,6 @@ from ._create import * from ._delete import * from ._export_specification import * -from ._head import * from ._import_specification import * from ._list import * from ._show import * diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_create.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_create.py index 176b0972967..eb800923c43 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_create.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_create.py @@ -15,10 +15,10 @@ "apic api definition create", ) class Create(AAZCommand): - """Create new or updates existing API definition. + """Create a new API definition or update an existing API definition. :example: Create API definition - az apic api definition create -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 --name "openapi" --title "OpenAPI" + az apic api definition create -g api-center-test -s contosoeuap --api-id echo-api --version-id 2023-01-01 --definition-id "openapi" --title "OpenAPI" """ _aaz_info = { @@ -44,20 +44,22 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.definition_name = AAZStrArg( - options=["--name", "--definition", "--definition-name"], - help="The name of the API definition.", + _args_schema.definition_id = AAZStrArg( + options=["--definition-id"], + help="The id of the API definition.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -70,15 +72,17 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The name of the API Center service.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.version_name = AAZStrArg( - options=["--version", "--version-name"], - help="The name of the API version.", + _args_schema.version_id = AAZStrArg( + options=["--version-id"], + help="The id of the API version.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -89,6 +93,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -106,6 +111,7 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["--title"], arg_group="Properties", help="API version.", + required=True, fmt=AAZStrArgFormat( max_length=50, min_length=1, @@ -160,11 +166,11 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( - "definitionName", self.ctx.args.definition_name, + "definitionName", self.ctx.args.definition_id, required=True, ), **self.serialize_url_param( @@ -180,7 +186,7 @@ def url_parameters(self): required=True, ), **self.serialize_url_param( - "versionName", self.ctx.args.version_name, + "versionName", self.ctx.args.version_id, required=True, ), **self.serialize_url_param( @@ -219,7 +225,7 @@ def content(self): typ=AAZObjectType, typ_kwargs={"flags": {"required": True, "client_flatten": True}} ) - _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True, "client_flatten": True}}) properties = _builder.get(".properties") if properties is not None: @@ -253,7 +259,7 @@ def _build_schema_on_200_201(cls): flags={"read_only": True}, ) _schema_on_200_201.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) _schema_on_200_201.system_data = AAZObjectType( serialized_name="systemData", diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_delete.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_delete.py index 5c508834a41..17523248fa3 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_delete.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_delete.py @@ -19,7 +19,7 @@ class Delete(AAZCommand): """Delete specified API definition. :example: Delete API definition - az apic api definition delete -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 --name "openapi" + az apic api definition delete -g api-center-test -s contosoeuap --api-id echo-api --version-id 2023-01-01 --definition-id "openapi" """ _aaz_info = { @@ -45,22 +45,24 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.definition_name = AAZStrArg( - options=["--name", "--definition", "--definition-name"], - help="The name of the API definition.", + _args_schema.definition_id = AAZStrArg( + options=["--definition-id"], + help="The id of the API definition.", required=True, id_part="child_name_4", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -74,16 +76,18 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.version_name = AAZStrArg( - options=["--version", "--version-name"], - help="The name of the API version.", + _args_schema.version_id = AAZStrArg( + options=["--version-id"], + help="The id of the API version.", required=True, id_part="child_name_3", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -95,6 +99,7 @@ def _build_arguments_schema(cls, *args, **kwargs): id_part="child_name_1", default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -146,11 +151,11 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( - "definitionName", self.ctx.args.definition_name, + "definitionName", self.ctx.args.definition_id, required=True, ), **self.serialize_url_param( @@ -166,7 +171,7 @@ def url_parameters(self): required=True, ), **self.serialize_url_param( - "versionName", self.ctx.args.version_name, + "versionName", self.ctx.args.version_id, required=True, ), **self.serialize_url_param( diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_export_specification.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_export_specification.py index b738c8cf9f0..8d6c3171071 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_export_specification.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_export_specification.py @@ -18,7 +18,7 @@ class ExportSpecification(AAZCommand): """Exports the API specification. :example: Export Specification - az apic api version definition export-specification -g api-center-test -s contosoeuap --api-name echo-api --version-name 2023-01-01 --definition-name default + az apic api version definition export-specification -g api-center-test -s contosoeuap --api-id echo-api --version-id 2023-01-01 --definition-id default """ _aaz_info = { @@ -45,22 +45,24 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.definition_name = AAZStrArg( - options=["--name", "--definition", "--definition-name"], - help="The name of the API definition.", + _args_schema.definition_id = AAZStrArg( + options=["--definition-id"], + help="The id of the API definition.", required=True, id_part="child_name_4", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -74,16 +76,18 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.version_name = AAZStrArg( - options=["--version", "--version-name"], - help="The name of the API version.", + _args_schema.version_id = AAZStrArg( + options=["--version-id"], + help="The id of the API version.", required=True, id_part="child_name_3", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -95,6 +99,7 @@ def _build_arguments_schema(cls, *args, **kwargs): id_part="child_name_1", default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -164,11 +169,11 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( - "definitionName", self.ctx.args.definition_name, + "definitionName", self.ctx.args.definition_id, required=True, ), **self.serialize_url_param( @@ -184,7 +189,7 @@ def url_parameters(self): required=True, ), **self.serialize_url_param( - "versionName", self.ctx.args.version_name, + "versionName", self.ctx.args.version_id, required=True, ), **self.serialize_url_param( diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_head.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_head.py deleted file mode 100644 index 53d99fabe0d..00000000000 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_head.py +++ /dev/null @@ -1,191 +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( - "apic api definition head", -) -class Head(AAZCommand): - """Checks if specified API definition exists. - """ - - _aaz_info = { - "version": "2024-03-01", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions/{}/definitions/{}", "2024-03-01"], - ] - } - - 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.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", - required=True, - id_part="child_name_2", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - _args_schema.definition_name = AAZStrArg( - options=["--name", "--definition", "--definition-name"], - help="The name of the API definition.", - required=True, - id_part="child_name_4", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - _args_schema.resource_group = AAZResourceGroupNameArg( - required=True, - ) - _args_schema.service_name = AAZStrArg( - options=["-s", "--service", "--service-name"], - help="The name of the API Center service.", - required=True, - id_part="name", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - _args_schema.version_name = AAZStrArg( - options=["--version", "--version-name"], - help="The name of the API version.", - required=True, - id_part="child_name_3", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - _args_schema.workspace_name = AAZStrArg( - options=["-w", "--workspace", "--workspace-name"], - help="The name of the workspace.", - required=True, - id_part="child_name_1", - default="default", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.ApiDefinitionsHead(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - class ApiDefinitionsHead(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.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}/definitions/{definitionName}", - **self.url_parameters - ) - - @property - def method(self): - return "HEAD" - - @property - def error_format(self): - return "MgmtErrorFormat" - - @property - def url_parameters(self): - parameters = { - **self.serialize_url_param( - "apiName", self.ctx.args.api_name, - required=True, - ), - **self.serialize_url_param( - "definitionName", self.ctx.args.definition_name, - required=True, - ), - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), - **self.serialize_url_param( - "serviceName", self.ctx.args.service_name, - required=True, - ), - **self.serialize_url_param( - "subscriptionId", self.ctx.subscription_id, - required=True, - ), - **self.serialize_url_param( - "versionName", self.ctx.args.version_name, - required=True, - ), - **self.serialize_url_param( - "workspaceName", self.ctx.args.workspace_name, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2024-03-01", - required=True, - ), - } - return parameters - - def on_200(self, session): - pass - - -class _HeadHelper: - """Helper class for Head""" - - -__all__ = ["Head"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_import_specification.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_import_specification.py index 943e3258a3a..9c61443f2cc 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_import_specification.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_import_specification.py @@ -17,11 +17,11 @@ class ImportSpecification(AAZCommand): """Imports the API specification. - :example: Import Sepecification - az apic api definition import-specification -g api-center-test -s contosoeuap --api-name echo-api-2 --version-name 2023-08-01 --definition-name openapi3 --format "inline" --value '{"openapi":"3.0.1","info":{"title":"httpbin.org","description":"API Management facade for a very handy and free online HTTP tool.","version":"1.0"}}' --specification '{"name":"openapi","version":"3.0.0"}' + :example: Import specification example 1 + az apic api definition import-specification -g api-center-test -s contosoeuap --api-id echo-api-2 --version-id 2023-08-01 --definition-id openapi3 --format "inline" --value '{"openapi":"3.0.1","info":{"title":"httpbin.org","description":"API Management facade for a very handy and free online HTTP tool.","version":"1.0"}}' --specification '{"name":"openapi","version":"3.0.0"}' - :example: Import Specification from a file - az apic api definition import-specification -g api-center-test -s contosoeuap --api-name echo-api-2 --version-name 2023-11-01 --definition-name openapi8 --format "link" --value 'https://alzaslonaztest.blob.core.windows.net/arpitestblobs/importspec4.txt' --specification '{"name":"openapi","version":"3.0.0"}' + :example: Import specification example 2 + az apic api definition import-specification -g api-center-test -s contoso --api-id echo-api --version-id 2023-11-01 --definition-id openapi --format "link" --value 'https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.json' --specification '{"name":"openapi","version":"3.0.0"}' """ _aaz_info = { @@ -48,22 +48,24 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.definition_name = AAZStrArg( - options=["--name", "--definition", "--definition-name"], - help="The name of the API definition.", + _args_schema.definition_id = AAZStrArg( + options=["--definition-id"], + help="The id of the API definition.", required=True, id_part="child_name_4", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -77,16 +79,18 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.version_name = AAZStrArg( - options=["--version", "--version-name"], - help="The name of the API version.", + _args_schema.version_id = AAZStrArg( + options=["--version-id"], + help="The id of the API version.", required=True, id_part="child_name_3", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -98,6 +102,7 @@ def _build_arguments_schema(cls, *args, **kwargs): id_part="child_name_1", default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -193,11 +198,11 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( - "definitionName", self.ctx.args.definition_name, + "definitionName", self.ctx.args.definition_id, required=True, ), **self.serialize_url_param( @@ -213,7 +218,7 @@ def url_parameters(self): required=True, ), **self.serialize_url_param( - "versionName", self.ctx.args.version_name, + "versionName", self.ctx.args.version_id, required=True, ), **self.serialize_url_param( diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_list.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_list.py index 5d1740729b3..a540d0f378e 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_list.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_list.py @@ -18,7 +18,7 @@ class List(AAZCommand): """List a collection of API definitions. :example: List API definitions - az apic api definition list -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 + az apic api definition list -g api-center-test -s contosoeuap --api-id echo-api --version-id 2023-01-01 """ _aaz_info = { @@ -45,11 +45,12 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -62,15 +63,17 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The name of the API Center service.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.version_name = AAZStrArg( - options=["--version", "--version-name"], - help="The name of the API version.", + _args_schema.version_id = AAZStrArg( + options=["--version-id"], + help="The id of the API version.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -81,6 +84,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -139,7 +143,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( @@ -155,7 +159,7 @@ def url_parameters(self): required=True, ), **self.serialize_url_param( - "versionName", self.ctx.args.version_name, + "versionName", self.ctx.args.version_id, required=True, ), **self.serialize_url_param( @@ -210,7 +214,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _schema_on_200.value = AAZListType( - flags={"read_only": True}, + flags={"required": True, "read_only": True}, ) value = cls._schema_on_200.value @@ -224,7 +228,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _element.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) _element.system_data = AAZObjectType( serialized_name="systemData", diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_show.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_show.py index 41b9ac3cd4d..5f5ddb471be 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_show.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_show.py @@ -18,7 +18,7 @@ class Show(AAZCommand): """Get details of the API definition. :example: Show API definition details - az apic api definition show -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 --name "openapi" + az apic api definition show -g api-center-test -s contosoeuap --api-id echo-api --version-id 2023-01-01 --definition-id "openapi" """ _aaz_info = { @@ -44,22 +44,24 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.definition_name = AAZStrArg( - options=["--name", "--definition", "--definition-name"], - help="The name of the API definition.", + _args_schema.definition_id = AAZStrArg( + options=["--definition-id"], + help="The id of the API definition.", required=True, id_part="child_name_4", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -73,16 +75,18 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.version_name = AAZStrArg( - options=["--version", "--version-name"], - help="The name of the API version.", + _args_schema.version_id = AAZStrArg( + options=["--version-id"], + help="The id of the API version.", required=True, id_part="child_name_3", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -94,6 +98,7 @@ def _build_arguments_schema(cls, *args, **kwargs): id_part="child_name_1", default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -147,11 +152,11 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( - "definitionName", self.ctx.args.definition_name, + "definitionName", self.ctx.args.definition_id, required=True, ), **self.serialize_url_param( @@ -167,7 +172,7 @@ def url_parameters(self): required=True, ), **self.serialize_url_param( - "versionName", self.ctx.args.version_name, + "versionName", self.ctx.args.version_id, required=True, ), **self.serialize_url_param( @@ -221,7 +226,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _schema_on_200.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) _schema_on_200.system_data = AAZObjectType( serialized_name="systemData", diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_update.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_update.py index f56031b5794..f5a22d40c7b 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_update.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/definition/_update.py @@ -15,10 +15,10 @@ "apic api definition update", ) class Update(AAZCommand): - """Update new or updates existing API definition. + """Update existing API definition. :example: Update API definition - az apic api definition update -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 --name "openapi" --title "OpenAPI" + az apic api definition update -g api-center-test -s contosoeuap --api-id echo-api --version-id 2023-01-01 --definition-id "openapi" --title "OpenAPI" """ _aaz_info = { @@ -46,22 +46,24 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.definition_name = AAZStrArg( - options=["--name", "--definition", "--definition-name"], - help="The name of the API definition.", + _args_schema.definition_id = AAZStrArg( + options=["--definition-id"], + help="The id of the API definition.", required=True, id_part="child_name_4", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -75,16 +77,18 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.version_name = AAZStrArg( - options=["--version", "--version-name"], - help="The name of the API version.", + _args_schema.version_id = AAZStrArg( + options=["--version-id"], + help="The id of the API version.", required=True, id_part="child_name_3", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -95,6 +99,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="child_name_1", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -180,11 +185,11 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( - "definitionName", self.ctx.args.definition_name, + "definitionName", self.ctx.args.definition_id, required=True, ), **self.serialize_url_param( @@ -200,7 +205,7 @@ def url_parameters(self): required=True, ), **self.serialize_url_param( - "versionName", self.ctx.args.version_name, + "versionName", self.ctx.args.version_id, required=True, ), **self.serialize_url_param( @@ -279,11 +284,11 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( - "definitionName", self.ctx.args.definition_name, + "definitionName", self.ctx.args.definition_id, required=True, ), **self.serialize_url_param( @@ -299,7 +304,7 @@ def url_parameters(self): required=True, ), **self.serialize_url_param( - "versionName", self.ctx.args.version_name, + "versionName", self.ctx.args.version_id, required=True, ), **self.serialize_url_param( @@ -371,7 +376,7 @@ def _update_instance(self, instance): value=instance, typ=AAZObjectType ) - _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True, "client_flatten": True}}) properties = _builder.get(".properties") if properties is not None: @@ -414,7 +419,7 @@ def _build_schema_api_definition_read(cls, _schema): flags={"read_only": True}, ) api_definition_read.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) api_definition_read.system_data = AAZObjectType( serialized_name="systemData", diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/__init__.py index a6ed8b6688f..c401f439385 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/__init__.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/__init__.py @@ -11,7 +11,6 @@ from .__cmd_group import * from ._create import * from ._delete import * -from ._head import * from ._list import * from ._show import * from ._update import * diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_create.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_create.py index 4dab39f92b5..2a479b12ec1 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_create.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_create.py @@ -15,10 +15,10 @@ "apic api deployment create", ) class Create(AAZCommand): - """Create new or updates existing API deployment. + """Create a new API deployment or update an existing API deployment. :example: Create deployment - az apic api deployment create -g api-center-test -s contoso --name production --title "Production deployment" --description "Public cloud production deployment." --api echo-api --environmentId "/workspaces/default/environments/production" --definitionId "/workspaces/default/apis/echo-api/versions/2023-01-01/definitions/openapi" + az apic api deployment create -g api-center-test -s contoso --deployment-id production --title "Production deployment" --description "Public cloud production deployment." --api-id echo-api --environment-id "/workspaces/default/environments/production" --definition-id "/workspaces/default/apis/echo-api/versions/2023-01-01/definitions/openapi" --server '{\"runtimeUri\":[\"https://example.com\"]}' """ _aaz_info = { @@ -44,20 +44,22 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.deployment_name = AAZStrArg( - options=["--name", "--deployment", "--deployment-name"], - help="The name of the API deployment.", + _args_schema.deployment_id = AAZStrArg( + options=["--deployment-id"], + help="The id of the API deployment.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -70,6 +72,7 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The name of the API Center service.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -80,6 +83,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -88,7 +92,7 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "Properties" _args_schema = cls._args_schema - _args_schema.custom_properties = AAZObjectArg( + _args_schema.custom_properties = AAZFreeFormDictArg( options=["--custom-properties"], arg_group="Properties", help="The custom metadata defined for API catalog entities.", @@ -194,11 +198,11 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( - "deploymentName", self.ctx.args.deployment_name, + "deploymentName", self.ctx.args.deployment_id, required=True, ), **self.serialize_url_param( @@ -253,7 +257,7 @@ def content(self): properties = _builder.get(".properties") if properties is not None: - properties.set_prop("customProperties", AAZObjectType, ".custom_properties") + properties.set_prop("customProperties", AAZFreeFormDictType, ".custom_properties") properties.set_prop("definitionId", AAZStrType, ".definition_id") properties.set_prop("description", AAZStrType, ".description") properties.set_prop("environmentId", AAZStrType, ".environment_id") @@ -261,6 +265,10 @@ def content(self): properties.set_prop("state", AAZStrType, ".state") properties.set_prop("title", AAZStrType, ".title") + custom_properties = _builder.get(".properties.customProperties") + if custom_properties is not None: + custom_properties.set_anytype_elements(".") + server = _builder.get(".properties.server") if server is not None: server.set_prop("runtimeUri", AAZListType, ".runtime_uri") @@ -307,7 +315,7 @@ def _build_schema_on_200_201(cls): ) properties = cls._schema_on_200_201.properties - properties.custom_properties = AAZObjectType( + properties.custom_properties = AAZFreeFormDictType( serialized_name="customProperties", ) properties.definition_id = AAZStrType( diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_delete.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_delete.py index 6584964b542..fe484c0f106 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_delete.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_delete.py @@ -19,7 +19,7 @@ class Delete(AAZCommand): """Delete API deployment. :example: Delete API deployment - az apic api deployment delete -g api-center-test -s contoso --name production --api-name echo-api + az apic api deployment delete -g api-center-test -s contoso --deployment-id production --api-id echo-api """ _aaz_info = { @@ -45,22 +45,24 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.deployment_name = AAZStrArg( - options=["--name", "--deployment", "--deployment-name"], - help="The name of the API deployment.", + _args_schema.deployment_id = AAZStrArg( + options=["--deployment-id"], + help="The id of the API deployment.", required=True, id_part="child_name_3", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -74,6 +76,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -85,6 +88,7 @@ def _build_arguments_schema(cls, *args, **kwargs): id_part="child_name_1", default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -136,11 +140,11 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( - "deploymentName", self.ctx.args.deployment_name, + "deploymentName", self.ctx.args.deployment_id, required=True, ), **self.serialize_url_param( diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_head.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_head.py deleted file mode 100644 index 6b24bbf7cb2..00000000000 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_head.py +++ /dev/null @@ -1,177 +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( - "apic api deployment head", -) -class Head(AAZCommand): - """Checks if specified API deployment exists. - """ - - _aaz_info = { - "version": "2024-03-01", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/deployments/{}", "2024-03-01"], - ] - } - - 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.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", - required=True, - id_part="child_name_2", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - _args_schema.deployment_name = AAZStrArg( - options=["--name", "--deployment", "--deployment-name"], - help="The name of the API deployment.", - required=True, - id_part="child_name_3", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - _args_schema.resource_group = AAZResourceGroupNameArg( - required=True, - ) - _args_schema.service_name = AAZStrArg( - options=["-s", "--service", "--service-name"], - help="The name of the API Center service.", - required=True, - id_part="name", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - _args_schema.workspace_name = AAZStrArg( - options=["-w", "--workspace", "--workspace-name"], - help="The name of the workspace.", - required=True, - id_part="child_name_1", - default="default", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.DeploymentsHead(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - class DeploymentsHead(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.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/deployments/{deploymentName}", - **self.url_parameters - ) - - @property - def method(self): - return "HEAD" - - @property - def error_format(self): - return "MgmtErrorFormat" - - @property - def url_parameters(self): - parameters = { - **self.serialize_url_param( - "apiName", self.ctx.args.api_name, - required=True, - ), - **self.serialize_url_param( - "deploymentName", self.ctx.args.deployment_name, - required=True, - ), - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), - **self.serialize_url_param( - "serviceName", self.ctx.args.service_name, - required=True, - ), - **self.serialize_url_param( - "subscriptionId", self.ctx.subscription_id, - required=True, - ), - **self.serialize_url_param( - "workspaceName", self.ctx.args.workspace_name, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2024-03-01", - required=True, - ), - } - return parameters - - def on_200(self, session): - pass - - -class _HeadHelper: - """Helper class for Head""" - - -__all__ = ["Head"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_list.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_list.py index 1df71cf6cba..2be0462a0a9 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_list.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_list.py @@ -18,7 +18,7 @@ class List(AAZCommand): """List a collection of API deployments. :example: List API deployments - az apic api deployment list -g api-center-test -s contoso --api-name echo-api + az apic api deployment list -g api-center-test -s contoso --api-id echo-api """ _aaz_info = { @@ -45,11 +45,12 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -62,6 +63,7 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The name of the API Center service.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -72,6 +74,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -130,7 +133,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( @@ -197,7 +200,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _schema_on_200.value = AAZListType( - flags={"read_only": True}, + flags={"required": True, "read_only": True}, ) value = cls._schema_on_200.value @@ -222,7 +225,7 @@ def _build_schema_on_200(cls): ) properties = cls._schema_on_200.value.Element.properties - properties.custom_properties = AAZObjectType( + properties.custom_properties = AAZFreeFormDictType( serialized_name="customProperties", ) properties.definition_id = AAZStrType( diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_show.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_show.py index 3e7484335ba..e485f3d2d86 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_show.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_show.py @@ -18,7 +18,7 @@ class Show(AAZCommand): """Get details of the API deployment. :example: Show API deployment details - az apic api deployment show -g api-center-test -s contoso --name production --api-name echo-api + az apic api deployment show -g api-center-test -s contoso --deployment-id production --api-id echo-api """ _aaz_info = { @@ -44,22 +44,24 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.deployment_name = AAZStrArg( - options=["--name", "--deployment", "--deployment-name"], - help="The name of the API deployment.", + _args_schema.deployment_id = AAZStrArg( + options=["--deployment-id"], + help="The id of the API deployment.", required=True, id_part="child_name_3", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -73,6 +75,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -84,6 +87,7 @@ def _build_arguments_schema(cls, *args, **kwargs): id_part="child_name_1", default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -137,11 +141,11 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( - "deploymentName", self.ctx.args.deployment_name, + "deploymentName", self.ctx.args.deployment_id, required=True, ), **self.serialize_url_param( @@ -218,7 +222,7 @@ def _build_schema_on_200(cls): ) properties = cls._schema_on_200.properties - properties.custom_properties = AAZObjectType( + properties.custom_properties = AAZFreeFormDictType( serialized_name="customProperties", ) properties.definition_id = AAZStrType( diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_update.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_update.py index 5d7975177c9..e2d34655206 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_update.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/deployment/_update.py @@ -15,10 +15,10 @@ "apic api deployment update", ) class Update(AAZCommand): - """Update new or updates existing API deployment. + """Update existing API deployment. :example: Update API deployment - az apic api deployment update -g api-center-test -s contoso --name production --title "Production deployment" --api echo-api + az apic api deployment update -g api-center-test -s contoso --deployment-id production --title "Production deployment" --api-id echo-api """ _aaz_info = { @@ -46,22 +46,24 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.deployment_name = AAZStrArg( - options=["--name", "--deployment", "--deployment-name"], - help="The name of the API deployment.", + _args_schema.deployment_id = AAZStrArg( + options=["--deployment-id"], + help="The id of the API deployment.", required=True, id_part="child_name_3", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -75,6 +77,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -85,6 +88,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="child_name_1", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -93,7 +97,7 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "Properties" _args_schema = cls._args_schema - _args_schema.custom_properties = AAZObjectArg( + _args_schema.custom_properties = AAZFreeFormDictArg( options=["--custom-properties"], arg_group="Properties", help="The custom metadata defined for API catalog entities.", @@ -221,11 +225,11 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( - "deploymentName", self.ctx.args.deployment_name, + "deploymentName", self.ctx.args.deployment_id, required=True, ), **self.serialize_url_param( @@ -316,11 +320,11 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( - "deploymentName", self.ctx.args.deployment_name, + "deploymentName", self.ctx.args.deployment_id, required=True, ), **self.serialize_url_param( @@ -408,7 +412,7 @@ def _update_instance(self, instance): properties = _builder.get(".properties") if properties is not None: - properties.set_prop("customProperties", AAZObjectType, ".custom_properties") + properties.set_prop("customProperties", AAZFreeFormDictType, ".custom_properties") properties.set_prop("definitionId", AAZStrType, ".definition_id") properties.set_prop("description", AAZStrType, ".description") properties.set_prop("environmentId", AAZStrType, ".environment_id") @@ -416,6 +420,10 @@ def _update_instance(self, instance): properties.set_prop("state", AAZStrType, ".state") properties.set_prop("title", AAZStrType, ".title") + custom_properties = _builder.get(".properties.customProperties") + if custom_properties is not None: + custom_properties.set_anytype_elements(".") + server = _builder.get(".properties.server") if server is not None: server.set_prop("runtimeUri", AAZListType, ".runtime_uri") @@ -471,7 +479,7 @@ def _build_schema_deployment_read(cls, _schema): ) properties = _schema_deployment_read.properties - properties.custom_properties = AAZObjectType( + properties.custom_properties = AAZFreeFormDictType( serialized_name="customProperties", ) properties.definition_id = AAZStrType( diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__cmd_group.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__cmd_group.py index 4ef241fb123..afb136e942c 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__cmd_group.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__cmd_group.py @@ -15,7 +15,7 @@ "apic api version", ) class __CMDGroup(AAZCommandGroup): - """Commands to manage API Versions in API Center + """Commands to manage API versions in API Center """ pass diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__init__.py index a6ed8b6688f..c401f439385 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__init__.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/__init__.py @@ -11,7 +11,6 @@ from .__cmd_group import * from ._create import * from ._delete import * -from ._head import * from ._list import * from ._show import * from ._update import * diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_create.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_create.py index da640e69e57..28b2b13e18f 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_create.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_create.py @@ -15,10 +15,10 @@ "apic api version create", ) class Create(AAZCommand): - """Create new or update existing API version. + """Create a new API version or update an existing API version. :example: Create API version - az apic api version create -g api-center-test -s contosoeuap --api-name echo-api --name 2023-01-01 --title "2023-01-01" + az apic api version create -g api-center-test -s contosoeuap --api-id echo-api --version-id 2023-01-01 --title "2023-01-01" """ _aaz_info = { @@ -44,11 +44,12 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -61,15 +62,17 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The name of the API Center service.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.version_name = AAZStrArg( - options=["--name", "--version", "--version-name"], - help="The name of the API version.", + _args_schema.version_id = AAZStrArg( + options=["--version-id"], + help="The id of the API version.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -80,6 +83,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -92,12 +96,14 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["--lifecycle-stage"], arg_group="Properties", help="Current lifecycle stage of the API.", + required=True, enum={"deprecated": "deprecated", "design": "design", "development": "development", "preview": "preview", "production": "production", "retired": "retired", "testing": "testing"}, ) _args_schema.title = AAZStrArg( options=["--title"], arg_group="Properties", help="API version.", + required=True, fmt=AAZStrArgFormat( max_length=50, min_length=1, @@ -152,7 +158,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( @@ -168,7 +174,7 @@ def url_parameters(self): required=True, ), **self.serialize_url_param( - "versionName", self.ctx.args.version_name, + "versionName", self.ctx.args.version_id, required=True, ), **self.serialize_url_param( @@ -207,7 +213,7 @@ def content(self): typ=AAZObjectType, typ_kwargs={"flags": {"required": True, "client_flatten": True}} ) - _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True, "client_flatten": True}}) properties = _builder.get(".properties") if properties is not None: @@ -241,7 +247,7 @@ def _build_schema_on_200_201(cls): flags={"read_only": True}, ) _schema_on_200_201.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) _schema_on_200_201.system_data = AAZObjectType( serialized_name="systemData", diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_delete.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_delete.py index f5d088936fa..e41d6192151 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_delete.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_delete.py @@ -19,7 +19,7 @@ class Delete(AAZCommand): """Delete specified API version :example: Delete API version - az apic api version delete -g api-center-test -s contosoeuap --api-name echo-api --name 2023-01-01 + az apic api version delete -g api-center-test -s contosoeuap --api-id echo-api --version-id 2023-01-01 """ _aaz_info = { @@ -45,12 +45,13 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -64,16 +65,18 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.version_name = AAZStrArg( - options=["--name", "--version", "--version-name"], - help="The name of the API version.", + _args_schema.version_id = AAZStrArg( + options=["--version-id"], + help="The id of the API version.", required=True, id_part="child_name_3", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -85,6 +88,7 @@ def _build_arguments_schema(cls, *args, **kwargs): id_part="child_name_1", default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -136,7 +140,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( @@ -152,7 +156,7 @@ def url_parameters(self): required=True, ), **self.serialize_url_param( - "versionName", self.ctx.args.version_name, + "versionName", self.ctx.args.version_id, required=True, ), **self.serialize_url_param( diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_head.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_head.py deleted file mode 100644 index 342fe97d095..00000000000 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_head.py +++ /dev/null @@ -1,177 +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( - "apic api version head", -) -class Head(AAZCommand): - """Checks if specified API version exists. - """ - - _aaz_info = { - "version": "2024-03-01", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/apis/{}/versions/{}", "2024-03-01"], - ] - } - - 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.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", - required=True, - id_part="child_name_2", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - _args_schema.resource_group = AAZResourceGroupNameArg( - required=True, - ) - _args_schema.service_name = AAZStrArg( - options=["-s", "--service", "--service-name"], - help="The name of the API Center service.", - required=True, - id_part="name", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - _args_schema.version_name = AAZStrArg( - options=["--version", "--version-name"], - help="The name of the API version.", - required=True, - id_part="child_name_3", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - _args_schema.workspace_name = AAZStrArg( - options=["-w", "--workspace", "--workspace-name"], - help="The name of the workspace.", - required=True, - id_part="child_name_1", - default="default", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.ApiVersionsHead(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - class ApiVersionsHead(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.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/apis/{apiName}/versions/{versionName}", - **self.url_parameters - ) - - @property - def method(self): - return "HEAD" - - @property - def error_format(self): - return "MgmtErrorFormat" - - @property - def url_parameters(self): - parameters = { - **self.serialize_url_param( - "apiName", self.ctx.args.api_name, - required=True, - ), - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), - **self.serialize_url_param( - "serviceName", self.ctx.args.service_name, - required=True, - ), - **self.serialize_url_param( - "subscriptionId", self.ctx.subscription_id, - required=True, - ), - **self.serialize_url_param( - "versionName", self.ctx.args.version_name, - required=True, - ), - **self.serialize_url_param( - "workspaceName", self.ctx.args.workspace_name, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2024-03-01", - required=True, - ), - } - return parameters - - def on_200(self, session): - pass - - -class _HeadHelper: - """Helper class for Head""" - - -__all__ = ["Head"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_list.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_list.py index 1df7b2cbb31..21c13daee76 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_list.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_list.py @@ -18,7 +18,7 @@ class List(AAZCommand): """List a collection of API versions. :example: List API versions - az apic api version list -g api-center-test -s contosoeuap --api-name echo-api + az apic api version list -g api-center-test -s contosoeuap --api-id echo-api """ _aaz_info = { @@ -45,11 +45,12 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -62,6 +63,7 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The name of the API Center service.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -72,6 +74,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -130,7 +133,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( @@ -197,7 +200,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _schema_on_200.value = AAZListType( - flags={"read_only": True}, + flags={"required": True, "read_only": True}, ) value = cls._schema_on_200.value @@ -211,7 +214,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _element.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) _element.system_data = AAZObjectType( serialized_name="systemData", diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_show.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_show.py index ee2fa6e309a..e4bd8847727 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_show.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_show.py @@ -18,7 +18,7 @@ class Show(AAZCommand): """Get details of the API version. :example: Show API version details - az apic api version show -g api-center-test -s contoso --api-name echo-api --name 2023-01-01 + az apic api version show -g api-center-test -s contoso --api-id echo-api --version-id 2023-01-01 """ _aaz_info = { @@ -44,12 +44,13 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -63,16 +64,18 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.version_name = AAZStrArg( - options=["--name", "--version", "--version-name"], - help="The name of the API version.", + _args_schema.version_id = AAZStrArg( + options=["--version-id"], + help="The id of the API version.", required=True, id_part="child_name_3", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -84,6 +87,7 @@ def _build_arguments_schema(cls, *args, **kwargs): id_part="child_name_1", default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -137,7 +141,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( @@ -153,7 +157,7 @@ def url_parameters(self): required=True, ), **self.serialize_url_param( - "versionName", self.ctx.args.version_name, + "versionName", self.ctx.args.version_id, required=True, ), **self.serialize_url_param( @@ -207,7 +211,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _schema_on_200.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) _schema_on_200.system_data = AAZObjectType( serialized_name="systemData", diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_update.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_update.py index 9af4e2602cd..97ae3567c77 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_update.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/api/version/_update.py @@ -15,10 +15,10 @@ "apic api version update", ) class Update(AAZCommand): - """Update new or updates existing API version. + """Update existing API version. :example: Update API version - az apic api version update -g api-center-test -s contosoeuap --api-name echo-api --name 2023-01-01 --title "2023-01-01" + az apic api version update -g api-center-test -s contosoeuap --api-id echo-api --version-id 2023-01-01 --title "2023-01-01" """ _aaz_info = { @@ -46,12 +46,13 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.api_name = AAZStrArg( - options=["--api", "--api-name"], - help="The name of the API.", + _args_schema.api_id = AAZStrArg( + options=["--api-id"], + help="The id of the API.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -65,16 +66,18 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - _args_schema.version_name = AAZStrArg( - options=["--name", "--version", "--version-name"], - help="The name of the API version.", + _args_schema.version_id = AAZStrArg( + options=["--version-id"], + help="The id of the API version.", required=True, id_part="child_name_3", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -85,6 +88,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="child_name_1", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -170,7 +174,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( @@ -186,7 +190,7 @@ def url_parameters(self): required=True, ), **self.serialize_url_param( - "versionName", self.ctx.args.version_name, + "versionName", self.ctx.args.version_id, required=True, ), **self.serialize_url_param( @@ -265,7 +269,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "apiName", self.ctx.args.api_name, + "apiName", self.ctx.args.api_id, required=True, ), **self.serialize_url_param( @@ -281,7 +285,7 @@ def url_parameters(self): required=True, ), **self.serialize_url_param( - "versionName", self.ctx.args.version_name, + "versionName", self.ctx.args.version_id, required=True, ), **self.serialize_url_param( @@ -353,7 +357,7 @@ def _update_instance(self, instance): value=instance, typ=AAZObjectType ) - _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True, "client_flatten": True}}) properties = _builder.get(".properties") if properties is not None: @@ -396,7 +400,7 @@ def _build_schema_api_version_read(cls, _schema): flags={"read_only": True}, ) api_version_read.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) api_version_read.system_data = AAZObjectType( serialized_name="systemData", diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__cmd_group.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__cmd_group.py index 2cf293557d5..443977cdcdb 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__cmd_group.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__cmd_group.py @@ -15,7 +15,7 @@ "apic environment", ) class __CMDGroup(AAZCommandGroup): - """Commands to manage Environments in API Center + """Commands to manage environments in API Center """ pass diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__init__.py index a6ed8b6688f..c401f439385 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__init__.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/__init__.py @@ -11,7 +11,6 @@ from .__cmd_group import * from ._create import * from ._delete import * -from ._head import * from ._list import * from ._show import * from ._update import * diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_create.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_create.py index 0c398be20a8..1b011e5bc13 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_create.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_create.py @@ -15,10 +15,10 @@ "apic environment create", ) class Create(AAZCommand): - """Create new or updates existing environment. + """Create a new environment or update an existing environment. :example: Create environment - az apic environment create -g api-center-test -s contosoeuap --name public --title "Public cloud" --kind "development" + az apic environment create -g api-center-test -s contosoeuap --environment-id public --title "Public cloud" --type "development" """ _aaz_info = { @@ -44,11 +44,12 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.environment_name = AAZStrArg( - options=["--name", "--environment", "--environment-name"], - help="The name of the environment.", + _args_schema.environment_id = AAZStrArg( + options=["--environment-id"], + help="The id of the environment.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -61,6 +62,7 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The name of the API Center service.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -71,6 +73,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -79,7 +82,7 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "Properties" _args_schema = cls._args_schema - _args_schema.custom_properties = AAZObjectArg( + _args_schema.custom_properties = AAZFreeFormDictArg( options=["--custom-properties"], arg_group="Properties", help="The custom metadata defined for API catalog entities.", @@ -88,17 +91,19 @@ def _build_arguments_schema(cls, *args, **kwargs): _args_schema.description = AAZStrArg( options=["--description"], arg_group="Properties", - help="Description.", + help="Environment description.", ) - _args_schema.kind = AAZStrArg( - options=["--kind"], + _args_schema.type = AAZStrArg( + options=["--type"], arg_group="Properties", - help="Environment kind.", + help="Environment type.", + required=True, enum={"development": "development", "production": "production", "staging": "staging", "testing": "testing"}, ) _args_schema.onboarding = AAZObjectArg( options=["--onboarding"], arg_group="Properties", + help="Provide onboarding documentation related to your environment, e.g. {developerPortalUri:['https://developer.contoso.com'],instructions:'instructions markdown'}", ) _args_schema.server = AAZObjectArg( options=["--server"], @@ -109,6 +114,7 @@ def _build_arguments_schema(cls, *args, **kwargs): options=["--title"], arg_group="Properties", help="Environment title.", + required=True, fmt=AAZStrArgFormat( max_length=50, min_length=1, @@ -118,6 +124,7 @@ def _build_arguments_schema(cls, *args, **kwargs): onboarding = cls._args_schema.onboarding onboarding.developer_portal_uri = AAZListArg( options=["developer-portal-uri"], + help="The location of the development portal", ) onboarding.instructions = AAZStrArg( options=["instructions"], @@ -130,6 +137,7 @@ def _build_arguments_schema(cls, *args, **kwargs): server = cls._args_schema.server server.management_portal_uri = AAZListArg( options=["management-portal-uri"], + help="The location of the management portal", ) server.type = AAZStrArg( options=["type"], @@ -188,7 +196,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "environmentName", self.ctx.args.environment_name, + "environmentName", self.ctx.args.environment_id, required=True, ), **self.serialize_url_param( @@ -239,17 +247,21 @@ def content(self): typ=AAZObjectType, typ_kwargs={"flags": {"required": True, "client_flatten": True}} ) - _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True, "client_flatten": True}}) properties = _builder.get(".properties") if properties is not None: - properties.set_prop("customProperties", AAZObjectType, ".custom_properties") + properties.set_prop("customProperties", AAZFreeFormDictType, ".custom_properties") properties.set_prop("description", AAZStrType, ".description") - properties.set_prop("kind", AAZStrType, ".kind", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("kind", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) properties.set_prop("onboarding", AAZObjectType, ".onboarding") properties.set_prop("server", AAZObjectType, ".server") properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) + custom_properties = _builder.get(".properties.customProperties") + if custom_properties is not None: + custom_properties.set_anytype_elements(".") + onboarding = _builder.get(".properties.onboarding") if onboarding is not None: onboarding.set_prop("developerPortalUri", AAZListType, ".developer_portal_uri") @@ -295,7 +307,7 @@ def _build_schema_on_200_201(cls): flags={"read_only": True}, ) _schema_on_200_201.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) _schema_on_200_201.system_data = AAZObjectType( serialized_name="systemData", @@ -306,7 +318,7 @@ def _build_schema_on_200_201(cls): ) properties = cls._schema_on_200_201.properties - properties.custom_properties = AAZObjectType( + properties.custom_properties = AAZFreeFormDictType( serialized_name="customProperties", ) properties.description = AAZStrType() diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_delete.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_delete.py index f13fa95c16d..8213231b6d6 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_delete.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_delete.py @@ -19,7 +19,7 @@ class Delete(AAZCommand): """Delete the environment. :example: Delete environment - az apic environment delete -g api-center-test -s contosoeuap --name public + az apic environment delete -g api-center-test -s contosoeuap --environment-id public """ _aaz_info = { @@ -45,12 +45,13 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.environment_name = AAZStrArg( - options=["--name", "--environment", "--environment-name"], - help="The name of the environment.", + _args_schema.environment_id = AAZStrArg( + options=["--environment-id"], + help="The id of the environment.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -64,6 +65,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -75,6 +77,7 @@ def _build_arguments_schema(cls, *args, **kwargs): id_part="child_name_1", default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -126,7 +129,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "environmentName", self.ctx.args.environment_name, + "environmentName", self.ctx.args.environment_id, required=True, ), **self.serialize_url_param( diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_head.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_head.py deleted file mode 100644 index 714acd4191d..00000000000 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_head.py +++ /dev/null @@ -1,163 +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( - "apic environment head", -) -class Head(AAZCommand): - """Checks if specified environment exists. - """ - - _aaz_info = { - "version": "2024-03-01", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/workspaces/{}/environments/{}", "2024-03-01"], - ] - } - - 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.environment_name = AAZStrArg( - options=["--name", "--environment", "--environment-name"], - help="The name of the environment.", - required=True, - id_part="child_name_2", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - _args_schema.resource_group = AAZResourceGroupNameArg( - required=True, - ) - _args_schema.service_name = AAZStrArg( - options=["-s", "--service", "--service-name"], - help="The name of the API Center service.", - required=True, - id_part="name", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - _args_schema.workspace_name = AAZStrArg( - options=["-w", "--workspace", "--workspace-name"], - help="The name of the workspace.", - required=True, - id_part="child_name_1", - default="default", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.EnvironmentsHead(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - class EnvironmentsHead(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.ApiCenter/services/{serviceName}/workspaces/{workspaceName}/environments/{environmentName}", - **self.url_parameters - ) - - @property - def method(self): - return "HEAD" - - @property - def error_format(self): - return "MgmtErrorFormat" - - @property - def url_parameters(self): - parameters = { - **self.serialize_url_param( - "environmentName", self.ctx.args.environment_name, - required=True, - ), - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), - **self.serialize_url_param( - "serviceName", self.ctx.args.service_name, - required=True, - ), - **self.serialize_url_param( - "subscriptionId", self.ctx.subscription_id, - required=True, - ), - **self.serialize_url_param( - "workspaceName", self.ctx.args.workspace_name, - required=True, - ), - } - return parameters - - @property - def query_parameters(self): - parameters = { - **self.serialize_query_param( - "api-version", "2024-03-01", - required=True, - ), - } - return parameters - - def on_200(self, session): - pass - - -class _HeadHelper: - """Helper class for Head""" - - -__all__ = ["Head"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_list.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_list.py index 158e9480dfe..e9a9ec010f5 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_list.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_list.py @@ -53,6 +53,7 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The name of the API Center service.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -63,6 +64,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -184,7 +186,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _schema_on_200.value = AAZListType( - flags={"read_only": True}, + flags={"required": True, "read_only": True}, ) value = cls._schema_on_200.value @@ -198,7 +200,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _element.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) _element.system_data = AAZObjectType( serialized_name="systemData", @@ -209,7 +211,7 @@ def _build_schema_on_200(cls): ) properties = cls._schema_on_200.value.Element.properties - properties.custom_properties = AAZObjectType( + properties.custom_properties = AAZFreeFormDictType( serialized_name="customProperties", ) properties.description = AAZStrType() diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_show.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_show.py index 7334504d1a9..a4fa6f3a605 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_show.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_show.py @@ -18,7 +18,7 @@ class Show(AAZCommand): """Get details of the environment. :example: Show environment details - az apic environment show -g api-center-test -s contosoeuap --name public + az apic environment show -g api-center-test -s contosoeuap --environment-id public """ _aaz_info = { @@ -44,12 +44,13 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.environment_name = AAZStrArg( - options=["--name", "--environment", "--environment-name"], - help="The name of the environment.", + _args_schema.environment_id = AAZStrArg( + options=["--environment-id"], + help="The id of the environment.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -63,6 +64,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -74,6 +76,7 @@ def _build_arguments_schema(cls, *args, **kwargs): id_part="child_name_1", default="default", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -127,7 +130,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "environmentName", self.ctx.args.environment_name, + "environmentName", self.ctx.args.environment_id, required=True, ), **self.serialize_url_param( @@ -193,7 +196,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _schema_on_200.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) _schema_on_200.system_data = AAZObjectType( serialized_name="systemData", @@ -204,7 +207,7 @@ def _build_schema_on_200(cls): ) properties = cls._schema_on_200.properties - properties.custom_properties = AAZObjectType( + properties.custom_properties = AAZFreeFormDictType( serialized_name="customProperties", ) properties.description = AAZStrType() diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_update.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_update.py index f10e33f301e..d5850e4198a 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_update.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/environment/_update.py @@ -15,10 +15,10 @@ "apic environment update", ) class Update(AAZCommand): - """Update new or updates existing environment. + """Update existing environment. :example: Update environment - az apic environment update -g api-center-test -s contosoeuap --name public --title "Public cloud" + az apic environment update -g api-center-test -s contosoeuap --environment-id public --title "Public cloud" """ _aaz_info = { @@ -46,12 +46,13 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "" _args_schema = cls._args_schema - _args_schema.environment_name = AAZStrArg( - options=["--name", "--environment", "--environment-name"], - help="The name of the environment.", + _args_schema.environment_id = AAZStrArg( + options=["--environment-id"], + help="The id of the environment.", required=True, id_part="child_name_2", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -65,6 +66,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -75,6 +77,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="child_name_1", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -83,7 +86,7 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "Properties" _args_schema = cls._args_schema - _args_schema.custom_properties = AAZObjectArg( + _args_schema.custom_properties = AAZFreeFormDictArg( options=["--custom-properties"], arg_group="Properties", help="The custom metadata defined for API catalog entities.", @@ -96,15 +99,16 @@ def _build_arguments_schema(cls, *args, **kwargs): help="Description.", nullable=True, ) - _args_schema.kind = AAZStrArg( - options=["--kind"], + _args_schema.type = AAZStrArg( + options=["--type"], arg_group="Properties", - help="Environment kind.", + help="Environment type.", enum={"development": "development", "production": "production", "staging": "staging", "testing": "testing"}, ) _args_schema.onboarding = AAZObjectArg( options=["--onboarding"], arg_group="Properties", + help="{developerPortalUri:['https://developer.contoso.com'],instructions:'instructions markdown'}", nullable=True, ) _args_schema.server = AAZObjectArg( @@ -126,6 +130,7 @@ def _build_arguments_schema(cls, *args, **kwargs): onboarding = cls._args_schema.onboarding onboarding.developer_portal_uri = AAZListArg( options=["developer-portal-uri"], + help="The location of the development portal", nullable=True, ) onboarding.instructions = AAZStrArg( @@ -142,6 +147,7 @@ def _build_arguments_schema(cls, *args, **kwargs): server = cls._args_schema.server server.management_portal_uri = AAZListArg( options=["management-portal-uri"], + help="The location of the management portal", nullable=True, ) server.type = AAZStrArg( @@ -217,7 +223,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "environmentName", self.ctx.args.environment_name, + "environmentName", self.ctx.args.environment_id, required=True, ), **self.serialize_url_param( @@ -308,7 +314,7 @@ def error_format(self): def url_parameters(self): parameters = { **self.serialize_url_param( - "environmentName", self.ctx.args.environment_name, + "environmentName", self.ctx.args.environment_id, required=True, ), **self.serialize_url_param( @@ -392,17 +398,21 @@ def _update_instance(self, instance): value=instance, typ=AAZObjectType ) - _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True, "client_flatten": True}}) properties = _builder.get(".properties") if properties is not None: - properties.set_prop("customProperties", AAZObjectType, ".custom_properties") + properties.set_prop("customProperties", AAZFreeFormDictType, ".custom_properties") properties.set_prop("description", AAZStrType, ".description") - properties.set_prop("kind", AAZStrType, ".kind", typ_kwargs={"flags": {"required": True}}) + properties.set_prop("kind", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}}) properties.set_prop("onboarding", AAZObjectType, ".onboarding") properties.set_prop("server", AAZObjectType, ".server") properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}}) + custom_properties = _builder.get(".properties.customProperties") + if custom_properties is not None: + custom_properties.set_anytype_elements(".") + onboarding = _builder.get(".properties.onboarding") if onboarding is not None: onboarding.set_prop("developerPortalUri", AAZListType, ".developer_portal_uri") @@ -457,7 +467,7 @@ def _build_schema_environment_read(cls, _schema): flags={"read_only": True}, ) environment_read.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) environment_read.system_data = AAZObjectType( serialized_name="systemData", @@ -468,7 +478,7 @@ def _build_schema_environment_read(cls, _schema): ) properties = _schema_environment_read.properties - properties.custom_properties = AAZObjectType( + properties.custom_properties = AAZFreeFormDictType( serialized_name="customProperties", ) properties.description = AAZStrType() diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/__cmd_group.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/__cmd_group.py similarity index 86% rename from src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/__cmd_group.py rename to src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/__cmd_group.py index b36b8f59458..4b11a3bd40d 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/__cmd_group.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/__cmd_group.py @@ -12,10 +12,10 @@ @register_command_group( - "apic metadata-schema", + "apic metadata", ) class __CMDGroup(AAZCommandGroup): - """Commands to manage Metadata Schemas in API Center + """Commands to manage metadata schemas in API Center """ pass diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/__init__.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/__init__.py similarity index 90% rename from src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/__init__.py rename to src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/__init__.py index 6d0e5820c01..a4fefa7cd42 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/__init__.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/__init__.py @@ -11,8 +11,7 @@ from .__cmd_group import * from ._create import * from ._delete import * -from ._export_metadata_schema import * -from ._head import * +from ._export import * from ._list import * from ._show import * from ._update import * diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_create.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_create.py similarity index 84% rename from src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_create.py rename to src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_create.py index 44833b8ee3a..8b4a1e1c749 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_create.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_create.py @@ -12,13 +12,16 @@ @register_command( - "apic metadata-schema create", + "apic metadata create", ) class Create(AAZCommand): - """Create new or updates existing metadata schema. + """Create a new metadata schema or update an existing metadata schema. - :example: Create schema - az az apic metadata-schema create --resource-group api-center-test --service-name contoso --name "test1" --schema '{\"type\":\"string\", \"title\":\"First name\", \"pattern\": \"^[a-zA-Z0-9]+$\"}' + :example: Create metadata example 1 + az apic metadata create --resource-group api-center-test --service-name contoso --name "test1" --schema '{\"type\":\"string\", \"title\":\"First name\", \"pattern\": \"^[a-zA-Z0-9]+$\"}' --assignments '[{entity:api,required:true,deprecated:false}]' + + :example: Create metadata example 2 + az apic metadata create --resource-group api-center-test --service-name contoso --name testregion --schema '{\"type\":\"string\",\"title\":\"testregion\",\"oneOf\":[{\"const\":\"Region1\",\"description\":\"\"},{\"const\":\"Region2\",\"description\":\"\"},{\"const\":\"Region3\",\"description\":\"\"}]}' --assignments '[{entity:api,required:true,deprecated:false},{entity:environment,required:true,deprecated:false}]' """ _aaz_info = { @@ -49,6 +52,7 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The name of the metadata schema.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -61,6 +65,7 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The name of the API Center service.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -69,22 +74,25 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "Properties" _args_schema = cls._args_schema - _args_schema.assigned_to = AAZListArg( - options=["--assigned-to"], + _args_schema.assignments = AAZListArg( + options=["--assignments"], arg_group="Properties", + help="Defines the assignment scope for the custom metadata, e.g. \"[{entity:api,required:true,deprecated:false}]\". The available entity values are: api, deployment, environment.", ) _args_schema.schema = AAZStrArg( options=["--schema"], arg_group="Properties", help="JSON schema defining the type.", + required=True, ) - assigned_to = cls._args_schema.assigned_to - assigned_to.Element = AAZObjectArg() + assignments = cls._args_schema.assignments + assignments.Element = AAZObjectArg() - _element = cls._args_schema.assigned_to.Element + _element = cls._args_schema.assignments.Element _element.deprecated = AAZBoolArg( options=["deprecated"], + help="Deprecated assignment", ) _element.entity = AAZStrArg( options=["entity"], @@ -93,6 +101,7 @@ def _build_arguments_schema(cls, *args, **kwargs): ) _element.required = AAZBoolArg( options=["required"], + help="Required assignment", ) return cls._args_schema @@ -190,11 +199,11 @@ def content(self): typ=AAZObjectType, typ_kwargs={"flags": {"required": True, "client_flatten": True}} ) - _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True, "client_flatten": True}}) properties = _builder.get(".properties") if properties is not None: - properties.set_prop("assignedTo", AAZListType, ".assigned_to") + properties.set_prop("assignedTo", AAZListType, ".assignments") properties.set_prop("schema", AAZStrType, ".schema", typ_kwargs={"flags": {"required": True}}) assigned_to = _builder.get(".properties.assignedTo") @@ -234,7 +243,7 @@ def _build_schema_on_200_201(cls): flags={"read_only": True}, ) _schema_on_200_201.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) _schema_on_200_201.system_data = AAZObjectType( serialized_name="systemData", diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_delete.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_delete.py similarity index 93% rename from src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_delete.py rename to src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_delete.py index f43943f8e96..47cc9e44922 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_delete.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_delete.py @@ -12,17 +12,17 @@ @register_command( - "apic metadata-schema delete", + "apic metadata delete", confirmation="Are you sure you want to perform this operation?", ) class Delete(AAZCommand): """Delete specified metadata schema. :example: Delete Metadata Schema - az az apic metadata-schema delete --resource-group api-center-test --service-name contoso --name "test1" + az apic metadata delete --resource-group api-center-test --service-name contoso --name "test1" :example: Delete schema - az apic metadata-schema delete -g api-center-test -s contosoeuap --name "approver" + az apic metadata delete -g api-center-test -s contosoeuap --name "approver" """ _aaz_info = { @@ -54,6 +54,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="child_name_1", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -67,6 +68,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_export_metadata_schema.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_export.py similarity index 89% rename from src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_export_metadata_schema.py rename to src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_export.py index c70a73a0aea..18478e3aa6a 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_export_metadata_schema.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_export.py @@ -12,19 +12,19 @@ @register_command( - "apic metadata-schema export-metadata-schema", + "apic metadata export", ) -class ExportMetadataSchema(AAZCommand): - """Exports the effective metadata schema. +class Export(AAZCommand): + """Exports the metadata schema. :example: Export Metadata Schema assigned to api - az apic metadata-schema export-metadata-schema -g api-center-test -s contosoeuap --assigned-to api --file-name filepath + az apic metadata export -g api-center-test -s contosoeuap --assignments api --file-name filename.json :example: Export Metadata Schema assigned to deployment - az apic metadata-schema export-metadata-schema -g api-center-test -s contosoeuap --assigned-to deployment --file-name filepath + az apic metadata export -g api-center-test -s contosoeuap --assignments deployment --file-name filename.json :example: Export Metadata Schema assigned to environment - az apic metadata-schema export-metadata-schema -g api-center-test -s contosoeuap --assigned-to environment --file-name filepath + az apic metadata export -g api-center-test -s contosoeuap --assignments environment --file-name filename.json """ _aaz_info = { @@ -60,6 +60,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -68,8 +69,8 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "Payload" _args_schema = cls._args_schema - _args_schema.assigned_to = AAZStrArg( - options=["--assigned-to"], + _args_schema.assignments = AAZStrArg( + options=["--assignments"], arg_group="Payload", help="An entity the metadata schema is requested for.", enum={"api": "api", "deployment": "deployment", "environment": "environment"}, @@ -182,7 +183,7 @@ def content(self): typ=AAZObjectType, typ_kwargs={"flags": {"required": True, "client_flatten": True}} ) - _builder.set_prop("assignedTo", AAZStrType, ".assigned_to") + _builder.set_prop("assignedTo", AAZStrType, ".assignments") return self.serialize_content(_content_value) @@ -210,8 +211,8 @@ def _build_schema_on_200(cls): return cls._schema_on_200 -class _ExportMetadataSchemaHelper: - """Helper class for ExportMetadataSchema""" +class _ExportHelper: + """Helper class for Export""" -__all__ = ["ExportMetadataSchema"] +__all__ = ["Export"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_list.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_list.py similarity index 96% rename from src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_list.py rename to src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_list.py index 9c37ddd3c5a..8b744c096c9 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_list.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_list.py @@ -12,13 +12,13 @@ @register_command( - "apic metadata-schema list", + "apic metadata list", ) class List(AAZCommand): """List a collection of metadata schemas. :example: List schemas - az apic metadata-schema list -g api-center-test -s contosoeuap + az apic metadata list -g api-center-test -s contosoeuap """ _aaz_info = { @@ -53,6 +53,7 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The name of the API Center service.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -170,7 +171,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _schema_on_200.value = AAZListType( - flags={"read_only": True}, + flags={"required": True, "read_only": True}, ) value = cls._schema_on_200.value @@ -184,7 +185,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _element.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) _element.system_data = AAZObjectType( serialized_name="systemData", diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_show.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_show.py similarity index 95% rename from src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_show.py rename to src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_show.py index 1a5cc17a037..5a12c7efb83 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_show.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_show.py @@ -12,16 +12,16 @@ @register_command( - "apic metadata-schema show", + "apic metadata show", ) class Show(AAZCommand): """Get details of the metadata schema. :example: Show schema details 1 - az apic metadata-schema show -g api-center-test -s contosoeuap --name approver + az apic metadata show -g api-center-test -s contosoeuap --name approver :example: Show schema details 2 - az az apic metadata-schema show --resource-group api-center-test --service-name contoso --name "testchoices" + az apic metadata show --resource-group api-center-test --service-name contoso --name "testchoices" """ _aaz_info = { @@ -53,6 +53,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="child_name_1", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -66,6 +67,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -181,7 +183,7 @@ def _build_schema_on_200(cls): flags={"read_only": True}, ) _schema_on_200.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) _schema_on_200.system_data = AAZObjectType( serialized_name="systemData", diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_update.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_update.py similarity index 92% rename from src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_update.py rename to src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_update.py index 77987d7e7ff..8ffae8a1c21 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_update.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_update.py @@ -12,13 +12,13 @@ @register_command( - "apic metadata-schema update", + "apic metadata update", ) class Update(AAZCommand): - """Update new or updates existing metadata schema. + """Update existing metadata schema. :example: Update schema - az az apic metadata-schema update --resource-group api-center-test --service-name contoso --name "test1" --schema '{\"type\":\"string\", \"title\":\"Last name\", \"pattern\": \"^[a-zA-Z0-9]+$\"}' + az apic metadata update --resource-group api-center-test --service-name contoso --name "test1" --schema '{\"type\":\"string\", \"title\":\"Last name\", \"pattern\": \"^[a-zA-Z0-9]+$\"}' """ _aaz_info = { @@ -52,6 +52,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="child_name_1", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -65,6 +66,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), @@ -73,9 +75,10 @@ def _build_arguments_schema(cls, *args, **kwargs): # define Arg Group "Properties" _args_schema = cls._args_schema - _args_schema.assigned_to = AAZListArg( - options=["--assigned-to"], + _args_schema.assignments = AAZListArg( + options=["--assignments"], arg_group="Properties", + help="Defines the assignment scope for the custom metadata, e.g. \"[{entity:api,required:true,deprecated:false}]\". The available entity values are: api, deployment, environment.", nullable=True, ) _args_schema.schema = AAZStrArg( @@ -84,14 +87,15 @@ def _build_arguments_schema(cls, *args, **kwargs): help="YAML schema defining the type.", ) - assigned_to = cls._args_schema.assigned_to - assigned_to.Element = AAZObjectArg( + assignments = cls._args_schema.assignments + assignments.Element = AAZObjectArg( nullable=True, ) - _element = cls._args_schema.assigned_to.Element + _element = cls._args_schema.assignments.Element _element.deprecated = AAZBoolArg( options=["deprecated"], + help="Deprecated assignment", nullable=True, ) _element.entity = AAZStrArg( @@ -102,6 +106,7 @@ def _build_arguments_schema(cls, *args, **kwargs): ) _element.required = AAZBoolArg( options=["required"], + help="Required assignment", nullable=True, ) return cls._args_schema @@ -333,11 +338,11 @@ def _update_instance(self, instance): value=instance, typ=AAZObjectType ) - _builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}}) + _builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True, "client_flatten": True}}) properties = _builder.get(".properties") if properties is not None: - properties.set_prop("assignedTo", AAZListType, ".assigned_to") + properties.set_prop("assignedTo", AAZListType, ".assignments") properties.set_prop("schema", AAZStrType, ".schema", typ_kwargs={"flags": {"required": True}}) assigned_to = _builder.get(".properties.assignedTo") @@ -386,7 +391,7 @@ def _build_schema_metadata_schema_read(cls, _schema): flags={"read_only": True}, ) metadata_schema_read.properties = AAZObjectType( - flags={"client_flatten": True}, + flags={"required": True, "client_flatten": True}, ) metadata_schema_read.system_data = AAZObjectType( serialized_name="systemData", diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_head.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_head.py deleted file mode 100644 index e711e70be17..00000000000 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata_schema/_head.py +++ /dev/null @@ -1,148 +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( - "apic metadata-schema head", -) -class Head(AAZCommand): - """Checks if specified metadata schema exists. - """ - - _aaz_info = { - "version": "2024-03-01", - "resources": [ - ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.apicenter/services/{}/metadataschemas/{}", "2024-03-01"], - ] - } - - 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.metadata_schema_name = AAZStrArg( - options=["--name", "--metadata-schema", "--metadata-schema-name"], - help="The name of the metadata schema.", - required=True, - id_part="child_name_1", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - _args_schema.resource_group = AAZResourceGroupNameArg( - required=True, - ) - _args_schema.service_name = AAZStrArg( - options=["-s", "--service", "--service-name"], - help="The name of the API Center service.", - required=True, - id_part="name", - fmt=AAZStrArgFormat( - max_length=90, - min_length=1, - ), - ) - return cls._args_schema - - def _execute_operations(self): - self.pre_operations() - self.MetadataSchemasHead(ctx=self.ctx)() - self.post_operations() - - @register_callback - def pre_operations(self): - pass - - @register_callback - def post_operations(self): - pass - - class MetadataSchemasHead(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.ApiCenter/services/{serviceName}/metadataSchemas/{metadataSchemaName}", - **self.url_parameters - ) - - @property - def method(self): - return "HEAD" - - @property - def error_format(self): - return "MgmtErrorFormat" - - @property - def url_parameters(self): - parameters = { - **self.serialize_url_param( - "metadataSchemaName", self.ctx.args.metadata_schema_name, - required=True, - ), - **self.serialize_url_param( - "resourceGroupName", self.ctx.args.resource_group, - required=True, - ), - **self.serialize_url_param( - "serviceName", self.ctx.args.service_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", "2024-03-01", - required=True, - ), - } - return parameters - - def on_200(self, session): - pass - - -class _HeadHelper: - """Helper class for Head""" - - -__all__ = ["Head"] diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/__cmd_group.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/__cmd_group.py index fec2c155973..4ee8cd4d0a7 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/__cmd_group.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/__cmd_group.py @@ -15,7 +15,7 @@ "apic service", ) class __CMDGroup(AAZCommandGroup): - """API Center + """Manage an Azure API Center service instance. """ pass diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_create.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_create.py index 6214b70abc6..e335b3b67b8 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_create.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_create.py @@ -15,13 +15,13 @@ "apic service create", ) class Create(AAZCommand): - """Create an instance of Azure API Center service. + """Creates an instance or update an existing instance of an Azure API Center service. :example: Create service Example 1 - az apic create -g contoso-resources -s contoso -l centraluseuap + az apic service create -g contoso-resources -s contoso -l eastus :example: Create Service Example 2 - az apic create --resource-group contoso-resources --name contoso --locationcentraluseuap + az apic service create --resource-group contoso-resources --name contoso --location eastus """ _aaz_info = { @@ -55,29 +55,24 @@ def _build_arguments_schema(cls, *args, **kwargs): help="The name of the API Center service.", required=True, fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - - # define Arg Group "Payload" - - _args_schema = cls._args_schema _args_schema.identity = AAZObjectArg( options=["--identity"], - arg_group="Payload", - help="Managed service identity (system assigned and/or user assigned identities)", + help="The managed service identities assigned to this resource.", ) _args_schema.location = AAZResourceLocationArg( - arg_group="Payload", help="The geo-location where the resource lives", + required=True, fmt=AAZResourceLocationArgFormat( resource_group_arg="resource_group", ), ) _args_schema.tags = AAZDictArg( options=["--tags"], - arg_group="Payload", help="Resource tags.", ) @@ -191,7 +186,7 @@ def content(self): _content_value, _builder = self.new_content_builder( self.ctx.args, typ=AAZObjectType, - typ_kwargs={"flags": {"client_flatten": True}} + typ_kwargs={"flags": {"required": True, "client_flatten": True}} ) _builder.set_prop("identity", AAZObjectType, ".identity") _builder.set_prop("location", AAZStrType, ".location", typ_kwargs={"flags": {"required": True}}) diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_delete.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_delete.py index 59236ef72eb..f4721d57ba1 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_delete.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_delete.py @@ -16,7 +16,7 @@ confirmation="Are you sure you want to perform this operation?", ) class Delete(AAZCommand): - """Delete service + """Deletes an instance of an Azure API Center service. :example: Delete service az apic service delete -s contoso -g contoso-resources @@ -54,6 +54,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_import_from_apim.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_import_from_apim.py index f4454a6c98f..cac158f5f98 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_import_from_apim.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_import_from_apim.py @@ -15,10 +15,10 @@ "apic service import-from-apim", ) class ImportFromApim(AAZCommand): - """Imports from APIM instance. + """Imports APIs from an Azure API Management service instance. :example: Import From APIM - az apic service import-from-apim -g api-center-test --service-name contosoeuap --source-resource-ids '/subscriptions/a200340d-6b82-494d-9dbf-687ba6e33f9e/resourceGroups/servicegroup/providers/Microsoft.ApiManagement/service/contoso/apis/contosoapi + az apic service import-from-apim -g api-center-test --service-name contosoeuap --source-resource-ids '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/servicegroup/providers/Microsoft.ApiManagement/service/contoso/apis/contosoapi' """ _aaz_info = { @@ -54,6 +54,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_list.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_list.py index 178d5eef624..a97cd95b67e 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_list.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_list.py @@ -15,10 +15,10 @@ "apic service list", ) class List(AAZCommand): - """List services within an Azure subscription. + """Lists Azure API Center services within an Azure subscription. :example: List services in resource group - az apic list -g contoso-resources + az apic service list -g contoso-resources """ _aaz_info = { @@ -151,9 +151,10 @@ def _build_schema_on_200(cls): _schema_on_200 = cls._schema_on_200 _schema_on_200.next_link = AAZStrType( serialized_name="nextLink", + flags={"read_only": True}, ) _schema_on_200.value = AAZListType( - flags={"required": True}, + flags={"required": True, "read_only": True}, ) value = cls._schema_on_200.value @@ -323,9 +324,10 @@ def _build_schema_on_200(cls): _schema_on_200 = cls._schema_on_200 _schema_on_200.next_link = AAZStrType( serialized_name="nextLink", + flags={"read_only": True}, ) _schema_on_200.value = AAZListType( - flags={"required": True}, + flags={"required": True, "read_only": True}, ) value = cls._schema_on_200.value diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_show.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_show.py index cc45ab554f0..1ce84a58499 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_show.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_show.py @@ -15,7 +15,7 @@ "apic service show", ) class Show(AAZCommand): - """Show service details + """Show details of an Azure API Center service instance. :example: Show service details az apic service show -g contoso-resources -s contoso @@ -53,6 +53,7 @@ def _build_arguments_schema(cls, *args, **kwargs): required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), diff --git a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_update.py b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_update.py index e4790148069..8ad8a6df53d 100644 --- a/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_update.py +++ b/src/apic-extension/azext_apic_extension/aaz/latest/apic/service/_update.py @@ -15,10 +15,10 @@ "apic service update", ) class Update(AAZCommand): - """Update service + """Update an instance of an Azure API Center service. :example: Update service details - az apic update -g contoso-resources -s contoso + az apic service update -g contoso-resources -s contoso """ _aaz_info = { @@ -28,8 +28,6 @@ class Update(AAZCommand): ] } - AZ_SUPPORT_GENERIC_UPDATE = True - def _handler(self, command_args): super()._handler(command_args) self._execute_operations() @@ -51,41 +49,34 @@ def _build_arguments_schema(cls, *args, **kwargs): ) _args_schema.service_name = AAZStrArg( options=["-s", "--name", "--service", "--service-name"], - help="The name of the API Center service.", + help="The name of Azure API Center service.", required=True, id_part="name", fmt=AAZStrArgFormat( + pattern="^[a-zA-Z0-9-]{3,90}$", max_length=90, min_length=1, ), ) - - # define Arg Group "Payload" - - _args_schema = cls._args_schema _args_schema.identity = AAZObjectArg( options=["--identity"], - arg_group="Payload", - help="Managed service identity (system assigned and/or user assigned identities)", - nullable=True, + help="The managed service identities assigned to this resource.", ) _args_schema.tags = AAZDictArg( options=["--tags"], - arg_group="Payload", help="Resource tags.", - nullable=True, ) identity = cls._args_schema.identity identity.type = AAZStrArg( options=["type"], help="Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).", + required=True, enum={"None": "None", "SystemAssigned": "SystemAssigned", "SystemAssigned,UserAssigned": "SystemAssigned,UserAssigned", "UserAssigned": "UserAssigned"}, ) identity.user_assigned_identities = AAZDictArg( options=["user-assigned-identities"], help="The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.", - nullable=True, ) user_assigned_identities = cls._args_schema.identity.user_assigned_identities @@ -95,19 +86,12 @@ def _build_arguments_schema(cls, *args, **kwargs): ) tags = cls._args_schema.tags - tags.Element = AAZStrArg( - nullable=True, - ) + tags.Element = AAZStrArg() return cls._args_schema def _execute_operations(self): self.pre_operations() - self.ServicesGet(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) - self.ServicesCreateOrUpdate(ctx=self.ctx)() + self.ServicesUpdate(ctx=self.ctx)() self.post_operations() @register_callback @@ -118,19 +102,11 @@ def pre_operations(self): 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 ServicesGet(AAZHttpOperation): + class ServicesUpdate(AAZHttpOperation): CLIENT_TYPE = "MgmtClient" def __call__(self, *args, **kwargs): @@ -150,90 +126,7 @@ def url(self): @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( - "serviceName", self.ctx.args.service_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", "2024-03-01", - required=True, - ), - } - return parameters - - @property - def header_parameters(self): - parameters = { - **self.serialize_header_param( - "Accept", "application/json", - ), - } - return parameters - - def on_200(self, session): - data = self.deserialize_http_content(session) - self.ctx.set_var( - "instance", - data, - schema_builder=self._build_schema_on_200 - ) - - _schema_on_200 = None - - @classmethod - def _build_schema_on_200(cls): - if cls._schema_on_200 is not None: - return cls._schema_on_200 - - cls._schema_on_200 = AAZObjectType() - _UpdateHelper._build_schema_service_read(cls._schema_on_200) - - return cls._schema_on_200 - - class ServicesCreateOrUpdate(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, 201]: - return self.on_200_201(session) - - return self.on_error(session.http_response) - - @property - def url(self): - return self.client.format_url( - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiCenter/services/{serviceName}", - **self.url_parameters - ) - - @property - def method(self): - return "PUT" + return "PATCH" @property def error_format(self): @@ -283,41 +176,8 @@ def header_parameters(self): 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_service_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 + typ=AAZObjectType, + typ_kwargs={"flags": {"required": True, "client_flatten": True}} ) _builder.set_prop("identity", AAZObjectType, ".identity") _builder.set_prop("tags", AAZDictType, ".tags") @@ -335,132 +195,117 @@ def _update_instance(self, instance): if tags is not None: tags.set_elements(AAZStrType, ".") - return _instance_value - - class InstanceUpdateByGeneric(AAZGenericInstanceUpdateOperation): + return self.serialize_content(_content_value) - def __call__(self, *args, **kwargs): - self._update_instance_by_generic( - self.ctx.vars.instance, - self.ctx.generic_update_args + 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 -class _UpdateHelper: - """Helper class for Update""" + @classmethod + def _build_schema_on_200(cls): + if cls._schema_on_200 is not None: + return cls._schema_on_200 - _schema_service_read = None + cls._schema_on_200 = AAZObjectType() - @classmethod - def _build_schema_service_read(cls, _schema): - if cls._schema_service_read is not None: - _schema.id = cls._schema_service_read.id - _schema.identity = cls._schema_service_read.identity - _schema.location = cls._schema_service_read.location - _schema.name = cls._schema_service_read.name - _schema.properties = cls._schema_service_read.properties - _schema.system_data = cls._schema_service_read.system_data - _schema.tags = cls._schema_service_read.tags - _schema.type = cls._schema_service_read.type - return - - cls._schema_service_read = _schema_service_read = AAZObjectType() - - service_read = _schema_service_read - service_read.id = AAZStrType( - flags={"read_only": True}, - ) - service_read.identity = AAZObjectType() - service_read.location = AAZStrType( - flags={"required": True}, - ) - service_read.name = AAZStrType( - flags={"read_only": True}, - ) - service_read.properties = AAZObjectType( - flags={"client_flatten": True}, - ) - service_read.system_data = AAZObjectType( - serialized_name="systemData", - flags={"read_only": True}, - ) - service_read.tags = AAZDictType() - service_read.type = AAZStrType( - flags={"read_only": True}, - ) + _schema_on_200 = cls._schema_on_200 + _schema_on_200.id = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.identity = AAZObjectType() + _schema_on_200.location = AAZStrType( + flags={"required": True}, + ) + _schema_on_200.name = AAZStrType( + flags={"read_only": True}, + ) + _schema_on_200.properties = AAZObjectType( + flags={"client_flatten": 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}, + ) - identity = _schema_service_read.identity - identity.principal_id = AAZStrType( - serialized_name="principalId", - flags={"read_only": True}, - ) - identity.tenant_id = AAZStrType( - serialized_name="tenantId", - flags={"read_only": True}, - ) - identity.type = AAZStrType( - flags={"required": True}, - ) - identity.user_assigned_identities = AAZDictType( - serialized_name="userAssignedIdentities", - ) + identity = cls._schema_on_200.identity + identity.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) + identity.tenant_id = AAZStrType( + serialized_name="tenantId", + flags={"read_only": True}, + ) + identity.type = AAZStrType( + flags={"required": True}, + ) + identity.user_assigned_identities = AAZDictType( + serialized_name="userAssignedIdentities", + ) - user_assigned_identities = _schema_service_read.identity.user_assigned_identities - user_assigned_identities.Element = AAZObjectType( - nullable=True, - ) + user_assigned_identities = cls._schema_on_200.identity.user_assigned_identities + user_assigned_identities.Element = AAZObjectType( + nullable=True, + ) - _element = _schema_service_read.identity.user_assigned_identities.Element - _element.client_id = AAZStrType( - serialized_name="clientId", - flags={"read_only": True}, - ) - _element.principal_id = AAZStrType( - serialized_name="principalId", - flags={"read_only": True}, - ) + _element = cls._schema_on_200.identity.user_assigned_identities.Element + _element.client_id = AAZStrType( + serialized_name="clientId", + flags={"read_only": True}, + ) + _element.principal_id = AAZStrType( + serialized_name="principalId", + flags={"read_only": True}, + ) - properties = _schema_service_read.properties - properties.data_api_hostname = AAZStrType( - serialized_name="dataApiHostname", - flags={"read_only": True}, - ) - properties.provisioning_state = AAZStrType( - serialized_name="provisioningState", - flags={"read_only": True}, - ) + properties = cls._schema_on_200.properties + properties.data_api_hostname = AAZStrType( + serialized_name="dataApiHostname", + flags={"read_only": True}, + ) + properties.provisioning_state = AAZStrType( + serialized_name="provisioningState", + flags={"read_only": True}, + ) - system_data = _schema_service_read.system_data - system_data.created_at = AAZStrType( - serialized_name="createdAt", - ) - system_data.created_by = AAZStrType( - serialized_name="createdBy", - ) - system_data.created_by_type = AAZStrType( - serialized_name="createdByType", - ) - system_data.last_modified_at = AAZStrType( - serialized_name="lastModifiedAt", - ) - system_data.last_modified_by = AAZStrType( - serialized_name="lastModifiedBy", - ) - system_data.last_modified_by_type = AAZStrType( - serialized_name="lastModifiedByType", - ) + system_data = cls._schema_on_200.system_data + system_data.created_at = AAZStrType( + serialized_name="createdAt", + ) + system_data.created_by = AAZStrType( + serialized_name="createdBy", + ) + system_data.created_by_type = AAZStrType( + serialized_name="createdByType", + ) + system_data.last_modified_at = AAZStrType( + serialized_name="lastModifiedAt", + ) + system_data.last_modified_by = AAZStrType( + serialized_name="lastModifiedBy", + ) + system_data.last_modified_by_type = AAZStrType( + serialized_name="lastModifiedByType", + ) + + tags = cls._schema_on_200.tags + tags.Element = AAZStrType() - tags = _schema_service_read.tags - tags.Element = AAZStrType() - - _schema.id = cls._schema_service_read.id - _schema.identity = cls._schema_service_read.identity - _schema.location = cls._schema_service_read.location - _schema.name = cls._schema_service_read.name - _schema.properties = cls._schema_service_read.properties - _schema.system_data = cls._schema_service_read.system_data - _schema.tags = cls._schema_service_read.tags - _schema.type = cls._schema_service_read.type + return cls._schema_on_200 + + +class _UpdateHelper: + """Helper class for Update""" __all__ = ["Update"] diff --git a/src/apic-extension/azext_apic_extension/azext_metadata.json b/src/apic-extension/azext_apic_extension/azext_metadata.json index 24862c32571..916deb3b5c2 100644 --- a/src/apic-extension/azext_apic_extension/azext_metadata.json +++ b/src/apic-extension/azext_apic_extension/azext_metadata.json @@ -1,4 +1,4 @@ { "azext.isPreview": true, - "azext.minCliCoreVersion": "2.51.0" + "azext.minCliCoreVersion": "2.57.0" } \ No newline at end of file diff --git a/src/apic-extension/azext_apic_extension/command_patches.py b/src/apic-extension/azext_apic_extension/command_patches.py new file mode 100644 index 00000000000..4a12609b527 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/command_patches.py @@ -0,0 +1,209 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +# This file patches the commands generated by aaz to provide expected user experience per product design +# Always use aaz to update the commands if it's possible +from .aaz.latest.apic.api import ( + Create as CreateAPI, + Delete as DeleteAPI, + List as ListAPI, + Show as ShowAPI, + Update as UpdateAPI +) +from .aaz.latest.apic.api.definition import ( + Create as CreateAPIDefinition, + Delete as DeleteAPIDefinition, + ExportSpecification as ExportAPIDefinition, + ImportSpecification as ImportAPIDefinition, + List as ListAPIDefinition, + Show as ShowAPIDefinition, + Update as UpdateAPIDefinition +) +from .aaz.latest.apic.api.version import ( + Create as CreateAPIVersion, + Delete as DeleteAPIVersion, + List as ListAPIVersion, + Show as ShowAPIVersion, + Update as UpdateAPIVersion +) +from .aaz.latest.apic.api.deployment import ( + Create as CreateAPIDeployment, + Delete as DeleteAPIDeployment, + List as ListAPIDeployment, + Show as ShowAPIDeployment, + Update as UpdateAPIDeployment +) +from .aaz.latest.apic.environment import ( + Create as CreateEnvironment, + Delete as DeleteEnvironment, + List as ListEnvironment, + Show as ShowEnvironment, + Update as UpdateEnvironment +) +from .aaz.latest.apic.metadata import ( + Create as CreateMetadata, + Export as ExportMetadata +) +from .aaz.latest.apic.service import ImportFromApim + + +class DefaultWorkspaceParameter: + # pylint: disable=too-few-public-methods + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + # pylint: disable=protected-access + args_schema = super()._build_arguments_schema(*args, **kwargs) + args_schema.workspace_name._required = False + args_schema.workspace_name._registered = False + return args_schema + + def pre_operations(self): + args = self.ctx.args + args.workspace_name = "default" + + +# `az apic api` commands +class CreateAPIExtension(DefaultWorkspaceParameter, CreateAPI): + pass + + +class DeleteAPIExtension(DefaultWorkspaceParameter, DeleteAPI): + pass + + +class ListAPIExtension(DefaultWorkspaceParameter, ListAPI): + pass + + +class ShowAPIExtension(DefaultWorkspaceParameter, ShowAPI): + pass + + +class UpdateAPIExtension(DefaultWorkspaceParameter, UpdateAPI): + pass + + +# `az apic api definition` commands +class CreateAPIDefinitionExtension(DefaultWorkspaceParameter, CreateAPIDefinition): + pass + + +class DeleteAPIDefinitionExtension(DefaultWorkspaceParameter, DeleteAPIDefinition): + pass + + +class ExportAPIDefinitionExtension(DefaultWorkspaceParameter, ExportAPIDefinition): + pass + + +class ImportAPIDefinitionExtension(DefaultWorkspaceParameter, ImportAPIDefinition): + pass + + +class ListAPIDefinitionExtension(DefaultWorkspaceParameter, ListAPIDefinition): + pass + + +class ShowAPIDefinitionExtension(DefaultWorkspaceParameter, ShowAPIDefinition): + pass + + +class UpdateAPIDefinitionExtension(DefaultWorkspaceParameter, UpdateAPIDefinition): + pass + + +# `az apic api version` commands +class CreateAPIVersionExtension(DefaultWorkspaceParameter, CreateAPIVersion): + pass + + +class DeleteAPIVersionExtension(DefaultWorkspaceParameter, DeleteAPIVersion): + pass + + +class ListAPIVersionExtension(DefaultWorkspaceParameter, ListAPIVersion): + pass + + +class ShowAPIVersionExtension(DefaultWorkspaceParameter, ShowAPIVersion): + pass + + +class UpdateAPIVersionExtension(DefaultWorkspaceParameter, UpdateAPIVersion): + pass + + +# `az apic api deployment` commands +class CreateAPIDeploymentExtension(DefaultWorkspaceParameter, CreateAPIDeployment): + pass + + +class DeleteAPIDeploymentExtension(DefaultWorkspaceParameter, DeleteAPIDeployment): + pass + + +class ListAPIDeploymentExtension(DefaultWorkspaceParameter, ListAPIDeployment): + pass + + +class ShowAPIDeploymentExtension(DefaultWorkspaceParameter, ShowAPIDeployment): + pass + + +class UpdateAPIDeploymentExtension(DefaultWorkspaceParameter, UpdateAPIDeployment): + pass + + +# `az apic environment` commands +class CreateEnvironmentExtension(DefaultWorkspaceParameter, CreateEnvironment): + pass + + +class DeleteEnvironmentExtension(DefaultWorkspaceParameter, DeleteEnvironment): + pass + + +class ListEnvironmentExtension(DefaultWorkspaceParameter, ListEnvironment): + pass + + +class ShowEnvironmentExtension(DefaultWorkspaceParameter, ShowEnvironment): + pass + + +class UpdateEnvironmentExtension(DefaultWorkspaceParameter, UpdateEnvironment): + pass + + +# `az apic metadata commands` +class CreateMetadataExtension(CreateMetadata): + # pylint: disable=too-few-public-methods + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + # pylint: disable=protected-access + args_schema = super()._build_arguments_schema(*args, **kwargs) + args_schema.assignments._required = True + return args_schema + + +class ExportMetadataExtension(ExportMetadata): + # pylint: disable=too-few-public-methods + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + # pylint: disable=protected-access + args_schema = super()._build_arguments_schema(*args, **kwargs) + args_schema.assignments._required = True + return args_schema + + +# `az apic service commands` +class ImportFromApimExtension(ImportFromApim): + # pylint: disable=too-few-public-methods + @classmethod + def _build_arguments_schema(cls, *args, **kwargs): + # pylint: disable=protected-access + args_schema = super()._build_arguments_schema(*args, **kwargs) + args_schema.source_resource_ids._required = True + return args_schema diff --git a/src/apic-extension/azext_apic_extension/commands.py b/src/apic-extension/azext_apic_extension/commands.py index c4ea801b8de..5d1def463a7 100644 --- a/src/apic-extension/azext_apic_extension/commands.py +++ b/src/apic-extension/azext_apic_extension/commands.py @@ -16,13 +16,13 @@ from .custom import UpdateMetadataSchemaExtension -def load_command_table(self, _): # pylint: disable=unused-argument +def load_custom_commands(self, _): # pylint: disable=unused-argument with self.command_group('apic api definition') as g: self.command_table['apic api definition import-specification'] = ImportSpecificationExtension(loader=self) self.command_table['apic api definition export-specification'] = ExportSpecificationExtension(loader=self) - with self.command_group('apic metadata-schema') as g: - self.command_table['apic metadata-schema create'] = CreateMetadataSchemaExtension(loader=self) - self.command_table['apic metadata-schema update'] = UpdateMetadataSchemaExtension(loader=self) - self.command_table['apic metadata-schema export-metadata-schema'] = ExportMetadataSchemaExtension(loader=self) + with self.command_group('apic metadata') as g: + self.command_table['apic metadata create'] = CreateMetadataSchemaExtension(loader=self) + self.command_table['apic metadata update'] = UpdateMetadataSchemaExtension(loader=self) + self.command_table['apic metadata export'] = ExportMetadataSchemaExtension(loader=self) with self.command_group('apic api') as g: - g.custom_command("register", "register_apic") + g.custom_command("register", "register_apic", is_preview=True) diff --git a/src/apic-extension/azext_apic_extension/custom.py b/src/apic-extension/azext_apic_extension/custom.py index b9d015ded75..3003b8ace29 100644 --- a/src/apic-extension/azext_apic_extension/custom.py +++ b/src/apic-extension/azext_apic_extension/custom.py @@ -13,20 +13,21 @@ import os import sys import json +import yaml import requests from knack.log import get_logger import chardet from azure.cli.core.aaz._arg import AAZStrArg -from .aaz.latest.apic.api.definition import ImportSpecification -from .aaz.latest.apic.api.definition import ExportSpecification -from .aaz.latest.apic.metadata_schema import Create -from .aaz.latest.apic.metadata_schema import Update -from .aaz.latest.apic.metadata_schema import ExportMetadataSchema +from .command_patches import ImportAPIDefinitionExtension +from .command_patches import ExportAPIDefinitionExtension +from .command_patches import CreateMetadataExtension +from .command_patches import ExportMetadataExtension +from .aaz.latest.apic.metadata import Update as UpdateMetadataSchema logger = get_logger(__name__) -class ImportSpecificationExtension(ImportSpecification): +class ImportSpecificationExtension(ImportAPIDefinitionExtension): @classmethod def _build_arguments_schema(cls, *args, **kwargs): args_schema = super()._build_arguments_schema(*args, **kwargs) @@ -39,6 +40,7 @@ def _build_arguments_schema(cls, *args, **kwargs): return args_schema def pre_operations(self): + super().pre_operations() args = self.ctx.args data = None value = None @@ -50,10 +52,19 @@ def pre_operations(self): result = chardet.detect(data) encoding = result['encoding'] - with open(str(args.source_profile), 'r', encoding=encoding) as f: - data = json.load(f) - if data: - value = json.dumps(data) + if str(args.source_profile).endswith('.yaml') or str(args.source_profile).endswith('.yml'): + with open(str(args.source_profile), 'r', encoding=encoding) as f: + content = f.read() + data = yaml.safe_load(content) + if data: + value = content + + if (str(args.source_profile).endswith('.json')): + with open(str(args.source_profile), 'r', encoding=encoding) as f: + content = f.read() + data = json.loads(content) + if data: + value = content # If any of the fields are None, get them from self.args if value is None: @@ -71,7 +82,7 @@ def pre_operations(self): 'Please use --format "url" to import the specification from a URL for size greater than 3 mb.') -class ExportSpecificationExtension(ExportSpecification): +class ExportSpecificationExtension(ExportAPIDefinitionExtension): @classmethod def _build_arguments_schema(cls, *args, **kwargs): @@ -123,7 +134,7 @@ def writeResultsToFile(self, results, file_name): f.write(results) -class CreateMetadataSchemaExtension(Create): +class CreateMetadataSchemaExtension(CreateMetadataExtension): @classmethod def _build_arguments_schema(cls, *args, **kwargs): args_schema = super()._build_arguments_schema(*args, **kwargs) @@ -164,7 +175,7 @@ def pre_operations(self): self.ctx.args.schema = value -class UpdateMetadataSchemaExtension(Update): +class UpdateMetadataSchemaExtension(UpdateMetadataSchema): @classmethod def _build_arguments_schema(cls, *args, **kwargs): args_schema = super()._build_arguments_schema(*args, **kwargs) @@ -205,7 +216,7 @@ def pre_operations(self): self.ctx.args.schema = value -class ExportMetadataSchemaExtension(ExportMetadataSchema): +class ExportMetadataSchemaExtension(ExportMetadataExtension): @classmethod def _build_arguments_schema(cls, *args, **kwargs): @@ -269,14 +280,22 @@ def register_apic(cmd, api_location, resource_group, service_name, environment_n encoding = result['encoding'] # TODO - read other file types later - with open(str(api_location), 'r', encoding=encoding) as f: - data = json.load(f) - if data: - value = json.dumps(data) + if str(api_location).endswith('.yaml') or str(api_location).endswith('.yml'): + with open(str(api_location), 'r', encoding=encoding) as f: + content = f.read() + data = yaml.safe_load(content) + if data: + value = content + if (str(api_location).endswith('.json')): + with open(str(api_location), 'r', encoding=encoding) as f: + content = f.read() + data = json.loads(content) + if data: + value = content # If we could not read the file, return error if value is None: - logger.error('Could not load json file') + logger.error('Could not load spec file') return # Check if the first field is 'swagger', 'openapi', or something else and get the definition name and version @@ -295,9 +314,9 @@ def register_apic(cmd, api_location, resource_group, service_name, environment_n info = data['info'] if info: # Create API and Create API Version - extracted_api_name = info.get('title', 'Default API').replace(" ", "-").lower() + extracted_api_name = _generate_api_id(info.get('title', 'Default-API')).lower() extracted_api_description = info.get('description', 'API Description') - extracted_api_summary = info.get('summary', extracted_api_description) + extracted_api_summary = info.get('summary', str(extracted_api_description)[:200]) extracted_api_title = info.get('title', 'API Title').replace(" ", "-").lower() extracted_api_version = info.get('version', 'v1').replace(".", "-").lower() extracted_api_version_title = info.get('version', 'v1').replace(".", "-").lower() @@ -348,13 +367,13 @@ def register_apic(cmd, api_location, resource_group, service_name, environment_n from .aaz.latest.apic.api import Create as CreateAPI api_args = { - 'api_name': extracted_api_name, + 'api_id': extracted_api_name, 'resource_group': resource_group, 'service_name': service_name, 'workspace_name': 'default', 'title': extracted_api_title, 'summary': extracted_api_summary, - 'kind': extracted_api_kind, + 'type': extracted_api_kind, 'contacts': contacts, 'license': extracted_api_license, 'terms_of_service': extracted_api_terms_of_service, @@ -369,10 +388,10 @@ def register_apic(cmd, api_location, resource_group, service_name, environment_n from .aaz.latest.apic.api.version import Create as CreateAPIVersion api_version_args = { - 'api_name': extracted_api_name, + 'api_id': extracted_api_name, 'resource_group': resource_group, 'service_name': service_name, - 'version_name': extracted_api_version, + 'version_id': extracted_api_version, 'workspace_name': 'default', 'lifecycle_stage': 'design', # TODO: Extract from spec or not pass. was it required? 'title': extracted_api_version_title @@ -385,12 +404,12 @@ def register_apic(cmd, api_location, resource_group, service_name, environment_n from .aaz.latest.apic.api.definition import Create as CreateAPIDefinition api_definition_args = { - 'api_name': extracted_api_name, + 'api_id': extracted_api_name, 'resource_group': resource_group, 'service_name': service_name, - 'version_name': extracted_api_version, + 'version_id': extracted_api_version, 'workspace_name': 'default', - 'definition_name': extracted_definition_name, + 'definition_id': extracted_definition_name, 'title': extracted_definition_name, # TODO Extract from spec 'description': extracted_api_description, # TODO Extract from spec } @@ -411,9 +430,9 @@ def register_apic(cmd, api_location, resource_group, service_name, environment_n 'resource_group': resource_group, 'service_name': service_name, 'workspace_name': 'default', - 'api_name': extracted_api_name, - 'version_name': extracted_api_version, - 'definition_name': extracted_definition_name, + 'api_id': extracted_api_name, + 'version_id': extracted_api_version, + 'definition_id': extracted_definition_name, 'format': 'inline', 'specification': specification_details, # TODO write the correct spec object 'source_profile': api_location @@ -434,7 +453,7 @@ def register_apic(cmd, api_location, resource_group, service_name, environment_n 'resource_group': resource_group, 'service_name': service_name, 'workspace_name': 'default', - 'environment_name': environment_name + 'environment_id': environment_name } getEnvironmentResults = GetEnvironment(cli_ctx=cmd.cli_ctx)(command_args=environment_args) @@ -461,8 +480,8 @@ def register_apic(cmd, api_location, resource_group, service_name, environment_n 'resource_group': resource_group, 'service_name': service_name, 'workspace_name': 'default', - 'api_name': extracted_api_name, - 'deployment_name': extracted_deployment_name, + 'api_id': extracted_api_name, + 'deployment_id': extracted_deployment_name, 'description': extracted_deployment_description, 'title': extracted_deployment_title, 'definition_id': extracted_definition_id, @@ -474,3 +493,12 @@ def register_apic(cmd, api_location, resource_group, service_name, environment_n CreateAPIDeployment(cli_ctx=cmd.cli_ctx)(command_args=api_deployment_args) logger.warning('API deployment was created successfully') + + +def _generate_api_id(title: str) -> str: + import re + # Remove invalid characters + api_id = re.sub('[^a-zA-Z0-9-]', '', title) + # Remove leading and trailing hyphens + api_id = api_id.strip('-') + return api_id diff --git a/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_create_service.yaml b/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_create_service.yaml new file mode 100644 index 00000000000..d129757d097 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_create_service.yaml @@ -0,0 +1,102 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic service create + Connection: + - keep-alive + ParameterSetName: + - -g --name + User-Agent: + - AZURECLI/2.58.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.19045-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/clirg000001?api-version=2022-09-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001","name":"clirg000001","type":"Microsoft.Resources/resourceGroups","location":"eastus","tags":{"product":"azurecli","cause":"automation","test":"test_create_service","date":"2024-04-25T05:46:56Z","module":"apic-extension"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '355' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 25 Apr 2024 05:47:05 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-msedge-ref: + - 'Ref A: FE43C70CE25C4A45A1D2A1F80B75D642 Ref B: MAA201060515053 Ref C: 2024-04-25T05:47:05Z' + status: + code: 200 + message: OK +- request: + body: '{"location": "eastus"}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic service create + Connection: + - keep-alive + Content-Length: + - '22' + Content-Type: + - application/json + ParameterSetName: + - -g --name + User-Agent: + - AZURECLI/2.58.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.19045-SP0) + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/cli000002?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services","location":"eastus","sku":{"name":"None"},"properties":{"dataApiHostname":"cli000002.data.eastus.azure-apicenter.ms","provisioningState":"InProgress"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/cli000002","name":"cli000002","tags":{},"systemData":{"createdAt":"2024-04-25T05:47:09.4451661Z","lastModifiedAt":"2024-04-25T05:47:09.4451443Z"}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01, 2024-03-15-preview + cache-control: + - no-cache + content-length: + - '460' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 25 Apr 2024 05:47:09 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + x-msedge-ref: + - 'Ref A: FCC75A00C6FC415899D258A5FA326F29 Ref B: MAA201060513053 Ref C: 2024-04-25T05:47:07Z' + x-powered-by: + - ASP.NET + status: + code: 201 + message: Created +version: 1 diff --git a/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_delete_service.yaml b/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_delete_service.yaml new file mode 100644 index 00000000000..67d235a859e --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_delete_service.yaml @@ -0,0 +1,46 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - apic service delete + Connection: + - keep-alive + Content-Length: + - '0' + ParameterSetName: + - -g -s --yes + User-Agent: + - AZURECLI/2.58.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.19045-SP0) + method: DELETE + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002a?api-version=2024-03-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + date: + - Thu, 25 Apr 2024 05:47:24 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-deletes: + - '14999' + x-msedge-ref: + - 'Ref A: 50BEA56C7F8448F2A9889B4487CB4C1A Ref B: MAA201060516021 Ref C: 2024-04-25T05:47:25Z' + status: + code: 204 + message: No Content +version: 1 diff --git a/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_show_service.yaml b/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_show_service.yaml new file mode 100644 index 00000000000..d202042a462 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_show_service.yaml @@ -0,0 +1,54 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic service show + Connection: + - keep-alive + ParameterSetName: + - -g -s + User-Agent: + - AZURECLI/2.58.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.19045-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services","location":"eastus","sku":{"name":"None"},"properties":{"dataApiHostname":"clitest000002.data.eastus.azure-apicenter.ms","provisioningState":"InProgress"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002","name":"clitest000002","tags":{},"systemData":{"createdAt":"2024-04-25T05:47:09.5042261Z","lastModifiedAt":"2024-04-25T05:47:09.504214Z"}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01, 2024-03-15-preview + cache-control: + - no-cache + content-length: + - '471' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 25 Apr 2024 05:47:12 GMT + etag: + - 7400a819-0000-0100-0000-6629ee5d0000 + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-msedge-ref: + - 'Ref A: 892D1AB7D8DF4DA799DBA03E5FCDD07E Ref B: MAA201060515031 Ref C: 2024-04-25T05:47:11Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +version: 1 diff --git a/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_update_service.yaml b/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_update_service.yaml new file mode 100644 index 00000000000..56a95425d41 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/recordings/test_update_service.yaml @@ -0,0 +1,60 @@ +interactions: +- request: + body: '{"tags": {"test": "value"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - apic service update + Connection: + - keep-alive + Content-Length: + - '27' + Content-Type: + - application/json + ParameterSetName: + - -g -s --tags + User-Agent: + - AZURECLI/2.58.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.19045-SP0) + method: PATCH + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002?api-version=2024-03-01 + response: + body: + string: '{"type":"Microsoft.ApiCenter/services","location":"eastus","identity":{"type":"None"},"sku":{"name":"None"},"properties":{"dataApiHostname":"clitest000002.data.eastus.azure-apicenter.ms"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002","name":"clitest000002","tags":{"test":"value"},"systemData":{"lastModifiedAt":"2024-04-25T05:47:34.2771576Z"}}' + headers: + api-supported-versions: + - 2023-07-01-preview, 2024-03-01, 2024-03-15-preview + cache-control: + - no-cache + content-length: + - '437' + content-type: + - application/json; charset=utf-8 + date: + - Thu, 25 Apr 2024 05:47:35 GMT + etag: + - 74005a1e-0000-0100-0000-6629ee760000 + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-cache: + - CONFIG_NOCACHE + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-msedge-ref: + - 'Ref A: DEF4CDC2694E41269679420F72147A72 Ref B: MAA201060516019 Ref C: 2024-04-25T05:47:32Z' + x-powered-by: + - ASP.NET + status: + code: 200 + message: OK +version: 1 diff --git a/src/apic-extension/azext_apic_extension/tests/latest/test_service_commands.py b/src/apic-extension/azext_apic_extension/tests/latest/test_service_commands.py new file mode 100644 index 00000000000..aaf52cd2fcf --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/test_service_commands.py @@ -0,0 +1,40 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk import ScenarioTest, ResourceGroupPreparer +from .utils import ApicServicePreparer + +class ServiceCommandsTests(ScenarioTest): + + @ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32) + def test_create_service(self, resource_group): + self.kwargs.update({ + 'name': self.create_random_name(prefix='cli', length=24), + 'rg': resource_group + }) + self.cmd('az apic service create -g {rg} --name {name}', checks=[ + self.check('name', '{name}'), + self.check('resourceGroup', '{rg}') + ]) + + @ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32) + @ApicServicePreparer() + def test_show_service(self): + self.cmd('az apic service show -g {rg} -s {s}', checks=[ + self.check('name', '{s}'), + self.check('resourceGroup', '{rg}') + ]) + + @ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32) + @ApicServicePreparer() + def test_update_service(self): + self.cmd('az apic service update -g {rg} -s {s} --tags "{{test:value}}"', checks=[ + self.check('tags.test', 'value') + ]) + + @ResourceGroupPreparer(name_prefix="clirg", location='eastus', random_name_length=32) + @ApicServicePreparer() + def test_delete_service(self): + self.cmd('az apic service delete -g {rg} -s {s}a --yes') \ No newline at end of file diff --git a/src/apic-extension/azext_apic_extension/tests/latest/utils.py b/src/apic-extension/azext_apic_extension/tests/latest/utils.py new file mode 100644 index 00000000000..0f38f1860b8 --- /dev/null +++ b/src/apic-extension/azext_apic_extension/tests/latest/utils.py @@ -0,0 +1,37 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.testsdk.preparers import NoTrafficRecordingPreparer, SingleValueReplacer, get_dummy_cli, CliTestError, ResourceGroupPreparer + +class ApicServicePreparer(NoTrafficRecordingPreparer, SingleValueReplacer): + def __init__(self, name_prefix='clitest', length=24, + parameter_name='service_name', resource_group_parameter_name='resource_group', key='s'): + super(ApicServicePreparer, self).__init__(name_prefix, length) + self.cli_ctx = get_dummy_cli() + self.resource_group_parameter_name = resource_group_parameter_name + self.parameter_name = parameter_name + self.key = key + + def create_resource(self, name, **kwargs): + group = self._get_resource_group(**kwargs) + + template = 'az apic service create --name {} -g {}' + print(template.format(name, group)) + self.live_only_execute(self.cli_ctx, template.format(name, group)) + + self.test_class_instance.kwargs[self.key] = name + return {self.parameter_name: name} + + def remove_resource(self, name, **kwargs): + # ResourceGroupPreparer will delete everything + pass + + def _get_resource_group(self, **kwargs): + try: + return kwargs.get(self.resource_group_parameter_name) + except KeyError: + template = 'To create a API Center service a resource group is required. Please add ' \ + 'decorator @{} in front of this preparer.' + raise CliTestError(template.format(ResourceGroupPreparer.__name__)) diff --git a/src/apic-extension/setup.py b/src/apic-extension/setup.py index 142b37e1f11..5e8d95d7556 100644 --- a/src/apic-extension/setup.py +++ b/src/apic-extension/setup.py @@ -10,7 +10,7 @@ # HISTORY.rst entry. -VERSION = '1.0.0b4' +VERSION = '1.0.0b5' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers