Skip to content

Commit

Permalink
{storage-blob-preview} Refine help message (#3071)
Browse files Browse the repository at this point in the history
* refine help message

* refine help message

* upgrade version

* test pass

* test pass

* refine history
  • Loading branch information
Juliehzl authored Mar 10, 2021
1 parent 1fa00f9 commit 9998c47
Show file tree
Hide file tree
Showing 101 changed files with 28,860 additions and 13,859 deletions.
6 changes: 6 additions & 0 deletions src/storage-blob-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Release History
===============
0.5.0
++++++
* `az storage blob upload`: Refine help message
* Remove `az storage account management-policy` because it is supported in main azure cli
* Upgrade api version to 2021-01-01 for `az storage account blob-service-properties`

0.4.1
++++++
* `az storage blob service-properties`: Adopt new api version with track2 SDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class StorageCommandsLoader(AzCommandsLoader):
def __init__(self, cli_ctx=None):
from azure.cli.core.commands import CliCommandType
register_resource_type('latest', CUSTOM_DATA_STORAGE_BLOB, '2020-02-10')
register_resource_type('latest', CUSTOM_MGMT_STORAGE, '2019-06-01')
register_resource_type('latest', CUSTOM_MGMT_STORAGE, '2021-01-01')
storage_custom = CliCommandType(operations_tmpl='azure.cli.command_modules.storage.custom#{}')
super(StorageCommandsLoader, self).__init__(cli_ctx=cli_ctx,
resource_type=CUSTOM_DATA_STORAGE_BLOB,
Expand Down
8 changes: 3 additions & 5 deletions src/storage-blob-preview/azext_storage_blob_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,14 @@
helps['storage blob upload'] = """
type: command
short-summary: Upload a file to a storage blob.
long-summary: Creates a new blob from a file path, or updates the content of an existing blob with automatic chunking and progress notifications.
long-summary: Create a new blob from a file path, or updates the content of an existing blob with automatic chunking and progress notifications.
parameters:
- name: --type -t
short-summary: Defaults to 'page' for *.vhd files, or 'block' otherwise.
short-summary: Default to 'page' for *.vhd files, or 'block' otherwise.
- name: --maxsize-condition
short-summary: The max length in bytes permitted for an append blob.
- name: --validate-content
short-summary: Specifies that an MD5 hash shall be calculated for each chunk of the blob and verified by the service when the chunk has arrived.
- name: --tier
short-summary: A page blob tier value to set the blob to. The tier correlates to the size of the blob and number of allowed IOPS. This is only applicable to page blobs on premium storage accounts.
short-summary: Specify that an MD5 hash shall be calculated for each chunk of the blob and verified by the service when the chunk has arrived.
examples:
- name: Upload to a blob.
text: az storage blob upload -f /path/to/file -c mycontainer -n MyBlob
Expand Down
26 changes: 16 additions & 10 deletions src/storage-blob-preview/azext_storage_blob_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,20 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem

with self.argument_context('storage account blob-service-properties update',
resource_type=CUSTOM_MGMT_STORAGE) as c:
from azure.cli.command_modules.storage._validators import get_api_version_type, \
validator_change_feed_retention_days
c.argument('account_name', acct_name_type, id_part=None)
c.argument('resource_group_name', required=False, validator=process_resource_group)
c.argument('enable_change_feed', arg_type=get_three_state_flag(), min_api='2019-04-01')
c.argument('enable_change_feed', arg_type=get_three_state_flag(), min_api='2019-04-01',
arg_group='Change Feed Policy')
c.argument('change_feed_retention_days', is_preview=True,
options_list=['--change-feed-retention-days', '--change-feed-days'],
type=int, min_api='2019-06-01', arg_group='Change Feed Policy',
validator=validator_change_feed_retention_days,
help='Indicate the duration of changeFeed retention in days. '
'Minimum value is 1 day and maximum value is 146000 days (400 years). '
'A null value indicates an infinite retention of the change feed.'
'(Use `--enable-change-feed` without `--change-feed-days` to indicate null)')
c.argument('enable_container_delete_retention',
arg_type=get_three_state_flag(),
options_list=['--enable-container-delete-retention', '--container-retention'],
Expand All @@ -167,15 +178,10 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.argument('enable_last_access_tracking', arg_type=get_three_state_flag(), min_api='2019-06-01',
options_list=['--enable-last-access-tracking', '-t'],
help='When set to true last access time based tracking policy is enabled.')

with self.argument_context('storage account management-policy create') as c:
c.argument('policy', type=file_type, completer=FilesCompleter(),
help='The Storage Account ManagementPolicies Rules, in JSON format. See more details in: '
'https://docs.microsoft.com/azure/storage/common/storage-lifecycle-managment-concepts.')
c.argument('account_name', help='The name of the storage account within the specified resource group.')

with self.argument_context('storage account management-policy update') as c:
c.argument('account_name', help='The name of the storage account within the specified resource group.')
c.argument('default_service_version', options_list=['--default-service-version', '-d'],
type=get_api_version_type(), min_api='2018-07-01',
help="Indicate the default version to use for requests to the Blob service if an incoming request's "
"version is not specified.")

with self.argument_context('storage blob') as c:
c.argument('blob_name', options_list=('--name', '-n'), arg_type=blob_name_type)
Expand Down
23 changes: 1 addition & 22 deletions src/storage-blob-preview/azext_storage_blob_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from azure.cli.core.profiles import ResourceType

from ._client_factory import cf_blob_client, cf_container_client, cf_blob_service, cf_blob_lease_client, \
cf_mgmt_blob_services, cf_sa, cf_mgmt_policy
cf_mgmt_blob_services, cf_sa
from .profiles import CUSTOM_DATA_STORAGE_BLOB, CUSTOM_MGMT_STORAGE


Expand Down Expand Up @@ -45,27 +45,6 @@ def get_custom_sdk(custom_module, client_factory, resource_type=ResourceType.DAT
setter_name='set_service_properties',
custom_func_name='update_blob_service_properties')

management_policy_sdk = CliCommandType(
operations_tmpl='azext_storage_blob_preview.vendored_sdks.azure_mgmt_storage.operations#'
'ManagementPoliciesOperations.{}',
client_factory=cf_mgmt_policy,
resource_type=ResourceType.MGMT_STORAGE
)

management_policy_custom_type = CliCommandType(
operations_tmpl='azure.cli.command_modules.storage.operations.account#{}',
client_factory=cf_mgmt_policy)

with self.command_group('storage account management-policy', management_policy_sdk,
resource_type=ResourceType.MGMT_STORAGE, min_api='2018-11-01',
custom_command_type=management_policy_custom_type) as g:
g.show_command('show', 'get')
g.custom_command('create', 'create_management_policies')
g.generic_update_command('update', getter_name='get',
setter_name='update_management_policies',
setter_type=management_policy_custom_type)
g.command('delete', 'delete')

blob_client_sdk = CliCommandType(
operations_tmpl='azext_storage_blob_preview.vendored_sdks.azure_storage_blob._blob_client#BlobClient.{}',
client_factory=cf_blob_client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ def update_management_policies(client, resource_group_name, account_name, parame


# TODO: support updating other properties besides 'enable_change_feed,delete_retention_policy'
def update_blob_service_properties(cmd, instance, enable_change_feed=None, enable_delete_retention=None,
delete_retention_days=None, enable_restore_policy=None, restore_days=None,
def update_blob_service_properties(cmd, instance, enable_change_feed=None, change_feed_retention_days=None,
enable_delete_retention=None, delete_retention_days=None,
enable_restore_policy=None, restore_days=None,
enable_versioning=None, enable_container_delete_retention=None,
container_delete_retention_days=None, enable_last_access_tracking=None):
container_delete_retention_days=None, enable_last_access_tracking=None,
default_service_version=None):
if enable_change_feed is not None:
instance.change_feed = cmd.get_models('ChangeFeed')(enabled=enable_change_feed)
if enable_change_feed is False:
change_feed_retention_days = None
instance.change_feed = cmd.get_models('ChangeFeed')(
enabled=enable_change_feed, retention_in_days=change_feed_retention_days)

if enable_container_delete_retention is not None:
if enable_container_delete_retention is False:
Expand Down Expand Up @@ -57,4 +62,7 @@ def update_blob_service_properties(cmd, instance, enable_change_feed=None, enabl
LastAccessTimeTrackingPolicy = cmd.get_models('LastAccessTimeTrackingPolicy')
instance.last_access_time_tracking_policy = LastAccessTimeTrackingPolicy(enable=enable_last_access_tracking)

if default_service_version is not None:
instance.default_service_version = default_service_version

return instance
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
interactions:
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
CommandName:
- storage account blob-service-properties show
Connection:
- keep-alive
ParameterSetName:
- -n -g
User-Agent:
- AZURECLI/2.20.0 azsdk-python-azure-mgmt-storage/17.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default?api-version=2021-01-01
response:
body:
string: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default","name":"default","type":"Microsoft.Storage/storageAccounts/blobServices","properties":{"cors":{"corsRules":[]},"deleteRetentionPolicy":{"enabled":false}}}'
headers:
cache-control:
- no-cache
content-length:
- '443'
content-type:
- application/json
date:
- Mon, 01 Mar 2021 04:07:14 GMT
expires:
- '-1'
pragma:
- no-cache
server:
- Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
strict-transport-security:
- max-age=31536000; includeSubDomains
transfer-encoding:
- chunked
vary:
- Accept-Encoding
x-content-type-options:
- nosniff
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
CommandName:
- storage account blob-service-properties update
Connection:
- keep-alive
ParameterSetName:
- --default-service-version -n -g
User-Agent:
- AZURECLI/2.20.0 azsdk-python-azure-mgmt-storage/17.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default?api-version=2021-01-01
response:
body:
string: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default","name":"default","type":"Microsoft.Storage/storageAccounts/blobServices","properties":{"cors":{"corsRules":[]},"deleteRetentionPolicy":{"enabled":false}}}'
headers:
cache-control:
- no-cache
content-length:
- '443'
content-type:
- application/json
date:
- Mon, 01 Mar 2021 04:07:15 GMT
expires:
- '-1'
pragma:
- no-cache
server:
- Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
strict-transport-security:
- max-age=31536000; includeSubDomains
transfer-encoding:
- chunked
vary:
- Accept-Encoding
x-content-type-options:
- nosniff
status:
code: 200
message: OK
- request:
body: '{"properties": {"cors": {"corsRules": []}, "defaultServiceVersion": "2018-11-09",
"deleteRetentionPolicy": {"enabled": false}}}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
CommandName:
- storage account blob-service-properties update
Connection:
- keep-alive
Content-Length:
- '127'
Content-Type:
- application/json
ParameterSetName:
- --default-service-version -n -g
User-Agent:
- AZURECLI/2.20.0 azsdk-python-azure-mgmt-storage/17.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
method: PUT
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default?api-version=2021-01-01
response:
body:
string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default","name":"default","type":"Microsoft.Storage/storageAccounts/blobServices","properties":{"cors":{"corsRules":[]},"defaultServiceVersion":"2018-11-09","deleteRetentionPolicy":{"enabled":false}}}'
headers:
cache-control:
- no-cache
content-length:
- '432'
content-type:
- application/json
date:
- Mon, 01 Mar 2021 04:07:16 GMT
expires:
- '-1'
pragma:
- no-cache
server:
- Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
strict-transport-security:
- max-age=31536000; includeSubDomains
transfer-encoding:
- chunked
vary:
- Accept-Encoding
x-content-type-options:
- nosniff
x-ms-ratelimit-remaining-subscription-writes:
- '1197'
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
CommandName:
- storage account blob-service-properties show
Connection:
- keep-alive
ParameterSetName:
- -n -g
User-Agent:
- AZURECLI/2.20.0 azsdk-python-azure-mgmt-storage/17.0.0 Python/3.7.7 (Windows-10-10.0.19041-SP0)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default?api-version=2021-01-01
response:
body:
string: '{"sku":{"name":"Standard_LRS","tier":"Standard"},"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/blobServices/default","name":"default","type":"Microsoft.Storage/storageAccounts/blobServices","properties":{"cors":{"corsRules":[]},"defaultServiceVersion":"2018-11-09","deleteRetentionPolicy":{"enabled":false}}}'
headers:
cache-control:
- no-cache
content-length:
- '480'
content-type:
- application/json
date:
- Mon, 01 Mar 2021 04:07:16 GMT
expires:
- '-1'
pragma:
- no-cache
server:
- Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
strict-transport-security:
- max-age=31536000; includeSubDomains
transfer-encoding:
- chunked
vary:
- Accept-Encoding
x-content-type-options:
- nosniff
status:
code: 200
message: OK
version: 1
Loading

0 comments on commit 9998c47

Please sign in to comment.