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
4 changes: 4 additions & 0 deletions src/notification-hub/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

2.0.0b1
++++++
* Remove `az notification-hub test-send`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may need to upgrade the major version as it's a breaking change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


1.0.0a1
++++++
* Migrate command to AAZ
Expand Down
4 changes: 1 addition & 3 deletions src/notification-hub/azext_notification_hub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ class NotificationHubsCommandsLoader(AzCommandsLoader):

def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
from azext_notification_hub._client_factory import cf_notificationhubs
notificationhubs_custom = CliCommandType(
operations_tmpl='azext_notification_hub.custom#{}',
client_factory=cf_notificationhubs)
operations_tmpl='azext_notification_hub.custom#{}')
super().__init__(cli_ctx=cli_ctx,
custom_command_type=notificationhubs_custom)

Expand Down
14 changes: 0 additions & 14 deletions src/notification-hub/azext_notification_hub/_client_factory.py

This file was deleted.

22 changes: 0 additions & 22 deletions src/notification-hub/azext_notification_hub/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,3 @@
# pylint: disable=too-many-lines
# pylint: disable=line-too-long
from knack.help_files import helps # pylint: disable=unused-import


helps['notification-hub test-send'] = """
type: command
short-summary: test send a push notification
examples:
- name: test send notification with message body
text: |-
az notification-hub test-send --resource-group MyResourceGroup --namespace-name \\
my-namespace --notification-hub-name my-hub --notification-format gcm \\
--message "test notification"
- name: test send notification from file
text: |-
az notification-hub test-send --resource-group MyResourceGroup --namespace-name \\
my-namespace --notification-hub-name my-hub --notification-format gcm \\
--payload @path/to/file
- name: test send notification with json string
text: |-
az notification-hub test-send --resource-group MyResourceGroup --namespace-name \\
my-namespace --notification-hub-name my-hub --notification-format gcm \\
--payload "{\\\"data\\\":{\\\"message\\\":\\\"test notification\\\"}}"
"""
18 changes: 1 addition & 17 deletions src/notification-hub/azext_notification_hub/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@
# pylint: disable=too-many-statements
# pylint: disable=unused-argument

from knack.arguments import CLIArgumentType
from azure.cli.core.commands.parameters import get_enum_type


def load_arguments(self, _):
payload_type = CLIArgumentType(
options_list=['--payload'],
help='The payload for the message in JSON format. '
)
with self.argument_context('notification-hub test-send') as c:
c.argument('namespace_name', help='The namespace name.')
c.argument('notification_hub_name', help='The notification hub name.')
c.argument('notification_format',
arg_type=get_enum_type(['apple', 'baidu', 'gcm', 'template', 'windows', 'windowsphone']),
help='The format of notification message.')
c.argument('message', help='The message body to send. If not None, payload will be ignored')
c.argument('title', help='The title of the notification.')
c.argument('payload', arg_type=payload_type, id_part=None)
c.argument('tag', help='You can send test notifications to a specific set of registrations using this option. Leave this field empty if you like to send push notifications to 10 random registrations on the selected platform.')
pass
11 changes: 0 additions & 11 deletions src/notification-hub/azext_notification_hub/_validators.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"azext.minCliCoreVersion": "2.49.0"
"azext.isPreview": true,
"azext.minCliCoreVersion": "2.67.0"
}
10 changes: 0 additions & 10 deletions src/notification-hub/azext_notification_hub/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,3 @@ def load_command_table(self, _):
self.command_table['notification-hub credential wns update'] = WnsUpdate(loader=self)
self.command_table['notification-hub credential mpns update'] = MpnsUpdate(loader=self)
self.command_table['notification-hub credential baidu update'] = BaiduUpdate(loader=self)

from ._client_factory import cf_notification_hubs
from ._validators import validate_notification_message
from azure.cli.core.commands import CliCommandType
notificationhubs_notification_hubs = CliCommandType(
operations_tmpl='azext_notification_hub.vendored_sdks.notificationhubs.operations.notification_hubs_operations#NotificationHubsOperations.{}',
client_factory=cf_notification_hubs)
with self.command_group('notification-hub', notificationhubs_notification_hubs, client_factory=cf_notification_hubs,
is_experimental=True) as g:
g.custom_command('test-send', 'debug_send_notificationhubs_hub', validator=validate_notification_message)
41 changes: 0 additions & 41 deletions src/notification-hub/azext_notification_hub/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,44 +209,3 @@ def _build_arguments_schema(cls, *args, **kwargs):
args_schema.policy_key._required = True
args_schema.policy_key.enum = AAZArgEnum({'Primary Key': 'Primary Key', 'Secondary Key': 'Secondary Key'})
return args_schema


def debug_send_notificationhubs_hub(cmd, client,
resource_group_name,
namespace_name,
notification_hub_name,
notification_format,
message=None,
title='',
payload=None,
tag=None):
# Refer to tutorials in https://docs.microsoft.com/azure/notification-hubs/ for more details
if message is not None:
if notification_format == 'gcm':
parameters = {"data": {"message": message}}
elif notification_format == 'baidu':
parameters = {"title": title, "description": message}
elif notification_format == 'apple':
parameters = {"aps": {"alert": message}}
elif notification_format == 'template':
parameters = {"message": message}
elif notification_format == 'windows':
parameters = message
elif notification_format == 'windowsphone':
parameters = '''<?xml version= "1.0" encoding= "utf-8" ?>
<root>
<Value1>{}</Value1>
<Value2>{}</Value2>
</root>
'''.format(title, message)
else:
if notification_format not in ['windows', 'windowsphone']:
import json
parameters = json.loads(payload)
else:
parameters = payload
custom_headers = {"servicebusnotification-format": notification_format}
if tag is not None:
custom_headers['servicebusnotification-tags'] = tag

return client.debug_send(resource_group_name=resource_group_name, namespace_name=namespace_name, notification_hub_name=notification_hub_name, parameters=parameters, custom_headers=custom_headers)
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ interactions:
User-Agent:
- AZURECLI/2.50.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.9 (Windows-10-10.0.22621-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/locations?api-version=2019-11-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/locations?api-version=2022-12-01
response:
body:
string: "{\"value\":[{\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus\"\
Expand Down Expand Up @@ -709,7 +709,7 @@ interactions:
User-Agent:
- AZURECLI/2.50.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.9 (Windows-10-10.0.22621-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/locations?api-version=2019-11-01
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/locations?api-version=2022-12-01
response:
body:
string: "{\"value\":[{\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus\"\
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading