Repository: Azure/azure-cli (Python)

Issue:
`rule-file` parameter documentation incomplete

The parameter `--rule-file` of the command `az monitor data-collection rule create` is documented poorly:
the format is not described anywhere, there's no example given, and it's unclear how to prepare such a file.

The current documentation

> The json file for rule parameters.

is not very helpful.

---
#### Document Details

⚠ *Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.*

* ID: cf6b7160-92be-96ab-a1c5-ad6e3c81e901
* Version Independent ID: 18ff06dd-51e0-6884-be2d-f079f5c9312b
* Content: [az monitor data-collection rule](https://learn.microsoft.com/en-us/cli/azure/monitor/data-collection/rule?view=azure-cli-latest#az-monitor-data-collection-rule-list)
* Content Source: [latest/docs-ref-autogen/monitor/data-collection/rule.yml](https://github.com/MicrosoftDocs/azure-docs-cli/blob/main/latest/docs-ref-autogen/monitor/data-collection/rule.yml)
* Service: **monitoring-and-diagnostics**
* GitHub Login: @rloutlaw
* Microsoft Alias: **routlaw**



Fix (patch):
diff --git a/privates/azure_mgmt_containerregistry-2.0.0-py2.py3-none-any.whl b/privates/azure_mgmt_containerregistry-2.0.0-py2.py3-none-any.whl
deleted file mode 100644
index 038c69c8132..00000000000
Binary files a/privates/azure_mgmt_containerregistry-2.0.0-py2.py3-none-any.whl and /dev/null differ
diff --git a/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_params.py b/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_params.py
index df9696a6d7e..c1962aabfdc 100644
--- a/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_params.py
+++ b/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/_params.py
@@ -7,6 +7,13 @@
 import argparse
 from argcomplete.completers import FilesCompleter
 
+from azure.mgmt.containerregistry.v2018_02_01_preview.models import (
+    BuildTaskStatus,
+    OsType,
+    BaseImageTriggerType,
+    BuildStatus
+)
+
 from azure.cli.core.commands.parameters import (
     resource_group_name_type,
     get_location_type,
@@ -108,8 +115,8 @@ def load_arguments(self, _):  # pylint: disable=too-many-statements
         # build task parameters
         c.argument('build_task_name', options_list=['--name', '-n'], help='The name of the build task.', completer=get_resource_name_completion_list(BUILD_TASK_RESOURCE_TYPE))
         c.argument('alias', help='The alternative name for build task. Default to the build task name.')
-        c.argument('status', help='The current status of build task.', choices=['Enabled', 'Disabled'])
-        c.argument('os_type', options_list=['--os'], help='The operating system type required for the build.', choices=['Linux', 'Windows'])
+        c.argument('status', help='The current status of build task.', choices=[BuildTaskStatus.enabled.value, BuildTaskStatus.disabled.value])
+        c.argument('os_type', options_list=['--os'], help='The operating system type required for the build.', choices=[OsType.linux.value, OsType.windows.value])
         c.argument('cpu', type=int, help='The CPU configuration in terms of number of cores required for the build.')
         c.argument('timeout', type=int, help='Build timeout in seconds.')
         c.argument('repository_url', options_list=['--context', '-c'], help="The full URL to the source code respository.")
@@ -119,10 +126,20 @@ def load_arguments(self, _):  # pylint: disable=too-many-statements
         c.argument('step_name', help='The name of the build step.', completer=get_resource_name_completion_list(BUILD_STEP_RESOURCE_TYPE))
         c.argument('branch', help="The source control branch name.")
         c.argument('no_cache', help='Indicates whether the image cache is enabled.', arg_type=get_three_state_flag())
-        c.argument('base_image_trigger', help="The type of the auto trigger for base image dependency updates.", choices=['All', 'Runtime', 'None'])
+        c.argument('base_image_trigger', help="The type of the auto trigger for base image dependency updates.", choices=[BaseImageTriggerType.all.value,
+                                                                                                                          BaseImageTriggerType.runtime.value,
+                                                                                                                          BaseImageTriggerType.none.value])
         # build parameters
         c.argument('top', help='Limit the number of latest builds in the results.')
         c.argument('build_id', help='The unique build identifier.')
+        c.argument('build_status', help='The current status of build.', choices=[BuildStatus.queued.value,
+                                                                                 BuildStatus.started.value,
+                                                                                 BuildStatus.running.value,
+                                                                                 BuildStatus.succeeded.value,
+                                                                                 BuildStatus.failed.value,
+                                                                                 BuildStatus.canceled.value,
+                                                                                 BuildStatus.error.value,
+                                                                                 BuildStatus.timeout.value])
 
     with self.argument_context('acr build-task create') as c:
         c.argument('build_task_name', completer=None)
diff --git a/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/build_task.py b/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/build_task.py
index 63b34269a6a..824e493e436 100644
--- a/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/build_task.py
+++ b/src/command_modules/azure-cli-acr/azure/cli/command_modules/acr/build_task.py
@@ -296,15 +296,24 @@ def acr_build_task_list_builds(cmd,
                                registry_name,
                                top=15,
                                build_task_name=None,
+                               build_status=None,
                                resource_group_name=None):
     _, resource_group_name = validate_managed_registry(
         cmd.cli_ctx, registry_name, resource_group_name, BUILD_TASKS_NOT_SUPPORTED)
 
-    if build_task_name:
-        filter_str = "BuildTaskName eq '{}'".format(build_task_name)
-        return client.list(resource_group_name, registry_name, filter=filter_str, top=top)
+    filter_str = None
+    filter_str = _add_build_filter(filter_str, 'BuildTaskName', build_task_name)
+    filter_str = _add_build_filter(filter_str, 'Status', build_status)
 
-    return client.list(resource_group_name, registry_name, top=top)
+    return client.list(resource_group_name, registry_name, filter=filter_str, top=top)
+
+
+def _add_build_filter(orig_filter, name, value):
+    if not value:
+        return orig_filter
+
+    new_filter_str = "{} eq '{}'".format(name, value)
+    return "{} and {}".format(orig_filter, new_filter_str) if orig_filter else new_filter_str
 
 
 def acr_build_task_logs(cmd,
@@ -318,7 +327,8 @@ def acr_build_task_logs(cmd,
 
     if not build_id:
         # show logs for the last build
-        paged_builds = acr_build_task_list_builds(cmd, client, registry_name, build_task_name)
+        paged_builds = acr_build_task_list_builds(cmd, client, registry_name,
+                                                  top=None, build_task_name=build_task_name)
         try:
             build_id = paged_builds.get(0)[0].build_id
             print("Showing logs for the last updated build")