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
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def load_arguments(self, _): # pylint: disable=too-many-statements

with self.argument_context('eventgrid topic key') as c:
c.argument('topic_name', arg_type=name_type, help='Name of the topic', id_part=None, completer=get_resource_name_completion_list('Microsoft.EventGrid/topics'))
c.argument('key_name', help='Key name to regenerate key1 or key2')
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed/added? Same for other key arguments for domains and partner namespaces

Copy link
Contributor

Choose a reason for hiding this comment

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

never mind.. I got it.


with self.argument_context('eventgrid topic list') as c:
c.argument('odata_query', arg_type=odata_query_type, id_part=None)
Expand All @@ -245,6 +246,7 @@ def load_arguments(self, _): # pylint: disable=too-many-statements

with self.argument_context('eventgrid domain key') as c:
c.argument('domain_name', arg_type=domain_name_type, options_list=['--name', '-n'], id_part=None)
c.argument('key_name', help='Key name to regenerate key1 or key2')

with self.argument_context('eventgrid domain topic') as c:
c.argument('domain_name', arg_type=domain_name_type, id_part='name')
Expand Down Expand Up @@ -278,6 +280,7 @@ def load_arguments(self, _): # pylint: disable=too-many-statements

with self.argument_context('eventgrid partner namespace key') as c:
c.argument('partner_namespace_name', arg_type=partner_namespace_name_type, help='Name of the partner namespace', id_part=None, completer=get_resource_name_completion_list('Microsoft.EventGrid/partnernamespaces'))
c.argument('key_name', help='Key name to regenerate key1 or key2')

with self.argument_context('eventgrid partner namespace show') as c:
c.argument('partner_namespace_name', arg_type=partner_namespace_name_type, options_list=['--name', '-n'], id_part='name', completer=get_resource_name_completion_list('Microsoft.EventGrid/partnernamespaces'))
Expand Down
22 changes: 11 additions & 11 deletions src/azure-cli/azure/cli/command_modules/eventgrid/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def load_command_table(self, _):
with self.command_group('eventgrid topic', topics_mgmt_util, client_factory=topics_factory) as g:
g.show_command('show', 'get')
g.command('key list', 'list_shared_access_keys')
g.command('key regenerate', 'regenerate_key')
g.command('delete', 'delete')
g.command('delete', 'begin_delete')
g.custom_command('key regenerate', 'cli_topic_regenerate_key')
g.custom_command('list', 'cli_topic_list')
g.custom_command('create', 'cli_topic_create_or_update')
g.custom_command('update', 'cli_topic_update')
Expand All @@ -118,22 +118,22 @@ def load_command_table(self, _):
with self.command_group('eventgrid domain', domains_mgmt_util, client_factory=domains_factory) as g:
g.show_command('show', 'get')
g.command('key list', 'list_shared_access_keys')
g.command('key regenerate', 'regenerate_key')
g.custom_command('key regenerate', 'cli_domain_regenerate_key')
g.custom_command('list', 'cli_domain_list')
g.custom_command('create', 'cli_domain_create_or_update')
g.command('delete', 'delete')
g.command('delete', 'begin_delete')
g.custom_command('update', 'cli_domain_update')

with self.command_group('eventgrid system-topic', system_topics_mgmt_util, client_factory=system_topics_factory, is_preview=True) as g:
g.show_command('show', 'get')
g.command('delete', 'delete', confirmation=True)
g.command('delete', 'begin_delete', confirmation=True)
g.custom_command('list', 'cli_system_topic_list')
g.custom_command('create', 'cli_system_topic_create_or_update')
g.custom_command('update', 'cli_system_topic_update')

with self.command_group('eventgrid system-topic event-subscription', system_topic_event_subscriptions_mgmt_util, client_factory=system_topic_event_subscriptions_factory, is_preview=True) as g:
g.custom_show_command('show', 'cli_system_topic_event_subscription_get')
g.command('delete', 'delete', confirmation=True)
g.command('delete', 'begin_delete', confirmation=True)
g.custom_command('list', 'cli_system_topic_event_subscription_list')
g.custom_command('create', 'cli_system_topic_event_subscription_create_or_update')
g.custom_command('update', 'cli_system_topic_event_subscription_update')
Expand All @@ -147,23 +147,23 @@ def load_command_table(self, _):

with self.command_group('eventgrid partner namespace', partner_namespaces_mgmt_util, client_factory=partner_namespaces_factory, is_preview=True) as g:
g.show_command('show', 'get')
g.command('delete', 'delete', confirmation=True)
g.command('delete', 'begin_delete', confirmation=True)
g.custom_command('list', 'cli_partner_namespace_list')
g.custom_command('create', 'cli_partner_namespace_create_or_update')
g.command('key list', 'list_shared_access_keys')
g.command('key regenerate', 'regenerate_key')
g.custom_command('key regenerate', 'cli_partner_namespace_regenerate_key')
# g.custom_command('update', 'cli_partner_namespace_update')

with self.command_group('eventgrid partner namespace event-channel', event_channels_mgmt_util, client_factory=event_channels_factory, is_preview=True) as g:
g.show_command('show', 'get')
g.command('delete', 'delete', confirmation=True)
g.command('delete', 'begin_delete', confirmation=True)
g.custom_command('list', 'cli_event_channel_list')
# g.custom_command('update', 'cli_event_channel_update')
g.custom_command('create', 'cli_event_channel_create_or_update')

with self.command_group('eventgrid partner topic', partner_topics_mgmt_util, client_factory=partner_topics_factory, is_preview=True) as g:
g.show_command('show', 'get')
g.command('delete', 'delete', confirmation=True)
g.command('delete', 'begin_delete', confirmation=True)
g.command('activate', 'activate')
g.command('deactivate', 'deactivate')
g.custom_command('list', 'cli_partner_topic_list')
Expand All @@ -172,7 +172,7 @@ def load_command_table(self, _):

with self.command_group('eventgrid partner topic event-subscription', partner_topic_event_subscriptions_mgmt_util, client_factory=partner_topic_event_subscriptions_factory, is_preview=True) as g:
g.custom_show_command('show', 'cli_partner_topic_event_subscription_get')
g.command('delete', 'delete', confirmation=True)
g.command('delete', 'begin_delete', confirmation=True)
g.custom_command('list', 'cli_partner_topic_event_subscription_list')
g.custom_command('create', 'cli_partner_topic_event_subscription_create_or_update')
g.custom_command('update', 'cli_partner_topic_event_subscription_update')
Expand Down
89 changes: 69 additions & 20 deletions src/azure-cli/azure/cli/command_modules/eventgrid/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@
StorageBlobDeadLetterDestination,
EventSubscriptionFilter,
TopicUpdateParameters,
TopicRegenerateKeyRequest,
DomainUpdateParameters,
DomainRegenerateKeyRequest,
ResourceSku,
IdentityInfo,
PartnerRegistration,
PartnerNamespace,
PartnerNamespaceRegenerateKeyRequest,
EventChannel,
PartnerTopic,
EventChannelSource,
Expand Down Expand Up @@ -155,7 +158,7 @@ def cli_topic_create_or_update(
kind=kind_name,
extended_location=extended_location)

return client.create_or_update(
return client.begin_create_or_update(
resource_group_name,
topic_name,
topic_info)
Expand Down Expand Up @@ -183,12 +186,26 @@ def cli_topic_update(
sku=sku_info,
identity=identity_info)

return client.update(
return client.begin_update(
resource_group_name=resource_group_name,
topic_name=topic_name,
topic_update_parameters=topic_update_parameters)


def cli_topic_regenerate_key(
client,
resource_group_name,
topic_name,
key_name):
regenerate_key_request = TopicRegenerateKeyRequest(key_name=key_name)

return client.begin_regenerate_key(
resource_group_name=resource_group_name,
topic_name=topic_name,
regenerate_key_request=regenerate_key_request
)


def cli_domain_update(
client,
resource_group_name,
Expand All @@ -211,7 +228,7 @@ def cli_domain_update(
sku=sku_info,
identity=identity_info)

return client.update(
return client.begin_update(
resource_group_name,
domain_name,
domain_update_parameters)
Expand All @@ -228,6 +245,20 @@ def cli_domain_list(
return client.list_by_subscription(odata_query, DEFAULT_TOP)


def cli_domain_regenerate_key(
client,
resource_group_name,
domain_name,
key_name):
regenerate_key_request = DomainRegenerateKeyRequest(key_name=key_name)

return client.regenerate_key(
resource_group_name=resource_group_name,
domain_name=domain_name,
regenerate_key_request=regenerate_key_request
)


def cli_domain_create_or_update(
client,
resource_group_name,
Expand Down Expand Up @@ -261,7 +292,7 @@ def cli_domain_create_or_update(
sku=sku_info,
identity=identity_info)

return client.create_or_update(
return client.begin_create_or_update(
resource_group_name,
domain_name,
domain_info)
Expand All @@ -272,7 +303,7 @@ def cli_domain_topic_create_or_update(
resource_group_name,
domain_name,
domain_topic_name):
return client.create_or_update(
return client.begin_create_or_update(
resource_group_name,
domain_name,
domain_topic_name)
Expand All @@ -283,7 +314,7 @@ def cli_domain_topic_delete(
resource_group_name,
domain_name,
domain_topic_name):
return client.delete(
return client.begin_delete(
resource_group_name,
domain_name,
domain_topic_name)
Expand Down Expand Up @@ -400,12 +431,26 @@ def cli_partner_namespace_create_or_update(
partner_registration_fully_qualified_id=partner_registration_id,
tags=tags)

return client.create_or_update(
return client.begin_create_or_update(
resource_group_name,
partner_namespace_name,
partner_namespace_info)


def cli_partner_namespace_regenerate_key(
client,
resource_group_name,
partner_namespace_name,
key_name):
regenerate_key_request = PartnerNamespaceRegenerateKeyRequest(key_name=key_name)

return client.regenerate_key(
resource_group_name=resource_group_name,
partner_namespace_name=partner_namespace_name,
regenerate_key_request=regenerate_key_request
)


def cli_event_channel_list(
client,
resource_group_name,
Expand Down Expand Up @@ -534,7 +579,7 @@ def cli_partner_topic_event_subscription_create_or_update( # pylint: disable=
enable_advanced_filtering_on_arrays=enable_advanced_filtering_on_arrays,
delivery_attribute_mapping=delivery_attribute_mapping)

return client.create_or_update(
return client.begin_create_or_update(
resource_group_name,
partner_topic_name,
event_subscription_name,
Expand Down Expand Up @@ -604,7 +649,7 @@ def cli_system_topic_create_or_update(
source=source,
identity=identity_info)

return client.create_or_update(
return client.begin_create_or_update(
resource_group_name,
system_topic_name,
system_topic_info)
Expand All @@ -623,7 +668,7 @@ def cli_system_topic_update(
tags=tags,
identity=identity_info)

return client.update(
return client.begin_update(
resource_group_name=resource_group_name,
system_topic_name=system_topic_name,
system_topic_update_parameters=system_topic_update_parameters)
Expand Down Expand Up @@ -682,7 +727,7 @@ def cli_system_topic_event_subscription_create_or_update( # pylint: disable=t
enable_advanced_filtering_on_arrays=enable_advanced_filtering_on_arrays,
delivery_attribute_mapping=delivery_attribute_mapping)

return client.create_or_update(
return client.begin_create_or_update(
resource_group_name,
system_topic_name,
event_subscription_name,
Expand Down Expand Up @@ -791,7 +836,7 @@ def cli_eventgrid_event_subscription_create( # pylint: disable=too-many-locals
enable_advanced_filtering_on_arrays=enable_advanced_filtering_on_arrays,
delivery_attribute_mapping=delivery_attribute_mapping)

return client.create_or_update(
return client.begin_create_or_update(
source_resource_id,
event_subscription_name,
event_subscription_info)
Expand All @@ -801,7 +846,7 @@ def cli_eventgrid_event_subscription_delete(
client,
event_subscription_name,
source_resource_id=None):
return client.delete(
return client.begin_delete(
source_resource_id,
event_subscription_name)

Expand All @@ -812,7 +857,7 @@ def event_subscription_setter(
event_subscription_name,
source_resource_id=None):

return client.update(
return client.begin_update(
source_resource_id,
event_subscription_name,
parameters)
Expand Down Expand Up @@ -840,6 +885,7 @@ def cli_eventgrid_event_subscription_get(


def cli_event_subscription_list( # pylint: disable=too-many-return-statements
cmd,
client,
source_resource_id=None,
location=None,
Expand All @@ -854,7 +900,7 @@ def cli_event_subscription_list( # pylint: disable=too-many-return-statements
raise CLIError('usage error: Since --source-resource-id is specified, none of the other parameters must '
'be specified.')

return _list_event_subscriptions_by_resource_id(client, source_resource_id, odata_query, DEFAULT_TOP)
return _list_event_subscriptions_by_resource_id(cmd, client, source_resource_id, odata_query, DEFAULT_TOP)

if location is None:
# Since resource-id was not specified, location must be specified: e.g. "westus2" or "global". If not error
Expand Down Expand Up @@ -1168,7 +1214,7 @@ def cli_system_topic_event_subscription_update(
enable_advanced_filtering_on_arrays=enable_advanced_filtering_on_arrays,
delivery_attribute_mapping=delivery_attribute_mapping)

return client.update(
return client.begin_update(
resource_group_name,
system_topic_name,
event_subscription_name,
Expand Down Expand Up @@ -1213,7 +1259,7 @@ def cli_partner_topic_event_subscription_update(
enable_advanced_filtering_on_arrays=enable_advanced_filtering_on_arrays,
delivery_attribute_mapping=delivery_attribute_mapping)

return client.update(
return client.begin_update(
resource_group_name,
partner_topic_name,
event_subscription_name,
Expand Down Expand Up @@ -1650,9 +1696,12 @@ def _get_input_schema_and_mapping(
return input_schema, input_schema_mapping


def _list_event_subscriptions_by_resource_id(client, resource_id, oDataQuery, top):
def _list_event_subscriptions_by_resource_id(cmd, client, resource_id, oDataQuery, top):
# parse_resource_id doesn't handle resource_ids for Azure subscriptions and RGs
# so, first try to look for those two patterns.
from azure.cli.core.commands.client_factory import get_subscription_id
default_subscription_id = get_subscription_id(cmd.cli_ctx)

if resource_id is not None:
id_parts = list(filter(None, resource_id.split('/')))
if len(id_parts) < 5:
Expand All @@ -1663,7 +1712,7 @@ def _list_event_subscriptions_by_resource_id(client, resource_id, oDataQuery, to

subscription_id = id_parts[1]
_validate_subscription_id_matches_default_subscription_id(
default_subscription_id=client.config.subscription_id,
default_subscription_id=default_subscription_id,
provided_subscription_id=subscription_id)

if len(id_parts) == 2:
Expand All @@ -1687,7 +1736,7 @@ def _list_event_subscriptions_by_resource_id(client, resource_id, oDataQuery, to
id_parts = parse_resource_id(resource_id)
subscription_id = id_parts.get('subscription')
_validate_subscription_id_matches_default_subscription_id(
default_subscription_id=client.config.subscription_id,
default_subscription_id=default_subscription_id,
provided_subscription_id=subscription_id)

rg_name = id_parts.get('resource_group')
Expand Down
Loading