Skip to content

Commit 25109ba

Browse files
authored
apic-extension 1.0.0b5 release (Azure#7432)
* fix: --title --kind --custom-property parameters (#1) * feat: support yaml file in register command (#3) * fix: workspace parameter should not be required (#2) * style: fix lint issues (#6) * chore: update codeowner for apic-extension (#5) * feat: revert changes to min cli version (#4) * feat: resolve comments to CLI experience (#10) * feat: mark "apic api register" command as preview (#13) * feat: remove --terms-of-service parameter (#12) * feat: remove --workspace-name parameter (#11) * feat: support python 3.8 and 3.9 (#14) * feat: fix command descriptions (#17) * tests: add test cases for 'apic service' commands (#16) * feat: Use 03-01 spec from azure-rest-api-specs repo to regenerate CLI (#19) * fix: CLI errors (#20) * fix: import error when run CLI command * fix: no workspace name error when run import specification command * feat: mark some parameters as required (#21) * feat: mark --assignments parameter required for metadata commands * doc: update sample commands * feat: mark --source-resource-ids parameter as required for import-from-apim command * doc: update description for import-from-apim command * feat: bump version to 1.0.0b5 and update changelog (#18) * build: fix ci (#22) * style: fix style warnings * test:fix test cases * fix: service update command failure (#28) * doc: fix command samples (#30) * doc: update changelog per feedback (#29) * doc: remove extra spaces in register command help message (#34) * doc: update api definition and metadata command samples (Azure#36)
1 parent cb7abc8 commit 25109ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1309
-1764
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
/src/subscription/ @wilcobmsft
1616

17-
/src/apic-extension/ @arpishahmsft
17+
/src/apic-extension/ @arpishahmsft @blackchoey @adashen
1818

1919
/src/alias/ @Juliehzl
2020

src/apic-extension/HISTORY.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ Release History
55

66
1.0.0b5
77
+++++
8-
* Remove: All portal commands as it should not be exposed to customers.
8+
* Add: Support yaml file for `az apic api register` command.
9+
* 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.
10+
* Update: Introduction to parameter constraints to ensure that valid values are provided.
11+
* Update: Minimum Azure CLI version requirement is updated to 2.57.
12+
* Fix: Various bug fixes for lastest preview version.
13+
* Remove: Portal commands as we don't support this capability any longer.
14+
* Remove: `--workspace-name` and `--terms-of-service` parameters are removed as they are not expected to be exposed.
15+
* Remove: `head` commands in each command group are removed.
916

1017
1.0.0b4
1118
+++++

src/apic-extension/README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ az apic service delete --resource-group api-center-test --service-name contosoeu
3535
az apic service delete --resource-group arpi-test-rg1 -s apictestcli3
3636
```
3737

38-
Show Workspace Example
39-
```
40-
Az apic workspace show -g api-center-test -s contosoeuap --name devdiv
41-
```
42-
4338
Create API Examples
4439
```
4540
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 -
5045

5146
Update API Examples
5247
```
53-
az apic api update -g api-center-test -s contosoeuap --name echo-api --summary "Basic REST API service" -w default
48+
az apic api update -g api-center-test -s contosoeuap --name echo-api --summary "Basic REST API service"
5449
```
5550
```
56-
az apic api update --resource-group api-center-test -s contosoeuap --name echo-api --summary "Basic REST API service" --workspace-name default
51+
az apic api update --resource-group api-center-test -s contosoeuap --name echo-api --summary "Basic REST API service"
5752
```
5853

5954
LIST Api Example
@@ -90,10 +85,10 @@ az apic api version create --resource-group api-center-test --service-name conto
9085

9186
UPDATE Api Version Examples
9287
```
93-
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
88+
Az apic api version update -g api-center-test -s contosoeuap --api-name echo-api --name 2023-01-01 --title "2023-01-01"
9489
```
9590
```
96-
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
91+
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"
9792
```
9893

9994
LIST Api Version Examples
@@ -127,7 +122,7 @@ az apic api definition create -g api-center-test -s contosoeuap --api-name echo-
127122

128123
UPDATE API Definition Example
129124
```
130-
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
125+
az apic api definition update -g api-center-test -s contosoeuap --api-name echo-api --version 2023-01-01 --name "openapi" --title "OpenAPI"
131126
```
132127

133128
SHOW API Definition Example
@@ -209,7 +204,7 @@ Where envcreate1.json contains
209204

210205
UPDATE Environment
211206
```
212-
az apic environment update -g api-center-test -s contosoeuap --name public --title "Public cloud" -w default
207+
az apic environment update -g api-center-test -s contosoeuap --name public --title "Public cloud"
213208
```
214209

215210
LIST Environment
@@ -283,4 +278,5 @@ az apic metadata-schema export-metadata-schema -g api-center-test -s contosoeuap
283278
Register API or Quick Add
284279
```
285280
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
281+
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
286282
```

src/apic-extension/azext_apic_extension/__init__.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
#
55
# Code generated by aaz-dev-tools
66
# --------------------------------------------------------------------------------------------
7+
from typing import Type
78

89
from azure.cli.core import AzCommandsLoader
10+
from azure.cli.core.aaz import AAZCommand
911
from azext_apic_extension._help import helps # pylint: disable=unused-import
1012

1113

@@ -19,7 +21,7 @@ def __init__(self, cli_ctx=None):
1921
custom_command_type=custom_command_type)
2022

2123
def load_command_table(self, args):
22-
from azext_apic_extension.commands import load_command_table
24+
from azext_apic_extension.commands import load_custom_commands
2325
from azure.cli.core.aaz import load_aaz_command_table
2426
try:
2527
from . import aaz
@@ -31,12 +33,28 @@ def load_command_table(self, args):
3133
aaz_pkg_name=aaz.__name__,
3234
args=args
3335
)
34-
load_command_table(self, args)
36+
load_command_patches(self)
37+
load_custom_commands(self, args)
3538
return self.command_table
3639

3740
def load_arguments(self, command):
3841
from azext_apic_extension._params import load_arguments
3942
load_arguments(self, command)
4043

4144

45+
def is_aaz_command_subclass(value: Type) -> bool:
46+
return isinstance(value, type) and issubclass(value, AAZCommand)
47+
48+
49+
def load_command_patches(loader: AzCommandsLoader) -> None:
50+
import inspect
51+
from azext_apic_extension import command_patches
52+
53+
for _, value in inspect.getmembers(command_patches):
54+
# Only load custom commands from the command_patches module
55+
if is_aaz_command_subclass(value) and value.__module__ == command_patches.__name__:
56+
if value.AZ_NAME:
57+
loader.command_table[value.AZ_NAME] = value(loader=loader)
58+
59+
4260
COMMAND_LOADER_CLS = ApicExtensionCommandsLoader

src/apic-extension/azext_apic_extension/_help.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
helps['apic api register'] = """
1414
type: command
15-
short-summary: Single Command for registering api, api version, api definition, import spec, create deployment provided a spec file.
15+
short-summary: Registers a new API with version, definition, and associated deployments using the specification file as the source of truth.
1616
parameters:
1717
- name: --api-location -l
1818
type: string
19-
short-summary: Location of spec file .
19+
short-summary: Location of spec file.
2020
- name: --resource-group -g
2121
type: string
2222
short-summary: Resource group name.
@@ -30,4 +30,5 @@
3030
- name: Register api by providing spec file.
3131
text: |
3232
az apic api register -g api-center-test -s contosoeuap --api-location "examples/cli-examples/spec-examples/openai.json" --environment-name public
33+
az apic api register -g api-center-test -s contosoeuap --api-location "examples/cli-examples/spec-examples/openai.yml" --environment-name public
3334
"""

src/apic-extension/azext_apic_extension/aaz/latest/apic/api/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from .__cmd_group import *
1212
from ._create import *
1313
from ._delete import *
14-
from ._head import *
1514
from ._list import *
1615
from ._show import *
1716
from ._update import *

src/apic-extension/azext_apic_extension/aaz/latest/apic/api/_create.py

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
"apic api create",
1616
)
1717
class Create(AAZCommand):
18-
"""Create new or updates existing API.
18+
"""Register a new API or update an existing API.
1919
2020
:example: Create API
21-
az apic api create -g contoso-resources -s contoso --name echo-api --title "Echo API"
21+
az apic api create -g contoso-resources -s contoso --api-id echo-api --title "Echo API" --type REST
22+
23+
:example: Create API with custom properties
24+
az apic api create -g contoso-resources -s contoso --api-id echo-api --title "Echo API" --type REST --custom-properties '{\"public-facing\":true}'
2225
"""
2326

2427
_aaz_info = {
@@ -44,11 +47,12 @@ def _build_arguments_schema(cls, *args, **kwargs):
4447
# define Arg Group ""
4548

4649
_args_schema = cls._args_schema
47-
_args_schema.api_name = AAZStrArg(
48-
options=["--api", "--name", "--api-name"],
49-
help="The name of the API.",
50+
_args_schema.api_id = AAZStrArg(
51+
options=["--api-id"],
52+
help="The id of the API.",
5053
required=True,
5154
fmt=AAZStrArgFormat(
55+
pattern="^[a-zA-Z0-9-]{3,90}$",
5256
max_length=90,
5357
min_length=1,
5458
),
@@ -61,6 +65,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
6165
help="The name of the API Center service.",
6266
required=True,
6367
fmt=AAZStrArgFormat(
68+
pattern="^[a-zA-Z0-9-]{3,90}$",
6469
max_length=90,
6570
min_length=1,
6671
),
@@ -71,6 +76,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
7176
required=True,
7277
default="default",
7378
fmt=AAZStrArgFormat(
79+
pattern="^[a-zA-Z0-9-]{3,90}$",
7480
max_length=90,
7581
min_length=1,
7682
),
@@ -84,7 +90,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
8490
arg_group="Properties",
8591
help="The contact information for the API.",
8692
)
87-
_args_schema.custom_properties = AAZObjectArg(
93+
_args_schema.custom_properties = AAZFreeFormDictArg(
8894
options=["--custom-properties"],
8995
arg_group="Properties",
9096
help="The custom metadata defined for API catalog entities.",
@@ -103,10 +109,11 @@ def _build_arguments_schema(cls, *args, **kwargs):
103109
arg_group="Properties",
104110
help="Additional, external documentation for the API.",
105111
)
106-
_args_schema.kind = AAZStrArg(
107-
options=["--kind"],
112+
_args_schema.type = AAZStrArg(
113+
options=["--type"],
108114
arg_group="Properties",
109-
help="Kind of API. For example, REST or GraphQL.",
115+
help="Type of API.",
116+
required=True,
110117
enum={"graphql": "graphql", "grpc": "grpc", "rest": "rest", "soap": "soap", "webhook": "webhook", "websocket": "websocket"},
111118
)
112119
_args_schema.license = AAZObjectArg(
@@ -122,15 +129,11 @@ def _build_arguments_schema(cls, *args, **kwargs):
122129
max_length=200,
123130
),
124131
)
125-
_args_schema.terms_of_service = AAZObjectArg(
126-
options=["--terms-of-service"],
127-
arg_group="Properties",
128-
help="Terms of service for the API.",
129-
)
130132
_args_schema.title = AAZStrArg(
131133
options=["--title"],
132134
arg_group="Properties",
133135
help="API title.",
136+
required=True,
134137
fmt=AAZStrArgFormat(
135138
max_length=50,
136139
min_length=1,
@@ -212,16 +215,6 @@ def _build_arguments_schema(cls, *args, **kwargs):
212215
max_length=200,
213216
),
214217
)
215-
216-
terms_of_service = cls._args_schema.terms_of_service
217-
terms_of_service.url = AAZStrArg(
218-
options=["url"],
219-
help="URL pointing to the terms of service.",
220-
required=True,
221-
fmt=AAZStrArgFormat(
222-
max_length=200,
223-
),
224-
)
225218
return cls._args_schema
226219

227220
def _execute_operations(self):
@@ -271,7 +264,7 @@ def error_format(self):
271264
def url_parameters(self):
272265
parameters = {
273266
**self.serialize_url_param(
274-
"apiName", self.ctx.args.api_name,
267+
"apiName", self.ctx.args.api_id,
275268
required=True,
276269
),
277270
**self.serialize_url_param(
@@ -322,18 +315,17 @@ def content(self):
322315
typ=AAZObjectType,
323316
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
324317
)
325-
_builder.set_prop("properties", AAZObjectType, typ_kwargs={"flags": {"client_flatten": True}})
318+
_builder.set_prop("properties", AAZObjectType, ".", typ_kwargs={"flags": {"required": True, "client_flatten": True}})
326319

327320
properties = _builder.get(".properties")
328321
if properties is not None:
329322
properties.set_prop("contacts", AAZListType, ".contacts")
330-
properties.set_prop("customProperties", AAZObjectType, ".custom_properties")
323+
properties.set_prop("customProperties", AAZFreeFormDictType, ".custom_properties")
331324
properties.set_prop("description", AAZStrType, ".description")
332325
properties.set_prop("externalDocumentation", AAZListType, ".external_documentation")
333-
properties.set_prop("kind", AAZStrType, ".kind", typ_kwargs={"flags": {"required": True}})
326+
properties.set_prop("kind", AAZStrType, ".type", typ_kwargs={"flags": {"required": True}})
334327
properties.set_prop("license", AAZObjectType, ".license")
335328
properties.set_prop("summary", AAZStrType, ".summary")
336-
properties.set_prop("termsOfService", AAZObjectType, ".terms_of_service")
337329
properties.set_prop("title", AAZStrType, ".title", typ_kwargs={"flags": {"required": True}})
338330

339331
contacts = _builder.get(".properties.contacts")
@@ -346,6 +338,10 @@ def content(self):
346338
_elements.set_prop("name", AAZStrType, ".name")
347339
_elements.set_prop("url", AAZStrType, ".url")
348340

341+
custom_properties = _builder.get(".properties.customProperties")
342+
if custom_properties is not None:
343+
custom_properties.set_anytype_elements(".")
344+
349345
external_documentation = _builder.get(".properties.externalDocumentation")
350346
if external_documentation is not None:
351347
external_documentation.set_elements(AAZObjectType, ".")
@@ -362,10 +358,6 @@ def content(self):
362358
license.set_prop("name", AAZStrType, ".name")
363359
license.set_prop("url", AAZStrType, ".url")
364360

365-
terms_of_service = _builder.get(".properties.termsOfService")
366-
if terms_of_service is not None:
367-
terms_of_service.set_prop("url", AAZStrType, ".url", typ_kwargs={"flags": {"required": True}})
368-
369361
return self.serialize_content(_content_value)
370362

371363
def on_200_201(self, session):
@@ -393,7 +385,7 @@ def _build_schema_on_200_201(cls):
393385
flags={"read_only": True},
394386
)
395387
_schema_on_200_201.properties = AAZObjectType(
396-
flags={"client_flatten": True},
388+
flags={"required": True, "client_flatten": True},
397389
)
398390
_schema_on_200_201.system_data = AAZObjectType(
399391
serialized_name="systemData",
@@ -405,7 +397,7 @@ def _build_schema_on_200_201(cls):
405397

406398
properties = cls._schema_on_200_201.properties
407399
properties.contacts = AAZListType()
408-
properties.custom_properties = AAZObjectType(
400+
properties.custom_properties = AAZFreeFormDictType(
409401
serialized_name="customProperties",
410402
)
411403
properties.description = AAZStrType()
@@ -418,6 +410,7 @@ def _build_schema_on_200_201(cls):
418410
properties.license = AAZObjectType()
419411
properties.lifecycle_stage = AAZStrType(
420412
serialized_name="lifecycleStage",
413+
flags={"read_only": True},
421414
)
422415
properties.summary = AAZStrType()
423416
properties.terms_of_service = AAZObjectType(

0 commit comments

Comments
 (0)