Skip to content

Conversation

@arrownj
Copy link
Contributor

@arrownj arrownj commented Apr 7, 2020

Spec is here


This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally?

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your PR is merged into master branch, a new PR will be created to update src/index.json automatically.
The precondition is to put your code inside this repo and upgrade the version in the PR but do not modify src/index.json.

@yonzhan
Copy link
Collaborator

yonzhan commented Apr 7, 2020

Import Export

text: |-
az import-export create --resource-group "myResourceGroup" --name "myJob"
--location "West US" --backup-drive-manifest true --diagnostics-path "waimportexport"
--drive-list bit-locker-key=238810-662376-448998-450120-652806-203390-606320-483076
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drive-list is an array right

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we can specify multi --dirve-list here.

def load_arguments(self, _):

with self.argument_context('import-export list') as c:
c.argument('top', help='An integer value that specifies how many jobs at most should be returned. The value cannot exceed 100.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems this isn't in help file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently top value can not be less than total count of jobs. It's very strange. I have sent an email to ask about this. I will remove these 2 parameters temporarily and add them back when get the final answer.

@@ -0,0 +1,2 @@
[bdist_wheel]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

azure-cli-core doesn't support Python 2 any more.

Leaving this would lead to the built wheel named as import-export-py2-py3-none-any.whl.

Should Leave this file empty and the wheel name would be import-export-py3-none-any.whl

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

'Intended Audience :: System Administrators',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

azure-cli-core don't support Python 3.5 Azure/azure-cli#12694

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

# --------------------------------------------------------------------------------------------


def example_name_or_id_validator(cmd, namespace):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted.

Comment on lines +25 to +42
if kl == 'recipient-name':
d['recipient_name'] = v
elif kl == 'street-address1':
d['street_address1'] = v
elif kl == 'street-address2':
d['street_address2'] = v
elif kl == 'city':
d['city'] = v
elif kl == 'state-or-province':
d['state_or_province'] = v
elif kl == 'postal-code':
d['postal_code'] = v
elif kl == 'country-or-region':
d['country_or_region'] = v
elif kl == 'phone':
d['phone'] = v
elif kl == 'email':
d['email'] = v
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if kl == 'recipient-name':
d['recipient_name'] = v
elif kl == 'street-address1':
d['street_address1'] = v
elif kl == 'street-address2':
d['street_address2'] = v
elif kl == 'city':
d['city'] = v
elif kl == 'state-or-province':
d['state_or_province'] = v
elif kl == 'postal-code':
d['postal_code'] = v
elif kl == 'country-or-region':
d['country_or_region'] = v
elif kl == 'phone':
d['phone'] = v
elif kl == 'email':
d['email'] = v
if kl in ['recipient-name', 'street-address1', ..., 'email']:
d[kl] = v

Copy link
Member

@qwordy qwordy Apr 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the variable naming is hard for human to read. d, k, kl, v

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the parameter name and the map key are not the same. For example, state-or-province is parameter name, state_or_province is the key, they are not the same. I prefer the current way because it is explicit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. Sorry. I haven't noticed it.

if kl == 'carrier-name':
d['carrier_name'] = v
elif kl == 'carrier-account-number':
d['carrier_account_number'] = v
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about feedback this to code gen team

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually the key and parameter name is not the same. It's a underscore in the key, and a minus in parameter name. I prefer current code because it is more explicitly and we can rename it easily.

Comment on lines +81 to +96
if kl == 'recipient-name':
d['recipient_name'] = v
elif kl == 'street-address1':
d['street_address1'] = v
elif kl == 'street-address2':
d['street_address2'] = v
elif kl == 'city':
d['city'] = v
elif kl == 'state-or-province':
d['state_or_province'] = v
elif kl == 'postal-code':
d['postal_code'] = v
elif kl == 'country-or-region':
d['country_or_region'] = v
elif kl == 'phone':
d['phone'] = v
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified.

Comment on lines +114 to +121
if kl == 'carrier-name':
d['carrier_name'] = v
elif kl == 'tracking-number':
d['tracking_number'] = v
elif kl == 'drive-count':
d['drive_count'] = v
elif kl == 'ship-date':
d['ship_date'] = v
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified.

Comment on lines +139 to +146
if kl == 'carrier-name':
d['carrier_name'] = v
elif kl == 'tracking-number':
d['tracking_number'] = v
elif kl == 'drive-count':
d['drive_count'] = v
elif kl == 'ship-date':
d['ship_date'] = v
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified.

Comment on lines +164 to +187
if kl == 'drive-id':
d['drive_id'] = v
elif kl == 'bit-locker-key':
d['bit_locker_key'] = v
elif kl == 'manifest-file':
d['manifest_file'] = v
elif kl == 'manifest-hash':
d['manifest_hash'] = v
elif kl == 'drive-header-hash':
d['drive_header_hash'] = v
elif kl == 'state':
d['state'] = v
elif kl == 'copy-status':
d['copy_status'] = v
elif kl == 'percent-complete':
d['percent_complete'] = v
elif kl == 'verbose-log-uri':
d['verbose_log_uri'] = v
elif kl == 'error-log-uri':
d['error_log_uri'] = v
elif kl == 'manifest-uri':
d['manifest_uri'] = v
elif kl == 'bytes-succeeded':
d['bytes_succeeded'] = v
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified.
And where do these string literals come from? Are they defined in SDK? If so, avoid so many string literals.

Comment on lines +205 to +210
if kl == 'blob-listblob-path':
d['blob_listblob_path'] = v
elif kl == 'blob-path':
d['blob_path'] = v
elif kl == 'blob-path-prefix':
d['blob_path_prefix'] = v
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified.

# regenerated.
# --------------------------------------------------------------------------

__path__ = __import__('pkgutil').extend_path(__path__, __name__) No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it written by you manually?
Some extensions use the following sentence.

__import__('pkg_resources').declare_namespace(__name__)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be autogenerated. what's the difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference document is here. __import__('pkg_resources').declare_namespace(__name__) is no longer recommentded.

c.argument('client_tenant_id', help='The tenant ID of the client making the request.')
c.argument('location', arg_type=get_location_type(self.cli_ctx), validator=get_default_location_from_resource_group)
c.argument('tags', tags_type)
c.argument('storage_account_id', help='The resource identifier of the storage account where data will be imported to or exported from.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

support id or name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

c.argument('delivery_package', action=AddDeliveryPackage, nargs='+', help='Contains information about the package being shipped by the customer to the Microsoft data center.')
c.argument('return_package', action=AddReturnPackage, nargs='+', help='Contains information about the package being shipped by the customer to the Microsoft data center.')
c.argument('diagnostics_path', help='The virtual blob directory to which the copy logs and backups of drive manifest files (if enabled) will be stored.')
c.argument('log_level', help='Default value is Error. Indicates whether error logging or verbose logging will be enabled.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this enum in swagger? if yes, pls feedback to code gen team.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's defined as string in swagger.

c.argument('incomplete_blob_list_uri', help='A blob path that points to a block blob containing a list of blob names that were not exported due to insufficient drive space. If all blobs were exported successfully, then this element is not included in the response.')
c.argument('drive_list', action=AddDriveList, nargs='+', help='List of up to ten drives that comprise the job. The drive list is a required element for an import job; it is not specified for export jobs.')
c.argument('export', action=AddExport, nargs='+', help='A property containing information about the blobs to be exported for an export job. This property is required for export jobs, but must not be specified for import jobs.')
c.argument('provisioning_state', help='Specifies the provisioning state of the job.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice finding. It should be a bug of swagger file. It reuse a JobDetail object in both PutParameter and JobResponse. As a result of that we can specify this value when create a job, however the server will ignore it. I think we should remove it from create command parameters.

if kl == 'carrier-name':
d['carrier_name'] = v
elif kl == 'carrier-account-number':
d['carrier_account_number'] = v
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about feedback this to code gen team

return client.get(job_name=name, resource_group_name=resource_group_name)


def import_export_job_create(cmd, client, name, resource_group_name, client_tenant_id=None, location=None, tags=None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls make sure indention correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be no problem with indention. It's a IDE suggested style and pass our style check.

# regenerated.
# --------------------------------------------------------------------------

__path__ = __import__('pkgutil').extend_path(__path__, __name__) No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be autogenerated. what's the difference?

@arrownj
Copy link
Contributor Author

arrownj commented Apr 14, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@arrownj arrownj merged commit 581cb60 into Azure:master Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants