Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ServiceBus] add keyword override support to update_ methods in mgmt module #18210

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
updat impl
  • Loading branch information
yunhaoling committed Apr 22, 2021
commit 1a6c80eb048a15717f62e6303740dac0fbbd1b72
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ async def update_queue(
)
)

override_properties_with_keyword_arguments(queue, **kwargs)
property_keyword_arguments = {key: kwargs.pop(key) for key in set(kwargs.keys()) if key in queue.keys()}
swathipil marked this conversation as resolved.
Show resolved Hide resolved
override_properties_with_keyword_arguments(queue, **property_keyword_arguments)
yunhaoling marked this conversation as resolved.
Show resolved Hide resolved

to_update = queue._to_internal_entity()

Expand Down Expand Up @@ -673,7 +674,8 @@ async def update_topic(
"""

topic = deepcopy(create_properties_from_dict_if_needed(topic, TopicProperties))
override_properties_with_keyword_arguments(topic, **kwargs)
property_keyword_arguments = {key: kwargs.pop(key) for key in set(kwargs.keys()) if key in topic.keys()}
override_properties_with_keyword_arguments(topic, **property_keyword_arguments)
to_update = topic._to_internal_entity()

to_update.default_message_time_to_live = avoid_timedelta_overflow( # type: ignore
Expand Down Expand Up @@ -944,10 +946,9 @@ async def update_subscription(
self.fully_qualified_namespace,
)
)
override_properties_with_keyword_arguments(
subscription,
**kwargs
)
property_keyword_arguments = {key: kwargs.pop(key) for key in set(kwargs.keys()) if key in subscription.keys()}
override_properties_with_keyword_arguments(subscription, **property_keyword_arguments)

to_update = subscription._to_internal_entity()

to_update.default_message_time_to_live = avoid_timedelta_overflow( # type: ignore
Expand Down Expand Up @@ -1150,7 +1151,8 @@ async def update_rule(
_validate_topic_and_subscription_types(topic_name, subscription_name)
# we should not mutate the input, making a copy first for update
rule = deepcopy(create_properties_from_dict_if_needed(rule, RuleProperties))
override_properties_with_keyword_arguments(rule, **kwargs)
property_keyword_arguments = {key: kwargs.pop(key) for key in set(kwargs.keys()) if key in rule.keys()}
override_properties_with_keyword_arguments(rule, **property_keyword_arguments)
to_update = rule._to_internal_entity()

create_entity_body = CreateRuleBody(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,7 @@ def update_queue(self, queue, **kwargs):
)

property_keyword_arguments = {key: kwargs.pop(key) for key in set(kwargs.keys()) if key in queue.keys()}
override_properties_with_keyword_arguments(
queue,
**property_keyword_arguments
)
override_properties_with_keyword_arguments(queue, **property_keyword_arguments)

to_update = queue._to_internal_entity()
to_update.default_message_time_to_live = avoid_timedelta_overflow(
Expand Down Expand Up @@ -668,10 +665,7 @@ def update_topic(self, topic, **kwargs):
# we should not mutate the input, making a copy first for update
topic = deepcopy(create_properties_from_dict_if_needed(topic, TopicProperties))
property_keyword_arguments = {key: kwargs.pop(key) for key in set(kwargs.keys()) if key in topic.keys()}
override_properties_with_keyword_arguments(
topic,
**property_keyword_arguments
)
override_properties_with_keyword_arguments(topic, **property_keyword_arguments)
to_update = topic._to_internal_entity()

to_update.default_message_time_to_live = avoid_timedelta_overflow( # type: ignore
Expand Down Expand Up @@ -939,7 +933,6 @@ def update_subscription(self, topic_name, subscription, **kwargs):
self.fully_qualified_namespace,
)
)

property_keyword_arguments = {key: kwargs.pop(key) for key in set(kwargs.keys()) if key in subscription.keys()}
override_properties_with_keyword_arguments(subscription, **property_keyword_arguments)

Expand Down Expand Up @@ -1135,10 +1128,7 @@ def update_rule(self, topic_name, subscription_name, rule, **kwargs):
# we should not mutate the input, making a copy first for update
rule = deepcopy(create_properties_from_dict_if_needed(rule, RuleProperties))
property_keyword_arguments = {key: kwargs.pop(key) for key in set(kwargs.keys()) if key in rule.keys()}
override_properties_with_keyword_arguments(
rule,
**property_keyword_arguments
)
override_properties_with_keyword_arguments(rule, **property_keyword_arguments)
to_update = rule._to_internal_entity()

create_entity_body = CreateRuleBody(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,6 @@ def override_properties_with_keyword_arguments(properties, **kwargs):
# type: (PropertiesType, Any) -> None
if not kwargs:
return
intersection_keys = set.intersection(set(properties.keys()), set(kwargs.keys()))
for key in intersection_keys:
properties[key] = kwargs.get(key)
for key in kwargs.keys():
if key in properties.keys():
properties[key] = kwargs.get(key)
swathipil marked this conversation as resolved.
Show resolved Hide resolved