Skip to content

Commit

Permalink
use generated code for default value in content type and events
Browse files Browse the repository at this point in the history
  • Loading branch information
HuiquanJiang-ms committed Jul 10, 2024
1 parent 26e04ba commit 7b1e85f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
6 changes: 4 additions & 2 deletions src/acat/azext_acat/aaz/latest/acat/report/webhook/_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
options=["--content-type-hidden"],
arg_group="Properties",
help="content type",
default="application/json",
enum={"application/json": "application/json"},
)
_args_schema.enable_ssl = AAZStrArg(
Expand All @@ -75,16 +76,17 @@ def _build_arguments_schema(cls, *args, **kwargs):
enum={"false": "false", "true": "true"},
)
_args_schema.events = AAZListArg(
options=["--events-hidden"],
options=["--events"],
arg_group="Properties",
help="under which event notification should be sent.",
default=[],
)
_args_schema.payload_url = AAZStrArg(
options=["--payload-url"],
arg_group="Properties",
help="webhook payload url",
fmt=AAZStrArgFormat(
pattern="^(http(s)?://)[\S]{0,64994}$",
pattern="^(http(s)?://)[\\S]{0,64994}$",
),
)
_args_schema.send_all_events = AAZStrArg(
Expand Down
24 changes: 0 additions & 24 deletions src/acat/azext_acat/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,33 +350,13 @@ def _build_arguments_schema(cls, *args, **kwargs):
from azure.cli.core.aaz import AAZListArg, AAZStrArg, AAZStrArgFormat

args_schema.payload_url._required = True
args_schema.content_type._required = False
args_schema.content_type._registered = False
args_schema.events._required = False
args_schema.events._registered = False
args_schema.send_all_events._required = False
args_schema.send_all_events._registered = False
args_schema.status._required = False
args_schema.status._registered = False
args_schema.update_webhook_key._required = False
args_schema.update_webhook_key._registered = False

args_schema.content_type_with_default = AAZStrArg(
options=["--content-type"],
arg_group="Properties",
help="content type",
required=False,
enum={"application/json": "application/json"},
default="application/json",
)
args_schema.events_with_default = AAZListArg(
options=["--events"],
arg_group="Properties",
help="under which event notification should be sent.",
required=False,
default=[],
)
args_schema.events_with_default.Element = AAZStrArg()
args_schema.trigger_mode = AAZStrArg(
options=["--trigger-mode"],
arg_group="Properties",
Expand All @@ -399,8 +379,6 @@ def pre_operations(self):
from azure.cli.core.aaz.utils import assign_aaz_list_arg

args = self.ctx.args
args.content_type = args.content_type_with_default
args.events = assign_aaz_list_arg(args.events, args.events_with_default)
args.status = args.status_with_default
args.send_all_events = args.trigger_mode

Expand Down Expand Up @@ -464,8 +442,6 @@ def _build_arguments_schema(cls, *args, **kwargs):
help="Webhook status.",
nullable=True,
enum={"false": "Enabled", "true": "Disabled"},
# default="enalbe",
# blank="disable"
)
args_schema.payload_url_nullable = AAZStrArg(
options=["--payload-url"],
Expand Down

0 comments on commit 7b1e85f

Please sign in to comment.