Repository: PrefectHQ/prefect
Pull request: fix(cli): prompt user confirmation for pausing work queue in default work pool

<!-- 
Thanks for opening a pull request to Prefect! We've got a few requests to help us review contributions:

- Make sure that your title neatly summarizes the proposed changes.
- Provide a short overview of the change and the value it adds.
- Share an example to help us understand the change in user experience.
- Confirm that you've done common tasks so we can give a timely review.
- Review our contribution guidelines: https://docs.prefect.io/latest/contributing/overview/

Happy engineering!
-->

<!-- Include an overview here -->

Fixes #12263 

### Example


Prompt for user confirmation if `--pool` is not specified to avoid ambiguous pause of work queue in default work pool, which  is `default-agent-pool` as of writing.

<img width="954" alt="image" src="https://github.com/PrefectHQ/prefect/assets/41283691/dc98f7fa-17a9-46e8-9c9c-721d24600e01">



### Checklist
<!-- These boxes may be checked after opening the pull request. -->

- [x] This pull request references any related issue by including "closes `<link to issue>`"
	- If no issue exists and your change is not a small fix, please [create an issue](https://github.com/PrefectHQ/prefect/issues/new/choose) first.
- [x] This pull request includes tests or only affects documentation.
- [ ] This pull request includes a label categorizing the change e.g. `maintenance`, `fix`, `feature`, `enhancement`, `docs`.
  <!-- If you do not have permission to add a label, a maintainer will add one for you -->

For documentation changes:

- [ ] This pull request includes redirect settings in `netlify.toml` for files that are removed or renamed.

For new functions or classes in the Python SDK:

- [ ] This pull request includes helpful docstrings.
- [ ] If a new Python file was added, this pull request contains a stub page in the Python SDK docs and an entry in `mkdocs.yml` navigation.

Problem statement:
Pausing a work queue via CLI without specifying work pool will pause `default-agent-pool `
### First check

- [X] I added a descriptive title to this issue.
- [X] I used the GitHub search to find a similar issue and didn't find it.
- [X] I searched the Prefect documentation for this issue.
- [X] I checked that this issue is related to Prefect and not one of its dependencies.

### Bug summary

It's ambiguous to allow pausing a work queue via CLI without needing to provide the work pool name, especially since `default` is generally the given work queue name. It makes sense to verify that we are pausing the right work queue.

### Reproduction

```python3
❯ prefect work-queue ls
                                  Work Queues
┏━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ Name ┃ Pool            ┃                                 ID ┃ Concurrency L… ┃
┡━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
│ def… │ zoompool        │ cae04397-7471-42ac-8cc1-9e32bcaba… │ None           │
│ def… │ default-agent-… │ c4a4ebf4-4e0d-4689-b139-7989f4dab… │ None           │
└──────┴─────────────────┴────────────────────────────────────┴────────────────┘
                          (**) denotes a paused queue
❯ prefect work-queue pause default
Work queue 'default' paused
```


### Error

_No response_

### Versions

```Text
Version:             2.16.3
API version:         0.8.4
Python version:      3.10.4
Git commit:          e3f02c00
Built:               Thu, Mar 7, 2024 4:56 PM
OS/Arch:             darwin/arm64
Profile:             local_sqlite
Server type:         ephemeral
Server:
  Database:          sqlite
  SQLite version:    3.43.2
```


### Additional context

_No response_

Hints from issue discussion:

Commit message: fix(cli): prompt user confirmation for pausing work queue in default work pool

Signed-off-by: hainenber <dotronghai96@gmail.com>

Patch to review:
diff --git a/src/prefect/cli/work_queue.py b/src/prefect/cli/work_queue.py
index bb66012c2def..351d361e18f7 100644
--- a/src/prefect/cli/work_queue.py
+++ b/src/prefect/cli/work_queue.py
@@ -263,6 +263,17 @@ async def pause(
     """
     Pause a work queue.
     """
+
+    # If work pool name is not specified,
+    # Get confirmation from user that they're OK to pause the work queue
+    # in the default work pool.
+    if not pool:
+        pause_workqueue_in_default_workpool = typer.confirm(
+            f"Do you want stop work queue {name} in default work pool ({DEFAULT_AGENT_WORK_POOL_NAME})?"
+        )
+        if not pause_workqueue_in_default_workpool:
+            raise typer.Abort()
+
     queue_id = await _get_work_queue_id_from_name_or_id(
         name_or_id=name,
         work_pool_name=pool,
diff --git a/tests/cli/test_work_queues.py b/tests/cli/test_work_queues.py
index 8391350f0c30..1a69c31a5fce 100644
--- a/tests/cli/test_work_queues.py
+++ b/tests/cli/test_work_queues.py
@@ -272,7 +272,7 @@ class TestPauseWorkQueue:
     def test_pause(self, prefect_client, work_queue):
         assert not work_queue.is_paused
         invoke_and_assert(
-            command=f"work-queue pause {work_queue.name}",
+            command=f"work-queue pause {work_queue.name} --pool default-agent-pool",
             expected_code=0,
         )
         q = read_queue(prefect_client, work_queue.name)
@@ -281,7 +281,7 @@ def test_pause(self, prefect_client, work_queue):
     def test_pause_by_id(self, prefect_client, work_queue):
         assert not work_queue.is_paused
         invoke_and_assert(
-            command=f"work-queue pause {work_queue.id}",
+            command=f"work-queue pause {work_queue.id} --pool default-agent-pool",
             expected_code=0,
         )
         q = read_queue(prefect_client, work_queue.name)
@@ -327,10 +327,31 @@ def test_pause_bad_pool_name(
             expected_code=1,
         )
 
+    def test_pause_without_specifying_pool_name_without_confirmation(
+        self,
+        work_queue,
+    ):
+        invoke_and_assert(
+            command=f"work-queue pause {work_queue.name}",
+            expected_code=1,
+        )
+
+    def test_pause_without_specifying_pool_name_with_confirmation(
+        self,
+        work_queue,
+    ):
+        invoke_and_assert(
+            command=f"work-queue pause {work_queue.name}",
+            user_input="Y",
+            expected_code=0,
+        )
+
 
 class TestResumeWorkQueue:
     def test_resume(self, prefect_client, work_queue):
-        invoke_and_assert(command=f"work-queue pause {work_queue.name}")
+        invoke_and_assert(
+            command=f"work-queue pause {work_queue.name} --pool default-agent-pool"
+        )
         invoke_and_assert(
             command=f"work-queue resume {work_queue.name}",
             expected_code=0,
@@ -339,7 +360,9 @@ def test_resume(self, prefect_client, work_queue):
         assert not q.is_paused
 
     def test_resume_by_id(self, prefect_client, work_queue):
-        invoke_and_assert(command=f"work-queue pause {work_queue.name}")
+        invoke_and_assert(
+            command=f"work-queue pause {work_queue.name} --pool default-agent-pool"
+        )
         invoke_and_assert(
             command=f"work-queue resume {work_queue.id}",
             expected_code=0,


Code review comments:
diff_hunk: @@ -263,6 +263,17 @@ async def pause(
     """
     Pause a work queue.
     """
+
+    # If work pool name is not specified,
+    # Get confirmation from user that they're OK to pause the work queue
+    # in the default work pool.
+    if not pool:
+        pause_workqueue_in_default_workpool = typer.confirm(
+            f"Do you want stop work queue {name} in default work pool ({DEFAULT_AGENT_WORK_POOL_NAME})?"
+        )
+        if not pause_workqueue_in_default_workpool:
+            raise typer.Abort()
path: src/prefect/cli/work_queue.py
text: @user1:
I think we can simplify this by doing
```suggestion
    if not pool and not typer.confirm(
            f"You have not specified a work pool. Are you sure you want to pause {name} work queue in `{DEFAULT_AGENT_WORK_POOL_NAME}`?"
        )
        exit_with_error("Work queue pause aborted! ")
```

@user1:
and we'll need to add `from prefect.cli._utilities import exit_with_error` to the top of the file

@author:
Done :D