1# -------------------------------------------------------------------------------------------- 2# Copyright (c) Microsoft Corporation. All rights reserved. 3# Licensed under the MIT License. See License.txt in the project root for license information. 4# -------------------------------------------------------------------------------------------- 5 6 7# ISO format with explicit indication of timezone 8DATE_TIME_FORMAT = '%Y-%m-%dT%H:%M:%SZ' 9 10 11def get_resource_group_location(cli_ctx, name): 12 from azure.cli.core.commands.client_factory import get_mgmt_service_client 13 from azure.cli.core.profiles import ResourceType 14 15 # pylint: disable=no-member 16 return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES).resource_groups.get(name).location 17 18 19def get_operator_map(): 20 from azure.mgmt.monitor.models import ConditionOperator 21 return {'>': ConditionOperator.greater_than, '>=': ConditionOperator.greater_than_or_equal, 22 '<': ConditionOperator.less_than, '<=': ConditionOperator.less_than_or_equal} 23 24 25def get_aggregation_map(): 26 from azure.mgmt.monitor.models import TimeAggregationOperator 27 return {'avg': TimeAggregationOperator.average, 'min': TimeAggregationOperator.minimum, 28 'max': TimeAggregationOperator.maximum, 'total': TimeAggregationOperator.total, 29 'last': TimeAggregationOperator.last} 30 31 32# region Autoscale Maps 33def get_autoscale_statistic_map(): 34 from azure.mgmt.monitor.models import MetricStatisticType 35 return {'avg': MetricStatisticType.average, 'min': MetricStatisticType.min, 36 'max': MetricStatisticType.max, 'sum': MetricStatisticType.sum} 37 38 39def get_autoscale_operator_map(): 40 from azure.mgmt.monitor.models import ComparisonOperationType 41 return {'==': ComparisonOperationType.equals, '!=': ComparisonOperationType.not_equals, 42 '>': ComparisonOperationType.greater_than, '>=': ComparisonOperationType.greater_than_or_equal, 43 '<': ComparisonOperationType.less_than, '<=': ComparisonOperationType.less_than_or_equal} 44 45 46def get_autoscale_aggregation_map(): 47 from azure.mgmt.monitor.models import TimeAggregationType 48 return {'avg': TimeAggregationType.average, 'min': TimeAggregationType.minimum, 49 'max': TimeAggregationType.maximum, 'total': TimeAggregationType.total, 50 'count': TimeAggregationType.count} 51 52 53def get_autoscale_scale_direction_map(): 54 from azure.mgmt.monitor.models import ScaleDirection 55 return {'to': ScaleDirection.none, 'out': ScaleDirection.increase, 56 'in': ScaleDirection.decrease} 57 58 59def gen_guid(): 60 import uuid 61 return uuid.uuid4() 62# endregion 63