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

feat: mark some parameters as required #21

Merged
merged 4 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class Create(AAZCommand):

:example: Create API
az apic api create -g contoso-resources -s contoso --api-id echo-api --title "Echo API" --type REST

:example: Create API with custom properties
az apic api create -g contoso-resources -s contoso --api-id echo-api --title "Echo API" --type REST --custom-properties '{\"public-facing\":true}'
"""

_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 API
az apic api update -g contoso-resources -s contoso --api-id echo-api --summary "Basic REST API service"

:example: Update custom properties
az apic api update -g contoso-resources -s contoso --api-id echo-api --custom-properties '{\"public-facing\":true}'
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ class Export(AAZCommand):
"""Exports the metadata schema.

:example: Export Metadata Schema assigned to api
az apic metadata export -g api-center-test -s contosoeuap --assignments api --file-name filepath
az apic metadata export -g api-center-test -s contosoeuap --assignments api --file-name filename.json

:example: Export Metadata Schema assigned to deployment
az apic metadata export -g api-center-test -s contosoeuap --assignments deployment --file-name filepath
az apic metadata export -g api-center-test -s contosoeuap --assignments deployment --file-name filename.json

:example: Export Metadata Schema assigned to environment
az apic metadata export -g api-center-test -s contosoeuap --assignments environment --file-name filepath
az apic metadata export -g api-center-test -s contosoeuap --assignments environment --file-name filename.json
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"apic service import-from-apim",
)
class ImportFromApim(AAZCommand):
"""Imports from APIM instance.
"""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/a200340d-6b82-494d-9dbf-687ba6e33f9e/resourceGroups/servicegroup/providers/Microsoft.ApiManagement/service/contoso/apis/contosoapi
Expand Down
33 changes: 33 additions & 0 deletions src/apic-extension/azext_apic_extension/command_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,36 @@ class ShowEnvironmentExtension(DefaultWorkspaceParameter, ShowEnvironment):

class UpdateEnvironmentExtension(DefaultWorkspaceParameter, UpdateEnvironment):
pass

# `az apic metadata commands`
from .aaz.latest.apic.metadata import Create as CreateMetadata, Export as ExportMetadata

class CreateMetadataExtension(CreateMetadata):
# pylint: disable=too-few-public-methods
@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
# pylint: disable=protected-access
args_schema = super()._build_arguments_schema(*args, **kwargs)
args_schema.assignments._required = True
return args_schema

class ExportMetadataExtension(ExportMetadata):
# pylint: disable=too-few-public-methods
@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
# pylint: disable=protected-access
args_schema = super()._build_arguments_schema(*args, **kwargs)
args_schema.assignments._required = True
return args_schema

# `az apic service commands`
from .aaz.latest.apic.service import ImportFromApim

class ImportFromApimExtension(ImportFromApim):
# pylint: disable=too-few-public-methods
@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
# pylint: disable=protected-access
args_schema = super()._build_arguments_schema(*args, **kwargs)
args_schema.source_resource_ids._required = True
return args_schema
8 changes: 4 additions & 4 deletions src/apic-extension/azext_apic_extension/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
from azure.cli.core.aaz._arg import AAZStrArg
from .command_patches import ImportAPIDefinitionExtension
from .command_patches import ExportAPIDefinitionExtension
from .aaz.latest.apic.metadata import Create as CreateMetadataSchema
from .command_patches import CreateMetadataExtension
from .command_patches import ExportMetadataExtension
from .aaz.latest.apic.metadata import Update as UpdateMetadataSchema
from .aaz.latest.apic.metadata import Export as ExportMetadataSchema

logger = get_logger(__name__)

Expand Down Expand Up @@ -133,7 +133,7 @@ def writeResultsToFile(self, results, file_name):
f.write(results)


class CreateMetadataSchemaExtension(CreateMetadataSchema):
class CreateMetadataSchemaExtension(CreateMetadataExtension):
@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
args_schema = super()._build_arguments_schema(*args, **kwargs)
Expand Down Expand Up @@ -215,7 +215,7 @@ def pre_operations(self):
self.ctx.args.schema = value


class ExportMetadataSchemaExtension(ExportMetadataSchema):
class ExportMetadataSchemaExtension(ExportMetadataExtension):

@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
Expand Down