def update_metric_rule(instance, target=None, condition=None, description=None, enabled=None, metric=None, operator=None, threshold=None, aggregation=None, period=None, tags=None, email_service_owners=None, add_actions=None, remove_actions=None):
    if (description is not None):
        instance.description = description
    if (enabled is not None):
        instance.is_enabled = enabled
    if (tags is not None):
        instance.tags = tags
    if (condition is not None):
        target = (target or instance.condition.data_source.resource_uri)
        instance.condition = condition
    if (metric is not None):
        instance.condition.data_source.metric_name = metric
    if (operator is not None):
        instance.condition.operator = get_operator_map()[operator]
    if (threshold is not None):
        instance.condition.threshold = threshold
    if (aggregation is not None):
        instance.condition.time_aggregation = get_aggregation_map()[aggregation]
    if (period is not None):
        instance.condition.window_size = period
    if (target is not None):
        instance.condition.data_source.resource_uri = target
    (emails, webhooks, curr_email_service_owners) = _parse_actions(instance.actions)
    if (remove_actions is not None):
        (removed_emails, removed_webhooks) = _parse_action_removals(remove_actions)
        emails = [x for x in emails if (x not in removed_emails)]
        webhooks = [x for x in webhooks if (x.service_uri not in removed_webhooks)]
    if (add_actions is not None):
        (added_emails, added_webhooks, _) = _parse_actions(add_actions)
        emails = list((set(emails) | set(added_emails)))
        webhooks = (webhooks + added_webhooks)
    from azure.mgmt.monitor.models import RuleEmailAction
    if (email_service_owners is None):
        email_service_owners = curr_email_service_owners
    actions = ([RuleEmailAction(send_to_service_owners=email_service_owners, custom_emails=emails)] + webhooks)
    instance.actions = actions
    return instance
def update_metric_rule(instance, target=None, condition=None, description=None, enabled=None, metric=None, operator=None, threshold=None, aggregation=None, period=None, tags=None, email_service_owners=None, add_actions=None, remove_actions=None):
    if (description is not None):
        instance.description = description
    if (enabled is not None):
        instance.is_enabled = enabled
    if (tags is not None):
        instance.tags = tags
    if (condition is not None):
        target = (target or instance.condition.data_source.resource_uri)
        instance.condition = condition
    if (metric is not None):
        instance.condition.data_source.metric_name = metric
    if (operator is not None):
        instance.condition.operator = get_operator_map()[operator]
    if (threshold is not None):
        instance.condition.threshold = threshold
    if (aggregation is not None):
        instance.condition.time_aggregation = get_aggregation_map()[aggregation]
    if (period is not None):
        instance.condition.window_size = period
    if (target is not None):
        instance.condition.data_source.resource_uri = target
    (emails, webhooks, curr_email_service_owners) = _parse_actions(instance.actions)
    if (remove_actions is not None):
        (removed_emails, removed_webhooks) = _parse_action_removals(remove_actions)
        emails = [x for x in emails if (x not in removed_emails)]
        webhooks = [x for x in webhooks if (x.service_uri not in removed_webhooks)]
    if (add_actions is not None):
        (added_emails, added_webhooks, _) = _parse_actions(add_actions)
        emails = list((set(emails) | set(added_emails)))
        webhooks = (webhooks + added_webhooks)
    from azure.mgmt.monitor.models import RuleEmailAction
    if (email_service_owners is None):
        email_service_owners = curr_email_service_owners
    actions = ([RuleEmailAction(send_to_service_owners=email_service_owners, custom_emails=emails)] + webhooks)
    instance.actions = actions
    return instance