forked from Azure/azure-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
407 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,5 +57,4 @@ src/build | |
/.vs/config/applicationhost.config | ||
|
||
# Azure deployment credentials | ||
*.pubxml | ||
|
||
*.pubxml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[bdist_wheel] | ||
universal=1 | ||
|
||
[install] | ||
[easy-install] | ||
single-version-externally-managed=1 | ||
record=RECORD.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
'login', | ||
'logout', | ||
'network', | ||
'resourcegroup', | ||
'resource', | ||
'storage', | ||
'taskhelp', | ||
'vm', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
from .._profile import Profile | ||
import azure.cli._debug as _debug | ||
import azure.cli as cli | ||
from .._logging import logger | ||
|
||
def get_mgmt_service_client(client_type, config_type): | ||
profile = Profile() | ||
config = config_type(*profile.get_login_credentials()) | ||
config.log_name = 'az' | ||
config.log_level = logger.level | ||
|
||
client = client_type(config) | ||
_debug.allow_debug_connection(client) | ||
client.config.add_user_agent("AZURECLI_{}".format(cli.__version__)) | ||
|
||
return client | ||
|
||
def get_data_service_client(service_type, account_name, account_key): | ||
client = service_type(account_name=account_name, account_key=account_key) | ||
def get_data_service_client(service_type, account_name, account_key, connection_string=None): | ||
client = service_type(account_name=account_name, | ||
account_key=account_key, | ||
connection_string=connection_string) | ||
# TODO: enable Fiddler and user agent (task #115270703, #115270881) | ||
return client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
from .._argparse import IncorrectUsageError | ||
from ..commands import command, description, option | ||
from ._command_creation import get_mgmt_service_client | ||
from .._locale import L | ||
|
||
from azure.mgmt.resource.resources import (ResourceManagementClient, | ||
ResourceManagementClientConfiguration) | ||
|
||
@command('resource group list') | ||
@description('List resource groups') | ||
@option('--tag-name -tn <tagName>', L("the resource group's tag name")) | ||
@option('--tag-value -tv <tagValue>', L("the resource group's tag value")) | ||
def list_groups(args, unexpected): #pylint: disable=unused-argument | ||
from azure.mgmt.resource.resources.models import ResourceGroup, ResourceGroupFilter | ||
|
||
rmc = get_mgmt_service_client(ResourceManagementClient, ResourceManagementClientConfiguration) | ||
|
||
filters = [] | ||
if args.get('tag-name'): | ||
filters.append("tagname eq '{}'".format(args.get('tag-name'))) | ||
if args.get('tag-value'): | ||
filters.append("tagvalue eq '{}'".format(args.get('tag-value'))) | ||
|
||
filter_text = ' and '.join(filters) if len(filters) > 0 else None | ||
|
||
groups = rmc.resource_groups.list(filter=filter_text) | ||
return list(groups) | ||
|
||
@command('resource show') | ||
@description(L('Show details of a specific resource in a resource group or subscription')) | ||
@option('--resource-group -g <resourceGroup>', L('the resource group name'), required=True) | ||
@option('--name -n <name>', L('the resource name'), required=True) | ||
@option('--resource-type -r <resourceType>', | ||
L('the resource type in format: <provider-namespace>/<type>'), required=True) | ||
@option('--api-version -o <apiVersion>', L('the API version of the resource provider')) | ||
@option('--parent <parent>', | ||
L('the name of the parent resource (if needed), in <parent-type>/<parent-name> format')) | ||
def show_resource(args, unexpected): #pylint: disable=unused-argument | ||
rmc = get_mgmt_service_client(ResourceManagementClient, ResourceManagementClientConfiguration) | ||
|
||
full_type = args.get('resource-type').split('/') | ||
try: | ||
provider_namespace = full_type[0] | ||
resource_type = full_type[1] | ||
except IndexError: | ||
raise IncorrectUsageError('Parameter --resource-type must be in <namespace>/<type> format.') | ||
|
||
api_version = _resolve_api_version(args, rmc) | ||
if not api_version: | ||
raise IncorrectUsageError( | ||
L('API version is required and could not be resolved for resource {}' | ||
.format(full_type))) | ||
|
||
results = rmc.resources.get( | ||
resource_group_name=args.get('resource-group'), | ||
resource_name=args.get('name'), | ||
resource_provider_namespace=provider_namespace, | ||
resource_type=resource_type, | ||
api_version=api_version, | ||
parent_resource_path=args.get('parent', '') | ||
) | ||
return results | ||
|
||
def _resolve_api_version(args, rmc): | ||
api_version = args.get('api-version') | ||
if api_version: | ||
return api_version | ||
|
||
# if api-version not supplied, attempt to resolve using provider namespace | ||
parent = args.get('parent') | ||
full_type = args.get('resource-type').split('/') | ||
try: | ||
provider_namespace = full_type[0] | ||
resource_type = full_type[1] | ||
except IndexError: | ||
raise IncorrectUsageError('Parameter --resource-type must be in <namespace>/<type> format.') | ||
|
||
if parent: | ||
try: | ||
parent_type = parent.split('/')[0] | ||
except IndexError: | ||
raise IncorrectUsageError('Parameter --parent must be in <type>/<name> format.') | ||
|
||
resource_type = "{}/{}".format(parent_type, resource_type) | ||
else: | ||
resource_type = resource_type | ||
provider = rmc.providers.get(provider_namespace) | ||
for t in provider.resource_types: | ||
if t.resource_type == resource_type: | ||
# Return first non-preview version | ||
for version in t.api_versions: | ||
if not version.find('preview'): | ||
return version | ||
# No non-preview version found. Take first preview version | ||
try: | ||
return t.api_versions[0] | ||
except IndexError: | ||
return None | ||
return None |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.