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] Create rule by default create a TrueRuleFilter #15507

Merged
merged 1 commit into from
Nov 23, 2020
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 sdk/servicebus/azure-servicebus/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ raise `ValueError` if the `queue_name` or `topic_name` does not match the `Entit

**BugFixes**

* `ServiceBusAdministrationClient.create_rule` by default now creates a `TrueRuleFilter` rule.
* FQDNs and Connection strings are now supported even with strippable whitespace or protocol headers (e.g. 'sb://').
* Using parameter `auto_lock_renewer` on a sessionful receiver alongside `ReceiveMode.ReceiveAndDelete` will no longer fail during receipt due to failure to register the message with the renewer.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@
from ...management import _constants as constants
from ._shared_key_policy_async import AsyncServiceBusSharedKeyCredentialPolicy
from ...management._models import QueueRuntimeProperties, QueueProperties, TopicProperties, TopicRuntimeProperties, \
SubscriptionProperties, SubscriptionRuntimeProperties, RuleProperties, NamespaceProperties
SubscriptionProperties, SubscriptionRuntimeProperties, RuleProperties, NamespaceProperties, TrueRuleFilter
from ...management._xml_workaround_policy import ServiceBusXMLWorkaroundPolicy
from ...management._handle_response_error import _handle_response_error
from ...management._model_workaround import avoid_timedelta_overflow
from ._utils import extract_data_template, extract_rule_data_template, get_next_template
from ...management._utils import deserialize_rule_key_values, serialize_rule_key_values, \
_validate_entity_name_type, _validate_topic_and_subscription_types, _validate_topic_subscription_and_rule_types


if TYPE_CHECKING:
from azure.core.credentials_async import AsyncTokenCredential # pylint:disable=ungrouped-imports

Expand Down Expand Up @@ -801,7 +800,7 @@ async def create_rule(
will own the to-be-created rule.
:param rule_name: Name of the rule.
:type rule_name: str
:keyword filter: The filter of the rule.
:keyword filter: The filter of the rule. The default value is ~azure.servicebus.management.TrueRuleFilter
:type filter: Union[~azure.servicebus.management.CorrelationRuleFilter,
~azure.servicebus.management.SqlRuleFilter]
:keyword action: The action of the rule.
Expand All @@ -813,7 +812,7 @@ async def create_rule(

rule = RuleProperties(
rule_name,
filter=kwargs.pop("filter", None),
filter=kwargs.pop("filter", TrueRuleFilter()),
action=kwargs.pop("action", None),
created_at_utc=None
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from ._model_workaround import avoid_timedelta_overflow
from . import _constants as constants
from ._models import QueueRuntimeProperties, QueueProperties, TopicProperties, TopicRuntimeProperties, \
SubscriptionProperties, SubscriptionRuntimeProperties, RuleProperties, NamespaceProperties
SubscriptionProperties, SubscriptionRuntimeProperties, RuleProperties, NamespaceProperties, TrueRuleFilter
from ._handle_response_error import _handle_response_error

if TYPE_CHECKING:
Expand Down Expand Up @@ -805,7 +805,7 @@ def create_rule(self, topic_name, subscription_name, rule_name, **kwargs):
will own the to-be-created rule.
:param rule_name: Name of the rule.
:type rule_name: str
:keyword filter: The filter of the rule.
:keyword filter: The filter of the rule. The default value is ~azure.servicebus.management.TrueRuleFilter
:type filter: Union[~azure.servicebus.management.CorrelationRuleFilter,
~azure.servicebus.management.SqlRuleFilter]
:keyword action: The action of the rule.
Expand All @@ -816,7 +816,7 @@ def create_rule(self, topic_name, subscription_name, rule_name, **kwargs):

rule = RuleProperties(
rule_name,
filter=kwargs.pop("filter", None),
filter=kwargs.pop("filter", TrueRuleFilter()),
action=kwargs.pop("action", None),
created_at_utc=None
)
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async def test_async_mgmt_rule_create(self, servicebus_namespace_connection_stri
rule_name_1 = 'test_rule_1'
rule_name_2 = 'test_rule_2'
rule_name_3 = 'test_rule_3'
rule_name_4 = 'test_rule_4'

correlation_fitler = CorrelationRuleFilter(correlation_id='testcid', properties={
"key_string": "str1",
Expand Down Expand Up @@ -83,10 +84,15 @@ async def test_async_mgmt_rule_create(self, servicebus_namespace_connection_stri
rule_desc = await mgmt_service.get_rule(topic_name, subscription_name, rule_name_3)
assert type(rule_desc.filter) == TrueRuleFilter

await mgmt_service.create_rule(topic_name, subscription_name, rule_name_4)
rule_desc = await mgmt_service.get_rule(topic_name, subscription_name, rule_name_4)
assert type(rule_desc.filter) == TrueRuleFilter

finally:
await mgmt_service.delete_rule(topic_name, subscription_name, rule_name_1)
await mgmt_service.delete_rule(topic_name, subscription_name, rule_name_2)
await mgmt_service.delete_rule(topic_name, subscription_name, rule_name_3)
await mgmt_service.delete_rule(topic_name, subscription_name, rule_name_4)
await mgmt_service.delete_subscription(topic_name, subscription_name)
await mgmt_service.delete_topic(topic_name)

Expand Down
Loading