Skip to content

Commit d5be14f

Browse files
frankqianmsblackchoeyjukasper
authored
apic-extension 1.1.0 release (Azure#8118)
* build: add cicd pipeline (#7) * build: move update version logic to workflow (#8) * build: Run CI on multiple python version (Azure#38) * build: Run CI in Python 3.8-3.11 * build: remove pull request event for CI to avoid duplicate runs * refactor: add apic api update example * tests: add test case * fix: fix style * fix: fix test case * fix: fix test case * fix: fix test case & add recording * fix: remove bad command prefix * refactor: optimize test case code * refactor: remove duplicate example for apic create * fix: fix style * feat: add examples for create & update apic service with system assigned identity * fix: fix external doc extracting bug in spec * fix: remove extra print * fix: fix style * fix: fix style * fix: fix style * fix: fix style * tests: fix test case * refactor: remove external docs from tags * tests: update test case * refactor: remove summary setting in api register * feat: support custom metadata export only * fix: fix test case * tests: add test case * fix: fix arg type * refactor: add help example * fix: fix bad logic of link format * refactor: remove extra example * refactor: update example * doc: update 1.0.1 release history * refactor: change note style * fix: fix * fix: remove breaking change label * build: bump version to 1.1.0 * Update V1.1.0 history (Azure#71) * Update HISTORY.rst * Update HISTORY.rst * Update HISTORY.rst --------- Co-authored-by: Julia Kasper <[email protected]> * test: fix test cases * build: remove files to get ready for release --------- Co-authored-by: Chaoyi Yuan <[email protected]> Co-authored-by: Julia Kasper <[email protected]>
1 parent 4b1efb0 commit d5be14f

File tree

128 files changed

+2156
-1801
lines changed

Some content is hidden

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

128 files changed

+2156
-1801
lines changed

src/apic-extension/HISTORY.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,28 @@
33
Release History
44
===============
55

6+
1.1.0
7+
++++++++++++++++++
8+
9+
**New Features:**
10+
11+
* Added ``--custom-metadata-only`` parameter to ``az apic metadata export`` command.
12+
* Added single custom metadata update for ``az apic api update`` command.
13+
14+
**Updates:**
15+
16+
* Added example for ``az apic api update`` command.
17+
* Added examples with system assigned identity for ``az apic create`` and ``az apic update`` commands.
18+
19+
**Fixes:**
20+
21+
* Set external document correctly in ``az apic api register`` command.
22+
* Do not use API description as summary in ``az apic api register`` command.
23+
24+
**Removals:**
25+
26+
* Eliminated duplicate example for ``az apic create`` command.
27+
628
1.0.0
729
++++++++++++++++++
830
Potential Impact: The changes in this release, including the renaming of commands and parameters, may require changes to existing scripts and integrations. Please review the changes carefully and update your code accordingly.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
class Create(AAZCommand):
1818
"""Creates an instance or update an existing instance of an Azure API Center service.
1919
20-
:example: Create service Example 1
20+
:example: Create service Example
2121
az apic create -g contoso-resources -n contoso -l eastus
2222
23-
:example: Create Service Example 2
24-
az apic create --resource-group contoso-resources --name contoso --location eastus
23+
:example: Create Service With System Assigned Identity Example
24+
az apic create -g contoso-resources -n contoso -l eastus --identity '{type:systemassigned}'
2525
"""
2626

2727
_aaz_info = {

src/apic-extension/azext_apic_extension/aaz/latest/apic/_update.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ class Update(AAZCommand):
1919
2020
:example: Update service details
2121
az apic update -g contoso-resources -n contoso
22+
23+
:example: Update Service With System Assigned Identity Example
24+
az apic create -g contoso-resources -n contoso --identity '{type:systemassigned}'
2225
"""
2326

2427
_aaz_info = {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class Update(AAZCommand):
2222
2323
:example: Update custom properties
2424
az apic api update -g contoso-resources -n contoso --api-id echo-api --custom-properties '{\"public-facing\":true}'
25+
26+
:example: Update single custom metadata
27+
az apic api update -g contoso-resources -n contoso --api-id echo-api --set customProperties.internal=false
2528
"""
2629

2730
_aaz_info = {

src/apic-extension/azext_apic_extension/aaz/latest/apic/metadata/_export.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class Export(AAZCommand):
2525
2626
:example: Export Metadata Schema assigned to environment
2727
az apic metadata export -g api-center-test -n contosoeuap --assignments environment --file-name filename.json
28+
29+
:example: Export Custom Metadata Schema Only
30+
az apic metadata export -g api-center-test -n contosoeuap --assignments api --file-name filename.json --custom-metadata-only
2831
"""
2932

3033
_aaz_info = {

src/apic-extension/azext_apic_extension/custom.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from knack.log import get_logger
1919
from knack.util import CLIError
2020
import chardet
21-
from azure.cli.core.aaz._arg import AAZStrArg
21+
from azure.cli.core.aaz._arg import AAZStrArg, AAZBoolArg
2222
from .command_patches import ImportAPIDefinitionExtension
2323
from .command_patches import ExportAPIDefinitionExtension
2424
from .command_patches import ExportMetadataExtension
@@ -105,6 +105,12 @@ def _build_arguments_schema(cls, *args, **kwargs):
105105
required=True,
106106
registered=True
107107
)
108+
args_schema.custom_metadata_only = AAZBoolArg(
109+
options=["--custom-metadata-only"],
110+
help='Export only custom metadata.',
111+
required=False,
112+
blank=True
113+
)
108114
return args_schema
109115

110116
def _output(self, *args, **kwargs):
@@ -118,9 +124,14 @@ def _output(self, *args, **kwargs):
118124
if response_format == 'link':
119125
getReponse = requests.get(exportedResults, timeout=10)
120126
if getReponse.status_code == 200:
121-
exportedResults = getReponse.content.decode()
127+
content = json.loads(getReponse.content.decode())
128+
# Check if custom metadata only
129+
exportedResults = content.get('properties').get('customProperties', {}) if arguments.custom_metadata_only else content
122130
else:
123131
logger.error('Error while fetching the results from the link. Status code: %s', getReponse.status_code)
132+
else:
133+
# Check if custom metadata only
134+
exportedResults = json.loads(exportedResults).get('properties').get('customProperties', {}) if arguments.custom_metadata_only else exportedResults
124135

125136
if arguments.source_profile:
126137
try:
@@ -158,6 +169,7 @@ def register_apic(cmd, api_location, resource_group, service_name, environment_i
158169
encoding = result['encoding']
159170

160171
# TODO - read other file types later
172+
value = None
161173
if str(api_location).endswith('.yaml') or str(api_location).endswith('.yml'):
162174
with open(str(api_location), 'r', encoding=encoding) as f:
163175
content = f.read()
@@ -194,49 +206,42 @@ def register_apic(cmd, api_location, resource_group, service_name, environment_i
194206
# Create API and Create API Version
195207
extracted_api_name = _generate_api_id(info.get('title', 'Default-API')).lower()
196208
extracted_api_description = info.get('description', 'API Description')[:1000]
197-
extracted_api_summary = info.get('summary', str(extracted_api_description)[:200])
198209
extracted_api_title = info.get('title', 'API Title')
199210
extracted_api_version = info.get('version', 'v1').replace(".", "-").lower()
200211
extracted_api_version_title = info.get('version', 'v1').replace(".", "-").lower()
201212
# TODO -Create API Version lifecycle_stage
202213

203214
# Create API - Get the contact details from info in spec
215+
contacts = None
204216
contact = info.get('contact')
205217
if contact:
206218
extracted_api_contact_email = contact.get('email')
207219
extracted_api_contact_name = contact.get('name')
208220
extracted_api_contact_url = contact.get('url')
209221
contacts = [{'email': extracted_api_contact_email, 'name': extracted_api_contact_name, 'url': extracted_api_contact_url}]
210-
else:
211-
contacts = None
212222

213223
# Create API - Get the license details from info in spec
224+
extracted_api_license = None
214225
licenseDetails = info.get('license')
215226
if licenseDetails:
216227
extracted_api_license_identifier = licenseDetails.get('identifier')
217228
extracted_api_license_name = licenseDetails.get('name')
218229
extracted_api_license_url = licenseDetails.get('url')
219230
extracted_api_license = {'identifier': extracted_api_license_identifier, 'name': extracted_api_license_name, 'url': extracted_api_license_url}
220-
else:
221-
extracted_api_license = None
222231

223232
# Create API - Get the terms of service from info in spec
233+
extracted_api_terms_of_service = {'url': None}
224234
extracted_api_terms_of_service_value = info.get('termsOfService')
225235
if extracted_api_terms_of_service_value:
226236
extracted_api_terms_of_service = {'url': extracted_api_terms_of_service_value}
227-
else:
228-
extracted_api_terms_of_service = {'url': None}
229237

230-
# Create API - Get the external documentation from info in spec
231-
extracted_api_external_documentation = None
232-
external_documentation = info.get('externalDocumentation')
238+
# Create API - Get the external documentation in spec
239+
extracted_api_external_documentation = []
240+
external_documentation = data.get('externalDocs')
233241
if external_documentation:
234242
extracted_api_external_documentation_description = external_documentation.get('description')
235-
extracted_api_external_documentation_title = external_documentation.get('title')
236243
extracted_api_external_documentation_url = external_documentation.get('url')
237-
extracted_api_external_documentation = {'description': extracted_api_external_documentation_description, 'title': extracted_api_external_documentation_title, 'url': extracted_api_external_documentation_url}
238-
else:
239-
extracted_api_external_documentation = None
244+
extracted_api_external_documentation.append({'description': extracted_api_external_documentation_description, 'title': 'Title', 'url': extracted_api_external_documentation_url})
240245

241246
# TODO: Create API - custom-properties
242247
# "The custom metadata defined for API catalog entities. #1
@@ -250,7 +255,6 @@ def register_apic(cmd, api_location, resource_group, service_name, environment_i
250255
'service_name': service_name,
251256
'workspace_name': 'default',
252257
'title': extracted_api_title,
253-
'summary': extracted_api_summary,
254258
'type': extracted_api_kind,
255259
'contacts': contacts,
256260
'license': extracted_api_license,

src/apic-extension/azext_apic_extension/tests/latest/recordings/test_api_create.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,26 @@ interactions:
1717
ParameterSetName:
1818
- -g -n --api-id --title --type
1919
User-Agent:
20-
- AZURECLI/2.58.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.19045-SP0)
20+
- AZURECLI/2.63.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.22631-SP0)
2121
method: PUT
2222
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002/workspaces/default/apis/cli000003?api-version=2024-03-01
2323
response:
2424
body:
2525
string: '{"type":"Microsoft.ApiCenter/services/workspaces/apis","properties":{"title":"Echo
26-
API","kind":"rest","externalDocumentation":[],"contacts":[],"customProperties":{}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002/workspaces/default/apis/cli000003","name":"cli000003","systemData":{"createdAt":"2024-06-17T06:00:44.9963937Z","lastModifiedAt":"2024-06-17T06:00:44.9963921Z"}}'
26+
API","kind":"rest","externalDocumentation":[],"contacts":[],"customProperties":{}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002/workspaces/default/apis/cli000003","name":"cli000003","systemData":{"createdAt":"2024-10-09T08:17:25.8179858Z","lastModifiedAt":"2024-10-09T08:17:25.817985Z"}}'
2727
headers:
2828
api-supported-versions:
2929
- 2023-07-01-preview, 2024-03-01, 2024-03-15-preview
3030
cache-control:
3131
- no-cache
3232
content-length:
33-
- '464'
33+
- '463'
3434
content-type:
3535
- application/json; charset=utf-8
3636
date:
37-
- Mon, 17 Jun 2024 06:00:44 GMT
37+
- Wed, 09 Oct 2024 08:17:25 GMT
3838
etag:
39-
- da02dc98-0000-0100-0000-666fd10c0000
39+
- c1000958-0000-0100-0000-67063c150000
4040
expires:
4141
- '-1'
4242
pragma:
@@ -50,11 +50,11 @@ interactions:
5050
x-content-type-options:
5151
- nosniff
5252
x-ms-ratelimit-remaining-subscription-global-writes:
53-
- '2999'
53+
- '2997'
5454
x-ms-ratelimit-remaining-subscription-writes:
55-
- '199'
55+
- '197'
5656
x-msedge-ref:
57-
- 'Ref A: CC39E9193ED345698E8CB1312E168A5A Ref B: MAA201060515029 Ref C: 2024-06-17T06:00:43Z'
57+
- 'Ref A: BB7A57E9360D4BFE8C3879306BD2225E Ref B: MAA201060516049 Ref C: 2024-10-09T08:17:24Z'
5858
x-powered-by:
5959
- ASP.NET
6060
status:

src/apic-extension/azext_apic_extension/tests/latest/recordings/test_api_create_with_all_optional_params.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ interactions:
2222
- -g -n --api-id --title --type --contacts --custom-properties --description
2323
--external-documentation --license --summary
2424
User-Agent:
25-
- AZURECLI/2.58.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.19045-SP0)
25+
- AZURECLI/2.63.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.22631-SP0)
2626
method: PUT
2727
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002/workspaces/default/apis/cli000004?api-version=2024-03-01
2828
response:
2929
body:
3030
string: '{"type":"Microsoft.ApiCenter/services/workspaces/apis","properties":{"title":"test
3131
api","summary":"summary","description":"API description","kind":"rest","license":{"url":"example.com"},"externalDocumentation":[{"title":"onboarding
32-
docs","url":"example.com"}],"contacts":[{"name":"test","url":"example.com","email":"[email protected]"}],"customProperties":{"clitest000003":true}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002/workspaces/default/apis/cli000004","name":"cli000004","systemData":{"createdAt":"2024-06-17T06:01:05.6377877Z","lastModifiedAt":"2024-06-17T06:01:05.6377761Z"}}'
32+
docs","url":"example.com"}],"contacts":[{"name":"test","url":"example.com","email":"[email protected]"}],"customProperties":{"clitest000003":true}},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002/workspaces/default/apis/cli000004","name":"cli000004","systemData":{"createdAt":"2024-10-09T08:17:39.4819888Z","lastModifiedAt":"2024-10-09T08:17:39.4819877Z"}}'
3333
headers:
3434
api-supported-versions:
3535
- 2023-07-01-preview, 2024-03-01, 2024-03-15-preview
@@ -40,9 +40,9 @@ interactions:
4040
content-type:
4141
- application/json; charset=utf-8
4242
date:
43-
- Mon, 17 Jun 2024 06:01:05 GMT
43+
- Wed, 09 Oct 2024 08:17:39 GMT
4444
etag:
45-
- da020b9a-0000-0100-0000-666fd1210000
45+
- c1000259-0000-0100-0000-67063c230000
4646
expires:
4747
- '-1'
4848
pragma:
@@ -60,7 +60,7 @@ interactions:
6060
x-ms-ratelimit-remaining-subscription-writes:
6161
- '199'
6262
x-msedge-ref:
63-
- 'Ref A: 65463DBC175045639714FEB0384BB4EF Ref B: MAA201060513047 Ref C: 2024-06-17T06:01:04Z'
63+
- 'Ref A: 8CC55F75DDCB4F02AC5DFCC20C4B4EED Ref B: MAA201060515035 Ref C: 2024-10-09T08:17:38Z'
6464
x-powered-by:
6565
- ASP.NET
6666
status:

src/apic-extension/azext_apic_extension/tests/latest/recordings/test_api_delete.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interactions:
1515
ParameterSetName:
1616
- -g -n --api-id --yes
1717
User-Agent:
18-
- AZURECLI/2.58.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.19045-SP0)
18+
- AZURECLI/2.63.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.22631-SP0)
1919
method: DELETE
2020
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002/workspaces/default/apis/clitest000003?api-version=2024-03-01
2121
response:
@@ -27,7 +27,7 @@ interactions:
2727
cache-control:
2828
- no-cache
2929
date:
30-
- Mon, 17 Jun 2024 06:01:23 GMT
30+
- Wed, 09 Oct 2024 08:17:51 GMT
3131
expires:
3232
- '-1'
3333
pragma:
@@ -43,7 +43,7 @@ interactions:
4343
x-ms-ratelimit-remaining-subscription-global-deletes:
4444
- '2999'
4545
x-msedge-ref:
46-
- 'Ref A: 3F5C22E176E04C06916635DD0AF9C415 Ref B: MAA201060516009 Ref C: 2024-06-17T06:01:22Z'
46+
- 'Ref A: CF464C6696BD4F96B3BDA9F59C318C4C Ref B: MAA201060515049 Ref C: 2024-10-09T08:17:50Z'
4747
x-powered-by:
4848
- ASP.NET
4949
status:
@@ -63,7 +63,7 @@ interactions:
6363
ParameterSetName:
6464
- -g -n --api-id
6565
User-Agent:
66-
- AZURECLI/2.58.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.19045-SP0)
66+
- AZURECLI/2.63.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.22631-SP0)
6767
method: GET
6868
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clirg000001/providers/Microsoft.ApiCenter/services/clitest000002/workspaces/default/apis/clitest000003?api-version=2024-03-01
6969
response:
@@ -79,7 +79,7 @@ interactions:
7979
content-type:
8080
- application/json; charset=utf-8
8181
date:
82-
- Mon, 17 Jun 2024 06:01:26 GMT
82+
- Wed, 09 Oct 2024 08:17:53 GMT
8383
expires:
8484
- '-1'
8585
pragma:
@@ -95,7 +95,7 @@ interactions:
9595
x-ms-ratelimit-remaining-subscription-global-reads:
9696
- '3749'
9797
x-msedge-ref:
98-
- 'Ref A: 395C337E0EC84498B4F49AB282F9ABE0 Ref B: MAA201060513035 Ref C: 2024-06-17T06:01:25Z'
98+
- 'Ref A: E132F768DBCA489D90E2E1D8A9B7207D Ref B: MAA201060514053 Ref C: 2024-10-09T08:17:52Z'
9999
x-powered-by:
100100
- ASP.NET
101101
status:

0 commit comments

Comments
 (0)