Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions azure-cli.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<Compile Include="azure\cli\commands\account.py" />
<Compile Include="azure\cli\commands\login.py" />
<Compile Include="azure\cli\commands\logout.py" />
<Compile Include="azure\cli\commands\resourcegroup.py" />
<Compile Include="azure\cli\commands\storage.py" />
<Compile Include="azure\cli\commands\__init__.py" />
<Compile Include="azure\cli\main.py" />
Expand Down
1 change: 1 addition & 0 deletions src/azure/cli/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'logout',
'account',
'storage',
'resourcegroup'
]

_COMMANDS = {}
Expand Down
32 changes: 32 additions & 0 deletions src/azure/cli/commands/resourcegroup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from .._util import TableOutput
from ..commands import command, description, option
from .._profile import Profile

@command('resource group list')
@description('List resource groups')
# TODO: waiting on Python Azure SDK bug fixes
#@option('--tag-name -g <tagName>', _("the resource group's tag name"))
#@option('--tag-value -g <tagValue>', _("the resource group's tag value"))
#@option('--top -g <number>', _("Top N resource groups to retrieve"))
def list_groups(args, unexpected):
from azure.mgmt.resource.resources import ResourceManagementClient, ResourceManagementClientConfiguration
from azure.mgmt.resource.resources.models import ResourceGroup, ResourceGroupFilter

rmc = ResourceManagementClient(ResourceManagementClientConfiguration(*Profile().get_login_credentials()))

# TODO: waiting on Python Azure SDK bug fixes
#group_filter = ResourceGroupFilter(args.get('tag-name'), args.get('tag-value'))
#groups = rmc.resource_groups.list(filter=None, top=args.get('top'))
groups = rmc.resource_groups.list()

with TableOutput() as to:
for grp in groups:
assert isinstance(grp, ResourceGroup)
to.cell('Name', grp.name)
to.cell('Type', grp.properties)
to.cell('Location', grp.location)
to.cell('Tags', grp.tags)
to.end_row()
if not to.any_rows:
print('No resource groups defined')

2 changes: 1 addition & 1 deletion src/azure/cli/commands/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def list_accounts(args, unexpected):

profile = Profile()
smc = StorageManagementClient(StorageManagementClientConfiguration(
*profile.get_login_credentials(),
*profile.get_login_credentials()
))

group = args.get('resource-group')
Expand Down