Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasz Stempniewicz committed Apr 26, 2018
2 parents abb2925 + f1e00f8 commit 970978c
Show file tree
Hide file tree
Showing 63 changed files with 3,811 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@

/src/managementpartner/ @jeffrey-ace

/src/dns/ @muwaqar
/src/dns/ @muwaqar

/src/signalr/ @zackliu
4 changes: 3 additions & 1 deletion src/alias/azext_alias/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

# pylint: disable=line-too-long

from knack.help_files import helps # pylint: disable=unused-import


Expand Down Expand Up @@ -41,7 +43,7 @@

helps['alias export'] = """
type: command
short-summary: Export all registered aliases to a given path, as an INI configuration file.
short-summary: Export all registered aliases to a given path, as an INI configuration file. If no export path is specified, the alias configuration file is exported to the current working directory.
"""


Expand Down
5 changes: 4 additions & 1 deletion src/alias/azext_alias/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ def create_alias(alias_name, alias_command):
_commit_change(alias_table)


def export_aliases(export_path=os.path.abspath(ALIAS_FILE_NAME), exclusions=None):
def export_aliases(export_path=None, exclusions=None):
"""
Export all registered aliases to a given path, as an INI configuration file.
Args:
export_path: The path of the alias configuration file to export to.
exclusions: Space-separated aliases excluded from export.
"""
if not export_path:
export_path = os.path.abspath(ALIAS_FILE_NAME)

alias_table = get_alias_table()
for exclusion in exclusions or []:
if exclusion not in alias_table.sections():
Expand Down
2 changes: 1 addition & 1 deletion src/alias/azext_alias/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

VERSION = '0.5.0'
VERSION = '0.5.1'
103 changes: 98 additions & 5 deletions src/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,9 @@
],
"alias": [
{
"filename": "alias-0.5.0-py2.py3-none-any.whl",
"sha256Digest": "f50723edb97a4f67535e0832d843abebf8272152efc4ec8201a48307999aa59c",
"downloadUrl": "https://azurecliprod.blob.core.windows.net/cli-extensions/alias-0.5.0-py2.py3-none-any.whl",
"filename": "alias-0.5.1-py2.py3-none-any.whl",
"sha256Digest": "81b9a7f1824bffcbd6e72680891476151dde868e030cdbf1bfd9135e1a8f3447",
"downloadUrl": "https://azurecliprod.blob.core.windows.net/cli-extensions/alias-0.5.1-py2.py3-none-any.whl",
"metadata": {
"azext.isPreview": true,
"azext.minCliCoreVersion": "2.0.31.dev0",
Expand Down Expand Up @@ -500,7 +500,7 @@
}
},
"extras": [],
"generator": "bdist_wheel (0.29.0)",
"generator": "bdist_wheel (0.30.0)",
"license": "MIT",
"metadata_version": "2.0",
"name": "alias",
Expand All @@ -512,7 +512,7 @@
}
],
"summary": "Support for command aliases",
"version": "0.5.0"
"version": "0.5.1"
}
}
],
Expand Down Expand Up @@ -605,6 +605,99 @@
"version": "0.0.2"
}
}
],
"signalr": [
{
"filename": "signalr-0.1.0-py2.py3-none-any.whl",
"sha256Digest": "0cd98580aa10b660602c1b4496c9beef24cf9c8e15df8113b2642c75457772ee",
"downloadUrl": "https://azureclisignalr.blob.core.windows.net/cli-extensions/signalr-0.1.0-py2.py3-none-any.whl",
"metadata": {
"azext.minCliCoreVersion": "2.0.32.dev0",
"azext.isPreview": true,
"classifiers": [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"License :: OSI Approved :: MIT License"
],
"extensions": {
"python.details": {
"contacts": [
{
"email": "vscsignalr@microsoft.com",
"name": "Visual Studio China SignalR Team",
"role": "author"
}
],
"document_names": {
"description": "DESCRIPTION.rst"
},
"project_urls": {
"Home": "https://github.com/Azure/azure-cli-extensions"
}
}
},
"generator": "bdist_wheel (0.30.0)",
"license": "MIT",
"metadata_version": "2.0",
"name": "signalr",
"summary": "Support for signalr management preview.",
"version": "0.1.0"
}
}
],
"keyvault-preview": [
{
"filename": "keyvault_preview-0.1.1-py2.py3-none-any.whl",
"sha256Digest": "be43e972cfd75797db01af7fcf99e086a9bf9ce4b3f8cadce0bab4e60e1d374a",
"downloadUrl": "https://github.com/Azure/azure-keyvault-cli-extension/releases/download/keyvault-preview_0.1.1/keyvault_preview-0.1.1-py2.py3-none-any.whl",
"metadata": {
"azext.isPreview": true,
"classifiers": [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"License :: OSI Approved :: MIT License"
],
"extensions": {
"python.details": {
"contacts": [
{
"email": "azurekeyvault@microsoft.com",
"name": "Azure Key Vault",
"role": "author"
}
],
"document_names": {
"description": "DESCRIPTION.rst"
},
"project_urls": {
"Home": "https://github.com/Azure/azure-keyvault-cli-extension"
}
}
},
"generator": "bdist_wheel (0.30.0)",
"license": "MIT",
"metadata_version": "2.0",
"name": "keyvault-preview",
"summary": "Preview Azure Key Vault commands.",
"version": "0.1.1"
}
}
]
}
}
27 changes: 27 additions & 0 deletions src/signalr/azext_signalr/__init__.py
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
14 changes: 14 additions & 0 deletions src/signalr/azext_signalr/_client_factory.py
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
9 changes: 9 additions & 0 deletions src/signalr/azext_signalr/_constants.py
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']
74 changes: 74 additions & 0 deletions src/signalr/azext_signalr/_help.py
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
"""
45 changes: 45 additions & 0 deletions src/signalr/azext_signalr/_params.py
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)
4 changes: 4 additions & 0 deletions src/signalr/azext_signalr/azext_metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"azext.minCliCoreVersion": "2.0.32.dev0",
"azext.isPreview": true
}
33 changes: 33 additions & 0 deletions src/signalr/azext_signalr/commands.py
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')
Loading

0 comments on commit 970978c

Please sign in to comment.