Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
f661669
build: add cicd pipeline (#7)
blackchoey Apr 9, 2024
fcb15b5
build: move update version logic to workflow (#8)
blackchoey Apr 9, 2024
274c40e
build: Run CI on multiple python version (#38)
blackchoey Apr 30, 2024
4053b6a
Merge branch 'Azure:main' into main
blackchoey May 6, 2024
9213d64
Merge branch 'Azure:main' into main
blackchoey Jul 17, 2024
e6b30ef
Merge branch 'Azure:main' into main
blackchoey Sep 11, 2024
34ab326
refactor: add apic api update example
frankqianms Sep 18, 2024
6e07880
tests: add test case
frankqianms Sep 18, 2024
9d91f60
fix: fix style
frankqianms Sep 18, 2024
5fc8a2b
fix: fix test case
frankqianms Sep 18, 2024
92dcff4
fix: fix test case
frankqianms Sep 18, 2024
89889ba
fix: fix test case & add recording
frankqianms Sep 18, 2024
ed12cc1
fix: remove bad command prefix
frankqianms Sep 19, 2024
b99e592
refactor: optimize test case code
frankqianms Sep 19, 2024
7b22cdd
Merge pull request #63 from blackchoey/frank/add_api_update_example
frankqianms Sep 19, 2024
b5b0fa2
refactor: remove duplicate example for apic create
frankqianms Sep 23, 2024
2b45d71
fix: fix style
frankqianms Sep 23, 2024
21e4bcd
Merge pull request #64 from blackchoey/frank/remove-duplicate-example
frankqianms Sep 23, 2024
1a199c9
feat: add examples for create & update apic service with system assig…
frankqianms Sep 23, 2024
f753dd8
Merge pull request #65 from blackchoey/frank/add-example
frankqianms Sep 24, 2024
cbbbb44
fix: fix external doc extracting bug in spec
frankqianms Sep 24, 2024
4bfa5c8
fix: remove extra print
frankqianms Sep 24, 2024
d64719c
fix: fix style
frankqianms Sep 24, 2024
8031a19
fix: fix style
frankqianms Sep 24, 2024
524d76a
fix: fix style
frankqianms Sep 24, 2024
b2315d4
fix: fix style
frankqianms Sep 24, 2024
14acd80
tests: fix test case
frankqianms Sep 24, 2024
f71785f
refactor: remove external docs from tags
frankqianms Sep 25, 2024
7a113c6
tests: update test case
frankqianms Sep 25, 2024
82c4099
Merge pull request #66 from blackchoey/frank/add_external_doc
frankqianms Sep 25, 2024
9ebebdb
refactor: remove summary setting in api register
frankqianms Sep 25, 2024
d912015
feat: support custom metadata export only
frankqianms Sep 25, 2024
f9341a5
fix: fix test case
frankqianms Sep 25, 2024
02827ef
Merge pull request #67 from blackchoey/frank/remove-summary-setting-i…
frankqianms Sep 25, 2024
d47f302
tests: add test case
frankqianms Sep 26, 2024
ecc4647
fix: fix arg type
frankqianms Sep 26, 2024
3a01240
refactor: add help example
frankqianms Sep 26, 2024
7296b18
Merge remote-tracking branch 'origin/v1.0.1' into frank/support-custo…
frankqianms Sep 26, 2024
911012c
fix: fix bad logic of link format
frankqianms Sep 26, 2024
f03bf96
refactor: remove extra example
frankqianms Sep 26, 2024
865d924
refactor: update example
frankqianms Sep 26, 2024
738f46a
Merge pull request #68 from blackchoey/frank/support-custom-metadata-…
frankqianms Sep 26, 2024
1650ba6
doc: update 1.0.1 release history
frankqianms Sep 30, 2024
b9cd37d
refactor: change note style
frankqianms Sep 30, 2024
e6e224b
fix: fix
frankqianms Sep 30, 2024
de969e8
fix: remove breaking change label
frankqianms Sep 30, 2024
349bfa4
Merge pull request #69 from blackchoey/frank/release-note
frankqianms Sep 30, 2024
4633343
build: bump version to 1.1.0
frankqianms Sep 30, 2024
a8f682e
Merge pull request #70 from blackchoey/frank/ga-110-changelog
frankqianms Sep 30, 2024
6a77054
Update V1.1.0 history (#71)
blackchoey Oct 9, 2024
5cebe06
test: fix test cases
frankqianms Oct 9, 2024
af4022e
build: remove files to get ready for release
frankqianms Oct 9, 2024
d5e41dd
Merge pull request #72 from blackchoey/frank/fix_test_case
frankqianms Oct 9, 2024
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
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