Skip to content

Commit

Permalink
apic-extension 1.1.0 release (#8118)
Browse files Browse the repository at this point in the history
* build: add cicd pipeline (#7)

* build: move update version logic to workflow (#8)

* build: Run CI on multiple python version (#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 (#71)

* Update HISTORY.rst

* Update HISTORY.rst

* Update HISTORY.rst

---------

Co-authored-by: Julia Kasper <42241691+juliajuju93@users.noreply.github.com>

* test: fix test cases

* build: remove files to get ready for release

---------

Co-authored-by: Chaoyi Yuan <blackchoey@gmail.com>
Co-authored-by: Julia Kasper <42241691+juliajuju93@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 9, 2024
1 parent 4b1efb0 commit d5be14f
Show file tree
Hide file tree
Showing 128 changed files with 2,156 additions and 1,801 deletions.
22 changes: 22 additions & 0 deletions src/apic-extension/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@
Release History
===============

1.1.0
++++++++++++++++++

**New Features:**

* Added ``--custom-metadata-only`` parameter to ``az apic metadata export`` command.
* Added single custom metadata update for ``az apic api update`` command.

**Updates:**

* Added example for ``az apic api update`` command.
* Added examples with system assigned identity for ``az apic create`` and ``az apic update`` commands.

**Fixes:**

* Set external document correctly in ``az apic api register`` command.
* Do not use API description as summary in ``az apic api register`` command.

**Removals:**

* Eliminated duplicate example for ``az apic create`` command.

1.0.0
++++++++++++++++++
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
class Create(AAZCommand):
"""Creates an instance or update an existing instance of an Azure API Center service.
:example: Create service Example 1
:example: Create service Example
az apic create -g contoso-resources -n contoso -l eastus
:example: Create Service Example 2
az apic create --resource-group contoso-resources --name contoso --location eastus
:example: Create Service With System Assigned Identity Example
az apic create -g contoso-resources -n contoso -l eastus --identity '{type:systemassigned}'
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class Update(AAZCommand):
:example: Update service details
az apic update -g contoso-resources -n contoso
:example: Update Service With System Assigned Identity Example
az apic create -g contoso-resources -n contoso --identity '{type:systemassigned}'
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class Update(AAZCommand):
:example: Update custom properties
az apic api update -g contoso-resources -n contoso --api-id echo-api --custom-properties '{\"public-facing\":true}'
:example: Update single custom metadata
az apic api update -g contoso-resources -n contoso --api-id echo-api --set customProperties.internal=false
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class Export(AAZCommand):
:example: Export Metadata Schema assigned to environment
az apic metadata export -g api-center-test -n contosoeuap --assignments environment --file-name filename.json
:example: Export Custom Metadata Schema Only
az apic metadata export -g api-center-test -n contosoeuap --assignments api --file-name filename.json --custom-metadata-only
"""

_aaz_info = {
Expand Down
38 changes: 21 additions & 17 deletions src/apic-extension/azext_apic_extension/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from knack.log import get_logger
from knack.util import CLIError
import chardet
from azure.cli.core.aaz._arg import AAZStrArg
from azure.cli.core.aaz._arg import AAZStrArg, AAZBoolArg
from .command_patches import ImportAPIDefinitionExtension
from .command_patches import ExportAPIDefinitionExtension
from .command_patches import ExportMetadataExtension
Expand Down Expand Up @@ -105,6 +105,12 @@ def _build_arguments_schema(cls, *args, **kwargs):
required=True,
registered=True
)
args_schema.custom_metadata_only = AAZBoolArg(
options=["--custom-metadata-only"],
help='Export only custom metadata.',
required=False,
blank=True
)
return args_schema

def _output(self, *args, **kwargs):
Expand All @@ -118,9 +124,14 @@ def _output(self, *args, **kwargs):
if response_format == 'link':
getReponse = requests.get(exportedResults, timeout=10)
if getReponse.status_code == 200:
exportedResults = getReponse.content.decode()
content = json.loads(getReponse.content.decode())
# Check if custom metadata only
exportedResults = content.get('properties').get('customProperties', {}) if arguments.custom_metadata_only else content
else:
logger.error('Error while fetching the results from the link. Status code: %s', getReponse.status_code)
else:
# Check if custom metadata only
exportedResults = json.loads(exportedResults).get('properties').get('customProperties', {}) if arguments.custom_metadata_only else exportedResults

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

# TODO - read other file types later
value = None
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()
Expand Down Expand Up @@ -194,49 +206,42 @@ def register_apic(cmd, api_location, resource_group, service_name, environment_i
# Create API and Create API Version
extracted_api_name = _generate_api_id(info.get('title', 'Default-API')).lower()
extracted_api_description = info.get('description', 'API Description')[:1000]
extracted_api_summary = info.get('summary', str(extracted_api_description)[:200])
extracted_api_title = info.get('title', 'API Title')
extracted_api_version = info.get('version', 'v1').replace(".", "-").lower()
extracted_api_version_title = info.get('version', 'v1').replace(".", "-").lower()
# TODO -Create API Version lifecycle_stage

# Create API - Get the contact details from info in spec
contacts = None
contact = info.get('contact')
if contact:
extracted_api_contact_email = contact.get('email')
extracted_api_contact_name = contact.get('name')
extracted_api_contact_url = contact.get('url')
contacts = [{'email': extracted_api_contact_email, 'name': extracted_api_contact_name, 'url': extracted_api_contact_url}]
else:
contacts = None

# Create API - Get the license details from info in spec
extracted_api_license = None
licenseDetails = info.get('license')
if licenseDetails:
extracted_api_license_identifier = licenseDetails.get('identifier')
extracted_api_license_name = licenseDetails.get('name')
extracted_api_license_url = licenseDetails.get('url')
extracted_api_license = {'identifier': extracted_api_license_identifier, 'name': extracted_api_license_name, 'url': extracted_api_license_url}
else:
extracted_api_license = None

# Create API - Get the terms of service from info in spec
extracted_api_terms_of_service = {'url': None}
extracted_api_terms_of_service_value = info.get('termsOfService')
if extracted_api_terms_of_service_value:
extracted_api_terms_of_service = {'url': extracted_api_terms_of_service_value}
else:
extracted_api_terms_of_service = {'url': None}

# Create API - Get the external documentation from info in spec
extracted_api_external_documentation = None
external_documentation = info.get('externalDocumentation')
# Create API - Get the external documentation in spec
extracted_api_external_documentation = []
external_documentation = data.get('externalDocs')
if external_documentation:
extracted_api_external_documentation_description = external_documentation.get('description')
extracted_api_external_documentation_title = external_documentation.get('title')
extracted_api_external_documentation_url = external_documentation.get('url')
extracted_api_external_documentation = {'description': extracted_api_external_documentation_description, 'title': extracted_api_external_documentation_title, 'url': extracted_api_external_documentation_url}
else:
extracted_api_external_documentation = None
extracted_api_external_documentation.append({'description': extracted_api_external_documentation_description, 'title': 'Title', 'url': extracted_api_external_documentation_url})

# TODO: Create API - custom-properties
# "The custom metadata defined for API catalog entities. #1
Expand All @@ -250,7 +255,6 @@ def register_apic(cmd, api_location, resource_group, service_name, environment_i
'service_name': service_name,
'workspace_name': 'default',
'title': extracted_api_title,
'summary': extracted_api_summary,
'type': extracted_api_kind,
'contacts': contacts,
'license': extracted_api_license,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ interactions:
ParameterSetName:
- -g -n --api-id --title --type
User-Agent:
- AZURECLI/2.58.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.19045-SP0)
- AZURECLI/2.63.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.22631-SP0)
method: PUT
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
response:
body:
string: '{"type":"Microsoft.ApiCenter/services/workspaces/apis","properties":{"title":"Echo
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"}}'
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"}}'
headers:
api-supported-versions:
- 2023-07-01-preview, 2024-03-01, 2024-03-15-preview
cache-control:
- no-cache
content-length:
- '464'
- '463'
content-type:
- application/json; charset=utf-8
date:
- Mon, 17 Jun 2024 06:00:44 GMT
- Wed, 09 Oct 2024 08:17:25 GMT
etag:
- da02dc98-0000-0100-0000-666fd10c0000
- c1000958-0000-0100-0000-67063c150000
expires:
- '-1'
pragma:
Expand All @@ -50,11 +50,11 @@ interactions:
x-content-type-options:
- nosniff
x-ms-ratelimit-remaining-subscription-global-writes:
- '2999'
- '2997'
x-ms-ratelimit-remaining-subscription-writes:
- '199'
- '197'
x-msedge-ref:
- 'Ref A: CC39E9193ED345698E8CB1312E168A5A Ref B: MAA201060515029 Ref C: 2024-06-17T06:00:43Z'
- 'Ref A: BB7A57E9360D4BFE8C3879306BD2225E Ref B: MAA201060516049 Ref C: 2024-10-09T08:17:24Z'
x-powered-by:
- ASP.NET
status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ interactions:
- -g -n --api-id --title --type --contacts --custom-properties --description
--external-documentation --license --summary
User-Agent:
- AZURECLI/2.58.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.19045-SP0)
- AZURECLI/2.63.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.22631-SP0)
method: PUT
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
response:
body:
string: '{"type":"Microsoft.ApiCenter/services/workspaces/apis","properties":{"title":"test
api","summary":"summary","description":"API description","kind":"rest","license":{"url":"example.com"},"externalDocumentation":[{"title":"onboarding
docs","url":"example.com"}],"contacts":[{"name":"test","url":"example.com","email":"contact@example.com"}],"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"}}'
docs","url":"example.com"}],"contacts":[{"name":"test","url":"example.com","email":"contact@example.com"}],"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"}}'
headers:
api-supported-versions:
- 2023-07-01-preview, 2024-03-01, 2024-03-15-preview
Expand All @@ -40,9 +40,9 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Mon, 17 Jun 2024 06:01:05 GMT
- Wed, 09 Oct 2024 08:17:39 GMT
etag:
- da020b9a-0000-0100-0000-666fd1210000
- c1000259-0000-0100-0000-67063c230000
expires:
- '-1'
pragma:
Expand All @@ -60,7 +60,7 @@ interactions:
x-ms-ratelimit-remaining-subscription-writes:
- '199'
x-msedge-ref:
- 'Ref A: 65463DBC175045639714FEB0384BB4EF Ref B: MAA201060513047 Ref C: 2024-06-17T06:01:04Z'
- 'Ref A: 8CC55F75DDCB4F02AC5DFCC20C4B4EED Ref B: MAA201060515035 Ref C: 2024-10-09T08:17:38Z'
x-powered-by:
- ASP.NET
status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interactions:
ParameterSetName:
- -g -n --api-id --yes
User-Agent:
- AZURECLI/2.58.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.19045-SP0)
- AZURECLI/2.63.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.22631-SP0)
method: DELETE
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
response:
Expand All @@ -27,7 +27,7 @@ interactions:
cache-control:
- no-cache
date:
- Mon, 17 Jun 2024 06:01:23 GMT
- Wed, 09 Oct 2024 08:17:51 GMT
expires:
- '-1'
pragma:
Expand All @@ -43,7 +43,7 @@ interactions:
x-ms-ratelimit-remaining-subscription-global-deletes:
- '2999'
x-msedge-ref:
- 'Ref A: 3F5C22E176E04C06916635DD0AF9C415 Ref B: MAA201060516009 Ref C: 2024-06-17T06:01:22Z'
- 'Ref A: CF464C6696BD4F96B3BDA9F59C318C4C Ref B: MAA201060515049 Ref C: 2024-10-09T08:17:50Z'
x-powered-by:
- ASP.NET
status:
Expand All @@ -63,7 +63,7 @@ interactions:
ParameterSetName:
- -g -n --api-id
User-Agent:
- AZURECLI/2.58.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.19045-SP0)
- AZURECLI/2.63.0 azsdk-python-core/1.28.0 Python/3.11.9 (Windows-10-10.0.22631-SP0)
method: GET
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
response:
Expand All @@ -79,7 +79,7 @@ interactions:
content-type:
- application/json; charset=utf-8
date:
- Mon, 17 Jun 2024 06:01:26 GMT
- Wed, 09 Oct 2024 08:17:53 GMT
expires:
- '-1'
pragma:
Expand All @@ -95,7 +95,7 @@ interactions:
x-ms-ratelimit-remaining-subscription-global-reads:
- '3749'
x-msedge-ref:
- 'Ref A: 395C337E0EC84498B4F49AB282F9ABE0 Ref B: MAA201060513035 Ref C: 2024-06-17T06:01:25Z'
- 'Ref A: E132F768DBCA489D90E2E1D8A9B7207D Ref B: MAA201060514053 Ref C: 2024-10-09T08:17:52Z'
x-powered-by:
- ASP.NET
status:
Expand Down
Loading

0 comments on commit d5be14f

Please sign in to comment.