Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: rename parameter names to align with other Azure CLI command experience #52

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/apic-extension/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ Release History
1.0.0
++++++
* Update: Redesigned `az apic service import-from-apim` command to provide easier way to specify APIM instance
* Update: Renamed `az apic service *` commands to `az apic *` commands
* Update: Renamed `--name/--service/--service-name/-s` parameters in `az apic *` commands to `--name/-n`
* Update: Renamed `--service/--service-name/-s` parameters in each sub commands to `--service-name/-n`
* Update: Renamed `--metadata-schema/--metadata-schema-name/--name` parameters in `az apic metadata *` commands to `--metadata-name`
* Update: Renamed `--environment-name` parameter in `az apic api register` command to `--environment-id`
* Fix: API title created by register command is not same with provided spec
* Fix: Error not thrown when import spec with >3MB file
* Fix: Error when register API with long description in spec
Expand Down
10 changes: 5 additions & 5 deletions src/apic-extension/azext_apic_extension/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
- name: --resource-group -g
type: string
short-summary: Resource group name.
- name: --service -s
- name: --service-name -n
type: string
short-summary: APICenter Catalog or Service name.
- name: --environment-name -e
- name: --environment-id
type: string
short-summary: Name of environment created before.
short-summary: Id of environment created before.
examples:
- 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
az apic api register -g api-center-test -n contosoeuap --api-location "examples/cli-examples/spec-examples/openai.json" --environment-id public
az apic api register -g api-center-test -n contosoeuap --api-location "examples/cli-examples/spec-examples/openai.yml" --environment-id public
"""
8 changes: 4 additions & 4 deletions src/apic-extension/azext_apic_extension/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ def load_arguments(self, _): # pylint: disable=unused-argument
)
c.argument(
"service_name",
options_list=['--service', '-s'],
options_list=['--service-name', '-n'],
help="Service name",
required=True,
)
c.argument(
"environment_name",
options_list=['--environment-name', '-e'],
help="Environemnt name",
"environment_id",
options_list=['--environment-id'],
help="Environemnt id",
required=False
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@
# flake8: noqa

from .__cmd_group import *
from ._create import *
from ._delete import *
from ._import_from_apim import *
from ._list import *
from ._show import *
from ._update import *
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@


@register_command(
"apic service create",
"apic create",
)
class Create(AAZCommand):
"""Creates an instance or update an existing instance of an Azure API Center service.

:example: Create service Example 1
az apic service create -g contoso-resources -s contoso -l eastus
az apic create -g contoso-resources -n contoso -l eastus

:example: Create Service Example 2
az apic service create --resource-group contoso-resources --name contoso --location eastus
az apic create --resource-group contoso-resources --name contoso --location eastus
"""

_aaz_info = {
Expand Down Expand Up @@ -50,8 +50,8 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
_args_schema.service_name = AAZStrArg(
options=["-s", "--name", "--service", "--service-name"],
_args_schema.name = AAZStrArg(
options=["-n", "--name"],
help="The name of the API Center service.",
required=True,
fmt=AAZStrArgFormat(
Expand Down Expand Up @@ -149,7 +149,7 @@ def url_parameters(self):
required=True,
),
**self.serialize_url_param(
"serviceName", self.ctx.args.service_name,
"serviceName", self.ctx.args.name,
required=True,
),
**self.serialize_url_param(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@


@register_command(
"apic service delete",
"apic delete",
confirmation="Are you sure you want to perform this operation?",
)
class Delete(AAZCommand):
"""Deletes an instance of an Azure API Center service.

:example: Delete service
az apic service delete -s contoso -g contoso-resources
az apic delete -n contoso -g contoso-resources
"""

_aaz_info = {
Expand Down Expand Up @@ -48,8 +48,8 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
_args_schema.service_name = AAZStrArg(
options=["-s", "--name", "--service", "--service-name"],
_args_schema.name = AAZStrArg(
options=["-n", "--name"],
help="The name of the API Center service.",
required=True,
id_part="name",
Expand Down Expand Up @@ -110,7 +110,7 @@ def url_parameters(self):
required=True,
),
**self.serialize_url_param(
"serviceName", self.ctx.args.service_name,
"serviceName", self.ctx.args.name,
required=True,
),
**self.serialize_url_param(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@


@register_command(
"apic service import-from-apim",
"apic import-from-apim",
)
class ImportFromApim(AAZCommand):
"""Imports APIs from an Azure API Management service instance.

:example: Import all APIs from APIM in same resource group
az apic service import-from-apim -g api-center-test --service-name contoso-apic --apim-name contoso-apim --apim-apis *
az apic import-from-apim -g api-center-test --service-name contoso-apic --apim-name contoso-apim --apim-apis *

:example: Import selected APIs from APIM in same resource group
az apic service import-from-apim -g api-center-test --service-name contoso-apic --apim-name contoso-apim --apim-apis [echo,foo]
az apic import-from-apim -g api-center-test --service-name contoso-apic --apim-name contoso-apim --apim-apis [echo,foo]

:example: Import all APIs from APIM in another subscription and resource group
az apic service import-from-apim -g api-center-test --service-name contoso-apic --apim-subscription 00000000-0000-0000-0000-000000000000 --apim-resource-group apim-rg --apim-name contoso-apim --apim-apis *
az apic import-from-apim -g api-center-test --service-name contoso-apic --apim-subscription 00000000-0000-0000-0000-000000000000 --apim-resource-group apim-rg --apim-name contoso-apim --apim-apis *
"""

_aaz_info = {
Expand Down Expand Up @@ -55,7 +55,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
required=True,
)
_args_schema.service_name = AAZStrArg(
options=["-s", "--service", "--service-name"],
options=["-n", "--service-name"],
help="The name of Azure API Center service.",
required=True,
id_part="name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@


@register_command(
"apic service list",
"apic list",
)
class List(AAZCommand):
"""Lists Azure API Center services within an Azure subscription.

:example: List services in resource group
az apic service list -g contoso-resources
az apic list -g contoso-resources
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@


@register_command(
"apic service show",
"apic show",
)
class Show(AAZCommand):
"""Show details of an Azure API Center service instance.

:example: Show service details
az apic service show -g contoso-resources -s contoso
az apic show -g contoso-resources -n contoso
"""

_aaz_info = {
Expand Down Expand Up @@ -47,8 +47,8 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
_args_schema.service_name = AAZStrArg(
options=["-s", "--name", "--service", "--service-name"],
_args_schema.name = AAZStrArg(
options=["-n", "--name"],
help="The name of the API Center service.",
required=True,
id_part="name",
Expand Down Expand Up @@ -111,7 +111,7 @@ def url_parameters(self):
required=True,
),
**self.serialize_url_param(
"serviceName", self.ctx.args.service_name,
"serviceName", self.ctx.args.name,
required=True,
),
**self.serialize_url_param(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@


@register_command(
"apic service update",
"apic update",
)
class Update(AAZCommand):
"""Update an instance of an Azure API Center service.

:example: Update service details
az apic service update -g contoso-resources -s contoso
az apic update -g contoso-resources -n contoso
"""

_aaz_info = {
Expand Down Expand Up @@ -47,9 +47,9 @@ def _build_arguments_schema(cls, *args, **kwargs):
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)
_args_schema.service_name = AAZStrArg(
options=["-s", "--name", "--service", "--service-name"],
help="The name of Azure API Center service.",
_args_schema.name = AAZStrArg(
options=["-n", "--name"],
help="The name of the API Center service.",
required=True,
id_part="name",
fmt=AAZStrArgFormat(
Expand Down Expand Up @@ -140,7 +140,7 @@ def url_parameters(self):
required=True,
),
**self.serialize_url_param(
"serviceName", self.ctx.args.service_name,
"serviceName", self.ctx.args.name,
required=True,
),
**self.serialize_url_param(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class Create(AAZCommand):
"""Register a new API or update an existing API.

:example: Create API
az apic api create -g contoso-resources -s contoso --api-id echo-api --title "Echo API" --type REST
az apic api create -g contoso-resources -n 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}'
az apic api create -g contoso-resources -n contoso --api-id echo-api --title "Echo API" --type REST --custom-properties '{\"public-facing\":true}'
"""

_aaz_info = {
Expand Down Expand Up @@ -61,8 +61,8 @@ def _build_arguments_schema(cls, *args, **kwargs):
required=True,
)
_args_schema.service_name = AAZStrArg(
options=["-s", "--service", "--service-name"],
help="The name of the API Center service.",
options=["-n", "--service-name"],
help="The name of Azure API Center service.",
required=True,
fmt=AAZStrArgFormat(
pattern="^[a-zA-Z0-9-]{3,90}$",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Delete(AAZCommand):
"""Delete specified API.

:example: Delete API
az apic api delete -g contoso-resources -s contoso --api-id echo-api
az apic api delete -g contoso-resources -n contoso --api-id echo-api
"""

_aaz_info = {
Expand Down Expand Up @@ -60,8 +60,8 @@ def _build_arguments_schema(cls, *args, **kwargs):
required=True,
)
_args_schema.service_name = AAZStrArg(
options=["-s", "--service", "--service-name"],
help="The name of the API Center service.",
options=["-n", "--service-name"],
help="The name of Azure API Center service.",
required=True,
id_part="name",
fmt=AAZStrArgFormat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class List(AAZCommand):
"""List a collection of APIs.

:example: List APIs
az apic api list -g contoso-resources -s contoso
az apic api list -g contoso-resources -n contoso

:example: List APIs with filter
az apic api list -g contoso-resources -s contoso --filter "kind eq 'rest'"
az apic api list -g contoso-resources -n contoso --filter "kind eq 'rest'"
"""

_aaz_info = {
Expand Down Expand Up @@ -52,8 +52,8 @@ def _build_arguments_schema(cls, *args, **kwargs):
required=True,
)
_args_schema.service_name = AAZStrArg(
options=["-s", "--service", "--service-name"],
help="The name of the API Center service.",
options=["-n", "--service-name"],
help="The name of Azure API Center service.",
required=True,
fmt=AAZStrArgFormat(
pattern="^[a-zA-Z0-9-]{3,90}$",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 --api-id echo-api
az apic api show -g contoso-resources -n contoso --api-id echo-api
"""

_aaz_info = {
Expand Down Expand Up @@ -59,8 +59,8 @@ def _build_arguments_schema(cls, *args, **kwargs):
required=True,
)
_args_schema.service_name = AAZStrArg(
options=["-s", "--service", "--service-name"],
help="The name of the API Center service.",
options=["-n", "--service-name"],
help="The name of Azure API Center service.",
required=True,
id_part="name",
fmt=AAZStrArgFormat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class Update(AAZCommand):
"""Update existing API.

:example: Update API
az apic api update -g contoso-resources -s contoso --api-id echo-api --summary "Basic REST API service"
az apic api update -g contoso-resources -n 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}'
az apic api update -g contoso-resources -n contoso --api-id echo-api --custom-properties '{\"public-facing\":true}'
"""

_aaz_info = {
Expand Down Expand Up @@ -64,8 +64,8 @@ def _build_arguments_schema(cls, *args, **kwargs):
required=True,
)
_args_schema.service_name = AAZStrArg(
options=["-s", "--service", "--service-name"],
help="The name of the API Center service.",
options=["-n", "--service-name"],
help="The name of Azure API Center service.",
required=True,
id_part="name",
fmt=AAZStrArgFormat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Create(AAZCommand):
"""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-id echo-api --version-id 2023-01-01 --definition-id "openapi" --title "OpenAPI"
az apic api definition create -g api-center-test -n contosoeuap --api-id echo-api --version-id 2023-01-01 --definition-id "openapi" --title "OpenAPI"
"""

_aaz_info = {
Expand Down Expand Up @@ -68,8 +68,8 @@ def _build_arguments_schema(cls, *args, **kwargs):
required=True,
)
_args_schema.service_name = AAZStrArg(
options=["-s", "--service", "--service-name"],
help="The name of the API Center service.",
options=["-n", "--service-name"],
help="The name of Azure API Center service.",
required=True,
fmt=AAZStrArgFormat(
pattern="^[a-zA-Z0-9-]{3,90}$",
Expand Down
Loading
Loading