def test_register_cli_argument(self): command_table.clear() cli_command('test register sample-vm-get', Test_command_registration.sample_vm_get) register_cli_argument( 'test register sample-vm-get', 'vm_name', CliArgumentType(options_list=('--wonky-name', '-n'), metavar='VMNAME', help='Completely WONKY name...', required=False)) _update_command_definitions(command_table) self.assertEqual(len(command_table), 1, 'We expect exactly one command in the command table') command_metadata = command_table['test register sample-vm-get'] self.assertEqual(len(command_metadata.arguments), 4, 'We expected exactly 4 arguments') some_expected_arguments = { 'resource_group_name': CliArgumentType(dest='resource_group_name', required=True), 'vm_name': CliArgumentType(dest='vm_name', required=False), } for probe in some_expected_arguments: existing = next(arg for arg in command_metadata.arguments if arg == probe) self.assertDictContainsSubset( some_expected_arguments[existing].settings, command_metadata.arguments[existing].options) self.assertEqual(command_metadata.arguments['vm_name'].options_list, ('--wonky-name', '-n'))
def test_register_extra_cli_argument(self): command_table.clear() cli_command('test command sample-vm-get', Test_command_registration.sample_vm_get, None) register_extra_cli_argument('test command sample-vm-get', 'added_param', options_list=('--added-param', ), metavar='ADDED', help='Just added this right now!', required=True) _update_command_definitions(command_table) self.assertEqual(len(command_table), 1, 'We expect exactly one command in the command table') command_metadata = command_table['test command sample-vm-get'] self.assertEqual(len(command_metadata.arguments), 5, 'We expected exactly 5 arguments') some_expected_arguments = { 'added_param': CliArgumentType(dest='added_param', required=True) } for probe in some_expected_arguments: existing = next(arg for arg in command_metadata.arguments if arg == probe) self.assertDictContainsSubset( some_expected_arguments[existing].settings, command_metadata.arguments[existing].options) command_table.clear()
def test_override_using_register_cli_argument(self): def sample_sdk_method(param_a): # pylint: disable=unused-argument pass def test_validator_completer(): pass command_table.clear() cli_command('override_using_register_cli_argument foo', sample_sdk_method, None) register_cli_argument('override_using_register_cli_argument', 'param_a', options_list=('--overridden', '-r'), validator=test_validator_completer, completer=test_validator_completer, required=False) _update_command_definitions(command_table) command_metadata = command_table[ 'override_using_register_cli_argument foo'] self.assertEqual(len(command_metadata.arguments), 1, 'We expected exactly 1 arguments') actual_arg = command_metadata.arguments['param_a'] self.assertEqual(actual_arg.options_list, ('--overridden', '-r')) self.assertEqual(actual_arg.validator, test_validator_completer) self.assertEqual(actual_arg.completer, test_validator_completer) self.assertFalse(actual_arg.options['required']) command_table.clear()
def test_command_build_argument_help_text(self): def sample_sdk_method_with_weird_docstring(param_a, param_b, param_c): # pylint: disable=unused-argument """ An operation with nothing good. :param dict param_a: :param param_b: The name of nothing. :param param_c: The name of nothing2. """ command_table.clear() cli_command('test command foo', sample_sdk_method_with_weird_docstring, None) _update_command_definitions(command_table) command_metadata = command_table['test command foo'] self.assertEqual(len(command_metadata.arguments), 3, 'We expected exactly 3 arguments') some_expected_arguments = { 'param_a': CliArgumentType(dest='param_a', required=True, help=''), 'param_b': CliArgumentType(dest='param_b', required=True, help='The name of nothing.'), 'param_c': CliArgumentType(dest='param_c', required=True, help='The name of nothing2.') } for probe in some_expected_arguments: existing = next(arg for arg in command_metadata.arguments if arg == probe) self.assertDictContainsSubset(some_expected_arguments[existing].settings, command_metadata.arguments[existing].options)
def test_override_using_register_cli_argument(self): def sample_sdk_method(param_a): # pylint: disable=unused-argument pass def test_validator_completer(): pass command_table.clear() cli_command('override_using_register_cli_argument foo', sample_sdk_method, None) register_cli_argument('override_using_register_cli_argument', 'param_a', options_list=('--overridden', '-r'), validator=test_validator_completer, completer=test_validator_completer, required=False) _update_command_definitions(command_table) command_metadata = command_table['override_using_register_cli_argument foo'] self.assertEqual(len(command_metadata.arguments), 1, 'We expected exactly 1 arguments') actual_arg = command_metadata.arguments['param_a'] self.assertEqual(actual_arg.options_list, ('--overridden', '-r')) self.assertEqual(actual_arg.validator, test_validator_completer) self.assertEqual(actual_arg.completer, test_validator_completer) self.assertFalse(actual_arg.options['required'])
def test_register_command(self): command_table.clear() cli_command('test command sample-vm-get', Test_command_registration.sample_vm_get, None) self.assertEqual(len(command_table), 1, 'We expect exactly one command in the command table') command_metadata = command_table['test command sample-vm-get'] self.assertEqual(len(command_metadata.arguments), 4, 'We expected exactly 4 arguments') some_expected_arguments = { 'resource_group_name': CliArgumentType(dest='resource_group_name', required=True, help='The name of the resource group.'), 'vm_name': CliArgumentType(dest='vm_name', required=True, help='The name of the virtual machine.'), 'opt_param': CliArgumentType(required=False, help='Used to verify reflection correctly identifies optional params.'), # pylint: disable=line-too-long 'expand': CliArgumentType(required=False, help='The expand expression to apply on the operation.') } for probe in some_expected_arguments: existing = next(arg for arg in command_metadata.arguments if arg == probe) self.assertDictContainsSubset(some_expected_arguments[existing].settings, command_metadata.arguments[existing].options) self.assertEqual(command_metadata.arguments['resource_group_name'].options_list, ('--resource-group-name',))
def test_command_build_argument_help_text(self): def sample_sdk_method_with_weird_docstring(param_a, param_b, param_c): # pylint: disable=unused-argument """ An operation with nothing good. :param dict param_a: :param param_b: The name of nothing. :param param_c: The name of nothing2. """ command_table.clear() cli_command('test command foo', sample_sdk_method_with_weird_docstring, None) _update_command_definitions(command_table) command_metadata = command_table['test command foo'] self.assertEqual(len(command_metadata.arguments), 3, 'We expected exactly 3 arguments') some_expected_arguments = { 'param_a': CliArgumentType(dest='param_a', required=True, help=''), 'param_b': CliArgumentType(dest='param_b', required=True, help='The name of nothing.'), 'param_c': CliArgumentType(dest='param_c', required=True, help='The name of nothing2.') } for probe in some_expected_arguments: existing = next(arg for arg in command_metadata.arguments if arg == probe) self.assertDictContainsSubset( some_expected_arguments[existing].settings, command_metadata.arguments[existing].options) command_table.clear()
def test_register_command(self): command_table.clear() cli_command('test command sample-vm-get', Test_command_registration.sample_vm_get, None) self.assertEqual(len(command_table), 1, 'We expect exactly one command in the command table') command_metadata = command_table['test command sample-vm-get'] self.assertEqual(len(command_metadata.arguments), 4, 'We expected exactly 4 arguments') some_expected_arguments = { 'resource_group_name': CliArgumentType(dest='resource_group_name', required=True, help='The name of the resource group.'), 'vm_name': CliArgumentType(dest='vm_name', required=True, help='The name of the virtual machine.'), 'opt_param': CliArgumentType( required=False, help= 'Used to verify reflection correctly identifies optional params.' ), # pylint: disable=line-too-long 'expand': CliArgumentType( required=False, help='The expand expression to apply on the operation.') } for probe in some_expected_arguments: existing = next(arg for arg in command_metadata.arguments if arg == probe) self.assertDictContainsSubset( some_expected_arguments[existing].settings, command_metadata.arguments[existing].options) self.assertEqual( command_metadata.arguments['resource_group_name'].options_list, ['--resource-group-name'])
def test_register_cli_argument_with_overrides(self): command_table.clear() global_vm_name_type = CliArgumentType( options_list=('--foo', '-f'), metavar='FOO', help='foo help' ) derived_vm_name_type = CliArgumentType(base_type=global_vm_name_type, help='first modification') cli_command('test vm-get', Test_command_registration.sample_vm_get, None) cli_command('test command vm-get-1', Test_command_registration.sample_vm_get, None) cli_command('test command vm-get-2', Test_command_registration.sample_vm_get, None) register_cli_argument('test', 'vm_name', global_vm_name_type) register_cli_argument('test command', 'vm_name', derived_vm_name_type) register_cli_argument('test command vm-get-2', 'vm_name', derived_vm_name_type, help='second modification') _update_command_definitions(command_table) self.assertEqual(len(command_table), 3, 'We expect exactly three commands in the command table') command1 = command_table['test vm-get'].arguments['vm_name'] command2 = command_table['test command vm-get-1'].arguments['vm_name'] command3 = command_table['test command vm-get-2'].arguments['vm_name'] self.assertTrue(command1.options['help'] == 'foo help') self.assertTrue(command2.options['help'] == 'first modification') self.assertTrue(command3.options['help'] == 'second modification')
def test_register_cli_argument(self): command_table.clear() cli_command('test register sample-vm-get', Test_command_registration.sample_vm_get) register_cli_argument('test register sample-vm-get', 'vm_name', CliArgumentType( options_list=('--wonky-name', '-n'), metavar='VMNAME', help='Completely WONKY name...', required=False )) _update_command_definitions(command_table) self.assertEqual(len(command_table), 1, 'We expect exactly one command in the command table') command_metadata = command_table['test register sample-vm-get'] self.assertEqual(len(command_metadata.arguments), 4, 'We expected exactly 4 arguments') some_expected_arguments = { 'resource_group_name': CliArgumentType(dest='resource_group_name', required=True), 'vm_name': CliArgumentType(dest='vm_name', required=False), } for probe in some_expected_arguments: existing = next(arg for arg in command_metadata.arguments if arg == probe) self.assertDictContainsSubset(some_expected_arguments[existing].settings, command_metadata.arguments[existing].options) self.assertEqual(command_metadata.arguments['vm_name'].options_list, ('--wonky-name', '-n'))
def test_register_extra_cli_argument(self): command_table.clear() cli_command('test command sample-vm-get', Test_command_registration.sample_vm_get, None) register_extra_cli_argument( 'test command sample-vm-get', 'added_param', options_list=('--added-param',), metavar='ADDED', help='Just added this right now!', required=True ) _update_command_definitions(command_table) self.assertEqual(len(command_table), 1, 'We expect exactly one command in the command table') command_metadata = command_table['test command sample-vm-get'] self.assertEqual(len(command_metadata.arguments), 5, 'We expected exactly 5 arguments') some_expected_arguments = { 'added_param': CliArgumentType(dest='added_param', required=True) } for probe in some_expected_arguments: existing = next(arg for arg in command_metadata.arguments if arg == probe) self.assertDictContainsSubset(some_expected_arguments[existing].settings, command_metadata.arguments[existing].options)
def test_register_cli_argument_with_overrides(self): command_table.clear() global_vm_name_type = CliArgumentType(options_list=('--foo', '-f'), metavar='FOO', help='foo help') derived_vm_name_type = CliArgumentType(base_type=global_vm_name_type, help='first modification') cli_command('test vm-get', Test_command_registration.sample_vm_get, None) cli_command('test command vm-get-1', Test_command_registration.sample_vm_get, None) cli_command('test command vm-get-2', Test_command_registration.sample_vm_get, None) register_cli_argument('test', 'vm_name', global_vm_name_type) register_cli_argument('test command', 'vm_name', derived_vm_name_type) register_cli_argument('test command vm-get-2', 'vm_name', derived_vm_name_type, help='second modification') _update_command_definitions(command_table) self.assertEqual( len(command_table), 3, 'We expect exactly three commands in the command table') command1 = command_table['test vm-get'].arguments['vm_name'] command2 = command_table['test command vm-get-1'].arguments['vm_name'] command3 = command_table['test command vm-get-2'].arguments['vm_name'] self.assertTrue(command1.options['help'] == 'foo help') self.assertTrue(command2.options['help'] == 'first modification') self.assertTrue(command3.options['help'] == 'second modification') command_table.clear()
reset_windows_admin, set_linux_user, delete_linux_user, disable_boot_diagnostics, enable_boot_diagnostics, get_boot_log, list_extensions, set_extension, set_diagnostics_extension, show_default_diagnostics_configuration, vmss_start, vmss_restart, vmss_delete_instances, vmss_deallocate, vmss_get_instance_view, vmss_stop, vmss_reimage, vmss_scale, vmss_update_instances, vmss_show, vmss_list ) from ._factory import _compute_client_factory # pylint: disable=line-too-long # VM factory = lambda _: get_mgmt_service_client(VMClient).vm cli_command('vm create', VmOperations.create_or_update, factory, transform=DeploymentOutputLongRunningOperation('Starting vm create')) factory = lambda _: _compute_client_factory().virtual_machines cli_command('vm delete', VirtualMachinesOperations.delete, factory) cli_command('vm deallocate', VirtualMachinesOperations.deallocate, factory) cli_command('vm generalize', VirtualMachinesOperations.generalize, factory) cli_command('vm show', VirtualMachinesOperations.get, factory, simple_output_query="{Name:name, ResourceGroup:resourceGroup, Location:location, VmSize:hardwareProfile.vmSize, OsType: storageProfile.osDisk.osType, Urn: join(':', [storageProfile.imageReference.publisher, storageProfile.imageReference.offer, storageProfile.imageReference.sku, storageProfile.imageReference.version])}") cli_command('vm list-vm-resize-options', VirtualMachinesOperations.list_available_sizes, factory) cli_command('vm stop', VirtualMachinesOperations.power_off, factory) cli_command('vm restart', VirtualMachinesOperations.restart, factory) cli_command('vm start', VirtualMachinesOperations.start, factory) cli_command('vm redeploy', VirtualMachinesOperations.redeploy, factory) cli_command('vm list-ip-addresses', list_ip_addresses) cli_command('vm list', list_vm, simple_output_query="[*].{Name: name, ResourceGroup: resourceGroup, Location: location, VmSize: hardwareProfile.vmSize, Urn: join(':', [storageProfile.imageReference.publisher, storageProfile.imageReference.offer, storageProfile.imageReference.sku, storageProfile.imageReference.version])} | sort_by(@, &Name)") cli_command('vm resize', resize_vm)
add_nic_ip_config_address_pool, remove_nic_ip_config_address_pool, add_nic_ip_config_inbound_nat_rule, remove_nic_ip_config_inbound_nat_rule, list_network_resource_property, get_network_resource_property_entry, delete_network_resource_property_entry, set_nic, list_lbs, list_express_route_circuits, list_public_ips, list_nics, list_route_tables, list_application_gateways) from ._factory import _network_client_factory # pylint: disable=line-too-long # Application gateways factory = lambda _: _network_client_factory().application_gateways cli_command('network application-gateway delete', ApplicationGatewaysOperations.delete, factory) cli_command('network application-gateway show', ApplicationGatewaysOperations.get, factory) cli_command('network application-gateway list', list_application_gateways) cli_command('network application-gateway start', ApplicationGatewaysOperations.start, factory) cli_command('network application-gateway stop', ApplicationGatewaysOperations.stop, factory) register_generic_update('network application-gateway update', ApplicationGatewaysOperations.get, ApplicationGatewaysOperations.create_or_update, factory) factory = lambda _: get_mgmt_service_client(AppGatewayClient).app_gateway cli_command('network application-gateway create', AppGatewayOperations.create_or_update,
from __future__ import print_function from azure.cli.commands import cli_command from .custom import (list_components, install, update, update_all, update_self, remove, check_component) # HELPER METHODS cli_command('component list', list_components) cli_command('component install', install) cli_command('component update', update) cli_command('component update-all', update_all) cli_command('component update-self', update_self) cli_command('component remove', remove) cli_command('component check', check_component)
#--------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. #--------------------------------------------------------------------------------------------- from __future__ import print_function from azure.cli.commands import cli_command from .custom import (login, logout, list_location, list_subscriptions, set_active_subscription, account_clear) cli_command('login', login) cli_command('logout', logout) cli_command('account list', list_subscriptions) cli_command('account set', set_active_subscription) cli_command('account clear', account_clear) cli_command('account list-location', list_location)
#--------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. #--------------------------------------------------------------------------------------------- from __future__ import print_function from azure.cli.commands import cli_command from .custom import (list_components, install, update, update_all, update_self, remove, check_component) # HELPER METHODS cli_command('component list', list_components, simple_output_query="[*].{Name:name, Version:version} | sort_by(@, &Name)") cli_command('component install', install) cli_command('component update', update) cli_command('component update-all', update_all) cli_command('component update-self', update_self) cli_command('component remove', remove) cli_command('component check', check_component)
# Add command module logic to this package. from azure.cli.commands import cli_command def example(my_required_arg, my_optional_arg='MyDefault'): '''Returns the params you passed in. :param str my_required_arg: The argument that is required ''' result = {'a': my_required_arg, 'b': my_optional_arg} return result cli_command('example', example)
from azure.mgmt.authorization.operations import RoleDefinitionsOperations from azure.graphrbac.operations import UsersOperations, GroupsOperations from azure.cli.commands import cli_command from azure.cli.commands.arm import register_generic_update from .custom import (create_role_assignment, list_role_assignments, delete_role_assignments, list_role_definitions, delete_role_definition, create_role_definition, list_sps, list_users, create_user, list_groups, list_apps, create_application, update_application, delete_application, show_application, create_service_principal, show_service_principal, delete_service_principal, create_service_principal_for_rbac, reset_service_principal_credential, _auth_client_factory, _graph_client_factory) factory = lambda _: _auth_client_factory().role_definitions simple_output_query = '[*].{Name:properties.roleName, Id:name, Type:properties.type}' cli_command('role list', list_role_definitions, simple_output_query=simple_output_query) cli_command('role delete', delete_role_definition) cli_command('role create', create_role_definition, simple_output_query=simple_output_query) register_generic_update('role update', RoleDefinitionsOperations.get, RoleDefinitionsOperations.create_or_update, factory) simple_output_query = '[*].{Name:name, PrincipalName:properties.principalName, Role:properties.roleDefinitionName, Scope:properties.scope}' factory = lambda _: _auth_client_factory().role_assignments cli_command('role assignment delete', delete_role_assignments) cli_command('role assignment list', list_role_assignments, simple_output_query='[*].{Name:name, PrincipalName:properties.principalName, Role:properties.roleDefinitionName, Scope:properties.scope}') cli_command('role assignment create', create_role_assignment, simple_output_query="{Name:name, PrincipalId:properties.principalId, Scope:properties.scope}")
EVENT_NAME, { 'response_what_changes': response_what_changes, 'response_do_well': response_do_well, 'response_email_address': email_address, 'version_components': version_components, 'version_python': version_python }, {'response_net_promoter_score': score}) tc.flush() def handle_feedback(): try: print(MESSAGES['intro']) score = _prompt_net_promoter_score() response_do_well = None response_what_changes = None if score == 10: response_do_well = input(MESSAGES['prompt_do_well']) else: response_what_changes = input(MESSAGES['prompt_what_changes']) email_address = input(MESSAGES['prompt_email_addr']) _send_feedback(score, response_what_changes, response_do_well, email_address) print(MESSAGES['thanks']) except KeyboardInterrupt: # Catch to prevent stacktrace and print newline print() cli_command('feedback', handle_feedback)
#--------------------------------------------------------------------------------------------- # pylint: disable=line-too-long from __future__ import print_function from azure.mgmt.authorization.operations import RoleAssignmentsOperations, RoleDefinitionsOperations from azure.graphrbac.operations import (ApplicationsOperations, ServicePrincipalsOperations, UsersOperations, GroupsOperations) from azure.cli.commands import cli_command from azure.cli.commands.arm import register_generic_update from .custom import (create_role_assignment, list_sps, list_users, create_user, list_groups, list_apps, _auth_client_factory, _graph_client_factory) factory = lambda _: _auth_client_factory().role_definitions cli_command('role list', RoleDefinitionsOperations.list, factory) cli_command('role delete', RoleDefinitionsOperations.delete, factory) cli_command('role show', RoleDefinitionsOperations.get, factory) cli_command('role show-by-id', RoleDefinitionsOperations.get_by_id, factory) register_generic_update('role update', RoleDefinitionsOperations.get, RoleDefinitionsOperations.create_or_update, factory) factory = lambda _: _auth_client_factory().role_assignments cli_command('role assignment delete', RoleAssignmentsOperations.delete, factory) cli_command('role assignment delete-by-id', RoleAssignmentsOperations.delete_by_id, factory) cli_command('role assignment show', RoleAssignmentsOperations.get, factory) cli_command('role assignment show-by-id', RoleAssignmentsOperations.get_by_id, factory) cli_command('role assignment list', RoleAssignmentsOperations.list, factory) cli_command('role assignment list-for-resource', RoleAssignmentsOperations.list_for_resource, factory)
reset_windows_admin, set_linux_user, delete_linux_user, disable_boot_diagnostics, enable_boot_diagnostics, get_boot_log, list_extensions, set_extension, set_diagnostics_extension, show_default_diagnostics_configuration, vmss_start, vmss_restart, vmss_delete_instances, vmss_deallocate, vmss_get_instance_view, vmss_stop, vmss_reimage, vmss_scale, vmss_update_instances, vmss_show, vmss_list ) from ._factory import _compute_client_factory # pylint: disable=line-too-long # VM factory = lambda _: get_mgmt_service_client(VMClient).vm cli_command('vm create', VmOperations.create_or_update, factory, transform=DeploymentOutputLongRunningOperation('Starting vm create'), simple_output_query="{ResourceGroup:resourceGroup, PublicIpAddress:publicIpAddress, PrivateIpAddress:privateIpAddress, MacAddress:macAddress, FQDN:fqdn}") factory = lambda _: _compute_client_factory().virtual_machines cli_command('vm delete', VirtualMachinesOperations.delete, factory) cli_command('vm deallocate', VirtualMachinesOperations.deallocate, factory) cli_command('vm generalize', VirtualMachinesOperations.generalize, factory) cli_command('vm show', VirtualMachinesOperations.get, factory, simple_output_query="{Name:name, ResourceGroup:resourceGroup, Location:location, VmSize:hardwareProfile.vmSize, OsType: storageProfile.osDisk.osType}") cli_command('vm list-vm-resize-options', VirtualMachinesOperations.list_available_sizes, factory, simple_output_query="[*].{Name: name, NumberOfCores: numberOfCores, MemoryInMb: memoryInMb, MaxDataDiskCount: maxDataDiskCount, ResourceDiskSizeInMb: resourceDiskSizeInMb, OsDiskSizeInMb: osDiskSizeInMb} | sort_by(@, &Name)") cli_command('vm get-instance-view', get_instance_view, simple_output_query="{Name:name, VmSize:hardwareProfile.vmSize, OsType: storageProfile.osDisk.osType, Status1: instanceView.statuses[0].code, Status2: instanceView.statuses[1].code}") cli_command('vm stop', VirtualMachinesOperations.power_off, factory) cli_command('vm restart', VirtualMachinesOperations.restart, factory) cli_command('vm start', VirtualMachinesOperations.start, factory) cli_command('vm redeploy', VirtualMachinesOperations.redeploy, factory) cli_command('vm list-ip-addresses', list_ip_addresses, simple_output_query="[*].{VmName: virtualMachine.name, VmResourceGroup: virtualMachine.resourceGroup, PublicIpAddressName: join(', ', virtualMachine.network.publicIpAddresses[].name), PublicIpAddress: join(', ', virtualMachine.network.publicIpAddresses[].ipAddress), PublicIpAllocationMethod: join(', ', virtualMachine.network.publicIpAddresses[].ipAllocationMethod)} | sort_by(@, &VmName)")
create_nsg_rule, update_nsg_rule, create_lb_inbound_nat_rule, set_lb_inbound_nat_rule, create_lb_frontend_ip_configuration, set_lb_frontend_ip_configuration, create_lb_inbound_nat_pool, set_lb_inbound_nat_pool, create_lb_backend_address_pool, create_lb_probe, set_lb_probe, create_lb_rule, set_lb_rule, list_load_balancer_property, get_load_balancer_property_entry, delete_load_balancer_property_entry) from ._factory import _network_client_factory # pylint: disable=line-too-long # Application gateways factory = lambda _: _network_client_factory().application_gateways cli_command('network application-gateway delete', ApplicationGatewaysOperations.delete, factory) cli_command('network application-gateway show', ApplicationGatewaysOperations.get, factory) cli_command('network application-gateway list', ApplicationGatewaysOperations.list, factory) cli_command('network application-gateway list-all', ApplicationGatewaysOperations.list_all, factory) cli_command('network application-gateway start', ApplicationGatewaysOperations.start, factory) cli_command('network application-gateway stop', ApplicationGatewaysOperations.stop, factory) factory = lambda _: get_mgmt_service_client(AppGatewayClient).app_gateway cli_command('network application-gateway create', AppGatewayOperations.create_or_update, factory, transform=DeploymentOutputLongRunningOperation('Starting network application-gateway create')) # ExpressRouteCircuitAuthorizationsOperations factory = lambda _: _network_client_factory().express_route_circuit_authorizations cli_command('network express-route circuit-auth delete', ExpressRouteCircuitAuthorizationsOperations.delete, factory) cli_command('network express-route circuit-auth show', ExpressRouteCircuitAuthorizationsOperations.get, factory) cli_command('network express-route circuit-auth list', ExpressRouteCircuitAuthorizationsOperations.list, factory)
VaultsOperations ) from azure.cli.commands import cli_command from azure.cli.commands.client_factory import get_mgmt_service_client from azure.cli.commands.arm import register_generic_update def _keyvault_client_factory(**_): return get_mgmt_service_client(KeyVaultManagementClient) factory = lambda args: _keyvault_client_factory(**args).vaults keyvault_show_query = "{Name:name, ResourceGroup:resourceGroup, Location:location, "\ "SkuFamily:properties.sku.family, SkuName:properties.sku.name, "\ "VaultUri:properties.vaultUri}" cli_command('keyvault create', create_keyvault, factory, simple_output_query=keyvault_show_query) cli_command('keyvault list', list_keyvault, factory, simple_output_query="[*].{Name:name, ResourceGroup:resourceGroup, Location:location} |"\ " sort_by(@, &Name)") cli_command('keyvault show', VaultsOperations.get, factory, simple_output_query=keyvault_show_query) cli_command('keyvault delete', VaultsOperations.delete, factory) cli_command('keyvault set-policy', set_policy, factory, simple_output_query=keyvault_show_query) cli_command('keyvault delete-policy', delete_policy, factory, simple_output_query=keyvault_show_query) def keyvault_update_setter(client, resource_group_name, vault_name, parameters): from azure.mgmt.keyvault.models import VaultCreateOrUpdateParameters return client.create_or_update(resource_group_name=resource_group_name, vault_name=vault_name, parameters=VaultCreateOrUpdateParameters(
from azure.cli.command_modules.storage._command_type import cli_storage_data_plane_command from azure.cli.command_modules.storage._factory import \ (storage_client_factory, blob_data_service_factory, file_data_service_factory, table_data_service_factory, queue_data_service_factory, cloud_storage_account_service_factory) from azure.cli.command_modules.storage.custom import \ (create_storage_account, list_storage_accounts, show_storage_account_usage, set_storage_account_properties, show_storage_account_connection_string, renew_storage_account_keys, upload_blob, get_acl_policy, create_acl_policy, delete_acl_policy, list_acl_policies, set_acl_policy, insert_table_entity) from azure.cli.command_modules.storage._validators import transform_acl_list_output, transform_url # storage account commands factory = lambda kwargs: storage_client_factory().storage_accounts cli_command('storage account check-name', StorageAccountsOperations.check_name_availability, factory) cli_command('storage account delete', StorageAccountsOperations.delete, factory) cli_command('storage account show', StorageAccountsOperations.get_properties, factory) cli_command('storage account create', create_storage_account) cli_command('storage account list', list_storage_accounts, simple_output_query='[*].{Name: name, ResourceGroup: resourceGroup, Location: location, SkuName: sku.name, SkuTier: sku.tier} | sort_by(@, &Name)') cli_command('storage account show-usage', show_storage_account_usage, simple_output_query='{Name:name.localizedValue, Current:currentValue, Max:limit}') cli_command('storage account update', set_storage_account_properties) cli_command('storage account connection-string', show_storage_account_connection_string) cli_command('storage account keys renew', renew_storage_account_keys) cli_command('storage account keys list', StorageAccountsOperations.list_keys, factory) cli_storage_data_plane_command('storage account generate-sas', CloudStorageAccount.generate_shared_access_signature, cloud_storage_account_service_factory) # container commands factory = blob_data_service_factory cli_storage_data_plane_command('storage container list', BlockBlobService.list_containers, factory, simple_output_query='items[*].{Name: name, LeaseState: properties.leaseState} | sort_by(@, &Name)') cli_storage_data_plane_command('storage container delete', BlockBlobService.delete_container, factory)
# pylint: disable=line-too-long from __future__ import print_function from azure.mgmt.authorization.operations import RoleAssignmentsOperations, RoleDefinitionsOperations from azure.graphrbac.operations import (ApplicationsOperations, ServicePrincipalsOperations, UsersOperations, GroupsOperations) from azure.cli.commands import cli_command from azure.cli.commands.arm import register_generic_update from .custom import (create_role_assignment, list_sps, list_users, create_user, list_groups, list_apps, _auth_client_factory, _graph_client_factory) factory = lambda _: _auth_client_factory().role_definitions cli_command('role list', RoleDefinitionsOperations.list, factory) cli_command('role delete', RoleDefinitionsOperations.delete, factory) cli_command('role show', RoleDefinitionsOperations.get, factory) cli_command('role show-by-id', RoleDefinitionsOperations.get_by_id, factory) register_generic_update('role update', RoleDefinitionsOperations.get, RoleDefinitionsOperations.create_or_update, factory) factory = lambda _: _auth_client_factory().role_assignments cli_command('role assignment delete', RoleAssignmentsOperations.delete, factory) cli_command('role assignment delete-by-id', RoleAssignmentsOperations.delete_by_id, factory) cli_command('role assignment show', RoleAssignmentsOperations.get, factory) cli_command('role assignment show-by-id', RoleAssignmentsOperations.get_by_id, factory) cli_command('role assignment list', RoleAssignmentsOperations.list, factory)
#--------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. #--------------------------------------------------------------------------------------------- # Add command module logic to this package. from azure.cli.commands import cli_command def example(my_required_arg, my_optional_arg='MyDefault'): '''Returns the params you passed in. :param str my_required_arg: The argument that is required ''' result = {'a': my_required_arg, 'b': my_optional_arg} return result cli_command('example', example)
RedisManagementClient ) from azure.mgmt.redis.operations import ( RedisOperations, PatchSchedulesOperations ) from azure.cli.commands import cli_command from azure.cli.commands.client_factory import get_mgmt_service_client def _redis_client_factory(**_): return get_mgmt_service_client(RedisManagementClient) factory = lambda args: _redis_client_factory(**args).redis #cli_command('redis create', RedisOperations.create_or_update, factory) cli_command('redis delete', RedisOperations.delete, factory) cli_command('redis export', cli_redis_export, factory) cli_command('redis force-reboot', RedisOperations.force_reboot, factory) cli_command('redis import-method', cli_redis_import_method, factory) cli_command('redis list', RedisOperations.list_by_resource_group, factory) cli_command('redis list-all', RedisOperations.list, factory) cli_command('redis list-keys', RedisOperations.list_keys, factory) cli_command('redis regenerate-keys', RedisOperations.regenerate_key, factory) cli_command('redis show', RedisOperations.get, factory) cli_command('redis update-settings', cli_redis_update_settings, factory) factory = lambda args: _redis_client_factory(**args).patch_schedules cli_command('redis patch-schedule set', PatchSchedulesOperations.create_or_update, factory) cli_command('redis patch-schedule delete', PatchSchedulesOperations.delete, factory) cli_command('redis patch-schedule show', PatchSchedulesOperations.get, factory)
from .custom import cli_redis_import_method, cli_redis_export, cli_redis_update_settings from azure.mgmt.redis import (RedisManagementClient) from azure.mgmt.redis.operations import (RedisOperations, PatchSchedulesOperations) from azure.cli.commands import cli_command from azure.cli.commands.client_factory import get_mgmt_service_client def _redis_client_factory(**_): return get_mgmt_service_client(RedisManagementClient) factory = lambda args: _redis_client_factory(**args).redis #cli_command('redis create', RedisOperations.create_or_update, factory) cli_command('redis delete', RedisOperations.delete, factory) cli_command('redis export', cli_redis_export, factory) cli_command('redis force-reboot', RedisOperations.force_reboot, factory) cli_command('redis import-method', cli_redis_import_method, factory) cli_command('redis list', RedisOperations.list_by_resource_group, factory) cli_command('redis list-all', RedisOperations.list, factory) cli_command('redis list-keys', RedisOperations.list_keys, factory) cli_command('redis regenerate-keys', RedisOperations.regenerate_key, factory) cli_command('redis show', RedisOperations.get, factory) cli_command('redis update-settings', cli_redis_update_settings, factory) factory = lambda args: _redis_client_factory(**args).patch_schedules cli_command('redis patch-schedule set', PatchSchedulesOperations.create_or_update, factory) cli_command('redis patch-schedule delete', PatchSchedulesOperations.delete,
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. #--------------------------------------------------------------------------------------------- #pylint: disable=unused-import from azure.mgmt.web.operations import SitesOperations from azure.cli.commands import LongRunningOperation, cli_command from azure.cli.commands.client_factory import get_mgmt_service_client from azure.cli.command_modules.webapp._params import _web_client_factory from azure.cli.command_modules.webapp.mgmt_webapp.lib \ import (WebappCreationClient as WebAppClient) from azure.cli.command_modules.webapp.mgmt_webapp.lib.operations import WebappOperations class DeploymentOutputLongRunningOperation(LongRunningOperation): #pylint: disable=too-few-public-methods def __call__(self, poller): result = super(DeploymentOutputLongRunningOperation, self).__call__(poller) return result.properties.outputs factory = lambda _: _web_client_factory() cli_command('webapp get-sites', SitesOperations.get_sites, factory) factory = lambda _: get_mgmt_service_client(WebAppClient).webapp cli_command('webapp create', WebappOperations.create_or_update, factory, transform=DeploymentOutputLongRunningOperation('Creating webapp'))
#--------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. #--------------------------------------------------------------------------------------------- from __future__ import print_function from azure.cli.commands import cli_command from .custom import deploy_arm_template cli_command('taskhelp deploy-arm-template', deploy_arm_template)
create_lb_rule, set_lb_rule, create_nic_ip_config, set_nic_ip_config, add_nic_ip_config_address_pool, remove_nic_ip_config_address_pool, add_nic_ip_config_inbound_nat_rule, remove_nic_ip_config_inbound_nat_rule, set_nic, list_network_resource_property, get_network_resource_property_entry, delete_network_resource_property_entry, list_application_gateways, list_express_route_circuits, list_lbs, list_nics, list_nsgs, list_public_ips, list_route_tables, list_vnet ) from ._factory import _network_client_factory # pylint: disable=line-too-long # Application gateways factory = lambda _: _network_client_factory().application_gateways cli_command('network application-gateway delete', ApplicationGatewaysOperations.delete, factory) cli_command('network application-gateway show', ApplicationGatewaysOperations.get, factory) cli_command('network application-gateway list', list_application_gateways, simple_output_query="[*].{Name:name, ResourceGroup:resourceGroup, Location:location, State:provisioningState} | sort_by(@, &Name)") cli_command('network application-gateway start', ApplicationGatewaysOperations.start, factory) cli_command('network application-gateway stop', ApplicationGatewaysOperations.stop, factory) register_generic_update('network application-gateway update', ApplicationGatewaysOperations.get, ApplicationGatewaysOperations.create_or_update, factory) factory = lambda _: get_mgmt_service_client(AppGatewayClient).app_gateway cli_command('network application-gateway create', AppGatewayOperations.create_or_update, factory, transform=DeploymentOutputLongRunningOperation('Starting network application-gateway create')) property_map = { 'ssl_certificates': 'ssl-cert', 'frontend_ip_configurations': 'frontend-ip', 'frontend_ports': 'frontend-port', 'backend_address_pools': 'address-pool', 'backend_http_settings_collection': 'http-settings',
from azure.cli.commands import cli_command from azure.cli.command_modules.storage._command_type import cli_storage_data_plane_command from azure.cli.command_modules.storage._factory import \ (storage_client_factory, blob_data_service_factory, file_data_service_factory, cloud_storage_account_service_factory) from azure.cli.command_modules.storage.custom import \ (create_storage_account, list_storage_accounts, show_storage_account_usage, set_storage_account_properties, show_storage_account_connection_string, renew_storage_account_keys, container_exists, blob_exists, download_blob, upload_blob, share_exists, dir_exists, file_exists, upload_file, download_file, get_acl_policy, create_acl_policy, delete_acl_policy, list_acl_policies, set_acl_policy) # storage account commands factory = lambda kwargs: storage_client_factory().storage_accounts cli_command('storage account check-name', StorageAccountsOperations.check_name_availability, factory) cli_command('storage account delete', StorageAccountsOperations.delete, factory) cli_command('storage account show', StorageAccountsOperations.get_properties, factory) cli_command('storage account create', create_storage_account) cli_command( 'storage account list', list_storage_accounts, simple_output_query= '[*].{Name: name, ResourceGroup: resourceGroup, Location: location, SkuName: sku.name, SkuTier: sku.tier} | sort_by(@, &Name)' ) cli_command('storage account show-usage', show_storage_account_usage) cli_command('storage account update', set_storage_account_properties) cli_command('storage account connection-string', show_storage_account_connection_string)
tc.context.application.ver = cli.__version__ #pylint: disable=no-member version_components, version_python = _get_version_info() tc.track_event( EVENT_NAME, {'response_what_changes': response_what_changes, 'response_do_well': response_do_well, 'response_email_address': email_address, 'version_components': version_components, 'version_python': version_python}, {'response_net_promoter_score':score}) tc.flush() def handle_feedback(): try: print(MESSAGES['intro']) score = _prompt_net_promoter_score() response_do_well = None response_what_changes = None if score == 10: response_do_well = input(MESSAGES['prompt_do_well']) else: response_what_changes = input(MESSAGES['prompt_what_changes']) email_address = input(MESSAGES['prompt_email_addr']) _send_feedback(score, response_what_changes, response_do_well, email_address) print(MESSAGES['thanks']) except KeyboardInterrupt: # Catch to prevent stacktrace and print newline print() cli_command('feedback', handle_feedback)
from azure.mgmt.resource.resources.operations.deployments_operations import DeploymentsOperations from azure.mgmt.resource.resources.operations.deployment_operations_operations \ import DeploymentOperationsOperations from azure.cli.commands import cli_command from azure.cli.commands.arm import register_generic_update from azure.cli.command_modules.resource._factory import _resource_client_factory from azure.cli.command_modules.resource.custom import ( list_resource_groups, create_resource_group, export_group_as_template, list_resources, move_resource, deploy_arm_template, validate_arm_template, tag_resource, export_deployment_as_template, register_provider, unregister_provider) # Resource group commands factory = lambda _: _resource_client_factory().resource_groups cli_command('resource group delete', ResourceGroupsOperations.delete, factory) cli_command('resource group show', ResourceGroupsOperations.get, factory) cli_command('resource group exists', ResourceGroupsOperations.check_existence, factory) cli_command('resource group list', list_resource_groups) cli_command('resource group create', create_resource_group) cli_command('resource group export', export_group_as_template) # Resource commands factory = lambda _: _resource_client_factory().resources cli_command('resource exists', ResourcesOperations.check_existence, factory) cli_command('resource delete', ResourcesOperations.delete, factory) cli_command('resource show', ResourcesOperations.get, factory) cli_command('resource list', list_resources) cli_command('resource tag', tag_resource) cli_command('resource move', move_resource)
from __future__ import print_function from azure.cli.commands import cli_command from .custom import (login, logout, list_location, list_subscriptions, set_active_subscription, account_clear, create_service_principal, reset_service_principal_credential) cli_command('login', login) cli_command('logout', logout) cli_command('account list', list_subscriptions) cli_command('account set', set_active_subscription) cli_command('account clear', account_clear) cli_command('account list-location', list_location) cli_command('account create-sp', create_service_principal) cli_command('account reset-sp-credentials', reset_service_principal_credential)
#pylint: disable=unused-import from azure.mgmt.web.operations import SitesOperations from azure.cli.commands import LongRunningOperation, cli_command from azure.cli.commands.client_factory import get_mgmt_service_client from azure.cli.command_modules.webapp._params import _web_client_factory from azure.cli.command_modules.webapp.mgmt_webapp.lib \ import (WebappCreationClient as WebAppClient) from azure.cli.command_modules.webapp.mgmt_webapp.lib.operations import WebappOperations class DeploymentOutputLongRunningOperation(LongRunningOperation): #pylint: disable=too-few-public-methods def __call__(self, poller): result = super(DeploymentOutputLongRunningOperation, self).__call__(poller) return result.properties.outputs factory = lambda _: _web_client_factory() cli_command('webapp get-sites', SitesOperations.get_sites, factory) factory = lambda _: get_mgmt_service_client(WebAppClient).webapp cli_command('webapp create', WebappOperations.create_or_update, factory, transform=DeploymentOutputLongRunningOperation('Creating webapp'))
from azure.mgmt.resource.resources.operations.deployment_operations_operations \ import DeploymentOperationsOperations from azure.cli.commands import cli_command from azure.cli.commands.arm import register_generic_update from azure.cli.command_modules.resource._factory import _resource_client_factory from azure.cli.command_modules.resource.custom import ( list_resource_groups, create_resource_group, export_group_as_template, list_resources, move_resource, deploy_arm_template, validate_arm_template, tag_resource, export_deployment_as_template, register_provider, unregister_provider ) # Resource group commands factory = lambda _: _resource_client_factory().resource_groups cli_command('resource group delete', ResourceGroupsOperations.delete, factory) cli_command('resource group show', ResourceGroupsOperations.get, factory) cli_command('resource group exists', ResourceGroupsOperations.check_existence, factory) cli_command('resource group list', list_resource_groups) cli_command('resource group create', create_resource_group) cli_command('resource group export', export_group_as_template) # Resource commands factory = lambda _: _resource_client_factory().resources cli_command('resource exists', ResourcesOperations.check_existence, factory) cli_command('resource delete', ResourcesOperations.delete, factory) cli_command('resource show', ResourcesOperations.get, factory) cli_command('resource list', list_resources) cli_command('resource tag', tag_resource) cli_command('resource move', move_resource)
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- # Add command module logic to this package. from azure.cli.commands import cli_command def example(my_required_arg, my_optional_arg="MyDefault"): """Returns the params you passed in. :param str my_required_arg: The argument that is required """ result = {"a": my_required_arg, "b": my_optional_arg} return result cli_command("example", example)
from azure.cli.commands import cli_command from azure.cli.command_modules.storage._command_type import cli_storage_data_plane_command from azure.cli.command_modules.storage._factory import \ (storage_client_factory, blob_data_service_factory, file_data_service_factory, cloud_storage_account_service_factory) from azure.cli.command_modules.storage.custom import \ (create_storage_account, list_storage_accounts, show_storage_account_usage, set_storage_account_properties, show_storage_account_connection_string, renew_storage_account_keys, container_exists, blob_exists, download_blob, upload_blob, share_exists, dir_exists, file_exists, upload_file, download_file, get_acl_policy, create_acl_policy, delete_acl_policy, list_acl_policies, set_acl_policy) # storage account commands factory = lambda kwargs: storage_client_factory().storage_accounts cli_command('storage account check-name', StorageAccountsOperations.check_name_availability, factory) cli_command('storage account delete', StorageAccountsOperations.delete, factory) cli_command('storage account show', StorageAccountsOperations.get_properties, factory) cli_command('storage account create', create_storage_account) cli_command('storage account list', list_storage_accounts) cli_command('storage account show-usage', show_storage_account_usage) cli_command('storage account set', set_storage_account_properties) cli_command('storage account connection-string', show_storage_account_connection_string) cli_command('storage account keys renew', renew_storage_account_keys) cli_command('storage account keys list', StorageAccountsOperations.list_keys, factory) cli_storage_data_plane_command('storage account generate-sas', CloudStorageAccount.generate_shared_access_signature, cloud_storage_account_service_factory) # container commands factory = blob_data_service_factory cli_storage_data_plane_command('storage container list', BlockBlobService.list_containers, factory) cli_storage_data_plane_command('storage container delete', BlockBlobService.delete_container, factory)
vm_open_port, reset_windows_admin, set_linux_user, delete_linux_user, disable_boot_diagnostics, enable_boot_diagnostics, get_boot_log, list_extensions, set_extension, set_diagnostics_extension, show_default_diagnostics_configuration, vmss_start, vmss_restart, vmss_delete_instances, vmss_deallocate, vmss_get_instance_view, vmss_stop, vmss_reimage, vmss_scale, vmss_update_instances, vmss_show, vmss_list) from ._factory import _compute_client_factory # pylint: disable=line-too-long # VM factory = lambda _: get_mgmt_service_client(VMClient).vm cli_command( 'vm create', VmOperations.create_or_update, factory, transform=DeploymentOutputLongRunningOperation('Starting vm create')) factory = lambda _: _compute_client_factory().virtual_machines cli_command('vm delete', VirtualMachinesOperations.delete, factory) cli_command('vm deallocate', VirtualMachinesOperations.deallocate, factory) cli_command('vm generalize', VirtualMachinesOperations.generalize, factory) cli_command( 'vm show', VirtualMachinesOperations.get, factory, simple_output_query= "{Name:name, ResourceGroup:resourceGroup, Location:location, VmSize:hardwareProfile.vmSize, OsType: storageProfile.osDisk.osType, Urn: join(':', [storageProfile.imageReference.publisher, storageProfile.imageReference.offer, storageProfile.imageReference.sku, storageProfile.imageReference.version])}" )
#--------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. #--------------------------------------------------------------------------------------------- from __future__ import print_function from azure.cli.commands import cli_command from .custom import (login, logout, list_location, list_subscriptions, set_active_subscription, account_clear, create_service_principal, reset_service_principal_credential) cli_command('login', login) cli_command('logout', logout) cli_command('account list', list_subscriptions) cli_command('account set', set_active_subscription) cli_command('account clear', account_clear) cli_command('account list-location', list_location) cli_command('account create-sp', create_service_principal) cli_command('account reset-sp-credentials', reset_service_principal_credential)