get_sql_database_usages_operations, get_sql_elastic_pools_operations, get_sql_encryption_protectors_operations, get_sql_firewall_rules_operations, get_sql_replication_links_operations, get_sql_restorable_dropped_databases_operations, get_sql_server_keys_operations, get_sql_servers_operations, get_sql_server_usages_operations, get_sql_virtual_network_rules_operations) if not supported_api_version(PROFILE_TYPE, max_api='2017-03-09-profile'): custom_path = 'azure.cli.command_modules.sql.custom#{}' ############################################### # sql capabilities # ############################################### capabilities_operations = create_service_adapter( 'azure.mgmt.sql.operations.capabilities_operations', 'CapabilitiesOperations') with ServiceGroup(__name__, get_sql_capabilities_operations, capabilities_operations, custom_path) as s: with s.group('sql db') as c: c.custom_command('list-editions', 'db_list_capabilities') with s.group('sql elastic-pool') as c: c.custom_command('list-editions', 'elastic_pool_list_capabilities') ############################################### # sql db # ############################################### database_operations = create_service_adapter(
def load_commands_from_factory(server_type, command_group_name, management_client): # server server_sa = create_service_adapter( 'azure.mgmt.rdbms.{}.operations.servers_operations'.format( server_type), 'ServersOperations') def server_factory(args): return management_client(args).servers with ServiceGroup(__name__, server_factory, server_sa, custom_path) as s: with s.group('{} server'.format(command_group_name)) as c: c.command('create', 'create_or_update') c.custom_command('restore', '_server_restore') c.command('delete', 'delete', confirmation=True) c.command('show', 'get') c.custom_command('list', '_server_list_custom_func') c.generic_update_command( 'update', 'get', 'update', custom_func_name='_server_update_custom_func') # firewall rule firewall_rule_sa = create_service_adapter( 'azure.mgmt.rdbms.{}.operations.firewall_rules_operations'.format( server_type), 'FirewallRulesOperations') def firewall_rule_factory(args): return management_client(args).firewall_rules with ServiceGroup(__name__, firewall_rule_factory, firewall_rule_sa, custom_path) as s: with s.group( '{} server firewall-rule'.format(command_group_name)) as c: c.command('create', 'create_or_update') c.command('delete', 'delete', confirmation=True) c.command('show', 'get') c.command('list', 'list_by_server') cli_generic_update_command( __name__, '{} server firewall-rule update'.format(command_group_name), firewall_rule_sa('get'), custom_path.format('_firewall_rule_custom_setter'), firewall_rule_factory, custom_function_op=custom_path.format( '_firewall_rule_update_custom_func')) # configuration configuration_sa = create_service_adapter( 'azure.mgmt.rdbms.{}.operations.configurations_operations'.format( server_type), 'ConfigurationsOperations') def configuration_factory(args): return management_client(args).configurations with ServiceGroup(__name__, configuration_factory, configuration_sa) as s: with s.group( '{} server configuration'.format(command_group_name)) as c: c.command('set', 'create_or_update') c.command('show', 'get') c.command('list', 'list_by_server') # log_files log_file_sa = create_service_adapter( 'azure.mgmt.rdbms.{}.operations.log_files_operations'.format( server_type), 'LogFilesOperations') def log_file_factory(args): return management_client(args).log_files with ServiceGroup(__name__, log_file_factory, log_file_sa, custom_path) as s: with s.group('{} server-logs'.format(command_group_name)) as c: c.custom_command('list', '_list_log_files_with_filter') c.custom_command('download', '_download_log_files') # database database_sa = create_service_adapter( 'azure.mgmt.rdbms.{}.operations.databases_operations'.format( server_type), 'DatabasesOperations') def database_factory(args): return management_client(args).databases with ServiceGroup(__name__, database_factory, database_sa) as s: with s.group('{} db'.format(command_group_name)) as c: # c.command('create', 'create_or_update') # c.command('delete', 'delete', confirmation=True) # c.command('show', 'get') c.command('list', 'list_by_server')
ServiceGroup) from ._util import ( get_sql_servers_operations, get_sql_firewall_rules_operations, get_sql_databases_operations, get_sql_elastic_pools_operations, get_sql_capabilities_operations) custom_path = 'azure.cli.command_modules.sql.custom#{}' ############################################### # sql capabilities # ############################################### capabilities_operations = create_service_adapter( 'azure.mgmt.sql.operations.capabilities_operations', 'CapabilitiesOperations') with ServiceGroup(__name__, get_sql_capabilities_operations, capabilities_operations, custom_path) as s: with s.group('sql db') as c: c.custom_command('list-editions', 'db_list_capabilities') with s.group('sql elastic-pool') as c: c.custom_command('list-editions', 'elastic_pool_list_capabilities') ############################################### # sql db # ############################################### database_operations = create_service_adapter('azure.mgmt.sql.operations.databases_operations',
monitor_command(__name__, 'monitor autoscale-settings show', autoscale_path + 'get', cf_autoscale) monitor_command(__name__, 'monitor autoscale-settings list', autoscale_path + 'list_by_resource_group', cf_autoscale) monitor_command(__name__, 'monitor autoscale-settings get-parameters-template', custom_path + 'scaffold_autoscale_settings_parameters', cf_autoscale) cli_generic_update_command(__name__, 'monitor autoscale-settings update', autoscale_path + 'get', autoscale_path + 'create_or_update', cf_autoscale, exception_handler=monitor_exception_handler) # endregion # region Activity Log monitor_command(__name__, 'monitor activity-log list', custom_path + 'list_activity_log', cf_activity_log) # endregion action_group_operations = create_service_adapter( 'azure.mgmt.monitor.operations.action_groups_operations', 'ActionGroupsOperations') ag_custom_path = '.'.join(__name__.split('.')[:-1] + ['action_groups']) + '#{}' with ServiceGroup(__name__, cf_action_groups, action_group_operations, ag_custom_path) as s: with s.group('monitor action-group') as c: c.command('show', 'get', table_transformer=action_group_list_table) c.command('create', 'create_or_update', table_transformer=action_group_list_table) c.command('delete', 'delete') c.command('enable-receiver', 'enable_receiver', table_transformer=action_group_list_table) c.custom_command('list', 'list_action_groups', table_transformer=action_group_list_table) c.generic_update_command('update', 'get', 'create_or_update', 'update_action_groups', setter_arg_name='action_group', table_transformer=action_group_list_table, exception_handler=monitor_exception_handler) activity_log_alerts_operations = create_service_adapter(
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from ._client_factory import (get_monitor_alert_rules_operation, get_monitor_alert_rule_incidents_operation, get_monitor_log_profiles_operation, get_monitor_autoscale_settings_operation, get_monitor_diagnostic_settings_operation, get_monitor_activity_log_operation, get_monitor_metric_definitions_operation, get_monitor_metrics_operation) from azure.cli.core.sdk.util import (ServiceGroup, create_service_adapter) # MANAGEMENT COMMANDS custom_operations = create_service_adapter( 'azure.cli.command_modules.monitor.custom') alert_rules_operations = create_service_adapter( 'azure.mgmt.monitor.operations.alert_rules_operations', 'AlertRulesOperations') with ServiceGroup(__name__, get_monitor_alert_rules_operation, alert_rules_operations) as s: with s.group('monitor alert-rules') as c: c.command('create', 'create_or_update') c.command('delete', 'delete') c.command('show', 'get') c.command('list', 'list_by_resource_group') c.generic_update_command('update', 'get', 'create_or_update') alert_rule_incidents_operations = create_service_adapter(
and ex.response.status_code == 404: raise CLIError(message) raise ex return _inner_not_found not_found_msg = "{}(s) not found. Please verify the resource(s), group or it's parent resources " \ "exist." profile_not_found_msg = not_found_msg.format('Profile') endpoint_not_found_msg = not_found_msg.format('Endpoint') cd_not_found_msg = not_found_msg.format('Custom Domain') origin_not_found_msg = not_found_msg.format('Origin') custom_operations = 'azure.cli.command_modules.cdn.custom#{}' mgmt_operations = create_service_adapter('azure.mgmt.cdn', 'CdnManagementClient') with ServiceGroup(__name__, cf_cdn, mgmt_operations, custom_operations) as s: with s.group('cdn') as c: c.command('name-exists', 'check_name_availability') c.command('usage', 'check_resource_usage') endpoint_operations = create_service_adapter('azure.mgmt.cdn.operations.endpoints_operations', 'EndpointsOperations') with ServiceGroup(__name__, cf_cdn, endpoint_operations, custom_operations, exception_handler=_not_found(endpoint_not_found_msg)) as s: with s.group('cdn endpoint') as c: for name in ['start', 'stop', 'delete']: c.command(name, name) c.command('show', 'get') c.command('list', 'list_by_profile') c.command('load', 'load_content')
def service_adapter(module_name, class_name): return create_service_adapter( 'azure.mgmt.monitor.operations.{}'.format(module_name), class_name)
get_sql_database_blob_auditing_policies_operations, get_sql_database_threat_detection_policies_operations, get_sql_database_usages_operations, get_sql_elastic_pools_operations, get_sql_firewall_rules_operations, get_sql_replication_links_operations, get_sql_servers_operations, get_sql_server_usages_operations, get_sql_virtual_network_rules_operations) if not supported_api_version(PROFILE_TYPE, max_api='2017-03-09-profile'): custom_path = 'azure.cli.command_modules.sql.custom#{}' ############################################### # sql capabilities # ############################################### capabilities_operations = create_service_adapter( 'azure.mgmt.sql.operations.capabilities_operations', 'CapabilitiesOperations') with ServiceGroup(__name__, get_sql_capabilities_operations, capabilities_operations, custom_path) as s: with s.group('sql db') as c: c.custom_command('list-editions', 'db_list_capabilities') with s.group('sql elastic-pool') as c: c.custom_command('list-editions', 'elastic_pool_list_capabilities') ############################################### # sql db # ############################################### database_operations = create_service_adapter(
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.core.sdk.util import ServiceGroup, create_service_adapter from ._client_factory import cf_cdn custom_operations = 'azure.cli.command_modules.cdn.custom#{}' mgmt_operations = create_service_adapter('azure.mgmt.cdn', 'CdnManagementClient') with ServiceGroup(__name__, cf_cdn, mgmt_operations, custom_operations) as s: with s.group('cdn') as c: c.command('name-exists', 'check_name_availability') c.command('usage', 'check_resource_usage') endpoint_operations = create_service_adapter( 'azure.mgmt.cdn.operations.endpoints_operations', 'EndpointsOperations') with ServiceGroup(__name__, cf_cdn, endpoint_operations, custom_operations) as s: with s.group('cdn endpoint') as c: for name in ['start', 'stop', 'delete']: c.command(name, name) c.command('show', 'get') c.command('list', 'list_by_profile') c.command('load', 'load_content') c.command('purge', 'purge_content') c.command('validate-custom-domain', 'validate_custom_domain') c.custom_command('create', 'create_endpoint') c.generic_update_command('update',
""" Exports artifacts from the given formula. This method removes some of the properties of the artifact model as they do not play important part for users in create or read context. """ artifacts = [] if formula and formula.formula_content and formula.formula_content.artifacts: artifacts = formula.formula_content.artifacts for artifact in formula.formula_content.artifacts: del artifact.status del artifact.deployment_status_message del artifact.vm_extension_status_message del artifact.install_time return artifacts # Custom Command's service adapter custom_operations = create_service_adapter(custom_path) # Virtual Machine Operations Commands virtual_machine_operations = create_service_adapter( mgmt_operations_path.format('virtual_machine_operations'), 'VirtualMachineOperations') with ServiceGroup(__name__, get_devtestlabs_virtual_machine_operation, virtual_machine_operations) as s: with s.group('lab vm') as c: c.command('show', 'get_resource') c.command('list', 'list') c.command('delete', 'delete_resource') c.command('start', 'start') c.command('stop', 'stop') c.command('apply-artifacts', 'apply_artifacts')
# Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from ._util import (get_sql_servers_operations, get_sql_firewall_rules_operations, get_sql_databases_operations, get_sql_elastic_pools_operations) from azure.cli.core.sdk.util import (create_service_adapter, ServiceGroup) custom_path = 'azure.cli.command_modules.sql.custom#{}' ############################################### # sql db # ############################################### database_operations = create_service_adapter( 'azure.mgmt.sql.operations.databases_operations', 'DatabasesOperations') with ServiceGroup(__name__, get_sql_databases_operations, database_operations, custom_path) as s: with s.group('sql db') as c: c.custom_command('create', 'db_create') c.custom_command('copy', 'db_copy') c.custom_command('restore', 'db_restore') c.command('show', 'get') c.custom_command('list', 'db_list') # # Usages will not be included in the first batch of GA commands # c.command('show-usage', 'list_usages') c.command('delete', 'delete', confirmation=True) c.generic_update_command('update', 'get', 'create_or_update',
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.command_modules.sf._factory import cf_sf_client from azure.cli.core.profiles import supported_api_version, PROFILE_TYPE from azure.cli.core.sdk.util import ( create_service_adapter, ServiceGroup ) DEPRECATE_SFCTL_STRING = "az sf sfctl" if not supported_api_version(PROFILE_TYPE, max_api='2017-03-09-profile'): custom_path = "azure.cli.command_modules.sf.custom#{}" cluster_operations = create_service_adapter("azure.servicefabric", "ServiceFabricClientAPIs") # No client commands with ServiceGroup(__name__, None, None, custom_path) as sg: with sg.group("sf cluster") as g: g.custom_command("select", "sf_select", deprecate_info=DEPRECATE_SFCTL_STRING) with sg.group("sf application") as g: g.custom_command("upload", "sf_upload_app", deprecate_info=DEPRECATE_SFCTL_STRING) with sg.group("sf") as g: # Command for more information on sfctl g.custom_command("sfctl", "sfctl_info") # Standard commands with ServiceGroup(__name__, cf_sf_client, cluster_operations, custom_path) as sg: # Cluster level commands
def load_commands_from_factory(server_type, command_group_name, management_client): # server server_sa = create_service_adapter( 'azure.mgmt.rdbms.{}.operations.servers_operations'.format(server_type), 'ServersOperations') def server_factory(args): return management_client(args).servers with ServiceGroup(__name__, server_factory, server_sa, custom_path) as s: with s.group('{} server'.format(command_group_name)) as c: c.command('create', 'create_or_update') c.custom_command('restore', '_server_restore') c.command('delete', 'delete', confirmation=True) c.command('show', 'get') c.custom_command('list', '_server_list_custom_func') c.generic_update_command('update', 'get', 'update', custom_func_name='_server_update_custom_func') # firewall rule firewall_rule_sa = create_service_adapter( 'azure.mgmt.rdbms.{}.operations.firewall_rules_operations'.format(server_type), 'FirewallRulesOperations') def firewall_rule_factory(args): return management_client(args).firewall_rules with ServiceGroup(__name__, firewall_rule_factory, firewall_rule_sa, custom_path) as s: with s.group('{} server firewall-rule'.format(command_group_name)) as c: c.command('create', 'create_or_update') c.command('delete', 'delete', confirmation=True) c.command('show', 'get') c.command('list', 'list_by_server') cli_generic_update_command(__name__, '{} server firewall-rule update'.format(command_group_name), firewall_rule_sa('get'), custom_path.format('_firewall_rule_custom_setter'), firewall_rule_factory, custom_function_op=custom_path.format('_firewall_rule_update_custom_func')) # configuration configuration_sa = create_service_adapter( 'azure.mgmt.rdbms.{}.operations.configurations_operations'.format(server_type), 'ConfigurationsOperations') def configuration_factory(args): return management_client(args).configurations with ServiceGroup(__name__, configuration_factory, configuration_sa) as s: with s.group('{} server configuration'.format(command_group_name)) as c: c.command('set', 'create_or_update') c.command('show', 'get') c.command('list', 'list_by_server') # log_files log_file_sa = create_service_adapter( 'azure.mgmt.rdbms.{}.operations.log_files_operations'.format(server_type), 'LogFilesOperations') def log_file_factory(args): return management_client(args).log_files with ServiceGroup(__name__, log_file_factory, log_file_sa, custom_path) as s: with s.group('{} server-logs'.format(command_group_name)) as c: c.custom_command('list', '_list_log_files_with_filter') c.custom_command('download', '_download_log_files') # database database_sa = create_service_adapter( 'azure.mgmt.rdbms.{}.operations.databases_operations'.format(server_type), 'DatabasesOperations') def database_factory(args): return management_client(args).databases with ServiceGroup(__name__, database_factory, database_sa) as s: with s.group('{} db'.format(command_group_name)) as c: # c.command('create', 'create_or_update') # c.command('delete', 'delete', confirmation=True) # c.command('show', 'get') c.command('list', 'list_by_server')
def transform_arm_template(result): return OrderedDict([('name', result['name']), ('resourceGroup', result['resourceGroup']), ('publisher', result.get('publisher'))]) def transform_vm_list(vm_list): return [transform_vm(v) for v in vm_list] def transform_vm(result): return OrderedDict([('name', result['name']), ('location', result['location']), ('osType', result['osType'])]) # Custom Command's service adapter custom_operations = create_service_adapter(custom_path) # Virtual Machine Operations Commands virtual_machine_operations = create_service_adapter( mgmt_operations_path.format('virtual_machines_operations'), 'VirtualMachinesOperations') with ServiceGroup(__name__, get_devtestlabs_virtual_machine_operation, virtual_machine_operations) as s: with s.group('lab vm') as c: c.command('show', 'get', table_transformer=transform_vm) c.command('delete', 'delete') c.command('start', 'start') c.command('stop', 'stop') c.command('apply-artifacts', 'apply_artifacts')
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from azure.cli.command_modules.sf._factory import cf_sf_client from azure.cli.core.profiles import supported_api_version, PROFILE_TYPE from azure.cli.core.sdk.util import (create_service_adapter, ServiceGroup) if not supported_api_version(PROFILE_TYPE, max_api='2017-03-09-profile'): custom_path = "azure.cli.command_modules.sf.custom#{}" cluster_operations = create_service_adapter("azure.servicefabric", "ServiceFabricClientAPIs") # No client commands with ServiceGroup(__name__, None, None, custom_path) as sg: with sg.group("sf cluster") as g: g.custom_command("select", "sf_select") with sg.group("sf application") as g: g.custom_command("upload", "sf_upload_app") # Standard commands with ServiceGroup(__name__, cf_sf_client, cluster_operations, custom_path) as sg: # Cluster level commands with sg.group("sf cluster") as cl_group: cl_group.command("manifest", "get_cluster_manifest") cl_group.command("code-version", "get_provisioned_fabric_code_version_info_list") cl_group.command( "config-version", "get_provisioned_fabric_config_version_info_list")
autoscale_path + 'get', autoscale_path + 'create_or_update', cf_autoscale, exception_handler=monitor_exception_handler) # endregion # region Activity Log monitor_command(__name__, 'monitor activity-log list', custom_path + 'list_activity_log', cf_activity_log) # endregion action_group_operations = create_service_adapter( 'azure.mgmt.monitor.operations.action_groups_operations', 'ActionGroupsOperations') ag_custom_path = '.'.join(__name__.split('.')[:-1] + ['action_groups']) + '#{}' with ServiceGroup(__name__, cf_action_groups, action_group_operations, ag_custom_path) as s: with s.group('monitor action-group') as c: c.command('show', 'get', table_transformer=action_group_list_table) c.command('create', 'create_or_update', table_transformer=action_group_list_table) c.command('delete', 'delete') c.command('enable-receiver', 'enable_receiver', table_transformer=action_group_list_table)
from ._util import (get_sql_servers_operations, get_sql_firewall_rules_operations, get_sql_databases_operations, get_sql_elastic_pools_operations, get_sql_server_azure_ad_administrators_operations, get_sql_capabilities_operations) if not supported_api_version(PROFILE_TYPE, max_api='2017-03-09-profile'): custom_path = 'azure.cli.command_modules.sql.custom#{}' ############################################### # sql capabilities # ############################################### capabilities_operations = create_service_adapter( 'azure.mgmt.sql.operations.capabilities_operations', 'CapabilitiesOperations') with ServiceGroup(__name__, get_sql_capabilities_operations, capabilities_operations, custom_path) as s: with s.group('sql db') as c: c.custom_command('list-editions', 'db_list_capabilities') with s.group('sql elastic-pool') as c: c.custom_command('list-editions', 'elastic_pool_list_capabilities') ############################################### # sql db # ############################################### database_operations = create_service_adapter(
get_sql_restorable_dropped_databases_operations, get_sql_server_keys_operations, get_sql_servers_operations, get_sql_server_usages_operations, get_sql_virtual_network_rules_operations ) if not supported_api_version(PROFILE_TYPE, max_api='2017-03-09-profile'): custom_path = 'azure.cli.command_modules.sql.custom#{}' ############################################### # sql capabilities # ############################################### capabilities_operations = create_service_adapter( 'azure.mgmt.sql.operations.capabilities_operations', 'CapabilitiesOperations') with ServiceGroup(__name__, get_sql_capabilities_operations, capabilities_operations, custom_path) as s: with s.group('sql db') as c: c.custom_command('list-editions', 'db_list_capabilities') with s.group('sql elastic-pool') as c: c.custom_command('list-editions', 'elastic_pool_list_capabilities') ############################################### # sql db # ############################################### database_operations = create_service_adapter('azure.mgmt.sql.operations.databases_operations', 'DatabasesOperations')
# Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- from ._client_factory import (get_monitor_alert_rules_operation, get_monitor_alert_rule_incidents_operation, get_monitor_log_profiles_operation, get_monitor_autoscale_settings_operation, get_monitor_diagnostic_settings_operation, get_monitor_activity_log_operation, get_monitor_metric_definitions_operation, get_monitor_metrics_operation) from azure.cli.core.sdk.util import (ServiceGroup, create_service_adapter) # MANAGEMENT COMMANDS custom_operations = create_service_adapter('azure.cli.command_modules.monitor.custom') alert_rules_operations = create_service_adapter( 'azure.mgmt.monitor.operations.alert_rules_operations', 'AlertRulesOperations') with ServiceGroup(__name__, get_monitor_alert_rules_operation, alert_rules_operations) as s: with s.group('monitor alert-rules') as c: c.command('create', 'create_or_update') c.command('delete', 'delete') c.command('show', 'get') c.command('list', 'list_by_resource_group') c.generic_update_command('update', 'get', 'create_or_update') alert_rule_incidents_operations = create_service_adapter( 'azure.mgmt.monitor.operations.alert_rule_incidents_operations',