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

Initial PR for Azure WebPubSub Service #3297

Merged
merged 8 commits into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Update to use enum
  • Loading branch information
zackliu committed Apr 27, 2021
commit 160e6d2d6347c437b018dfde94c0edcf6e1d0914
4 changes: 0 additions & 4 deletions src/webpubsub/azext_webpubsub/_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@
# pylint: disable=protected-access, too-few-public-methods
class EventHandlerTemplateUpdateAction(argparse._AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
logger.warning(self.dest)
logger.warning(namespace)
logger.warning(values)
kwargs = {}
for item in values:
try:
key, value = item.split('=', 1)
kwargs[key.replace('-', '_')] = value
except ValueError:
raise InvalidArgumentValueError('usage error: {} KEY=VALUE [KEY=VALUE ...]'.format(option_string))
logger.warning(kwargs)
value = EventHandlerTemplate(**kwargs)
super().__call__(parser, namespace, value, option_string)
14 changes: 8 additions & 6 deletions src/webpubsub/azext_webpubsub/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
from knack.arguments import CLIArgumentType
from azure.cli.core.commands.parameters import (
tags_type,
get_three_state_flag
get_three_state_flag,
get_enum_type
)
from .vendored_sdks.azure.mgmt.webpubsub.models import WebPubSubRequestType
from ._actions import (
EventHandlerTemplateUpdateAction
)

WEBPUBSUB_KEY_TYPE = ['primary', 'secondary']

SKU_TYPE = ['Standard_S1', 'Free_F1']
NETWORK_RULE_TYPE = []

def load_arguments(self, _):
from azure.cli.core.commands.validators import get_default_location_from_resource_group
Expand All @@ -32,18 +34,18 @@ def load_arguments(self, _):
c.argument('unit_count', help='The number of signalr service unit count', type=int)

with self.argument_context('webpubsub update') as c:
c.argument('sku', help='The sku name of the signalr service. E.g. Standard_S1, Free_F1')
c.argument('sku', arg_type=get_enum_type(SKU_TYPE), help='The sku name of the signalr service.')
c.argument('unit_count', help='The number of signalr service unit count', type=int)

with self.argument_context('webpubsub key regenerate') as c:
c.argument('key_type', help='The name of access key to regenerate', choices=WEBPUBSUB_KEY_TYPE)
c.argument('key_type', arg_type=get_enum_type(WEBPUBSUB_KEY_TYPE), help='The name of access key to regenerate')

# Network Rule
with self.argument_context('webpubsub network-rule update') as c:
c.argument('connection_name', nargs='*', help='Space-separeted list of private endpoint connection name.', required=False, arg_group='Private Endpoint Connection')
c.argument('public_network', arg_type=get_three_state_flag(), help='Set rules for public network.', required=False, arg_group='Public Network')
c.argument('allow', nargs='*', help='The allowed virtual network rule. Space-separeted list of scope to assign. Allowed values: ClientConnection, ServerConnection, RESTAPI, Trace', type=WebPubSubRequestType, required=False)
c.argument('deny', nargs='*', help='The denied virtual network rule. Space-separeted list of scope to assign. Allowed values: ClientConnection, ServerConnection, RESTAPI, Trace', type=WebPubSubRequestType, required=False)
c.argument('allow', arg_type=get_enum_type(WebPubSubRequestType), nargs='*', help='The allowed virtual network rule. Space-separeted list of scope to assign.', type=WebPubSubRequestType, required=False)
c.argument('deny', arg_type=get_enum_type(WebPubSubRequestType), nargs='*', help='The denied virtual network rule. Space-separeted list of scope to assign.', type=WebPubSubRequestType, required=False)

with self.argument_context('webpubsub event-handler update') as c:
c.argument('items', help='A JSON-formatted string containing event handler items')
Expand Down