diff --git a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusClientBuilder.java b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusClientBuilder.java index 35ee837a92f7b..52dd169e8a18a 100644 --- a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusClientBuilder.java +++ b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusClientBuilder.java @@ -1990,7 +1990,7 @@ ServiceBusReceiverAsyncClient buildAsyncClient(boolean isAutoCompleteAllowed, bo * * @see ServiceBusRuleManagerAsyncClient */ - @ServiceClientBuilder(serviceClients = {ServiceBusRuleManagerAsyncClient.class}) + @ServiceClientBuilder(serviceClients = {ServiceBusRuleManagerAsyncClient.class, ServiceBusRuleManagerClient.class}) public final class ServiceBusRuleManagerBuilder { private String subscriptionName; private String topicName; diff --git a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusRuleManagerAsyncClient.java b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusRuleManagerAsyncClient.java index 467aa5bb736c4..e0fc6b728e2f9 100644 --- a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusRuleManagerAsyncClient.java +++ b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusRuleManagerAsyncClient.java @@ -8,7 +8,6 @@ import com.azure.messaging.servicebus.administration.ServiceBusAdministrationAsyncClient; import com.azure.messaging.servicebus.administration.models.CorrelationRuleFilter; import com.azure.messaging.servicebus.administration.models.CreateRuleOptions; -import com.azure.messaging.servicebus.administration.models.RuleFilter; import com.azure.messaging.servicebus.administration.models.RuleProperties; import com.azure.messaging.servicebus.administration.models.SqlRuleAction; import com.azure.messaging.servicebus.administration.models.SqlRuleFilter; @@ -143,24 +142,6 @@ public Mono createRule(String ruleName, CreateRuleOptions options) { return createRuleInternal(ruleName, options); } - /** - * Creates a rule to the current subscription to filter the messages reaching from topic to the subscription. - * - * @param ruleName Name of rule. - * @param filter The filter expression against which messages will be matched. - * @return A Mono that completes when the rule is created. - * - * @throws NullPointerException if {@code filter}, {@code ruleName} is null. - * @throws IllegalStateException if client is disposed. - * @throws IllegalArgumentException if ruleName is empty string, {@code filter} is not instanceof {@link SqlRuleFilter} or - * {@link CorrelationRuleFilter}. - * @throws ServiceBusException if filter matches {@code ruleName} is already created in subscription. - */ - public Mono createRule(String ruleName, RuleFilter filter) { - CreateRuleOptions options = new CreateRuleOptions(filter); - return createRuleInternal(ruleName, options); - } - /** * Fetches all rules associated with the topic and subscription. * @@ -169,7 +150,7 @@ public Mono createRule(String ruleName, RuleFilter filter) { * @throws IllegalStateException if client is disposed. * @throws UnsupportedOperationException if client cannot support filter with descriptor in message body. */ - public Flux getRules() { + public Flux listRules() { if (isDisposed.get()) { return fluxError(LOGGER, new IllegalStateException( String.format(INVALID_OPERATION_DISPOSED_RULE_MANAGER, "getRules") @@ -178,7 +159,7 @@ public Flux getRules() { return connectionProcessor .flatMap(connection -> connection.getManagementNode(entityPath, entityType)) - .flatMapMany(ServiceBusManagementNode::getRules); + .flatMapMany(ServiceBusManagementNode::listRules); } /** diff --git a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusRuleManagerClient.java b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusRuleManagerClient.java index fd3cf6c559b46..c1f730b38c4d1 100644 --- a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusRuleManagerClient.java +++ b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusRuleManagerClient.java @@ -8,7 +8,6 @@ import com.azure.messaging.servicebus.administration.ServiceBusAdministrationAsyncClient; import com.azure.messaging.servicebus.administration.models.CorrelationRuleFilter; import com.azure.messaging.servicebus.administration.models.CreateRuleOptions; -import com.azure.messaging.servicebus.administration.models.RuleFilter; import com.azure.messaging.servicebus.administration.models.RuleProperties; import com.azure.messaging.servicebus.administration.models.SqlRuleAction; import com.azure.messaging.servicebus.administration.models.SqlRuleFilter; @@ -83,22 +82,6 @@ public void createRule(String ruleName, CreateRuleOptions options) { asyncClient.createRule(ruleName, options).block(operationTimeout); } - /** - * Creates a rule to the current subscription to filter the messages reaching from topic to the subscription. - * - * @param ruleName Name of rule. - * @param filter The filter expression against which messages will be matched. - * - * @throws NullPointerException if {@code filter}, {@code ruleName} is null. - * @throws IllegalStateException if client is disposed. - * @throws IllegalArgumentException if ruleName is empty string, {@code filter} is not instanceof {@link SqlRuleFilter} or - * {@link CorrelationRuleFilter}. - * @throws ServiceBusException if filter matches {@code ruleName} is already created in subscription. - */ - public void createRule(String ruleName, RuleFilter filter) { - asyncClient.createRule(ruleName, filter).block(operationTimeout); - } - /** * Fetches all rules associated with the topic and subscription. * @@ -107,8 +90,8 @@ public void createRule(String ruleName, RuleFilter filter) { * @throws IllegalStateException if client is disposed. * @throws UnsupportedOperationException if client cannot support filter with descriptor in message body. */ - public IterableStream getRules() { - return new IterableStream<>(asyncClient.getRules()); + public IterableStream listRules() { + return new IterableStream<>(asyncClient.listRules()); } /** diff --git a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/implementation/ManagementChannel.java b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/implementation/ManagementChannel.java index c8ba06c5ac21a..30a289bea3887 100644 --- a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/implementation/ManagementChannel.java +++ b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/implementation/ManagementChannel.java @@ -506,7 +506,7 @@ public Mono deleteRule(String ruleName) { * {@inheritDoc} */ @Override - public Flux getRules() { + public Flux listRules() { return isAuthorized(OPERATION_GET_RULES).then(createChannel.flatMap(channel -> { final Message message = createManagementMessage(OPERATION_GET_RULES, null); diff --git a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/implementation/ServiceBusManagementNode.java b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/implementation/ServiceBusManagementNode.java index a8055321cf7dd..1ec1f222cc5f0 100644 --- a/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/implementation/ServiceBusManagementNode.java +++ b/sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/implementation/ServiceBusManagementNode.java @@ -146,7 +146,7 @@ Mono updateDisposition(String lockToken, DispositionStatus dispositionStat * * @return A collection of {@link RuleProperties rules}. */ - Flux getRules(); + Flux listRules(); @Override void close(); diff --git a/sdk/servicebus/azure-messaging-servicebus/src/samples/java/com/azure/messaging/servicebus/ManageRulesAsyncSample.java b/sdk/servicebus/azure-messaging-servicebus/src/samples/java/com/azure/messaging/servicebus/ManageRulesAsyncSample.java index f7b0841dc64d0..761115c6486cc 100644 --- a/sdk/servicebus/azure-messaging-servicebus/src/samples/java/com/azure/messaging/servicebus/ManageRulesAsyncSample.java +++ b/sdk/servicebus/azure-messaging-servicebus/src/samples/java/com/azure/messaging/servicebus/ManageRulesAsyncSample.java @@ -61,7 +61,7 @@ public void run() { ); // Fetch all rules. - ruleManager.getRules().subscribe(ruleProperties -> System.out.println(ruleProperties.getName())); + ruleManager.listRules().subscribe(ruleProperties -> System.out.println(ruleProperties.getName())); // Delete rule. ruleManager.deleteRule("exist-rule").subscribe( diff --git a/sdk/servicebus/azure-messaging-servicebus/src/samples/java/com/azure/messaging/servicebus/ServiceBusRuleManagerAsyncClientJavaDocSample.java b/sdk/servicebus/azure-messaging-servicebus/src/samples/java/com/azure/messaging/servicebus/ServiceBusRuleManagerAsyncClientJavaDocSample.java index 6af5a27b9701a..d0b21933706c3 100644 --- a/sdk/servicebus/azure-messaging-servicebus/src/samples/java/com/azure/messaging/servicebus/ServiceBusRuleManagerAsyncClientJavaDocSample.java +++ b/sdk/servicebus/azure-messaging-servicebus/src/samples/java/com/azure/messaging/servicebus/ServiceBusRuleManagerAsyncClientJavaDocSample.java @@ -84,7 +84,7 @@ public void createRule() { @Test public void getRules() { // BEGIN: com.azure.messaging.servicebus.servicebusrulemanagerasyncclient.getRules - ruleManager.getRules().subscribe(ruleProperties -> System.out.println(ruleProperties.getName())); + ruleManager.listRules().subscribe(ruleProperties -> System.out.println(ruleProperties.getName())); // END: com.azure.messaging.servicebus.servicebusrulemanagerasyncclient.getRules } diff --git a/sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/ServiceBusRuleManagerAsyncClientTest.java b/sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/ServiceBusRuleManagerAsyncClientTest.java index d4bdc2b0d7448..30506854f379d 100644 --- a/sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/ServiceBusRuleManagerAsyncClientTest.java +++ b/sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/ServiceBusRuleManagerAsyncClientTest.java @@ -12,7 +12,6 @@ import com.azure.core.util.ClientOptions; import com.azure.core.util.logging.ClientLogger; import com.azure.messaging.servicebus.administration.models.CreateRuleOptions; -import com.azure.messaging.servicebus.administration.models.RuleFilter; import com.azure.messaging.servicebus.administration.models.RuleProperties; import com.azure.messaging.servicebus.administration.models.SqlRuleFilter; import com.azure.messaging.servicebus.implementation.MessagingEntityType; @@ -37,8 +36,6 @@ import java.time.Duration; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; public class ServiceBusRuleManagerAsyncClientTest { @@ -120,20 +117,6 @@ void teardown(TestInfo testInfo) throws Exception { mocksCloseable.close(); } - /** - * Verifies that create a rule with a {@link RuleFilter}. - */ - @Test - void createRuleWithFilter() { - // Arrange - when(managementNode.createRule(eq(RULE_NAME), any(CreateRuleOptions.class))).thenReturn(Mono.empty()); - - // Act & Assert - StepVerifier.create(ruleManager.createRule(RULE_NAME, ruleFilter)) - .expectComplete() - .verify(); - } - /** * Verifies that create a rule with a {@link CreateRuleOptions}. */ @@ -150,10 +133,10 @@ void createRuleWithOptions() { @Test void getRules() { // Arrange - when(managementNode.getRules()).thenReturn(Flux.fromArray(new RuleProperties[]{ruleProperties1, ruleProperties2})); + when(managementNode.listRules()).thenReturn(Flux.fromArray(new RuleProperties[]{ruleProperties1, ruleProperties2})); // Act & Assert - StepVerifier.create(ruleManager.getRules()).expectNext(ruleProperties1, ruleProperties2).verifyComplete(); + StepVerifier.create(ruleManager.listRules()).expectNext(ruleProperties1, ruleProperties2).verifyComplete(); } @Test diff --git a/sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/implementation/ManagementChannelTests.java b/sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/implementation/ManagementChannelTests.java index 3ab7c031a7a51..9b712904fcc57 100644 --- a/sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/implementation/ManagementChannelTests.java +++ b/sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/implementation/ManagementChannelTests.java @@ -586,7 +586,7 @@ void getRules() { responseMessage.setBody(message.getBody()); // Assert response message content. - StepVerifier.create(managementChannel.getRules()) + StepVerifier.create(managementChannel.listRules()) .assertNext(ruleProperties -> { assertEquals("$Default", ruleProperties.getName()); assertEquals(ruleProperties.getFilter(), new TrueRuleFilter());