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

apic-extension GA release #7677

Merged
merged 25 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
25 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
793e9be
test: add test cases for commands (#40)
blackchoey May 10, 2024
dcd00c3
fix: error when register API with long description spec (#41)
blackchoey May 13, 2024
5ce1621
test: add test cases for optional parameters (#42)
blackchoey May 20, 2024
0c62319
feat!: remove file name param (#43)
blackchoey May 20, 2024
82ff581
fix: error not thrown when import spec with >3MB file (#44)
blackchoey May 21, 2024
7b62c18
feat!: remove state param for deployment commands (#46)
blackchoey May 21, 2024
6539ccd
fix: API title created by register command is not same with provided …
blackchoey May 22, 2024
e24d94a
feat!: redesign parameters to specify APIM instance for import-from-a…
blackchoey May 22, 2024
69ff9f8
test: clean up legacy test cases (#48)
blackchoey May 28, 2024
a5d7113
test: add test cases for command examples (#49)
blackchoey May 28, 2024
061bea3
docs: update help message per feedback (#50)
blackchoey May 28, 2024
3cc02dd
build: bump version to 1.0.0 and add changelog (#51)
blackchoey May 28, 2024
0473617
fix: some parameters should be required in import-specification and d…
blackchoey Jun 3, 2024
51dd403
feat!: rename parameter names to align with other Azure CLI command e…
blackchoey Jun 3, 2024
f16122a
test: enable test for import-from-apim (#54)
blackchoey Jun 14, 2024
1fa23a9
test: fix show service test case (#55)
blackchoey Jun 17, 2024
5472fec
docs: update changelog for 1.0.0 (#56)
juliajuju93 Jun 24, 2024
9487783
docs: update readme for apic-extension (#57)
juliajuju93 Jun 24, 2024
d26e680
fix: cannot run create command against existing resource (#58)
blackchoey Jun 25, 2024
6fcc37c
build: remove cicd pipeline (#59)
blackchoey Jun 25, 2024
0b05ab6
build: resolve review comments (#60)
blackchoey Jun 26, 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
78 changes: 78 additions & 0 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: CD
blackchoey marked this conversation as resolved.
Show resolved Hide resolved

on:
pull_request:
types: [closed]
workflow_dispatch:

permissions:
actions: read
contents: read

jobs:
build:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.11

- name: Setup development environment
run: |
python -m venv .venv
source .venv/bin/activate
python -m pip install -U pip
pip install azdev
azdev setup -r .
azdev extension add apic-extension

# Append commit hash to the version. E.g. 1.0.0b4+abc1234
- name: Update version
run: |
python -c "
import re
import os

# Open the file
with open('src/apic-extension/setup.py', 'r') as f:
content = f.read()

# Find the version string
version_match = re.search(r'VERSION = \'(.*?)\'', content)
if version_match is None:
raise ValueError('Could not find version string in setup.py')

# Extract the original version
original_version = version_match.group(1)

# Get the commit hash
commit_hash = os.getenv('GITHUB_SHA', 'daily')[:7]

# Create the new version string
new_version = original_version + '+' + commit_hash

# Replace the old version string with the new one
content_new = re.sub(r'VERSION = \'(.*?)\'', f'VERSION = \'{new_version}\'', content)

# Write the updated content back to the file
with open('src/apic-extension/setup.py', 'w') as f:
f.write(content_new)
"

- name: Build binary
run: |
source .venv/bin/activate
azdev extension build apic-extension

- name: Upload release asset
uses: actions/upload-artifact@v3
with:
name: release
path: |
./dist/*.whl
43 changes: 43 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI
blackchoey marked this conversation as resolved.
Show resolved Hide resolved

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Setup development environment
run: |
python -m venv .venv
source .venv/bin/activate
python -m pip install -U pip
pip install azdev
azdev setup -r .
azdev extension add apic-extension

- name: Run style check
run: |
source .venv/bin/activate
azdev style apic-extension

- name: Run linter
run: |
source .venv/bin/activate
azdev linter apic-extension

- name: Run tests
run: |
source .venv/bin/activate
azdev test apic-extension
28 changes: 22 additions & 6 deletions src/apic-extension/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,24 @@
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
* Fix: `--definition-id`, `--environment-id`, `--server`, `--title` parameters should be required in `az apic api deployment create` command
* Fix: `--format`, `--specification`, `--value` parameters should be required in `az apic api definition import-specification` command
* Remove: `--state`` parameter for `az apic api deployment` commands.
* Remove: `--file-name`` parameter for `az apic api definition import-specification`, `az apic metadata create` and `az apic metadata update` command. Use the `@filename` syntax provided by Azure CLI to read parameter value from a file directly.

1.0.0b5
+++++
++++++++++++++++++
* Add: Support yaml file for `az apic api register` command.
* 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.
* Update: Introduction to parameter constraints to ensure that valid values are provided.
Expand All @@ -15,17 +31,17 @@ Release History
* Remove: `head` commands in each command group are removed.

1.0.0b4
+++++
++++++++++++++++++
* Add: Support for Default Portal configuration and default hostname provisoning deprovisioning commands

1.0.0b3
+++++
++++++++++++++++++
* Add: Support for Import from apim command along with add examples for create service

1.0.0b2
++++++
++++++++++++++++++
* Remove: All workspace cli commands as it should not be exposed to customers just yet.

1.0.0b1
++++++
* Initial release.
++++++++++++++++++
* Initial release.
12 changes: 6 additions & 6 deletions src/apic-extension/azext_apic_extension/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@

helps['apic api register'] = """
type: command
short-summary: Registers a new API with version, definition, and associated deployments using the specification file as the source of truth.
short-summary: Registers a new API with version, definition, and associated deployments using the specification file as the source of truth. For now we only support OpenAPI JSON/YAML format.
parameters:
- name: --api-location -l
type: string
short-summary: Location of spec file.
- 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,13 +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 From APIM
az apic service import-from-apim -g api-center-test --service-name contosoeuap --source-resource-ids '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/servicegroup/providers/Microsoft.ApiManagement/service/contoso/apis/contosoapi'
:example: Import all APIs from APIM in same resource group
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 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 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 @@ -49,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,15 @@


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

There is a known issue that listing all resources under a subscription does not work. Please list resources by resource group.

: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
Loading