Skip to content

Commit e18297e

Browse files
authored
[Notification-hub] Remove az notification-hub test-send command (#8877)
* update * version
1 parent b4e3f99 commit e18297e

81 files changed

Lines changed: 11 additions & 5842 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/notification-hub/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
Release History
44
===============
55

6+
2.0.0b1
7+
++++++
8+
* Remove `az notification-hub test-send`
9+
610
1.0.0a1
711
++++++
812
* Migrate command to AAZ

src/notification-hub/azext_notification_hub/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ class NotificationHubsCommandsLoader(AzCommandsLoader):
1212

1313
def __init__(self, cli_ctx=None):
1414
from azure.cli.core.commands import CliCommandType
15-
from azext_notification_hub._client_factory import cf_notificationhubs
1615
notificationhubs_custom = CliCommandType(
17-
operations_tmpl='azext_notification_hub.custom#{}',
18-
client_factory=cf_notificationhubs)
16+
operations_tmpl='azext_notification_hub.custom#{}')
1917
super().__init__(cli_ctx=cli_ctx,
2018
custom_command_type=notificationhubs_custom)
2119

src/notification-hub/azext_notification_hub/_client_factory.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/notification-hub/azext_notification_hub/_help.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,3 @@
77
# pylint: disable=too-many-lines
88
# pylint: disable=line-too-long
99
from knack.help_files import helps # pylint: disable=unused-import
10-
11-
12-
helps['notification-hub test-send'] = """
13-
type: command
14-
short-summary: test send a push notification
15-
examples:
16-
- name: test send notification with message body
17-
text: |-
18-
az notification-hub test-send --resource-group MyResourceGroup --namespace-name \\
19-
my-namespace --notification-hub-name my-hub --notification-format gcm \\
20-
--message "test notification"
21-
- name: test send notification from file
22-
text: |-
23-
az notification-hub test-send --resource-group MyResourceGroup --namespace-name \\
24-
my-namespace --notification-hub-name my-hub --notification-format gcm \\
25-
--payload @path/to/file
26-
- name: test send notification with json string
27-
text: |-
28-
az notification-hub test-send --resource-group MyResourceGroup --namespace-name \\
29-
my-namespace --notification-hub-name my-hub --notification-format gcm \\
30-
--payload "{\\\"data\\\":{\\\"message\\\":\\\"test notification\\\"}}"
31-
"""

src/notification-hub/azext_notification_hub/_params.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,6 @@
77
# pylint: disable=too-many-statements
88
# pylint: disable=unused-argument
99

10-
from knack.arguments import CLIArgumentType
11-
from azure.cli.core.commands.parameters import get_enum_type
12-
1310

1411
def load_arguments(self, _):
15-
payload_type = CLIArgumentType(
16-
options_list=['--payload'],
17-
help='The payload for the message in JSON format. '
18-
)
19-
with self.argument_context('notification-hub test-send') as c:
20-
c.argument('namespace_name', help='The namespace name.')
21-
c.argument('notification_hub_name', help='The notification hub name.')
22-
c.argument('notification_format',
23-
arg_type=get_enum_type(['apple', 'baidu', 'gcm', 'template', 'windows', 'windowsphone']),
24-
help='The format of notification message.')
25-
c.argument('message', help='The message body to send. If not None, payload will be ignored')
26-
c.argument('title', help='The title of the notification.')
27-
c.argument('payload', arg_type=payload_type, id_part=None)
28-
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.')
12+
pass

src/notification-hub/azext_notification_hub/_validators.py

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"azext.minCliCoreVersion": "2.49.0"
2+
"azext.isPreview": true,
3+
"azext.minCliCoreVersion": "2.67.0"
34
}

src/notification-hub/azext_notification_hub/commands.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,3 @@ def load_command_table(self, _):
3636
self.command_table['notification-hub credential wns update'] = WnsUpdate(loader=self)
3737
self.command_table['notification-hub credential mpns update'] = MpnsUpdate(loader=self)
3838
self.command_table['notification-hub credential baidu update'] = BaiduUpdate(loader=self)
39-
40-
from ._client_factory import cf_notification_hubs
41-
from ._validators import validate_notification_message
42-
from azure.cli.core.commands import CliCommandType
43-
notificationhubs_notification_hubs = CliCommandType(
44-
operations_tmpl='azext_notification_hub.vendored_sdks.notificationhubs.operations.notification_hubs_operations#NotificationHubsOperations.{}',
45-
client_factory=cf_notification_hubs)
46-
with self.command_group('notification-hub', notificationhubs_notification_hubs, client_factory=cf_notification_hubs,
47-
is_experimental=True) as g:
48-
g.custom_command('test-send', 'debug_send_notificationhubs_hub', validator=validate_notification_message)

src/notification-hub/azext_notification_hub/custom.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -209,44 +209,3 @@ def _build_arguments_schema(cls, *args, **kwargs):
209209
args_schema.policy_key._required = True
210210
args_schema.policy_key.enum = AAZArgEnum({'Primary Key': 'Primary Key', 'Secondary Key': 'Secondary Key'})
211211
return args_schema
212-
213-
214-
def debug_send_notificationhubs_hub(cmd, client,
215-
resource_group_name,
216-
namespace_name,
217-
notification_hub_name,
218-
notification_format,
219-
message=None,
220-
title='',
221-
payload=None,
222-
tag=None):
223-
# Refer to tutorials in https://docs.microsoft.com/azure/notification-hubs/ for more details
224-
if message is not None:
225-
if notification_format == 'gcm':
226-
parameters = {"data": {"message": message}}
227-
elif notification_format == 'baidu':
228-
parameters = {"title": title, "description": message}
229-
elif notification_format == 'apple':
230-
parameters = {"aps": {"alert": message}}
231-
elif notification_format == 'template':
232-
parameters = {"message": message}
233-
elif notification_format == 'windows':
234-
parameters = message
235-
elif notification_format == 'windowsphone':
236-
parameters = '''<?xml version= "1.0" encoding= "utf-8" ?>
237-
<root>
238-
<Value1>{}</Value1>
239-
<Value2>{}</Value2>
240-
</root>
241-
'''.format(title, message)
242-
else:
243-
if notification_format not in ['windows', 'windowsphone']:
244-
import json
245-
parameters = json.loads(payload)
246-
else:
247-
parameters = payload
248-
custom_headers = {"servicebusnotification-format": notification_format}
249-
if tag is not None:
250-
custom_headers['servicebusnotification-tags'] = tag
251-
252-
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)

src/notification-hub/azext_notification_hub/tests/latest/recordings/test_notificationhubs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ interactions:
6969
User-Agent:
7070
- AZURECLI/2.50.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.9 (Windows-10-10.0.22621-SP0)
7171
method: GET
72-
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/locations?api-version=2019-11-01
72+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/locations?api-version=2022-12-01
7373
response:
7474
body:
7575
string: "{\"value\":[{\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus\"\
@@ -709,7 +709,7 @@ interactions:
709709
User-Agent:
710710
- AZURECLI/2.50.0 azsdk-python-azure-mgmt-resource/23.1.0b2 Python/3.10.9 (Windows-10-10.0.22621-SP0)
711711
method: GET
712-
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/locations?api-version=2019-11-01
712+
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/locations?api-version=2022-12-01
713713
response:
714714
body:
715715
string: "{\"value\":[{\"id\":\"/subscriptions/00000000-0000-0000-0000-000000000000/locations/eastus\"\

0 commit comments

Comments
 (0)