# Magic Network Monitoring # VPC Flows # Tokens ## Generate authentication token for VPC flow logs export. `magic_network_monitoring.vpc_flows.tokens.create(TokenCreateParams**kwargs) -> TokenCreateResponse` **post** `/accounts/{account_id}/mnm/vpc-flows/token` Generate authentication token for VPC flow logs export. ### Parameters - `account_id: str` ### Returns - `str` Authentication token to be used for VPC Flows export authentication. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) token = client.magic_network_monitoring.vpc_flows.tokens.create( account_id="6f91088a406011ed95aed352566e8d4c", ) print(token) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": "JWE/JWT auth token", "success": true } ``` ## Domain Types ### Token Create Response - `str` Authentication token to be used for VPC Flows export authentication. # Configs ## List account configuration `magic_network_monitoring.configs.get(ConfigGetParams**kwargs) -> Configuration` **get** `/accounts/{account_id}/mnm/config` Lists default sampling, router IPs and warp devices for account. ### Parameters - `account_id: str` ### Returns - `class Configuration: …` - `default_sampling: float` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `name: str` The account name. - `router_ips: List[str]` - `warp_devices: List[WARPDevice]` - `id: str` Unique identifier for the warp device. - `name: str` Name of the warp device. - `router_ip: str` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) configuration = client.magic_network_monitoring.configs.get( account_id="6f91088a406011ed95aed352566e8d4c", ) print(configuration.default_sampling) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "default_sampling": 1, "name": "cloudflare user's account", "router_ips": [ "203.0.113.1" ], "warp_devices": [ { "id": "5360368d-b351-4791-abe1-93550dabd351", "name": "My warp device", "router_ip": "203.0.113.1" } ] }, "success": true } ``` ## Create account configuration `magic_network_monitoring.configs.create(ConfigCreateParams**kwargs) -> Configuration` **post** `/accounts/{account_id}/mnm/config` Create a new network monitoring configuration. ### Parameters - `account_id: str` - `default_sampling: float` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `name: str` The account name. - `router_ips: Optional[SequenceNotStr[str]]` - `warp_devices: Optional[Iterable[WARPDevice]]` - `id: str` Unique identifier for the warp device. - `name: str` Name of the warp device. - `router_ip: str` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Returns - `class Configuration: …` - `default_sampling: float` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `name: str` The account name. - `router_ips: List[str]` - `warp_devices: List[WARPDevice]` - `id: str` Unique identifier for the warp device. - `name: str` Name of the warp device. - `router_ip: str` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) configuration = client.magic_network_monitoring.configs.create( account_id="6f91088a406011ed95aed352566e8d4c", default_sampling=1, name="cloudflare user's account", ) print(configuration.default_sampling) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "default_sampling": 1, "name": "cloudflare user's account", "router_ips": [ "203.0.113.1" ], "warp_devices": [ { "id": "5360368d-b351-4791-abe1-93550dabd351", "name": "My warp device", "router_ip": "203.0.113.1" } ] }, "success": true } ``` ## Update an entire account configuration `magic_network_monitoring.configs.update(ConfigUpdateParams**kwargs) -> Configuration` **put** `/accounts/{account_id}/mnm/config` Update an existing network monitoring configuration, requires the entire configuration to be updated at once. ### Parameters - `account_id: str` - `default_sampling: float` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `name: str` The account name. - `router_ips: Optional[SequenceNotStr[str]]` - `warp_devices: Optional[Iterable[WARPDevice]]` - `id: str` Unique identifier for the warp device. - `name: str` Name of the warp device. - `router_ip: str` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Returns - `class Configuration: …` - `default_sampling: float` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `name: str` The account name. - `router_ips: List[str]` - `warp_devices: List[WARPDevice]` - `id: str` Unique identifier for the warp device. - `name: str` Name of the warp device. - `router_ip: str` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) configuration = client.magic_network_monitoring.configs.update( account_id="6f91088a406011ed95aed352566e8d4c", default_sampling=1, name="cloudflare user's account", ) print(configuration.default_sampling) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "default_sampling": 1, "name": "cloudflare user's account", "router_ips": [ "203.0.113.1" ], "warp_devices": [ { "id": "5360368d-b351-4791-abe1-93550dabd351", "name": "My warp device", "router_ip": "203.0.113.1" } ] }, "success": true } ``` ## Update account configuration fields `magic_network_monitoring.configs.edit(ConfigEditParams**kwargs) -> Configuration` **patch** `/accounts/{account_id}/mnm/config` Update fields in an existing network monitoring configuration. ### Parameters - `account_id: str` - `default_sampling: Optional[float]` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `name: Optional[str]` The account name. - `router_ips: Optional[SequenceNotStr[str]]` - `warp_devices: Optional[Iterable[WARPDevice]]` - `id: str` Unique identifier for the warp device. - `name: str` Name of the warp device. - `router_ip: str` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Returns - `class Configuration: …` - `default_sampling: float` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `name: str` The account name. - `router_ips: List[str]` - `warp_devices: List[WARPDevice]` - `id: str` Unique identifier for the warp device. - `name: str` Name of the warp device. - `router_ip: str` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) configuration = client.magic_network_monitoring.configs.edit( account_id="6f91088a406011ed95aed352566e8d4c", ) print(configuration.default_sampling) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "default_sampling": 1, "name": "cloudflare user's account", "router_ips": [ "203.0.113.1" ], "warp_devices": [ { "id": "5360368d-b351-4791-abe1-93550dabd351", "name": "My warp device", "router_ip": "203.0.113.1" } ] }, "success": true } ``` ## Delete account configuration `magic_network_monitoring.configs.delete(ConfigDeleteParams**kwargs) -> Configuration` **delete** `/accounts/{account_id}/mnm/config` Delete an existing network monitoring configuration. ### Parameters - `account_id: str` ### Returns - `class Configuration: …` - `default_sampling: float` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `name: str` The account name. - `router_ips: List[str]` - `warp_devices: List[WARPDevice]` - `id: str` Unique identifier for the warp device. - `name: str` Name of the warp device. - `router_ip: str` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) configuration = client.magic_network_monitoring.configs.delete( account_id="6f91088a406011ed95aed352566e8d4c", ) print(configuration.default_sampling) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "default_sampling": 1, "name": "cloudflare user's account", "router_ips": [ "203.0.113.1" ], "warp_devices": [ { "id": "5360368d-b351-4791-abe1-93550dabd351", "name": "My warp device", "router_ip": "203.0.113.1" } ] }, "success": true } ``` ## Domain Types ### Configuration - `class Configuration: …` - `default_sampling: float` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `name: str` The account name. - `router_ips: List[str]` - `warp_devices: List[WARPDevice]` - `id: str` Unique identifier for the warp device. - `name: str` Name of the warp device. - `router_ip: str` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. # Full ## List rules and account configuration `magic_network_monitoring.configs.full.get(FullGetParams**kwargs) -> Configuration` **get** `/accounts/{account_id}/mnm/config/full` Lists default sampling, router IPs, warp devices, and rules for account. ### Parameters - `account_id: str` ### Returns - `class Configuration: …` - `default_sampling: float` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `name: str` The account name. - `router_ips: List[str]` - `warp_devices: List[WARPDevice]` - `id: str` Unique identifier for the warp device. - `name: str` Name of the warp device. - `router_ip: str` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) configuration = client.magic_network_monitoring.configs.full.get( account_id="6f91088a406011ed95aed352566e8d4c", ) print(configuration.default_sampling) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "default_sampling": 1, "name": "cloudflare user's account", "router_ips": [ "203.0.113.1" ], "warp_devices": [ { "id": "5360368d-b351-4791-abe1-93550dabd351", "name": "My warp device", "router_ip": "203.0.113.1" } ] }, "success": true } ``` # Rules ## List rules `magic_network_monitoring.rules.list(RuleListParams**kwargs) -> SyncSinglePage[Optional[MagicNetworkMonitoringRule]]` **get** `/accounts/{account_id}/mnm/rules` Lists network monitoring rules for account. ### Parameters - `account_id: str` ### Returns - `class MagicNetworkMonitoringRule: …` - `automatic_advertisement: Optional[bool]` Toggle on if you would like Cloudflare to automatically advertise the IP Prefixes within the rule via Magic Transit when the rule is triggered. Only available for users of Magic Transit. - `name: str` The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (_), dash (-), period (.), and tilde (~). You can’t have a space in the rule name. Max 256 characters. - `prefixes: List[str]` - `type: Literal["threshold", "zscore", "advanced_ddos"]` MNM rule type. - `"threshold"` - `"zscore"` - `"advanced_ddos"` - `id: Optional[str]` The id of the rule. Must be unique. - `bandwidth_threshold: Optional[float]` The number of bits per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `duration: Optional[Literal["1m", "5m", "10m", 5 more]]` The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 values ["1m","5m","10m","15m","20m","30m","45m","60m"]. - `"1m"` - `"5m"` - `"10m"` - `"15m"` - `"20m"` - `"30m"` - `"45m"` - `"60m"` - `packet_threshold: Optional[float]` The number of packets per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `prefix_match: Optional[Literal["exact", "subnet", "supernet"]]` Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. - `"exact"` - `"subnet"` - `"supernet"` - `zscore_sensitivity: Optional[Literal["low", "medium", "high"]]` Level of sensitivity set for zscore rules. - `"low"` - `"medium"` - `"high"` - `zscore_target: Optional[Literal["bits", "packets"]]` Target of the zscore rule analysis. - `"bits"` - `"packets"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) page = client.magic_network_monitoring.rules.list( account_id="6f91088a406011ed95aed352566e8d4c", ) page = page.result[0] print(page.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": [ { "automatic_advertisement": true, "name": "my_rule_1", "prefixes": [ "203.0.113.1/32" ], "type": "zscore", "id": "2890e6fa406311ed9b5a23f70f6fb8cf", "bandwidth_threshold": 1000, "duration": "1m", "packet_threshold": 10000, "prefix_match": "exact", "zscore_sensitivity": "high", "zscore_target": "bits" } ], "success": true, "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Get rule `magic_network_monitoring.rules.get(strrule_id, RuleGetParams**kwargs) -> MagicNetworkMonitoringRule` **get** `/accounts/{account_id}/mnm/rules/{rule_id}` List a single network monitoring rule for account. ### Parameters - `account_id: str` - `rule_id: str` The id of the rule. Must be unique. ### Returns - `class MagicNetworkMonitoringRule: …` - `automatic_advertisement: Optional[bool]` Toggle on if you would like Cloudflare to automatically advertise the IP Prefixes within the rule via Magic Transit when the rule is triggered. Only available for users of Magic Transit. - `name: str` The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (_), dash (-), period (.), and tilde (~). You can’t have a space in the rule name. Max 256 characters. - `prefixes: List[str]` - `type: Literal["threshold", "zscore", "advanced_ddos"]` MNM rule type. - `"threshold"` - `"zscore"` - `"advanced_ddos"` - `id: Optional[str]` The id of the rule. Must be unique. - `bandwidth_threshold: Optional[float]` The number of bits per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `duration: Optional[Literal["1m", "5m", "10m", 5 more]]` The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 values ["1m","5m","10m","15m","20m","30m","45m","60m"]. - `"1m"` - `"5m"` - `"10m"` - `"15m"` - `"20m"` - `"30m"` - `"45m"` - `"60m"` - `packet_threshold: Optional[float]` The number of packets per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `prefix_match: Optional[Literal["exact", "subnet", "supernet"]]` Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. - `"exact"` - `"subnet"` - `"supernet"` - `zscore_sensitivity: Optional[Literal["low", "medium", "high"]]` Level of sensitivity set for zscore rules. - `"low"` - `"medium"` - `"high"` - `zscore_target: Optional[Literal["bits", "packets"]]` Target of the zscore rule analysis. - `"bits"` - `"packets"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) magic_network_monitoring_rule = client.magic_network_monitoring.rules.get( rule_id="2890e6fa406311ed9b5a23f70f6fb8cf", account_id="6f91088a406011ed95aed352566e8d4c", ) print(magic_network_monitoring_rule.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "automatic_advertisement": true, "name": "my_rule_1", "prefixes": [ "203.0.113.1/32" ], "type": "zscore", "id": "2890e6fa406311ed9b5a23f70f6fb8cf", "bandwidth_threshold": 1000, "duration": "1m", "packet_threshold": 10000, "prefix_match": "exact", "zscore_sensitivity": "high", "zscore_target": "bits" }, "success": true } ``` ## Create rules `magic_network_monitoring.rules.create(RuleCreateParams**kwargs) -> MagicNetworkMonitoringRule` **post** `/accounts/{account_id}/mnm/rules` Create network monitoring rules for account. Currently only supports creating a single rule per API request. ### Parameters - `account_id: str` - `duration: Literal["1m", "5m", "10m", 5 more]` The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 values ["1m","5m","10m","15m","20m","30m","45m","60m"]. - `"1m"` - `"5m"` - `"10m"` - `"15m"` - `"20m"` - `"30m"` - `"45m"` - `"60m"` - `name: str` The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (_), dash (-), period (.), and tilde (~). You can’t have a space in the rule name. Max 256 characters. - `automatic_advertisement: Optional[bool]` Toggle on if you would like Cloudflare to automatically advertise the IP Prefixes within the rule via Magic Transit when the rule is triggered. Only available for users of Magic Transit. - `bandwidth: Optional[float]` The number of bits per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `packet_threshold: Optional[float]` The number of packets per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `prefixes: Optional[SequenceNotStr[str]]` ### Returns - `class MagicNetworkMonitoringRule: …` - `automatic_advertisement: Optional[bool]` Toggle on if you would like Cloudflare to automatically advertise the IP Prefixes within the rule via Magic Transit when the rule is triggered. Only available for users of Magic Transit. - `name: str` The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (_), dash (-), period (.), and tilde (~). You can’t have a space in the rule name. Max 256 characters. - `prefixes: List[str]` - `type: Literal["threshold", "zscore", "advanced_ddos"]` MNM rule type. - `"threshold"` - `"zscore"` - `"advanced_ddos"` - `id: Optional[str]` The id of the rule. Must be unique. - `bandwidth_threshold: Optional[float]` The number of bits per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `duration: Optional[Literal["1m", "5m", "10m", 5 more]]` The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 values ["1m","5m","10m","15m","20m","30m","45m","60m"]. - `"1m"` - `"5m"` - `"10m"` - `"15m"` - `"20m"` - `"30m"` - `"45m"` - `"60m"` - `packet_threshold: Optional[float]` The number of packets per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `prefix_match: Optional[Literal["exact", "subnet", "supernet"]]` Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. - `"exact"` - `"subnet"` - `"supernet"` - `zscore_sensitivity: Optional[Literal["low", "medium", "high"]]` Level of sensitivity set for zscore rules. - `"low"` - `"medium"` - `"high"` - `zscore_target: Optional[Literal["bits", "packets"]]` Target of the zscore rule analysis. - `"bits"` - `"packets"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) magic_network_monitoring_rule = client.magic_network_monitoring.rules.create( account_id="6f91088a406011ed95aed352566e8d4c", duration="1m", name="my_rule_1", ) print(magic_network_monitoring_rule.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "automatic_advertisement": true, "name": "my_rule_1", "prefixes": [ "203.0.113.1/32" ], "type": "zscore", "id": "2890e6fa406311ed9b5a23f70f6fb8cf", "bandwidth_threshold": 1000, "duration": "1m", "packet_threshold": 10000, "prefix_match": "exact", "zscore_sensitivity": "high", "zscore_target": "bits" }, "success": true } ``` ## Update rules `magic_network_monitoring.rules.update(RuleUpdateParams**kwargs) -> MagicNetworkMonitoringRule` **put** `/accounts/{account_id}/mnm/rules` Update network monitoring rules for account. ### Parameters - `account_id: str` - `duration: Literal["1m", "5m", "10m", 5 more]` The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 values ["1m","5m","10m","15m","20m","30m","45m","60m"]. - `"1m"` - `"5m"` - `"10m"` - `"15m"` - `"20m"` - `"30m"` - `"45m"` - `"60m"` - `name: str` The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (_), dash (-), period (.), and tilde (~). You can’t have a space in the rule name. Max 256 characters. - `id: Optional[str]` The id of the rule. Must be unique. - `automatic_advertisement: Optional[bool]` Toggle on if you would like Cloudflare to automatically advertise the IP Prefixes within the rule via Magic Transit when the rule is triggered. Only available for users of Magic Transit. - `bandwidth: Optional[float]` The number of bits per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `packet_threshold: Optional[float]` The number of packets per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `prefixes: Optional[SequenceNotStr[str]]` ### Returns - `class MagicNetworkMonitoringRule: …` - `automatic_advertisement: Optional[bool]` Toggle on if you would like Cloudflare to automatically advertise the IP Prefixes within the rule via Magic Transit when the rule is triggered. Only available for users of Magic Transit. - `name: str` The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (_), dash (-), period (.), and tilde (~). You can’t have a space in the rule name. Max 256 characters. - `prefixes: List[str]` - `type: Literal["threshold", "zscore", "advanced_ddos"]` MNM rule type. - `"threshold"` - `"zscore"` - `"advanced_ddos"` - `id: Optional[str]` The id of the rule. Must be unique. - `bandwidth_threshold: Optional[float]` The number of bits per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `duration: Optional[Literal["1m", "5m", "10m", 5 more]]` The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 values ["1m","5m","10m","15m","20m","30m","45m","60m"]. - `"1m"` - `"5m"` - `"10m"` - `"15m"` - `"20m"` - `"30m"` - `"45m"` - `"60m"` - `packet_threshold: Optional[float]` The number of packets per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `prefix_match: Optional[Literal["exact", "subnet", "supernet"]]` Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. - `"exact"` - `"subnet"` - `"supernet"` - `zscore_sensitivity: Optional[Literal["low", "medium", "high"]]` Level of sensitivity set for zscore rules. - `"low"` - `"medium"` - `"high"` - `zscore_target: Optional[Literal["bits", "packets"]]` Target of the zscore rule analysis. - `"bits"` - `"packets"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) magic_network_monitoring_rule = client.magic_network_monitoring.rules.update( account_id="6f91088a406011ed95aed352566e8d4c", duration="1m", name="my_rule_1", ) print(magic_network_monitoring_rule.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "automatic_advertisement": true, "name": "my_rule_1", "prefixes": [ "203.0.113.1/32" ], "type": "zscore", "id": "2890e6fa406311ed9b5a23f70f6fb8cf", "bandwidth_threshold": 1000, "duration": "1m", "packet_threshold": 10000, "prefix_match": "exact", "zscore_sensitivity": "high", "zscore_target": "bits" }, "success": true } ``` ## Update rule `magic_network_monitoring.rules.edit(strrule_id, RuleEditParams**kwargs) -> MagicNetworkMonitoringRule` **patch** `/accounts/{account_id}/mnm/rules/{rule_id}` Update a network monitoring rule for account. ### Parameters - `account_id: str` - `rule_id: str` The id of the rule. Must be unique. - `automatic_advertisement: Optional[bool]` Toggle on if you would like Cloudflare to automatically advertise the IP Prefixes within the rule via Magic Transit when the rule is triggered. Only available for users of Magic Transit. - `bandwidth: Optional[float]` The number of bits per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `duration: Optional[Literal["1m", "5m", "10m", 5 more]]` The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 values ["1m","5m","10m","15m","20m","30m","45m","60m"]. - `"1m"` - `"5m"` - `"10m"` - `"15m"` - `"20m"` - `"30m"` - `"45m"` - `"60m"` - `name: Optional[str]` The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (_), dash (-), period (.), and tilde (~). You can’t have a space in the rule name. Max 256 characters. - `packet_threshold: Optional[float]` The number of packets per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `prefixes: Optional[SequenceNotStr[str]]` ### Returns - `class MagicNetworkMonitoringRule: …` - `automatic_advertisement: Optional[bool]` Toggle on if you would like Cloudflare to automatically advertise the IP Prefixes within the rule via Magic Transit when the rule is triggered. Only available for users of Magic Transit. - `name: str` The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (_), dash (-), period (.), and tilde (~). You can’t have a space in the rule name. Max 256 characters. - `prefixes: List[str]` - `type: Literal["threshold", "zscore", "advanced_ddos"]` MNM rule type. - `"threshold"` - `"zscore"` - `"advanced_ddos"` - `id: Optional[str]` The id of the rule. Must be unique. - `bandwidth_threshold: Optional[float]` The number of bits per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `duration: Optional[Literal["1m", "5m", "10m", 5 more]]` The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 values ["1m","5m","10m","15m","20m","30m","45m","60m"]. - `"1m"` - `"5m"` - `"10m"` - `"15m"` - `"20m"` - `"30m"` - `"45m"` - `"60m"` - `packet_threshold: Optional[float]` The number of packets per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `prefix_match: Optional[Literal["exact", "subnet", "supernet"]]` Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. - `"exact"` - `"subnet"` - `"supernet"` - `zscore_sensitivity: Optional[Literal["low", "medium", "high"]]` Level of sensitivity set for zscore rules. - `"low"` - `"medium"` - `"high"` - `zscore_target: Optional[Literal["bits", "packets"]]` Target of the zscore rule analysis. - `"bits"` - `"packets"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) magic_network_monitoring_rule = client.magic_network_monitoring.rules.edit( rule_id="2890e6fa406311ed9b5a23f70f6fb8cf", account_id="6f91088a406011ed95aed352566e8d4c", ) print(magic_network_monitoring_rule.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "automatic_advertisement": true, "name": "my_rule_1", "prefixes": [ "203.0.113.1/32" ], "type": "zscore", "id": "2890e6fa406311ed9b5a23f70f6fb8cf", "bandwidth_threshold": 1000, "duration": "1m", "packet_threshold": 10000, "prefix_match": "exact", "zscore_sensitivity": "high", "zscore_target": "bits" }, "success": true } ``` ## Delete rule `magic_network_monitoring.rules.delete(strrule_id, RuleDeleteParams**kwargs) -> MagicNetworkMonitoringRule` **delete** `/accounts/{account_id}/mnm/rules/{rule_id}` Delete a network monitoring rule for account. ### Parameters - `account_id: str` - `rule_id: str` The id of the rule. Must be unique. ### Returns - `class MagicNetworkMonitoringRule: …` - `automatic_advertisement: Optional[bool]` Toggle on if you would like Cloudflare to automatically advertise the IP Prefixes within the rule via Magic Transit when the rule is triggered. Only available for users of Magic Transit. - `name: str` The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (_), dash (-), period (.), and tilde (~). You can’t have a space in the rule name. Max 256 characters. - `prefixes: List[str]` - `type: Literal["threshold", "zscore", "advanced_ddos"]` MNM rule type. - `"threshold"` - `"zscore"` - `"advanced_ddos"` - `id: Optional[str]` The id of the rule. Must be unique. - `bandwidth_threshold: Optional[float]` The number of bits per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `duration: Optional[Literal["1m", "5m", "10m", 5 more]]` The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 values ["1m","5m","10m","15m","20m","30m","45m","60m"]. - `"1m"` - `"5m"` - `"10m"` - `"15m"` - `"20m"` - `"30m"` - `"45m"` - `"60m"` - `packet_threshold: Optional[float]` The number of packets per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `prefix_match: Optional[Literal["exact", "subnet", "supernet"]]` Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. - `"exact"` - `"subnet"` - `"supernet"` - `zscore_sensitivity: Optional[Literal["low", "medium", "high"]]` Level of sensitivity set for zscore rules. - `"low"` - `"medium"` - `"high"` - `zscore_target: Optional[Literal["bits", "packets"]]` Target of the zscore rule analysis. - `"bits"` - `"packets"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) magic_network_monitoring_rule = client.magic_network_monitoring.rules.delete( rule_id="2890e6fa406311ed9b5a23f70f6fb8cf", account_id="6f91088a406011ed95aed352566e8d4c", ) print(magic_network_monitoring_rule.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "automatic_advertisement": true, "name": "my_rule_1", "prefixes": [ "203.0.113.1/32" ], "type": "zscore", "id": "2890e6fa406311ed9b5a23f70f6fb8cf", "bandwidth_threshold": 1000, "duration": "1m", "packet_threshold": 10000, "prefix_match": "exact", "zscore_sensitivity": "high", "zscore_target": "bits" }, "success": true } ``` ## Domain Types ### Magic Network Monitoring Rule - `class MagicNetworkMonitoringRule: …` - `automatic_advertisement: Optional[bool]` Toggle on if you would like Cloudflare to automatically advertise the IP Prefixes within the rule via Magic Transit when the rule is triggered. Only available for users of Magic Transit. - `name: str` The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, underscore (_), dash (-), period (.), and tilde (~). You can’t have a space in the rule name. Max 256 characters. - `prefixes: List[str]` - `type: Literal["threshold", "zscore", "advanced_ddos"]` MNM rule type. - `"threshold"` - `"zscore"` - `"advanced_ddos"` - `id: Optional[str]` The id of the rule. Must be unique. - `bandwidth_threshold: Optional[float]` The number of bits per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `duration: Optional[Literal["1m", "5m", "10m", 5 more]]` The amount of time that the rule threshold must be exceeded to send an alert notification. The final value must be equivalent to one of the following 8 values ["1m","5m","10m","15m","20m","30m","45m","60m"]. - `"1m"` - `"5m"` - `"10m"` - `"15m"` - `"20m"` - `"30m"` - `"45m"` - `"60m"` - `packet_threshold: Optional[float]` The number of packets per second for the rule. When this value is exceeded for the set duration, an alert notification is sent. Minimum of 1 and no maximum. - `prefix_match: Optional[Literal["exact", "subnet", "supernet"]]` Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. - `"exact"` - `"subnet"` - `"supernet"` - `zscore_sensitivity: Optional[Literal["low", "medium", "high"]]` Level of sensitivity set for zscore rules. - `"low"` - `"medium"` - `"high"` - `zscore_target: Optional[Literal["bits", "packets"]]` Target of the zscore rule analysis. - `"bits"` - `"packets"` # Advertisements ## Update advertisement for rule `magic_network_monitoring.rules.advertisements.edit(strrule_id, AdvertisementEditParams**kwargs) -> Advertisement` **patch** `/accounts/{account_id}/mnm/rules/{rule_id}/advertisement` Update advertisement for rule. ### Parameters - `account_id: str` - `rule_id: str` The id of the rule. Must be unique. - `body: object` ### Returns - `class Advertisement: …` - `automatic_advertisement: Optional[bool]` Toggle on if you would like Cloudflare to automatically advertise the IP Prefixes within the rule via Magic Transit when the rule is triggered. Only available for users of Magic Transit. ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_email=os.environ.get("CLOUDFLARE_EMAIL"), # This is the default and can be omitted api_key=os.environ.get("CLOUDFLARE_API_KEY"), # This is the default and can be omitted ) advertisement = client.magic_network_monitoring.rules.advertisements.edit( rule_id="2890e6fa406311ed9b5a23f70f6fb8cf", account_id="6f91088a406011ed95aed352566e8d4c", body={}, ) print(advertisement.automatic_advertisement) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "automatic_advertisement": true }, "success": true } ``` ## Domain Types ### Advertisement - `class Advertisement: …` - `automatic_advertisement: Optional[bool]` Toggle on if you would like Cloudflare to automatically advertise the IP Prefixes within the rule via Magic Transit when the rule is triggered. Only available for users of Magic Transit.