Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{Util} Add util module for version and rest #13783

Merged
merged 5 commits into from
Jun 5, 2020
Merged

Conversation

jiasli
Copy link
Member

@jiasli jiasli commented Jun 2, 2020

Description

Peel off az version and az rest from resource module. A new module util is created. Thus they don't carry the burden of

  1. azure-mgmt-resource initialization when running these commands
  2. scenario tests on resource command module when developing these commands

This makes running and developing az version and az rest significantly faster.

Testing Guide

> az version
{
  "azure-cli": "2.6.0",
  "azure-cli-command-modules-nspkg": "2.0.3",
  "azure-cli-core": "2.6.0",
  "azure-cli-dev-tools": "0.1.1",
  "azure-cli-nspkg": "3.0.4",
  "azure-cli-telemetry": "1.0.4",
  "azure-cli-testsdk": "0.2.4",
  "extensions": {
    "application-insights": "0.1.1",
    "interactive": "0.4.4",
    "mesh": "0.10.6",
    "timeseriesinsights": "0.1.2",
    "webapp": "0.2.24"
  }
}

> az rest -m GET -u https://management.azure.com/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourcegroups/rg1?api-version=2019-07-01
{
  "id": "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourceGroups/rg1",
  "location": "westus",
  "name": "rg1",
  "properties": {
    "provisioningState": "Succeeded"
  },
  "tags": {
    "StorageType": "Standard_LRS",
    "type": "test"
  },
  "type": "Microsoft.Resources/resourceGroups"
}

@jiasli jiasli changed the title [Util] Add util module for version and rest {Util} Add util module for version and rest Jun 2, 2020
@yonzhan yonzhan added this to the S171 milestone Jun 2, 2020
@yonzhan
Copy link
Collaborator

yonzhan commented Jun 2, 2020

add to S171

# Conflicts:
#	src/azure-cli/azure/cli/command_modules/resource/_help.py
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from __future__ import print_function
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't support Python 2.0+ anymore, right?
Do we still need from __future__ import print_function? print-as-a-function

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch! I simply migrated the code from src/azure-cli/azure/cli/command_modules/resource/custom.py. Removed.

@zhoxing-ms zhoxing-ms self-requested a review June 5, 2020 05:32
Copy link
Contributor

@zhoxing-ms zhoxing-ms left a comment

Choose a reason for hiding this comment

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

LGTM

except ValueError:
logger.warning('Not a json response, outputting to stdout. For binary data '
'suggest use "--output-file" to write to a file')
print(r.text)
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer to not use print() according to command guideline.

@jiasli jiasli merged commit 8538b5e into Azure:dev Jun 5, 2020
@jiasli jiasli deleted the util-module branch June 5, 2020 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants