def remove_afd_rule_action(client: RulesOperations, resource_group_name, profile_name, rule_set_name, rule_name, index): existing_rule = client.get(resource_group_name, profile_name, rule_set_name, rule_name) if len(existing_rule.actions) > 1 and index < len(existing_rule.actions): existing_rule.actions.pop(index) else: logger.warning("Invalid condition index found. This command will be skipped. Please check the rule.") return client.create(resource_group_name, profile_name, rule_set_name, rule_name, rule=existing_rule)
def add_afd_rule_condition(client: RulesOperations, resource_group_name, profile_name, rule_set_name, rule_name, match_variable, operator, match_values=None, selector=None, negate_condition=None, transform=None): from .custom import create_condition existing_rule = client.get(resource_group_name, profile_name, rule_set_name, rule_name) condition = create_condition(match_variable, operator, match_values, selector, negate_condition, transform) existing_rule.conditions.append(condition) return client.create(resource_group_name, profile_name, rule_set_name, rule_name, rule=existing_rule)
def add_afd_rule_action(client: RulesOperations, resource_group_name, profile_name, rule_set_name, rule_name, action_name, cache_behavior=None, cache_duration=None, header_action=None, header_name=None, header_value=None, query_string_behavior=None, query_parameters=None, redirect_type=None, redirect_protocol=None, custom_hostname=None, custom_path=None, custom_querystring=None, custom_fragment=None, source_pattern=None, destination=None, preserve_unmatched_path=None): from .custom import create_action existing_rule = client.get(resource_group_name, profile_name, rule_set_name, rule_name) action = create_action(action_name, cache_behavior, cache_duration, header_action, header_name, header_value, query_string_behavior, query_parameters, redirect_type, redirect_protocol, custom_hostname, custom_path, custom_querystring, custom_fragment, source_pattern, destination, preserve_unmatched_path) existing_rule.actions.append(action) return client.create(resource_group_name, profile_name, rule_set_name, rule_name, rule=existing_rule)
def create_afd_rule(client: RulesOperations, resource_group_name, profile_name, rule_set_name, order, rule_name, action_name, match_variable=None, operator=None, match_values=None, selector=None, negate_condition=None, transform=None, cache_behavior=None, cache_duration=None, header_action=None, header_name=None, header_value=None, query_string_behavior=None, query_parameters=None, redirect_type=None, redirect_protocol=None, custom_hostname=None, custom_path=None, custom_querystring=None, custom_fragment=None, source_pattern=None, destination=None, preserve_unmatched_path=None, match_processing_behavior: MatchProcessingBehavior = None): from azure.mgmt.cdn.models import Rule from .custom import create_condition from .custom import create_action conditions = [] condition = create_condition(match_variable, operator, match_values, selector, negate_condition, transform) if condition is not None: conditions.append(condition) actions = [] action = create_action(action_name, cache_behavior, cache_duration, header_action, header_name, header_value, query_string_behavior, query_parameters, redirect_type, redirect_protocol, custom_hostname, custom_path, custom_querystring, custom_fragment, source_pattern, destination, preserve_unmatched_path) if action is not None: actions.append(action) rule = Rule( name=rule_name, order=order, conditions=conditions, actions=actions, match_processing_behavior=match_processing_behavior ) return client.create(resource_group_name, profile_name, rule_set_name, rule_name, rule=rule)
def list_afd_rule_action(client: RulesOperations, resource_group_name, profile_name, rule_set_name, rule_name): rule = client.get(resource_group_name, profile_name, rule_set_name, rule_name) return rule.actions
def add_afd_rule_action( cmd, client: RulesOperations, resource_group_name, profile_name, rule_set_name, rule_name, action_name, cache_behavior=None, cache_duration=None, header_action=None, header_name=None, header_value=None, query_parameters=None, redirect_type=None, redirect_protocol=None, custom_hostname=None, custom_path=None, custom_querystring=None, custom_fragment=None, source_pattern=None, destination=None, preserve_unmatched_path=None, origin_group=None, forwarding_protocol: ForwardingProtocol = None, query_string_caching_behavior: AfdQueryStringCachingBehavior = None, is_compression_enabled=None, enable_caching=None): from .custom import create_action existing_rule = client.get(resource_group_name, profile_name, rule_set_name, rule_name) action = create_action( action_name, cache_behavior, cache_duration, header_action, header_name, header_value, None, None if query_parameters is None else ",".join(query_parameters), redirect_type, redirect_protocol, custom_hostname, custom_path, custom_querystring, custom_fragment, source_pattern, destination, preserve_unmatched_path, cmd=cmd, resource_group_name=resource_group_name, forwarding_protocol=forwarding_protocol, origin_group=origin_group, profile_name=profile_name, query_string_caching_behavior=query_string_caching_behavior, is_compression_enabled=is_compression_enabled, enable_caching=enable_caching) existing_rule.actions.append(action) return client.begin_create(resource_group_name, profile_name, rule_set_name, rule_name, rule=existing_rule)
def create_afd_rule(cmd, client: RulesOperations, resource_group_name, profile_name, rule_set_name, order, rule_name, action_name, match_variable=None, operator=None, match_values=None, selector=None, negate_condition=None, transforms=None, cache_behavior=None, cache_duration=None, header_action=None, header_name=None, header_value=None, query_parameters=None, redirect_type=None, redirect_protocol=None, custom_hostname=None, custom_path=None, custom_querystring=None, custom_fragment=None, source_pattern=None, destination=None, preserve_unmatched_path=None, origin_group=None, enable_caching=None, is_compression_enabled=None, query_string_caching_behavior=None, match_processing_behavior: MatchProcessingBehavior = None, forwarding_protocol: ForwardingProtocol = None): from azure.mgmt.cdn.models import Rule from .custom import create_condition from .custom import create_action conditions = [] condition = create_condition(match_variable, operator, match_values, selector, negate_condition, transforms) if condition is not None: conditions.append(condition) actions = [] action = create_action( action_name, cache_behavior, cache_duration, header_action, header_name, header_value, None, None if query_parameters is None else ",".join(query_parameters), redirect_type, redirect_protocol, custom_hostname, custom_path, custom_querystring, custom_fragment, source_pattern, destination, preserve_unmatched_path, origin_group=origin_group, cmd=cmd, enable_caching=enable_caching, resource_group_name=resource_group_name, profile_name=profile_name, is_compression_enabled=is_compression_enabled, query_string_caching_behavior=query_string_caching_behavior, forwarding_protocol=forwarding_protocol) if action is not None: actions.append(action) rule = Rule(name=rule_name, order=order, conditions=conditions, actions=actions, match_processing_behavior=match_processing_behavior) return client.begin_create(resource_group_name, profile_name, rule_set_name, rule_name, rule=rule)