@@ -303,7 +303,8 @@ Deleting a virtual host will permanently delete all entities (queues, exchanges,
303303
304304### Using CLI Tools
305305
306- A virtual host can be deleted using CLI tools:
306+ A virtual host can be deleted using [ rabbitmqctl] ( ./cli ) 's ` delete_vhost ` command
307+ which accepts virtual host name as the only mandatory argument.
307308
308309<Tabs groupId =" examples " >
309310<TabItem value =" bash " label =" rabbitmqctl with bash " default >
@@ -318,9 +319,9 @@ rabbitmqadmin vhosts delete --name qa1
318319```
319320</TabItem >
320321
321- <TabItem value =" powershell " label =" rabbitmqctl with PowerShell " >
322+ <TabItem value =" PowerShell " label =" rabbitmqctl with PowerShell " >
322323``` PowerShell
323- rabbitmqctl.exe delete_vhost qa1
324+ rabbitmqctl.bat delete_vhost qa1
324325```
325326</TabItem >
326327
@@ -334,7 +335,7 @@ rabbitmqadmin.exe vhosts delete --name qa1
334335### Using HTTP API
335336
336337A virtual host can be deleted using the ` DELETE /api/vhosts/{name} ` [ HTTP API] ( ./management ) endpoint
337- where ` {name} ` is the name of the virtual host
338+ where ` {name} ` is the name of the virtual host.
338339
339340Here's an example that uses [ curl] ( https://curl.haxx.se/ ) to delete a virtual host ` vh1 ` by contacting
340341a node at ` rabbitmq.local:15672 ` :
@@ -349,10 +350,10 @@ curl -u userename:pa$sw0rD -X DELETE http://rabbitmq.local:15672/api/vhosts/vh1
349350
350351::: danger
351352
352- ** THIS IS AN EXTREMELY DESTRUCTIVE OPERATION AND MUST BE USED WITH EXTREME CARE .**
353+ ** This is an extremely destructive operation and must be used with great care .**
353354
354- This command will delete ALL virtual hosts matching the provided regular expression pattern.
355- ALL data in those virtual hosts will be permanently lost, including:
355+ This command will delete all virtual hosts matching the provided regular expression pattern.
356+ All data in those virtual hosts will be permanently lost, including:
356357
357358 * Queues, streams, and partitioned streams
358359 * Exchanges and bindings
@@ -363,7 +364,7 @@ ALL data in those virtual hosts will be permanently lost, including:
363364 * Policies and operator policies
364365 * Runtime parameters
365366
366- ** ALWAYS use ` --dry-run ` first to verify what will be deleted before running the actual deletion.**
367+ ** Always use ` --dry-run ` first to verify what will be deleted before running the actual deletion.**
367368
368369:::
369370
@@ -404,40 +405,138 @@ until the protection is removed.
404405
405406### Using CLI Tools
406407
407- ` rabbitmqctl enable_vhost_protection_from_deletion ` is the command that marks a virtual host
408- as protected from deletion:
408+ A virtual host can be protected from deletion using ` rabbitmqctl ` or ` rabbitmqadmin ` .
409409
410+ <Tabs groupId =" examples " >
411+ <TabItem value =" bash " label =" rabbitmqctl with bash " default >
410412``` bash
411413rabbitmqctl enable_vhost_protection_from_deletion " vhost-name"
412414```
415+ </TabItem >
416+
417+ <TabItem value =" rabbitmqadmin " label =" rabbitmqadmin with bash " >
418+ ``` bash
419+ rabbitmqadmin vhosts enable_deletion_protection --name " vhost-name"
420+ ```
421+ </TabItem >
422+
423+ <TabItem value =" PowerShell " label =" rabbitmqctl with PowerShell " >
424+ ``` PowerShell
425+ rabbitmqctl.bat enable_vhost_protection_from_deletion "vhost-name"
426+ ```
427+ </TabItem >
428+
429+ <TabItem value =" rabbitmqadmin-PowerShell " label =" rabbitmqadmin with PowerShell " >
430+ ``` PowerShell
431+ rabbitmqadmin.exe vhosts enable_deletion_protection --name "vhost-name"
432+ ```
433+ </TabItem >
434+ </Tabs >
413435
414436An attempt to delete the virtual host then will fail with a specific message:
415437
438+ <Tabs groupId =" examples " >
439+ <TabItem value =" bash " label =" rabbitmqctl with bash " default >
416440``` bash
417441rabbitmqctl delete_vhost " vhost-name"
418442# ...
419443# => Error:
420444# => Cannot delete this virtual host: it is protected from deletion. To lift the protection, inspect and update its metadata
421445```
446+ </TabItem >
447+
448+ <TabItem value =" rabbitmqadmin " label =" rabbitmqadmin with bash " >
449+ ``` bash
450+ rabbitmqadmin vhosts delete --name " vhost-name"
451+ # => Error: HTTP request failed with status 412: Precondition Failed
452+ # => Refusing to delete virtual host 'vhost-name' because it is protected from deletion
453+ ```
454+ </TabItem >
455+
456+ <TabItem value =" PowerShell " label =" rabbitmqctl with PowerShell " >
457+ ``` PowerShell
458+ rabbitmqctl.bat delete_vhost "vhost-name"
459+ # ...
460+ # => Error:
461+ # => Cannot delete this virtual host: it is protected from deletion. To lift the protection, inspect and update its metadata
462+ ```
463+ </TabItem >
422464
423- To remove the protection, use ` rabbitmqctl disable_vhost_protection_from_deletion ` :
465+ <TabItem value =" rabbitmqadmin-PowerShell " label =" rabbitmqadmin with PowerShell " >
466+ ``` PowerShell
467+ rabbitmqadmin.exe vhosts delete --name "vhost-name"
468+ # => Error: HTTP request failed with status 412: Precondition Failed
469+ # => Refusing to delete virtual host 'vhost-name' because it is protected from deletion
470+ ```
471+ </TabItem >
472+ </Tabs >
424473
474+ To remove the protection:
475+
476+ <Tabs groupId =" examples " >
477+ <TabItem value =" bash " label =" rabbitmqctl with bash " default >
425478``` bash
426- # # removes virtual host deletion protection
427479rabbitmqctl disable_vhost_protection_from_deletion " vhost-name"
428480```
481+ </TabItem >
482+
483+ <TabItem value =" rabbitmqadmin " label =" rabbitmqadmin with bash " >
484+ ``` bash
485+ rabbitmqadmin vhosts disable_deletion_protection --name " vhost-name"
486+ ```
487+ </TabItem >
488+
489+ <TabItem value =" PowerShell " label =" rabbitmqctl with PowerShell " >
490+ ``` PowerShell
491+ rabbitmqctl.bat disable_vhost_protection_from_deletion "vhost-name"
492+ ```
493+ </TabItem >
494+
495+ <TabItem value =" rabbitmqadmin-PowerShell " label =" rabbitmqadmin with PowerShell " >
496+ ``` PowerShell
497+ rabbitmqadmin.exe vhosts disable_deletion_protection --name "vhost-name"
498+ ```
499+ </TabItem >
500+ </Tabs >
429501
430502with the protection removed, the virtual host can be deleted again:
431503
504+ <Tabs groupId =" examples " >
505+ <TabItem value =" bash " label =" rabbitmqctl with bash " default >
432506``` bash
433507rabbitmqctl delete_vhost " vhost-name"
434508# => Deleting vhost "vhost-name" ...
435509```
510+ </TabItem >
511+
512+ <TabItem value =" rabbitmqadmin " label =" rabbitmqadmin with bash " >
513+ ``` bash
514+ rabbitmqadmin vhosts delete --name " vhost-name"
515+ # => (No output on success)
516+ ```
517+ </TabItem >
518+
519+ <TabItem value =" PowerShell " label =" rabbitmqctl with PowerShell " >
520+ ``` PowerShell
521+ rabbitmqctl.bat delete_vhost "vhost-name"
522+ # => Deleting vhost "vhost-name" ...
523+ ```
524+ </TabItem >
525+
526+ <TabItem value =" rabbitmqadmin-PowerShell " label =" rabbitmqadmin with PowerShell " >
527+ ``` PowerShell
528+ rabbitmqadmin.exe vhosts delete --name "vhost-name"
529+ # => (No output on success)
530+ ```
531+ </TabItem >
532+ </Tabs >
436533
437534To see whether a virtual host is protected from deletion, use ` list_vhosts ` command with
438535an extra column, ` protected_from_deletion ` :
439536
440- ``` shell
537+ <Tabs groupId =" examples " >
538+ <TabItem value =" bash " label =" rabbitmqctl with bash " default >
539+ ``` bash
441540rabbitmqctl list_vhosts name tags default_queue_type metadata protected_from_deletion --formatter=pretty_table
442541# => Listing vhosts ...
443542# => ┌───────────────────────────┬─────────────────────────┐
@@ -450,6 +549,38 @@ rabbitmqctl list_vhosts name tags default_queue_type metadata protected_from_del
450549# => │ vh2 │ false │
451550# => └───────────────────────────┴─────────────────────────┘
452551```
552+ </TabItem >
553+
554+ <TabItem value =" rabbitmqadmin " label =" rabbitmqadmin with bash " >
555+ ``` bash
556+ rabbitmqadmin vhosts list
557+ # Shows all virtual hosts (protection status not displayed in list view)
558+ ```
559+ </TabItem >
560+
561+ <TabItem value =" PowerShell " label =" rabbitmqctl with PowerShell " >
562+ ``` PowerShell
563+ rabbitmqctl.bat list_vhosts name tags default_queue_type metadata protected_from_deletion --formatter=pretty_table
564+ # => Listing vhosts ...
565+ # => ┌───────────────────────────┬─────────────────────────┐
566+ # => │ name │ protected_from_deletion │
567+ # => ├───────────────────────────┼─────────────────────────┤
568+ # => │ / │ false │
569+ # => ├───────────────────────────┼─────────────────────────┤
570+ # => │ vh1 │ true │
571+ # => ├───────────────────────────┼─────────────────────────┤
572+ # => │ vh2 │ false │
573+ # => └───────────────────────────┴─────────────────────────┘
574+ ```
575+ </TabItem >
576+
577+ <TabItem value =" rabbitmqadmin-PowerShell " label =" rabbitmqadmin with PowerShell " >
578+ ``` PowerShell
579+ rabbitmqadmin.exe vhosts list
580+ # Shows all virtual hosts (protection status not displayed in list view)
581+ ```
582+ </TabItem >
583+ </Tabs >
453584
454585### Using HTTP API
455586
0 commit comments