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

fix: workspace parameter should not be required #2

Merged
merged 4 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 14 additions & 0 deletions src/apic-extension/azext_apic_extension/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@
from .custom import ExportMetadataSchemaExtension
from .custom import CreateMetadataSchemaExtension
from .custom import UpdateMetadataSchemaExtension
from .custom import UpdateAPIExtension
from .custom import UpdateAPIDefinitionExtension
from .custom import UpdateAPIVersionExtension
from .custom import UpdateAPIDeploymentExtension
from .custom import UpdateEnvironmentExtension


def load_command_table(self, _): # pylint: disable=unused-argument
with self.command_group('apic api definition') as g:
self.command_table['apic api definition update'] = UpdateAPIDefinitionExtension(loader=self)
self.command_table['apic api definition import-specification'] = ImportSpecificationExtension(loader=self)
self.command_table['apic api definition export-specification'] = ExportSpecificationExtension(loader=self)
with self.command_group('apic metadata-schema') as g:
Expand All @@ -26,3 +32,11 @@ def load_command_table(self, _): # pylint: disable=unused-argument
self.command_table['apic metadata-schema export-metadata-schema'] = ExportMetadataSchemaExtension(loader=self)
with self.command_group('apic api') as g:
g.custom_command("register", "register_apic")
with self.command_group('apic api') as g:
self.command_table['apic api update'] = UpdateAPIExtension(loader=self)
with self.command_group('apic api version') as g:
self.command_table['apic api version update'] = UpdateAPIVersionExtension(loader=self)
with self.command_group('apic api deployment') as g:
self.command_table['apic api deployment update'] = UpdateAPIDeploymentExtension(loader=self)
with self.command_group('apic environment') as g:
self.command_table['apic environment update'] = UpdateEnvironmentExtension(loader=self)
31 changes: 31 additions & 0 deletions src/apic-extension/azext_apic_extension/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,40 @@
from .aaz.latest.apic.metadata_schema import Create
from .aaz.latest.apic.metadata_schema import Update
from .aaz.latest.apic.metadata_schema import ExportMetadataSchema
from .aaz.latest.apic.api import Update as UpdateAPI
from .aaz.latest.apic.api.definition import Update as UpdateAPIDefinition
from .aaz.latest.apic.api.deployment import Update as UpdateAPIDeployment
from .aaz.latest.apic.api.version import Update as UpdateAPIVersion
from .aaz.latest.apic.environment import Update as UpdateEnvironment

logger = get_logger(__name__)

class DefaultWorkspaceParameter:
@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
args_schema = super()._build_arguments_schema(*args, **kwargs)
args_schema.workspace_name._required = False
args_schema.workspace_name._registered = False
return args_schema

def pre_operations(self):
args = self.ctx.args
args.workspace_name = "default"

class UpdateAPIExtension(DefaultWorkspaceParameter, UpdateAPI):
pass

class UpdateAPIDefinitionExtension(DefaultWorkspaceParameter, UpdateAPIDefinition):
pass

class UpdateAPIDeploymentExtension(DefaultWorkspaceParameter, UpdateAPIDeployment):
pass

class UpdateAPIVersionExtension(DefaultWorkspaceParameter, UpdateAPIVersion):
pass

class UpdateEnvironmentExtension(DefaultWorkspaceParameter, UpdateEnvironment):
pass

class ImportSpecificationExtension(ImportSpecification):
@classmethod
Expand Down