forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ServiceBusAdministrationClient.java
1341 lines (1276 loc) · 70.8 KB
/
ServiceBusAdministrationClient.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.messaging.servicebus.administration;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.exception.ClientAuthenticationException;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceExistsException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;
import com.azure.messaging.servicebus.administration.models.CreateQueueOptions;
import com.azure.messaging.servicebus.administration.models.CreateRuleOptions;
import com.azure.messaging.servicebus.administration.models.CreateSubscriptionOptions;
import com.azure.messaging.servicebus.administration.models.CreateTopicOptions;
import com.azure.messaging.servicebus.administration.models.NamespaceProperties;
import com.azure.messaging.servicebus.administration.models.QueueProperties;
import com.azure.messaging.servicebus.administration.models.QueueRuntimeProperties;
import com.azure.messaging.servicebus.administration.models.RuleProperties;
import com.azure.messaging.servicebus.administration.models.SubscriptionProperties;
import com.azure.messaging.servicebus.administration.models.SubscriptionRuntimeProperties;
import com.azure.messaging.servicebus.administration.models.TopicProperties;
import com.azure.messaging.servicebus.administration.models.TopicRuntimeProperties;
import reactor.core.publisher.Mono;
import java.time.Duration;
import java.util.Objects;
import java.util.function.Function;
/**
* A <b>synchronous</b> client for managing a Service Bus namespace.
*
* <p><strong>Create a queue</strong></p>
* {@codesnippet com.azure.messaging.servicebus.administration.servicebusadministrationclient.createqueue#string}
*
* <p><strong>Edit an existing subscription</strong></p>
* {@codesnippet com.azure.messaging.servicebus.administration.servicebusadministrationclient.updatesubscription#subscriptionproperties}
*
* <p><strong>List all queues</strong></p>
* {@codesnippet com.azure.messaging.servicebus.administration.servicebusadministrationclient.listQueues}
*
* @see ServiceBusAdministrationClientBuilder
* @see ServiceBusAdministrationAsyncClient ServiceBusAdministrationAsyncClient for an asynchronous client.
*/
@ServiceClient(builder = ServiceBusAdministrationClientBuilder.class)
public final class ServiceBusAdministrationClient {
private final ServiceBusAdministrationAsyncClient asyncClient;
/**
* Creates a new instance with the given client.
*
* @param asyncClient Asynchronous client to perform management calls through.
*/
ServiceBusAdministrationClient(ServiceBusAdministrationAsyncClient asyncClient) {
this.asyncClient = Objects.requireNonNull(asyncClient, "'asyncClient' cannot be null.");
}
/**
* Creates a queue with the given name.
*
* @param queueName Name of the queue to create.
*
* @return The created queue.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If the request body was invalid, the queue quota is exceeded, or an error
* occurred processing the request.
* @throws NullPointerException if {@code queueName} is null.
* @throws IllegalArgumentException if {@code queueName} is an empty string.
* @throws ResourceExistsException if a queue exists with the same {@code queueName}.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/update-entity">Create or Update Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public QueueProperties createQueue(String queueName) {
return asyncClient.createQueue(queueName).block();
}
/**
* Creates a queue with the {@link CreateQueueOptions}.
*
* @param queueName Name of the queue to create.
* @param queueOptions Information about the queue to create.
*
* @return The created queue.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If the request body was invalid, the queue quota is exceeded, or an error
* occurred processing the request.
* @throws NullPointerException if {@code queue} is null.
* @throws ResourceExistsException if a queue exists with the same {@link QueueProperties#getName() queueName}.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/update-entity">Create or Update Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public QueueProperties createQueue(String queueName, CreateQueueOptions queueOptions) {
return asyncClient.createQueue(queueName, queueOptions).block();
}
/**
* Creates a queue and returns the created queue in addition to the HTTP response.
*
* @param queueName Name of the queue to create.
* @param queueOptions Information about the queue to create.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return The created queue in addition to the HTTP response.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If the request body was invalid, the queue quota is exceeded, or an error
* occurred processing the request.
* @throws NullPointerException if {@code queue} is null.
* @throws ResourceExistsException if a queue exists with the same {@link QueueProperties#getName() queueName}.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/update-entity">Create or Update Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<QueueProperties> createQueueWithResponse(String queueName, CreateQueueOptions queueOptions,
Context context) {
return asyncClient.createQueueWithResponse(queueName, queueOptions, context != null ? context : Context.NONE)
.block();
}
/**
* Creates a rule under the given topic and subscription
*
* @param topicName Name of the topic associated with rule.
* @param subscriptionName Name of the subscription associated with the rule.
* @param ruleName Name of the rule.
*
* @return Information about the created rule.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If the request body was invalid, the quota is exceeded, or an error occurred
* processing the request.
* @throws IllegalArgumentException if {@code topicName} or {@code ruleName} are are empty strings.
* @throws NullPointerException if {@code topicName} or {@code ruleName} are are null.
* @throws ResourceExistsException if a rule exists with the same topic, subscription, and rule name.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public RuleProperties createRule(String topicName, String subscriptionName, String ruleName) {
return asyncClient.createRule(topicName, subscriptionName, ruleName).block();
}
/**
* Creates a rule with the {@link CreateRuleOptions}.
*
* @param topicName Name of the topic associated with rule.
* @param subscriptionName Name of the subscription associated with the rule.
* @param ruleName Name of the rule.
* @param ruleOptions Information about the rule to create.
*
* @return Information about the created rule.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If the request body was invalid, the quota is exceeded, or an error occurred
* processing the request.
* @throws IllegalArgumentException if {@code topicName} or {@code ruleName} are are empty strings.
* @throws NullPointerException if {@code topicName}, {@code ruleName}, or {@code ruleOptions} are are null.
* @throws ResourceExistsException if a rule exists with the same topic and rule name.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public RuleProperties createRule(String topicName, String ruleName, String subscriptionName,
CreateRuleOptions ruleOptions) {
return asyncClient.createRule(topicName, subscriptionName, ruleName, ruleOptions).block();
}
/**
* Creates a rule and returns the created rule in addition to the HTTP response.
*
* @param topicName Name of the topic associated with rule.
* @param subscriptionName Name of the subscription associated with the rule.
* @param ruleName Name of the rule.
* @param ruleOptions Information about the rule to create.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return The created rule in addition to the HTTP response.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If the request body was invalid, the quota is exceeded, or an error occurred
* processing the request.
* @throws IllegalArgumentException if {@code topicName} or {@code ruleName} are are empty strings.
* @throws NullPointerException if {@code topicName}, {@code ruleName}, or {@code ruleOptions} are are null.
* @throws ResourceExistsException if a rule exists with the same topic and rule name.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<RuleProperties> createRuleWithResponse(String topicName, String subscriptionName,
String ruleName, CreateRuleOptions ruleOptions, Context context) {
return asyncClient.createRuleWithResponse(topicName, subscriptionName, ruleName, ruleOptions, context).block();
}
/**
* Creates a subscription with the given topic and subscription names.
*
* @param topicName Name of the topic associated with subscription.
* @param subscriptionName Name of the subscription.
*
* @return Information about the created subscription.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If the request body was invalid, the quota is exceeded, or an error occurred
* processing the request.
* @throws NullPointerException if {@code topicName} or {@code subscriptionName} are are empty strings.
* @throws IllegalArgumentException if {@code topicName} or {@code subscriptionName} are are null.
* @throws ResourceExistsException if a subscription exists with the same topic and subscription name.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/update-entity">Create or Update Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SubscriptionProperties createSubscription(String topicName, String subscriptionName) {
return asyncClient.createSubscription(topicName, subscriptionName).block();
}
/**
* Creates a subscription with the {@link SubscriptionProperties}.
*
* @param topicName Name of the topic associated with subscription.
* @param subscriptionName Name of the subscription.
* @param subscriptionOptions Information about the subscription to create.
*
* @return Information about the created subscription.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If the request body was invalid, the quota is exceeded, or an error occurred
* processing the request.
* @throws IllegalArgumentException if {@code topicName} or {@code subscriptionName} are are empty strings.
* @throws NullPointerException if {@code topicName}, {@code subscriptionName}, or {@code subscriptionOptions}
* are are null.
* @throws ResourceExistsException if a subscription exists with the same topic and subscription name.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/update-entity">Create or Update Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SubscriptionProperties createSubscription(String topicName, String subscriptionName,
CreateSubscriptionOptions subscriptionOptions) {
return asyncClient.createSubscription(topicName, subscriptionName, subscriptionOptions).block();
}
/**
* Creates a queue and returns the created queue in addition to the HTTP response.
*
* @param topicName Name of the topic associated with subscription.
* @param subscriptionName Name of the subscription.
* @param subscriptionOptions Information about the subscription to create.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return The created subscription in addition to the HTTP response.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If the request body was invalid, the quota is exceeded, or an error occurred
* processing the request.
* @throws NullPointerException if {@code subscription} is null.
* @throws ResourceExistsException if a subscription exists with the same topic and subscription name.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/update-entity">Create or Update Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<SubscriptionProperties> createSubscriptionWithResponse(String topicName, String subscriptionName,
CreateSubscriptionOptions subscriptionOptions, Context context) {
return asyncClient.createSubscriptionWithResponse(topicName, subscriptionName, subscriptionOptions,
context != null ? context : Context.NONE).block();
}
/**
* Creates a topic with the given name.
*
* @param topicName Name of the topic to create.
*
* @return Information about the created topic.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If the request body was invalid, the topic quota is exceeded, or an error
* occurred processing the request.
* @throws NullPointerException if {@code topicName} is null.
* @throws IllegalArgumentException if {@code topicName} is an empty string.
* @throws ResourceExistsException if a topic exists with the same {@code topicName}.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/update-entity">Create or Update Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public TopicProperties createTopic(String topicName) {
return asyncClient.createTopic(topicName).block();
}
/**
* Creates a topic with the {@link CreateTopicOptions}.
*
* @param topicName Name of the topic to create.
* @param topicOptions Information about the topic to create.
*
* @return Information about the created topic.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If the request body was invalid, the topicOptions quota is exceeded, or an
* error occurred processing the request.
* @throws IllegalArgumentException if {@code topicName} is an empty string.
* @throws NullPointerException if {@code topicName} or {@code topicOptions} is null.
* @throws ResourceExistsException if a topic exists with the same {@code topicName}.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/update-entity">Create or Update Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public TopicProperties createTopic(String topicName, CreateTopicOptions topicOptions) {
return asyncClient.createTopic(topicName, topicOptions).block();
}
/**
* Creates a topic and returns the created topic in addition to the HTTP response.
*
* @param topicName Name of the topic to create.
* @param topicOptions Information about the topic to create.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return The created topic in addition to the HTTP response.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If the request body was invalid, the topic quota is exceeded, or an error
* occurred processing the request.
* @throws IllegalArgumentException if {@code topicName} is an empty string.
* @throws NullPointerException if {@code topicName} or {@code topicOptions} is null.
* @throws ResourceExistsException if a topic exists with the same {@code topicName}.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/update-entity">Create or Update Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<TopicProperties> createTopicWithResponse(String topicName, CreateTopicOptions topicOptions,
Context context) {
return asyncClient.createTopicWithResponse(topicName, topicOptions, context != null ? context : Context.NONE)
.block();
}
/**
* Deletes a queue the matching {@code queueName}.
*
* @param queueName Name of queue to delete.
*
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code queueName} is an empty string.
* @throws NullPointerException if {@code queueName} is null.
* @throws ResourceNotFoundException if the {@code queueName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/delete-queue">Delete Queue</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void deleteQueue(String queueName) {
asyncClient.deleteQueue(queueName).block();
}
/**
* Deletes a queue the matching {@code queueName} and returns the HTTP response.
*
* @param queueName Name of queue to delete.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return The HTTP response when the queue is successfully deleted.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code queueName} is an empty string.
* @throws NullPointerException if {@code queueName} is null.
* @throws ResourceNotFoundException if the {@code queueName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/delete-queue">Delete Queue</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> deleteQueueWithResponse(String queueName, Context context) {
return asyncClient.deleteQueueWithResponse(queueName, context != null ? context : Context.NONE).block();
}
/**
* Deletes a rule the matching {@code ruleName}.
*
* @param topicName Name of topic associated with rule to delete.
* @param subscriptionName Name of the subscription associated with the rule to delete.
* @param ruleName Name of rule to delete.
*
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code topicName} or {@code ruleName} is an empty string.
* @throws NullPointerException if {@code topicName} or {@code ruleName} is null.
* @throws ResourceNotFoundException if the {@code ruleName} does not exist.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void deleteRule(String topicName, String subscriptionName, String ruleName) {
asyncClient.deleteRule(topicName, subscriptionName, ruleName).block();
}
/**
* Deletes a rule the matching {@code ruleName} and returns the HTTP response.
*
* @param topicName Name of topic associated with rule to delete.
* @param subscriptionName Name of the subscription associated with the rule to delete.
* @param ruleName Name of rule to delete.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return The HTTP response.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code topicName}, {@code subscriptionName}, or {@code ruleName} is an
* empty string.
* @throws NullPointerException if {@code topicName}, {@code subscriptionName}, or {@code ruleName} is null.
* @throws ResourceNotFoundException if the {@code ruleName} does not exist.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> deleteRuleWithResponse(String topicName, String subscriptionName,
String ruleName, Context context) {
return asyncClient.deleteRuleWithResponse(topicName, subscriptionName, ruleName,
context != null ? context : Context.NONE).block();
}
/**
* Deletes a subscription the matching {@code subscriptionName}.
*
* @param topicName Name of topic associated with subscription to delete.
* @param subscriptionName Name of subscription to delete.
*
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code topicName} or {@code subscriptionName} is an empty string.
* @throws NullPointerException if {@code topicName} or {@code subscriptionName} is null.
* @throws ResourceNotFoundException if the {@code subscriptionName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/delete-subscription">Delete Subscription</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void deleteSubscription(String topicName, String subscriptionName) {
asyncClient.deleteSubscription(topicName, subscriptionName);
}
/**
* Deletes a subscription the matching {@code subscriptionName} and returns the HTTP response.
*
* @param topicName Name of topic associated with subscription to delete.
* @param subscriptionName Name of subscription to delete.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return The HTTP response.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code topicName} or {@code subscriptionName} is an empty string.
* @throws NullPointerException if {@code topicName} or {@code subscriptionName} is null.
* @throws ResourceNotFoundException if the {@code subscriptionName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/delete-subscription">Delete Subscription</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> deleteSubscriptionWithResponse(String topicName, String subscriptionName, Context context) {
return asyncClient.deleteSubscriptionWithResponse(topicName, subscriptionName,
context != null ? context : Context.NONE).block();
}
/**
* Deletes a topic the matching {@code topicName}.
*
* @param topicName Name of topic to delete.
*
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code topicName} is an empty string.
* @throws NullPointerException if {@code topicName} is null.
* @throws ResourceNotFoundException if the {@code topicName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/delete-topic">Delete Topic</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public void deleteTopic(String topicName) {
asyncClient.deleteTopic(topicName).block();
}
/**
* Deletes a topic the matching {@code topicName} and returns the HTTP response.
*
* @param topicName Name of topic to delete.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return The HTTP response.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code topicName} is an empty string.
* @throws NullPointerException if {@code topicName} is null.
* @throws ResourceNotFoundException if the {@code topicName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/delete-topic">Delete Topic</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Void> deleteTopicWithResponse(String topicName, Context context) {
return asyncClient.deleteTopicWithResponse(topicName, context != null ? context : Context.NONE).block();
}
/**
* Gets information about the queue.
*
* @param queueName Name of queue to get information about.
*
* @return Information about the queue.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code queueName} is an empty string.
* @throws NullPointerException if {@code queueName} is null.
* @throws ResourceNotFoundException if the {@code queueName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/get-entity">Get Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public QueueProperties getQueue(String queueName) {
return asyncClient.getQueue(queueName).block();
}
/**
* Gets information about the queue along with its HTTP response.
*
* @param queueName Name of queue to get information about.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return Information about the queue and the associated HTTP response.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code queueName} is an empty string.
* @throws NullPointerException if {@code queueName} is null.
* @throws ResourceNotFoundException if the {@code queueName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/get-entity">Get Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<QueueProperties> getQueueWithResponse(String queueName, Context context) {
return asyncClient.getQueueWithResponse(queueName, context != null ? context : Context.NONE,
Function.identity()).block();
}
/**
* Gets whether or not a queue with {@code queueName} exists in the Service Bus namespace.
*
* @param queueName Name of the queue.
*
* @return {@code true} if the queue exists; otherwise {@code false}.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code queueName} is an empty string.
* @throws NullPointerException if {@code queueName} is null.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public boolean getQueueExists(String queueName) {
final Boolean exists = asyncClient.getQueueExists(queueName).block();
return exists != null && exists;
}
/**
* Gets whether or not a queue with {@code queueName} exists in the Service Bus namespace.
*
* @param queueName Name of the queue.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return The HTTP response and {@code true} if the queue exists; otherwise {@code false}.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code queueName} is an empty string.
* @throws NullPointerException if {@code queueName} is null.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Boolean> getQueueExistsWithResponse(String queueName, Context context) {
final Mono<Response<QueueProperties>> queueWithResponse =
asyncClient.getQueueWithResponse(queueName, context != null ? context : Context.NONE, Function.identity());
return asyncClient.getEntityExistsWithResponse(queueWithResponse).block();
}
/**
* Gets runtime properties about the queue.
*
* @param queueName Name of queue to get information about.
*
* @return Runtime properties about the queue.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code queueName} is an empty string.
* @throws NullPointerException if {@code queueName} is null.
* @throws ResourceNotFoundException if the {@code queueName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/get-entity">Get Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public QueueRuntimeProperties getQueueRuntimeProperties(String queueName) {
return asyncClient.getQueueRuntimeProperties(queueName).block();
}
/**
* Gets runtime properties about the queue along with its HTTP response.
*
* @param queueName Name of queue to get information about.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return Runtime properties about the queue and the associated HTTP response.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code queueName} is an empty string.
* @throws NullPointerException if {@code queueName} is null.
* @throws ResourceNotFoundException if the {@code queueName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/get-entity">Get Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<QueueRuntimeProperties> getQueueRuntimePropertiesWithResponse(String queueName, Context context) {
return asyncClient.getQueueWithResponse(queueName, context != null ? context : Context.NONE,
QueueRuntimeProperties::new).block();
}
/**
* Gets information about the Service Bus namespace.
*
* @return Information about the Service Bus namespace.
* @throws ClientAuthenticationException if the client's credentials do not have access to the namespace.
* @throws HttpResponseException If error occurred processing the request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public NamespaceProperties getNamespaceProperties() {
return asyncClient.getNamespaceProperties().block();
}
/**
* Gets information about the Service Bus namespace along with its HTTP response.
*
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return Information about the namespace and the associated HTTP response.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<NamespaceProperties> getNamespacePropertiesWithResponse(Context context) {
return asyncClient.getNamespacePropertiesWithResponse(context).block();
}
/**
* Gets a rule from the service namespace.
*
* Only following data types are deserialized in Filters and Action parameters - string, int, long, boolean, double,
* and OffsetDateTime. Other data types would return its string value.
*
* @param topicName The name of the topic relative to service bus namespace.
* @param subscriptionName The subscription name the rule belongs to.
* @param ruleName The name of the rule to retrieve.
*
* @return The associated rule.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public RuleProperties getRule(String topicName, String subscriptionName, String ruleName) {
return asyncClient.getRule(topicName, subscriptionName, ruleName).block();
}
/**
* Gets a rule from the service namespace.
*
* Only following data types are deserialized in Filters and Action parameters - string, int, long, bool, double,
* and OffsetDateTime. Other data types would return its string value.
*
* @param topicName The name of the topic relative to service bus namespace.
* @param subscriptionName The subscription name the rule belongs to.
* @param ruleName The name of the rule to retrieve.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return The associated rule with the corresponding HTTP response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<RuleProperties> getRuleWithResponse(String topicName, String subscriptionName,
String ruleName, Context context) {
return asyncClient.getRuleWithResponse(topicName, subscriptionName, ruleName,
context != null ? context : Context.NONE).block();
}
/**
* Gets information about the queue.
*
* @param topicName Name of topic associated with subscription.
* @param subscriptionName Name of subscription to get information about.
*
* @return Information about the subscription.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code topicName} or {@code subscriptionName} are empty strings.
* @throws NullPointerException if {@code topicName} or {@code subscriptionName} are null.
* @throws ResourceNotFoundException if the {@code subscriptionName} does not exist in the {@code topicName}.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/get-entity">Get Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SubscriptionProperties getSubscription(String topicName, String subscriptionName) {
return asyncClient.getSubscription(topicName, subscriptionName).block();
}
/**
* Gets information about the subscription along with its HTTP response.
*
* @param topicName Name of topic associated with subscription.
* @param subscriptionName Name of subscription to get information about.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return Information about the subscription and the associated HTTP response.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code topicName} or {@code subscriptionName} are empty strings.
* @throws NullPointerException if {@code topicName} or {@code subscriptionName} are null.
* @throws ResourceNotFoundException if the {@code subscriptionName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/get-entity">Get Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<SubscriptionProperties> getSubscriptionWithResponse(String topicName,
String subscriptionName, Context context) {
return asyncClient.getSubscriptionWithResponse(topicName, subscriptionName,
context != null ? context : Context.NONE, Function.identity()).block();
}
/**
* Gets whether or not a subscription within a topic exists.
*
* @param topicName Name of topic associated with subscription.
* @param subscriptionName Name of the subscription.
*
* @return {@code true} if the subscription exists.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code subscriptionName} is an empty string.
* @throws NullPointerException if {@code subscriptionName} is null.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public boolean getSubscriptionExists(String topicName, String subscriptionName) {
final Boolean exists = asyncClient.getSubscriptionExists(topicName, subscriptionName).block();
return exists != null && exists;
}
/**
* Gets whether or not a subscription within a topic exists.
*
* @param topicName Name of topic associated with subscription.
* @param subscriptionName Name of the subscription.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return The HTTP response and {@code true} if the subscription exists; otherwise {@code false}.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code subscriptionName} is an empty string.
* @throws NullPointerException if {@code subscriptionName} is null.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Boolean> getSubscriptionExistsWithResponse(String topicName, String subscriptionName,
Context context) {
final Mono<Response<SubscriptionProperties>> subscriptionWithResponse =
asyncClient.getSubscriptionWithResponse(topicName, subscriptionName,
context != null ? context : Context.NONE, Function.identity());
return asyncClient.getEntityExistsWithResponse(subscriptionWithResponse).block();
}
/**
* Gets runtime properties about the subscription.
*
* @param topicName Name of topic associated with subscription.
* @param subscriptionName Name of subscription to get information about.
*
* @return Runtime properties about the subscription.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code subscriptionName} is an empty string.
* @throws NullPointerException if {@code subscriptionName} is null.
* @throws ResourceNotFoundException if the {@code subscriptionName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/get-entity">Get Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public SubscriptionRuntimeProperties getSubscriptionRuntimeProperties(String topicName, String subscriptionName) {
return asyncClient.getSubscriptionRuntimeProperties(topicName, subscriptionName).block();
}
/**
* Gets runtime properties about the subscription.
*
* @param topicName Name of topic associated with subscription.
* @param subscriptionName Name of subscription to get information about.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return Runtime properties about the subscription.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code subscriptionName} is an empty string.
* @throws NullPointerException if {@code subscriptionName} is null.
* @throws ResourceNotFoundException if the {@code subscriptionName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/get-entity">Get Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<SubscriptionRuntimeProperties> getSubscriptionRuntimePropertiesWithResponse(
String topicName, String subscriptionName, Context context) {
return asyncClient.getSubscriptionWithResponse(topicName, subscriptionName,
context != null ? context : Context.NONE, SubscriptionRuntimeProperties::new).block();
}
/**
* Gets information about the topic.
*
* @param topicName Name of topic to get information about.
*
* @return Information about the topic.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code topicName} is an empty string.
* @throws NullPointerException if {@code topicName} is null.
* @throws ResourceNotFoundException if the {@code topicName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/get-entity">Get Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public TopicProperties getTopic(String topicName) {
return asyncClient.getTopic(topicName).block();
}
/**
* Gets information about the topic along with its HTTP response.
*
* @param topicName Name of topic to get information about.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return Information about the topic and the associated HTTP response.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code topicName} is an empty string.
* @throws NullPointerException if {@code topicName} is null.
* @throws ResourceNotFoundException if the {@code topicName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/get-entity">Get Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<TopicProperties> getTopicWithResponse(String topicName, Context context) {
return asyncClient.getTopicWithResponse(topicName, context != null ? context : Context.NONE,
Function.identity()).block();
}
/**
* Gets whether or not a topic with {@code topicName} exists in the Service Bus namespace.
*
* @param topicName Name of the topic.
*
* @return {@code true} if the topic exists.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code topicName} is an empty string.
* @throws NullPointerException if {@code topicName} is null.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public boolean getTopicExists(String topicName) {
final Boolean exists = asyncClient.getTopicExists(topicName).block();
return exists != null && exists;
}
/**
* Gets whether or not a topic with {@code topicName} exists in the Service Bus namespace.
*
* @param topicName Name of the topic.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return The HTTP response and {@code true} if the topic exists; otherwise {@code false}.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code topicName} is an empty string.
* @throws NullPointerException if {@code topicName} is null.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<Boolean> getTopicExistsWithResponse(String topicName, Context context) {
final Mono<Response<TopicProperties>> topicWithResponse =
asyncClient.getTopicWithResponse(topicName, context != null ? context : Context.NONE, Function.identity());
return asyncClient.getEntityExistsWithResponse(topicWithResponse).block();
}
/**
* Gets runtime properties about the topic.
*
* @param topicName Name of topic to get information about.
*
* @return Runtime properties about the topic.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code topicName} is an empty string.
* @throws NullPointerException if {@code topicName} is null.
* @throws ResourceNotFoundException if the {@code topicName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/get-entity">Get Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public TopicRuntimeProperties getTopicRuntimeProperties(String topicName) {
return asyncClient.getTopicRuntimeProperties(topicName).block();
}
/**
* Gets runtime properties about the topic with its HTTP response.
*
* @param topicName Name of topic to get information about.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return Runtime properties about the topic and the associated HTTP response.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws HttpResponseException If error occurred processing the request.
* @throws IllegalArgumentException if {@code topicName} is an empty string.
* @throws NullPointerException if {@code topicName} is null.
* @throws ResourceNotFoundException if the {@code topicName} does not exist.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/get-entity">Get Entity</a>
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<TopicRuntimeProperties> getTopicRuntimePropertiesWithResponse(String topicName, Context context) {
return asyncClient.getTopicWithResponse(topicName, context != null ? context : Context.NONE,
TopicRuntimeProperties::new).block();
}
/**
* Fetches all the queues in the Service Bus namespace.
*
* @return A PagedIterable of {@link QueueProperties queues} in the Service Bus namespace.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/enumeration">List Queues, Subscriptions, or
* Authorization Rules</a>
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<QueueProperties> listQueues() {
return new PagedIterable<>(asyncClient.listQueues());
}
/**
* Fetches all the queues in the Service Bus namespace.
*
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return A PagedIterable of {@link QueueProperties queues} in the Service Bus namespace.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/enumeration">List Queues, Subscriptions, or
* Authorization Rules</a>
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<QueueProperties> listQueues(Context context) {
final PagedFlux<QueueProperties> pagedFlux = new PagedFlux<>(
() -> asyncClient.listQueuesFirstPage(context),
continuationToken -> asyncClient.listQueuesNextPage(continuationToken,
context != null ? context : Context.NONE));
return new PagedIterable<>(pagedFlux);
}
/**
* Fetches all the rules for a topic and subscription.
*
* @param topicName The topic name under which all the rules need to be retrieved.
* @param subscriptionName The name of the subscription for which all rules need to be retrieved.
*
* @return An iterable of {@link RuleProperties rules} for the {@code topicName} and {@code subscriptionName}.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws NullPointerException if {@code topicName} or {@code subscriptionName} is null.
* @throws IllegalArgumentException if {@code topicName} or {@code subscriptionName} is an empty string.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/enumeration">List entities, rules, or
* authorization rules</a>
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<RuleProperties> listRules(String topicName, String subscriptionName) {
return new PagedIterable<>(asyncClient.listRules(topicName, subscriptionName));
}
/**
* Fetches all the subscriptions for a topic.
*
* @param topicName The topic name under which all the subscriptions need to be retrieved.
*
* @return A paged iterable of {@link SubscriptionProperties subscriptions} for the {@code topicName}.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws NullPointerException if {@code topicName} is null.
* @throws IllegalArgumentException if {@code topicName} is an empty string.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/enumeration">List entities, subscriptions, or
* authorization rules</a>
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<SubscriptionProperties> listSubscriptions(String topicName) {
return new PagedIterable<>(asyncClient.listSubscriptions(topicName));
}
/**
* Fetches all the subscriptions for a topic.
*
* @param topicName The topic name under which all the subscriptions need to be retrieved.
* @param context Additional context that is passed through the HTTP pipeline during the service call.
*
* @return A paged iterable of {@link SubscriptionProperties subscriptions} for the {@code topicName}.
* @throws ClientAuthenticationException if the client's credentials do not have access to modify the
* namespace.
* @throws NullPointerException if {@code topicName} is null.
* @throws IllegalArgumentException if {@code topicName} is an empty string.
* @see <a href="https://docs.microsoft.com/rest/api/servicebus/enumeration">List entities, subscriptions, or
* authorization rules</a>