Skip to content

Commit

Permalink
Storage extension updates (Azure#262)
Browse files Browse the repository at this point in the history
* re-recorded failing test

* initial migration of module changes

* updated tests and recordings

* tests fixes

* static check
  • Loading branch information
williexu authored Aug 15, 2018
1 parent 3af4272 commit 1a2f7f0
Show file tree
Hide file tree
Showing 26 changed files with 2,112 additions and 938 deletions.
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[MASTER]
ignore-patterns=test_*
reports=no
score=no

[MESSAGES CONTROL]
# For all codes, run 'pylint --list-msgs' or go to 'https://pylint.readthedocs.io/en/latest/reference_guide/features.html'
Expand Down
13 changes: 0 additions & 13 deletions src/storage-preview/azext_storage_preview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,6 @@ def storage_custom_command_oauth(self, *args, **kwargs):
_merge_new_exception_handler(kwargs, self.get_handler_suppress_403())
self.storage_custom_command(*args, oauth=True, **kwargs)

def get_handler_suppress_404(self):
def handler(ex):
from azure.cli.core.profiles import get_sdk

t_error = get_sdk(self.command_loader.cli_ctx,
CUSTOM_DATA_STORAGE,
'common._error#AzureMissingResourceHttpError')
if isinstance(ex, t_error):
return
raise ex

return handler

def get_handler_suppress_403(self):
def handler(ex):
from azure.cli.core.profiles import get_sdk
Expand Down
10 changes: 10 additions & 0 deletions src/storage-preview/azext_storage_preview/_help.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding=utf-8
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
Expand Down Expand Up @@ -497,6 +498,15 @@
helps['storage entity query'] = """
type: command
short-summary: List entities which satisfy a query.
parameters:
- name: --marker
type: list
short-summary: Space-separated list of key=value pairs. Must contain a nextpartitionkey and a nextrowkey.
long-summary: This value can be retrieved from the
next_marker field of a previous generator object if max_results was
specified and that generator has finished enumerating results. If
specified, this generator will begin returning results from the
point where the previous generator stopped.
"""

helps['storage file'] = """
Expand Down
42 changes: 22 additions & 20 deletions src/storage-preview/azext_storage_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from ._validators import (get_datetime_type, validate_metadata, get_permission_validator, get_permission_help_string,
resource_type_type, services_type, validate_entity, validate_select, validate_blob_type,
validate_included_datasets, validate_custom_domain, validate_container_public_access,
validate_table_payload_format, validate_key, add_progress_callback,
validate_table_payload_format, validate_key, add_progress_callback, process_resource_group,
storage_account_key_options, process_file_download_namespace, process_metric_update_namespace,
get_char_options_validator, validate_bypass, validate_encryption_source)
get_char_options_validator, validate_bypass, validate_encryption_source, validate_marker)
from .profiles import CUSTOM_MGMT_STORAGE


Expand Down Expand Up @@ -84,9 +84,10 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.argument('if_match')
c.argument('if_none_match')

for item in ['delete', 'list', 'show', 'update', 'keys']:
for item in ['delete', 'show', 'update', 'show-connection-string', 'keys', 'network-rule']:
with self.argument_context('storage account {}'.format(item)) as c:
c.argument('account_name', acct_name_type, options_list=['--name', '-n'])
c.argument('resource_group_name', required=False, validator=process_resource_group)

with self.argument_context('storage account check-name') as c:
c.argument('name', options_list=['--name', '-n'])
Expand Down Expand Up @@ -138,7 +139,6 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
help='Default action to apply when no rule matches.')

with self.argument_context('storage account show-connection-string') as c:
c.argument('account_name', acct_name_type, options_list=['--name', '-n'])
c.argument('protocol', help='The default endpoint protocol.', arg_type=get_enum_type(['http', 'https']))
c.argument('key_name', options_list=['--key'], help='The key to use.',
arg_type=get_enum_type(list(storage_account_key_options.keys())))
Expand All @@ -155,10 +155,11 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem

with self.argument_context('storage account network-rule') as c:
from ._validators import validate_subnet
c.argument('storage_account_name', acct_name_type, id_part=None)
c.argument('account_name', acct_name_type, id_part=None)
c.argument('ip_address', help='IPv4 address or CIDR range.')
c.argument('subnet', help='Name or ID of subnet. If name is supplied, `--vnet-name` must be supplied.')
c.argument('vnet_name', help='Name of a virtual network.', validator=validate_subnet)
c.argument('action', help='The action of virtual network rule.')

with self.argument_context('storage account generate-sas') as c:
t_account_permissions = self.get_sdk('common.models#AccountPermissions')
Expand All @@ -167,7 +168,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.argument('resource_types', type=resource_type_type(self))
c.argument('expiry', type=get_datetime_type(True))
c.argument('start', type=get_datetime_type(True))
c.argument('account_name', acct_name_type, options_list=('--account-name',))
c.argument('account_name', acct_name_type, options_list=['--account-name'])
c.argument('permission', options_list=('--permissions',),
help='The permissions the SAS grants. Allowed values: {}. Can be combined.'.format(
get_permission_help_string(t_account_permissions)),
Expand Down Expand Up @@ -207,7 +208,9 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem

with self.argument_context('storage blob list') as c:
c.argument('include', validator=validate_included_datasets)
c.argument('num_results', type=int)
c.argument('num_results', type=int,
help='Specifies the maximum number of blobs to return. Must be in range [1,5000]. '
'If this parameter is not provided, all blobs will be returned.')
c.ignore('marker') # https://github.com/Azure/azure-cli/issues/3745

with self.argument_context('storage blob generate-sas') as c:
Expand Down Expand Up @@ -281,15 +284,15 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem

with self.argument_context('storage blob upload-batch') as c:
from .sdkutil import get_blob_types
from ._validators import process_blob_upload_batch_parameters

t_blob_content_settings = self.get_sdk('blob.models#ContentSettings')
c.register_content_settings_argument(t_blob_content_settings, update=False, arg_group='Content Control')
c.ignore('source_files', 'destination_container_name')

c.argument('source', options_list=('--source', '-s'), validator=process_blob_upload_batch_parameters)
c.argument('source', options_list=('--source', '-s'))
c.argument('destination', options_list=('--destination', '-d'))
c.argument('max_connections', type=int)
c.argument('max_connections', type=int,
help='Maximum number of parallel connections to use when the blob size exceeds 64MB.')
c.argument('maxsize_condition', arg_group='Content Control')
c.argument('validate_content', action='store_true', min_api='2016-05-31', arg_group='Content Control')
c.argument('blob_type', options_list=('--type', '-t'), arg_type=get_enum_type(get_blob_types()))
Expand All @@ -306,25 +309,24 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.extra('socket_timeout', socket_timeout_type)

with self.argument_context('storage blob download-batch') as c:
from ._validators import process_blob_download_batch_parameters

c.ignore('source_container_name')
c.argument('destination', options_list=('--destination', '-d'))
c.argument('source', options_list=('--source', '-s'), validator=process_blob_download_batch_parameters)
c.argument('source', options_list=('--source', '-s'))
c.extra('no_progress', progress_type)
c.extra('socket_timeout', socket_timeout_type)
c.argument('max_connections', type=int)
c.argument('max_connections', type=int,
help='Maximum number of parallel connections to use when the blob size exceeds 64MB.')

with self.argument_context('storage blob delete') as c:
from .sdkutil import get_delete_blob_snapshot_type_names
c.argument('delete_snapshots', arg_type=get_enum_type(get_delete_blob_snapshot_type_names()))

with self.argument_context('storage blob delete-batch') as c:
from ._validators import process_blob_batch_source_parameters

c.ignore('source_container_name')
c.argument('source', options_list=('--source', '-s'), validator=process_blob_batch_source_parameters)
c.argument('delete_snapshots', arg_type=get_enum_type(get_delete_blob_snapshot_type_names()))
c.argument('source', options_list=('--source', '-s'))
c.argument('delete_snapshots', arg_type=get_enum_type(get_delete_blob_snapshot_type_names()),
help='Required if the blob has associated snapshots.')
c.argument('lease_id', help='Required if the blob has an active lease.')

with self.argument_context('storage blob lease') as c:
c.argument('lease_duration', type=int)
Expand All @@ -348,7 +350,7 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.register_source_uri_arguments(validator=validate_source_uri)

with self.argument_context('storage blob copy start-batch', arg_group='Copy Source') as c:
from ._validators import (get_source_file_or_blob_service_client, process_blob_copy_batch_namespace)
from ._validators import get_source_file_or_blob_service_client

c.argument('source_client', ignore_type, validator=get_source_file_or_blob_service_client)

Expand All @@ -358,7 +360,6 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.argument('source_sas')
c.argument('source_container')
c.argument('source_share')
c.argument('prefix', validator=process_blob_copy_batch_namespace)

with self.argument_context('storage blob incremental-copy start') as c:
from ._validators import process_blob_source_uri
Expand Down Expand Up @@ -724,3 +725,4 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.argument('accept', default='minimal', validator=validate_table_payload_format,
arg_type=get_enum_type(['none', 'minimal', 'full']),
help='Specifies how much metadata to include in the response payload.')
c.argument('marker', validator=validate_marker, nargs='+')
Loading

0 comments on commit 1a2f7f0

Please sign in to comment.