Skip to content

Commit 979eede

Browse files
authored
[storage-blob-preview] az storage blob filter: Add --container-name to support filter blobs in specific container (#5481)
* `az storage blob filter`: Add `--container-name` to support filter blobs in specific container * rerun tests
1 parent 49586d4 commit 979eede

File tree

73 files changed

+41341
-741
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+41341
-741
lines changed

src/storage-blob-preview/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
33
Release History
44
===============
5+
0.6.2
6+
++++++
7+
* `az storage blob filter`: Add `--container-name` to support filter blobs in specific container
8+
59
0.6.1
610
++++++
711
* `az storage blob immutability-policy set/delete`: Extend/Lock/Unlock/Delete blob's immutability policy

src/storage-blob-preview/azext_storage_blob_preview/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
class StorageCommandsLoader(AzCommandsLoader):
1515
def __init__(self, cli_ctx=None):
1616
from azure.cli.core.commands import CliCommandType
17-
register_resource_type('latest', CUSTOM_DATA_STORAGE_BLOB, '2020-10-02')
17+
register_resource_type('latest', CUSTOM_DATA_STORAGE_BLOB, '2021-04-10')
1818
storage_custom = CliCommandType(operations_tmpl='azure.cli.command_modules.storage.custom#{}')
1919
super(StorageCommandsLoader, self).__init__(cli_ctx=cli_ctx,
2020
resource_type=CUSTOM_DATA_STORAGE_BLOB,

src/storage-blob-preview/azext_storage_blob_preview/_help.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,11 @@
7676
helps['storage blob filter'] = """
7777
type: command
7878
short-summary: List blobs across all containers whose tags match a given search expression.
79-
long-summary: >
80-
Filter blobs searches across all containers within a storage account but can be scoped within the expression to
81-
a single container.
8279
parameters:
8380
- name: --tag-filter
8481
short-summary: >
8582
The expression to find blobs whose tags matches the specified condition.
8683
eg. ""yourtagname"='firsttag' and "yourtagname2"='secondtag'"
87-
To specify a container, eg. "@container='containerName' and "Name"='C'"
8884
"""
8985

9086
helps['storage blob list'] = """

src/storage-blob-preview/azext_storage_blob_preview/_params.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
264264

265265
with self.argument_context('storage blob filter') as c:
266266
c.argument('filter_expression', options_list=['--tag-filter'])
267+
c.argument('container_name', container_name_type,
268+
help='Used when you want to list blobs under a specified container')
267269

268270
with self.argument_context('storage blob generate-sas') as c:
269271
from .completers import get_storage_acl_name_completion_list

src/storage-blob-preview/azext_storage_blob_preview/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
8585
with self.command_group('storage blob', blob_service_sdk, resource_type=CUSTOM_DATA_STORAGE_BLOB,
8686
min_api='2019-12-12',
8787
custom_command_type=blob_service_custom_sdk) as g:
88-
g.storage_command_oauth('filter', 'find_blobs_by_tags', is_preview=True)
88+
g.storage_custom_command_oauth('filter', 'find_blobs_by_tags', is_preview=True)
8989

9090
blob_lease_client_sdk = CliCommandType(
9191
operations_tmpl='azure.multiapi.storagev2.blob._lease#BlobLeaseClient.{}',

src/storage-blob-preview/azext_storage_blob_preview/operations/blob.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,3 +720,9 @@ def query_blob(cmd, client, query_expression, input_config=None, output_config=N
720720
return None
721721

722722
return reader.readall().decode("utf-8")
723+
724+
725+
def find_blobs_by_tags(client, filter_expression, container_name=None):
726+
if container_name:
727+
client = client.get_container_client(container_name)
728+
return client.find_blobs_by_tags(filter_expression=filter_expression)

0 commit comments

Comments
 (0)