Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions doc/sphinx/azhelpgen/doc_source_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"resource": "src/command_modules/azure-cli-resource/azure/cli/command_modules/resource/_help.py",
"relay": "src/command_modules/azure-cli-relay/azure/cli/command_modules/relay/_help.py",
"role": "src/command_modules/azure-cli-role/azure/cli/command_modules/role/_help.py",
"signalr": "src/command_modules/azure-cli-signalr/azure/cli/command_modules/signalr/_help.py",
"sql": "src/command_modules/azure-cli-sql/azure/cli/command_modules/sql/_help.py",
"storage": "src/command_modules/azure-cli-storage/azure/cli/command_modules/storage/_help.py",
"tag": "src/command_modules/azure-cli-resource/azure/cli/command_modules/resource/_help.py",
Expand Down
9 changes: 9 additions & 0 deletions src/command_modules/azure-cli-signalr/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. :changelog:

Release History
===============

1.0.0
+++++++++++++++++++++

* General available release.
1 change: 1 addition & 0 deletions src/command_modules/azure-cli-signalr/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include *.rst
5 changes: 5 additions & 0 deletions src/command_modules/azure-cli-signalr/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Microsoft Azure CLI 'signalr' Command Module
=============================================

This package is for the 'signalr' module.
i.e. 'az signalr'
7 changes: 7 additions & 0 deletions src/command_modules/azure-cli-signalr/azure/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import pkg_resources
pkg_resources.declare_namespace(__name__)
7 changes: 7 additions & 0 deletions src/command_modules/azure-cli-signalr/azure/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import pkg_resources
pkg_resources.declare_namespace(__name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import pkg_resources
pkg_resources.declare_namespace(__name__)
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 azure.cli.command_modules.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
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 azure.mgmt.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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------


SIGNALR_RESOURCE_TYPE = 'Microsoft.SignalRService/SignalR'
SIGNALR_KEY_TYPE = ['primary', 'secondary']
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# 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.
# --------------------------------------------------------------------------------------------

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 Standard_S1 --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
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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 azure.cli.core.commands.parameters import (
resource_group_name_type,
get_location_type,
get_resource_name_completion_list,
tags_type
)

from knack.log import get_logger

from ._constants import (
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. E.g. Standard_S1')
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)
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 azure.cli.core.util import empty_on_404

from ._client_factory import cf_signalr


def load_command_table(self, _):

signalr_custom_utils = CliCommandType(
operations_tmpl='azure.cli.command_modules.signalr.custom#{}',
client_factory=cf_signalr
)

signalr_key_utils = CliCommandType(
operations_tmpl='azure.cli.command_modules.signalr.key#{}',
client_factory=cf_signalr
)

with self.command_group('signalr', signalr_custom_utils) 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')
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.mgmt.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)
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 azure.mgmt.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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
Loading