-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial PR for SignalR Service preview CLI extension (#142)
* Init for signalr cli extension * Fix some style issues * Use wheel==0.30.0 * Update sha256 * Update summery * Update sdk and fix some issues * fix some issues * update CODEOWNERS * update package_data * update minCliCoreVersion
- Loading branch information
1 parent
6b9b2a9
commit aa5b268
Showing
60 changed files
with
3,752 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,6 @@ | |
|
||
/src/managementpartner/ @jeffrey-ace | ||
|
||
/src/dns/ @muwaqar | ||
/src/dns/ @muwaqar | ||
|
||
/src/signalr/ @zackliu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
from azure.cli.core import AzCommandsLoader | ||
|
||
import azext_signalr._help # pylint: disable=unused-import | ||
|
||
|
||
class SignalRCommandsLoader(AzCommandsLoader): | ||
|
||
def __init__(self, cli_ctx=None): | ||
super(SignalRCommandsLoader, self).__init__(cli_ctx=cli_ctx, | ||
min_profile='2017-03-10-profile') | ||
|
||
def load_command_table(self, args): | ||
from .commands import load_command_table | ||
load_command_table(self, args) | ||
return self.command_table | ||
|
||
def load_arguments(self, command): | ||
from ._params import load_arguments | ||
load_arguments(self, command) | ||
|
||
|
||
COMMAND_LOADER_CLS = SignalRCommandsLoader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
|
||
def _signalr_client_factory(cli_ctx, *_): | ||
from azext_signalr.signalr import SignalRManagementClient | ||
from azure.cli.core.commands.client_factory import get_mgmt_service_client | ||
return get_mgmt_service_client(cli_ctx, SignalRManagementClient) | ||
|
||
|
||
def cf_signalr(cli_ctx, *_): | ||
return _signalr_client_factory(cli_ctx).signal_r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
|
||
SIGNALR_SKU = ['Basic_DS2'] | ||
SIGNALR_RESOURCE_TYPE = 'Microsoft.SignalRService/SignalR' | ||
SIGNALR_KEY_TYPE = ['primary', 'secondary'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
|
||
from knack.help_files import helps | ||
|
||
helps['signalr'] = """ | ||
type: group | ||
short-summary: Manage Azure SignalR Service. | ||
""" | ||
|
||
helps['signalr key'] = """ | ||
type: group | ||
short-summary: Manage keys for Azure SignalR Service. | ||
""" | ||
|
||
helps['signalr list'] = """ | ||
type: command | ||
short-summary: Lists all the SignalR Service under the current subscription. | ||
examples: | ||
- name: List SignalR Service and show the results in a table. | ||
text: > | ||
az signalr list -o table | ||
- name: List SignalR Service in a resource group and show the results in a table. | ||
text: > | ||
az signalr list -g MySignalR -o table | ||
""" | ||
|
||
helps['signalr create'] = """ | ||
type: command | ||
short-summary: Creates a SignalR Service. | ||
examples: | ||
- name: Create a SignalR Service with the Basic SKU. | ||
text: > | ||
az signalr create -n MySignalR -g MyResourceGroup --sku Basic_DS2 --unit-count 1 | ||
""" | ||
|
||
helps['signalr delete'] = """ | ||
type: command | ||
short-summary: Deletes a SignalR Service. | ||
examples: | ||
- name: Delete a SignalR Service. | ||
text: > | ||
az signalr delete -n MySignalR -g MyResourceGroup | ||
""" | ||
|
||
helps['signalr show'] = """ | ||
type: command | ||
short-summary: Get the details of a SignalR Service. | ||
examples: | ||
- name: Get the sku for a SignalR Service. | ||
text: > | ||
az signalr show -n MySignalR -g MyResourceGroup --query sku | ||
""" | ||
|
||
helps['signalr key list'] = """ | ||
type: command | ||
short-summary: List the access keys for a SignalR Service. | ||
examples: | ||
- name: Get the primary key for a SignalR Service. | ||
text: > | ||
az signalr key list -n MySignalR -g MyResourceGroup --query primaryKey -o tsv | ||
""" | ||
|
||
helps['signalr key renew'] = """ | ||
type: command | ||
short-summary: Regenerate the access key for a SignalR Service. | ||
examples: | ||
- name: Renew the secondary key for a SignalR Service. | ||
text: > | ||
az signalr key renew -n MySignalR -g MyResourceGroup --key-type secondary | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# pylint: disable=line-too-long | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
|
||
from azure.cli.core.commands.validators import get_default_location_from_resource_group | ||
|
||
from knack.log import get_logger | ||
|
||
from azure.cli.core.commands.parameters import ( | ||
resource_group_name_type, | ||
get_location_type, | ||
get_resource_name_completion_list, | ||
tags_type | ||
) | ||
|
||
from ._constants import ( | ||
SIGNALR_SKU, | ||
SIGNALR_RESOURCE_TYPE, | ||
SIGNALR_KEY_TYPE | ||
) | ||
|
||
|
||
logger = get_logger(__name__) | ||
|
||
|
||
def load_arguments(self, _): | ||
with self.argument_context('signalr') as c: | ||
c.argument('resource_group_name', arg_type=resource_group_name_type) | ||
c.argument('location', | ||
arg_type=get_location_type(self.cli_ctx), | ||
validator=get_default_location_from_resource_group) | ||
c.argument('signalr_name', options_list=['--name', '-n'], | ||
completer=get_resource_name_completion_list(SIGNALR_RESOURCE_TYPE), | ||
help='Name of signalr service.') | ||
c.argument('tags', arg_type=tags_type) | ||
|
||
with self.argument_context('signalr create') as c: | ||
c.argument('sku', help='The sku name of the signalr service', choices=SIGNALR_SKU) | ||
c.argument('unit_count', help='The number of signalr service unit count', type=int) | ||
|
||
with self.argument_context('signalr key renew') as c: | ||
c.argument('key_type', help='The name of access key to regenerate', choices=SIGNALR_KEY_TYPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"azext.minCliCoreVersion": "2.0.32.dev0", | ||
"azext.isPreview": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
|
||
from azure.cli.core.commands import CliCommandType | ||
|
||
from ._client_factory import cf_signalr | ||
from azure.cli.core.util import empty_on_404 | ||
|
||
|
||
def load_command_table(self, _): | ||
|
||
signalr_custom_util = CliCommandType( | ||
operations_tmpl='azext_signalr.custom#{}', | ||
client_factory=cf_signalr | ||
) | ||
|
||
signalr_key_utils = CliCommandType( | ||
operations_tmpl='azext_signalr.key#{}', | ||
client_factory=cf_signalr | ||
) | ||
|
||
with self.command_group('signalr', signalr_custom_util) as g: | ||
g.command('create', 'signalr_create') | ||
g.command('delete', 'signalr_delete') | ||
g.command('list', 'signalr_list') | ||
g.command('show', 'signalr_show', exception_handler=empty_on_404) | ||
|
||
with self.command_group('signalr key', signalr_key_utils) as g: | ||
g.command('list', 'signalr_key_list') | ||
g.command('renew', 'signalr_key_renew') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
|
||
from azext_signalr.signalr.models import (ResourceSku, SignalRCreateOrUpdateProperties, SignalRCreateParameters) | ||
|
||
|
||
def signalr_create(client, signalr_name, resource_group_name, sku, unit_count=1, location=None, tags=None): | ||
sku = ResourceSku(name=sku, capacity=unit_count) | ||
properties = SignalRCreateOrUpdateProperties(host_name_prefix=signalr_name) | ||
|
||
parameter = SignalRCreateParameters(tags=tags, | ||
sku=sku, | ||
properties=properties, | ||
location=location) | ||
|
||
return client.create_or_update(resource_group_name, signalr_name, parameter) | ||
|
||
|
||
def signalr_delete(client, signalr_name, resource_group_name): | ||
return client.delete(resource_group_name, signalr_name) | ||
|
||
|
||
def signalr_list(client, resource_group_name=None): | ||
if not resource_group_name: | ||
return client.list_by_subscription() | ||
return client.list_by_resource_group(resource_group_name) | ||
|
||
|
||
def signalr_show(client, signalr_name, resource_group_name): | ||
return client.get(resource_group_name, signalr_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
|
||
from azext_signalr.signalr.models import KeyType | ||
|
||
|
||
def signalr_key_list(client, resource_group_name, signalr_name): | ||
return client.list_keys(resource_group_name, signalr_name) | ||
|
||
|
||
def signalr_key_renew(client, resource_group_name, signalr_name, key_type): | ||
if key_type == 'primary': | ||
key_type = KeyType.primary | ||
else: | ||
key_type = KeyType.secondary | ||
return client.regenerate_key(resource_group_name, signalr_name, key_type, polling=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from .signal_rmanagement_client import SignalRManagementClient | ||
from .version import VERSION | ||
|
||
__all__ = ['SignalRManagementClient'] | ||
|
||
__version__ = VERSION | ||
|
Oops, something went wrong.