# Magic Network Monitoring # VPC Flows # Tokens ## Generate authentication token for VPC flow logs export. `client.MagicNetworkMonitoring.VPCFlows.Tokens.New(ctx, body) (*string, error)` **post** `/accounts/{account_id}/mnm/vpc-flows/token` Generate authentication token for VPC flow logs export. ### Parameters - `body VPCFlowTokenNewParams` - `AccountID param.Field[string]` ### Returns - `type VPCFlowTokenNewResponseEnvelopeResult string` Authentication token to be used for VPC Flows export authentication. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_network_monitoring" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) token, err := client.MagicNetworkMonitoring.VPCFlows.Tokens.New(context.TODO(), magic_network_monitoring.VPCFlowTokenNewParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", 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 } ``` # Configs ## List account configuration `client.MagicNetworkMonitoring.Configs.Get(ctx, query) (*Configuration, error)` **get** `/accounts/{account_id}/mnm/config` Lists default sampling, router IPs and warp devices for account. ### Parameters - `query ConfigGetParams` - `AccountID param.Field[string]` ### Returns - `type Configuration struct{…}` - `DefaultSampling float64` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `Name string` The account name. - `RouterIPs []string` - `WARPDevices []ConfigurationWARPDevice` - `ID string` Unique identifier for the warp device. - `Name string` Name of the warp device. - `RouterIP string` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_network_monitoring" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) configuration, err := client.MagicNetworkMonitoring.Configs.Get(context.TODO(), magic_network_monitoring.ConfigGetParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", configuration.DefaultSampling) } ``` #### 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 `client.MagicNetworkMonitoring.Configs.New(ctx, params) (*Configuration, error)` **post** `/accounts/{account_id}/mnm/config` Create a new network monitoring configuration. ### Parameters - `params ConfigNewParams` - `AccountID param.Field[string]` Path param - `DefaultSampling param.Field[float64]` Body param: Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `Name param.Field[string]` Body param: The account name. - `RouterIPs param.Field[[]string]` Body param - `WARPDevices param.Field[[]ConfigNewParamsWARPDevice]` Body param - `ID string` Unique identifier for the warp device. - `Name string` Name of the warp device. - `RouterIP string` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Returns - `type Configuration struct{…}` - `DefaultSampling float64` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `Name string` The account name. - `RouterIPs []string` - `WARPDevices []ConfigurationWARPDevice` - `ID string` Unique identifier for the warp device. - `Name string` Name of the warp device. - `RouterIP string` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_network_monitoring" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) configuration, err := client.MagicNetworkMonitoring.Configs.New(context.TODO(), magic_network_monitoring.ConfigNewParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), DefaultSampling: cloudflare.F(1.000000), Name: cloudflare.F("cloudflare user's account"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", configuration.DefaultSampling) } ``` #### 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 `client.MagicNetworkMonitoring.Configs.Update(ctx, params) (*Configuration, error)` **put** `/accounts/{account_id}/mnm/config` Update an existing network monitoring configuration, requires the entire configuration to be updated at once. ### Parameters - `params ConfigUpdateParams` - `AccountID param.Field[string]` Path param - `DefaultSampling param.Field[float64]` Body param: Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `Name param.Field[string]` Body param: The account name. - `RouterIPs param.Field[[]string]` Body param - `WARPDevices param.Field[[]ConfigUpdateParamsWARPDevice]` Body param - `ID string` Unique identifier for the warp device. - `Name string` Name of the warp device. - `RouterIP string` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Returns - `type Configuration struct{…}` - `DefaultSampling float64` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `Name string` The account name. - `RouterIPs []string` - `WARPDevices []ConfigurationWARPDevice` - `ID string` Unique identifier for the warp device. - `Name string` Name of the warp device. - `RouterIP string` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_network_monitoring" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) configuration, err := client.MagicNetworkMonitoring.Configs.Update(context.TODO(), magic_network_monitoring.ConfigUpdateParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), DefaultSampling: cloudflare.F(1.000000), Name: cloudflare.F("cloudflare user's account"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", configuration.DefaultSampling) } ``` #### 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 `client.MagicNetworkMonitoring.Configs.Edit(ctx, params) (*Configuration, error)` **patch** `/accounts/{account_id}/mnm/config` Update fields in an existing network monitoring configuration. ### Parameters - `params ConfigEditParams` - `AccountID param.Field[string]` Path param - `DefaultSampling param.Field[float64]` Body param: Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `Name param.Field[string]` Body param: The account name. - `RouterIPs param.Field[[]string]` Body param - `WARPDevices param.Field[[]ConfigEditParamsWARPDevice]` Body param - `ID string` Unique identifier for the warp device. - `Name string` Name of the warp device. - `RouterIP string` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Returns - `type Configuration struct{…}` - `DefaultSampling float64` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `Name string` The account name. - `RouterIPs []string` - `WARPDevices []ConfigurationWARPDevice` - `ID string` Unique identifier for the warp device. - `Name string` Name of the warp device. - `RouterIP string` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_network_monitoring" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) configuration, err := client.MagicNetworkMonitoring.Configs.Edit(context.TODO(), magic_network_monitoring.ConfigEditParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", configuration.DefaultSampling) } ``` #### 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 `client.MagicNetworkMonitoring.Configs.Delete(ctx, body) (*Configuration, error)` **delete** `/accounts/{account_id}/mnm/config` Delete an existing network monitoring configuration. ### Parameters - `body ConfigDeleteParams` - `AccountID param.Field[string]` ### Returns - `type Configuration struct{…}` - `DefaultSampling float64` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `Name string` The account name. - `RouterIPs []string` - `WARPDevices []ConfigurationWARPDevice` - `ID string` Unique identifier for the warp device. - `Name string` Name of the warp device. - `RouterIP string` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_network_monitoring" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) configuration, err := client.MagicNetworkMonitoring.Configs.Delete(context.TODO(), magic_network_monitoring.ConfigDeleteParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", configuration.DefaultSampling) } ``` #### 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 - `type Configuration struct{…}` - `DefaultSampling float64` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `Name string` The account name. - `RouterIPs []string` - `WARPDevices []ConfigurationWARPDevice` - `ID string` Unique identifier for the warp device. - `Name string` Name of the warp device. - `RouterIP string` 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 `client.MagicNetworkMonitoring.Configs.Full.Get(ctx, query) (*Configuration, error)` **get** `/accounts/{account_id}/mnm/config/full` Lists default sampling, router IPs, warp devices, and rules for account. ### Parameters - `query ConfigFullGetParams` - `AccountID param.Field[string]` ### Returns - `type Configuration struct{…}` - `DefaultSampling float64` Fallback sampling rate of flow messages being sent in packets per second. This should match the packet sampling rate configured on the router. - `Name string` The account name. - `RouterIPs []string` - `WARPDevices []ConfigurationWARPDevice` - `ID string` Unique identifier for the warp device. - `Name string` Name of the warp device. - `RouterIP string` IPv4 CIDR of the router sourcing flow data associated with this warp device. Only /32 addresses are currently supported. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_network_monitoring" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) configuration, err := client.MagicNetworkMonitoring.Configs.Full.Get(context.TODO(), magic_network_monitoring.ConfigFullGetParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", configuration.DefaultSampling) } ``` #### 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 `client.MagicNetworkMonitoring.Rules.List(ctx, query) (*SinglePage[MagicNetworkMonitoringRule], error)` **get** `/accounts/{account_id}/mnm/rules` Lists network monitoring rules for account. ### Parameters - `query RuleListParams` - `AccountID param.Field[string]` ### Returns - `type MagicNetworkMonitoringRule struct{…}` - `AutomaticAdvertisement 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 string` 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 []string` - `Type MagicNetworkMonitoringRuleType` MNM rule type. - `const MagicNetworkMonitoringRuleTypeThreshold MagicNetworkMonitoringRuleType = "threshold"` - `const MagicNetworkMonitoringRuleTypeZscore MagicNetworkMonitoringRuleType = "zscore"` - `const MagicNetworkMonitoringRuleTypeAdvancedDDoS MagicNetworkMonitoringRuleType = "advanced_ddos"` - `ID string` The id of the rule. Must be unique. - `BandwidthThreshold float64` 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 MagicNetworkMonitoringRuleDuration` 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"]. - `const MagicNetworkMonitoringRuleDuration1m MagicNetworkMonitoringRuleDuration = "1m"` - `const MagicNetworkMonitoringRuleDuration5m MagicNetworkMonitoringRuleDuration = "5m"` - `const MagicNetworkMonitoringRuleDuration10m MagicNetworkMonitoringRuleDuration = "10m"` - `const MagicNetworkMonitoringRuleDuration15m MagicNetworkMonitoringRuleDuration = "15m"` - `const MagicNetworkMonitoringRuleDuration20m MagicNetworkMonitoringRuleDuration = "20m"` - `const MagicNetworkMonitoringRuleDuration30m MagicNetworkMonitoringRuleDuration = "30m"` - `const MagicNetworkMonitoringRuleDuration45m MagicNetworkMonitoringRuleDuration = "45m"` - `const MagicNetworkMonitoringRuleDuration60m MagicNetworkMonitoringRuleDuration = "60m"` - `PacketThreshold float64` 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. - `PrefixMatch MagicNetworkMonitoringRulePrefixMatch` Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. - `const MagicNetworkMonitoringRulePrefixMatchExact MagicNetworkMonitoringRulePrefixMatch = "exact"` - `const MagicNetworkMonitoringRulePrefixMatchSubnet MagicNetworkMonitoringRulePrefixMatch = "subnet"` - `const MagicNetworkMonitoringRulePrefixMatchSupernet MagicNetworkMonitoringRulePrefixMatch = "supernet"` - `ZscoreSensitivity MagicNetworkMonitoringRuleZscoreSensitivity` Level of sensitivity set for zscore rules. - `const MagicNetworkMonitoringRuleZscoreSensitivityLow MagicNetworkMonitoringRuleZscoreSensitivity = "low"` - `const MagicNetworkMonitoringRuleZscoreSensitivityMedium MagicNetworkMonitoringRuleZscoreSensitivity = "medium"` - `const MagicNetworkMonitoringRuleZscoreSensitivityHigh MagicNetworkMonitoringRuleZscoreSensitivity = "high"` - `ZscoreTarget MagicNetworkMonitoringRuleZscoreTarget` Target of the zscore rule analysis. - `const MagicNetworkMonitoringRuleZscoreTargetBits MagicNetworkMonitoringRuleZscoreTarget = "bits"` - `const MagicNetworkMonitoringRuleZscoreTargetPackets MagicNetworkMonitoringRuleZscoreTarget = "packets"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_network_monitoring" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.MagicNetworkMonitoring.Rules.List(context.TODO(), magic_network_monitoring.RuleListParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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 `client.MagicNetworkMonitoring.Rules.Get(ctx, ruleID, query) (*MagicNetworkMonitoringRule, error)` **get** `/accounts/{account_id}/mnm/rules/{rule_id}` List a single network monitoring rule for account. ### Parameters - `ruleID string` The id of the rule. Must be unique. - `query RuleGetParams` - `AccountID param.Field[string]` ### Returns - `type MagicNetworkMonitoringRule struct{…}` - `AutomaticAdvertisement 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 string` 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 []string` - `Type MagicNetworkMonitoringRuleType` MNM rule type. - `const MagicNetworkMonitoringRuleTypeThreshold MagicNetworkMonitoringRuleType = "threshold"` - `const MagicNetworkMonitoringRuleTypeZscore MagicNetworkMonitoringRuleType = "zscore"` - `const MagicNetworkMonitoringRuleTypeAdvancedDDoS MagicNetworkMonitoringRuleType = "advanced_ddos"` - `ID string` The id of the rule. Must be unique. - `BandwidthThreshold float64` 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 MagicNetworkMonitoringRuleDuration` 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"]. - `const MagicNetworkMonitoringRuleDuration1m MagicNetworkMonitoringRuleDuration = "1m"` - `const MagicNetworkMonitoringRuleDuration5m MagicNetworkMonitoringRuleDuration = "5m"` - `const MagicNetworkMonitoringRuleDuration10m MagicNetworkMonitoringRuleDuration = "10m"` - `const MagicNetworkMonitoringRuleDuration15m MagicNetworkMonitoringRuleDuration = "15m"` - `const MagicNetworkMonitoringRuleDuration20m MagicNetworkMonitoringRuleDuration = "20m"` - `const MagicNetworkMonitoringRuleDuration30m MagicNetworkMonitoringRuleDuration = "30m"` - `const MagicNetworkMonitoringRuleDuration45m MagicNetworkMonitoringRuleDuration = "45m"` - `const MagicNetworkMonitoringRuleDuration60m MagicNetworkMonitoringRuleDuration = "60m"` - `PacketThreshold float64` 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. - `PrefixMatch MagicNetworkMonitoringRulePrefixMatch` Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. - `const MagicNetworkMonitoringRulePrefixMatchExact MagicNetworkMonitoringRulePrefixMatch = "exact"` - `const MagicNetworkMonitoringRulePrefixMatchSubnet MagicNetworkMonitoringRulePrefixMatch = "subnet"` - `const MagicNetworkMonitoringRulePrefixMatchSupernet MagicNetworkMonitoringRulePrefixMatch = "supernet"` - `ZscoreSensitivity MagicNetworkMonitoringRuleZscoreSensitivity` Level of sensitivity set for zscore rules. - `const MagicNetworkMonitoringRuleZscoreSensitivityLow MagicNetworkMonitoringRuleZscoreSensitivity = "low"` - `const MagicNetworkMonitoringRuleZscoreSensitivityMedium MagicNetworkMonitoringRuleZscoreSensitivity = "medium"` - `const MagicNetworkMonitoringRuleZscoreSensitivityHigh MagicNetworkMonitoringRuleZscoreSensitivity = "high"` - `ZscoreTarget MagicNetworkMonitoringRuleZscoreTarget` Target of the zscore rule analysis. - `const MagicNetworkMonitoringRuleZscoreTargetBits MagicNetworkMonitoringRuleZscoreTarget = "bits"` - `const MagicNetworkMonitoringRuleZscoreTargetPackets MagicNetworkMonitoringRuleZscoreTarget = "packets"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_network_monitoring" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) magicNetworkMonitoringRule, err := client.MagicNetworkMonitoring.Rules.Get( context.TODO(), "2890e6fa406311ed9b5a23f70f6fb8cf", magic_network_monitoring.RuleGetParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", magicNetworkMonitoringRule.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 `client.MagicNetworkMonitoring.Rules.New(ctx, params) (*MagicNetworkMonitoringRule, error)` **post** `/accounts/{account_id}/mnm/rules` Create network monitoring rules for account. Currently only supports creating a single rule per API request. ### Parameters - `params RuleNewParams` - `AccountID param.Field[string]` Path param - `Duration param.Field[RuleNewParamsDuration]` Body param: 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"]. - `const RuleNewParamsDuration1m RuleNewParamsDuration = "1m"` - `const RuleNewParamsDuration5m RuleNewParamsDuration = "5m"` - `const RuleNewParamsDuration10m RuleNewParamsDuration = "10m"` - `const RuleNewParamsDuration15m RuleNewParamsDuration = "15m"` - `const RuleNewParamsDuration20m RuleNewParamsDuration = "20m"` - `const RuleNewParamsDuration30m RuleNewParamsDuration = "30m"` - `const RuleNewParamsDuration45m RuleNewParamsDuration = "45m"` - `const RuleNewParamsDuration60m RuleNewParamsDuration = "60m"` - `Name param.Field[string]` Body param: 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. - `AutomaticAdvertisement param.Field[bool]` Body param: 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 param.Field[float64]` Body param: 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. - `PacketThreshold param.Field[float64]` Body param: 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 param.Field[[]string]` Body param ### Returns - `type MagicNetworkMonitoringRule struct{…}` - `AutomaticAdvertisement 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 string` 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 []string` - `Type MagicNetworkMonitoringRuleType` MNM rule type. - `const MagicNetworkMonitoringRuleTypeThreshold MagicNetworkMonitoringRuleType = "threshold"` - `const MagicNetworkMonitoringRuleTypeZscore MagicNetworkMonitoringRuleType = "zscore"` - `const MagicNetworkMonitoringRuleTypeAdvancedDDoS MagicNetworkMonitoringRuleType = "advanced_ddos"` - `ID string` The id of the rule. Must be unique. - `BandwidthThreshold float64` 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 MagicNetworkMonitoringRuleDuration` 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"]. - `const MagicNetworkMonitoringRuleDuration1m MagicNetworkMonitoringRuleDuration = "1m"` - `const MagicNetworkMonitoringRuleDuration5m MagicNetworkMonitoringRuleDuration = "5m"` - `const MagicNetworkMonitoringRuleDuration10m MagicNetworkMonitoringRuleDuration = "10m"` - `const MagicNetworkMonitoringRuleDuration15m MagicNetworkMonitoringRuleDuration = "15m"` - `const MagicNetworkMonitoringRuleDuration20m MagicNetworkMonitoringRuleDuration = "20m"` - `const MagicNetworkMonitoringRuleDuration30m MagicNetworkMonitoringRuleDuration = "30m"` - `const MagicNetworkMonitoringRuleDuration45m MagicNetworkMonitoringRuleDuration = "45m"` - `const MagicNetworkMonitoringRuleDuration60m MagicNetworkMonitoringRuleDuration = "60m"` - `PacketThreshold float64` 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. - `PrefixMatch MagicNetworkMonitoringRulePrefixMatch` Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. - `const MagicNetworkMonitoringRulePrefixMatchExact MagicNetworkMonitoringRulePrefixMatch = "exact"` - `const MagicNetworkMonitoringRulePrefixMatchSubnet MagicNetworkMonitoringRulePrefixMatch = "subnet"` - `const MagicNetworkMonitoringRulePrefixMatchSupernet MagicNetworkMonitoringRulePrefixMatch = "supernet"` - `ZscoreSensitivity MagicNetworkMonitoringRuleZscoreSensitivity` Level of sensitivity set for zscore rules. - `const MagicNetworkMonitoringRuleZscoreSensitivityLow MagicNetworkMonitoringRuleZscoreSensitivity = "low"` - `const MagicNetworkMonitoringRuleZscoreSensitivityMedium MagicNetworkMonitoringRuleZscoreSensitivity = "medium"` - `const MagicNetworkMonitoringRuleZscoreSensitivityHigh MagicNetworkMonitoringRuleZscoreSensitivity = "high"` - `ZscoreTarget MagicNetworkMonitoringRuleZscoreTarget` Target of the zscore rule analysis. - `const MagicNetworkMonitoringRuleZscoreTargetBits MagicNetworkMonitoringRuleZscoreTarget = "bits"` - `const MagicNetworkMonitoringRuleZscoreTargetPackets MagicNetworkMonitoringRuleZscoreTarget = "packets"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_network_monitoring" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) magicNetworkMonitoringRule, err := client.MagicNetworkMonitoring.Rules.New(context.TODO(), magic_network_monitoring.RuleNewParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), Duration: cloudflare.F(magic_network_monitoring.RuleNewParamsDuration1m), Name: cloudflare.F("my_rule_1"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", magicNetworkMonitoringRule.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 `client.MagicNetworkMonitoring.Rules.Update(ctx, params) (*MagicNetworkMonitoringRule, error)` **put** `/accounts/{account_id}/mnm/rules` Update network monitoring rules for account. ### Parameters - `params RuleUpdateParams` - `AccountID param.Field[string]` Path param - `Duration param.Field[RuleUpdateParamsDuration]` Body param: 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"]. - `const RuleUpdateParamsDuration1m RuleUpdateParamsDuration = "1m"` - `const RuleUpdateParamsDuration5m RuleUpdateParamsDuration = "5m"` - `const RuleUpdateParamsDuration10m RuleUpdateParamsDuration = "10m"` - `const RuleUpdateParamsDuration15m RuleUpdateParamsDuration = "15m"` - `const RuleUpdateParamsDuration20m RuleUpdateParamsDuration = "20m"` - `const RuleUpdateParamsDuration30m RuleUpdateParamsDuration = "30m"` - `const RuleUpdateParamsDuration45m RuleUpdateParamsDuration = "45m"` - `const RuleUpdateParamsDuration60m RuleUpdateParamsDuration = "60m"` - `Name param.Field[string]` Body param: 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 param.Field[string]` Body param: The id of the rule. Must be unique. - `AutomaticAdvertisement param.Field[bool]` Body param: 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 param.Field[float64]` Body param: 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. - `PacketThreshold param.Field[float64]` Body param: 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 param.Field[[]string]` Body param ### Returns - `type MagicNetworkMonitoringRule struct{…}` - `AutomaticAdvertisement 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 string` 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 []string` - `Type MagicNetworkMonitoringRuleType` MNM rule type. - `const MagicNetworkMonitoringRuleTypeThreshold MagicNetworkMonitoringRuleType = "threshold"` - `const MagicNetworkMonitoringRuleTypeZscore MagicNetworkMonitoringRuleType = "zscore"` - `const MagicNetworkMonitoringRuleTypeAdvancedDDoS MagicNetworkMonitoringRuleType = "advanced_ddos"` - `ID string` The id of the rule. Must be unique. - `BandwidthThreshold float64` 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 MagicNetworkMonitoringRuleDuration` 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"]. - `const MagicNetworkMonitoringRuleDuration1m MagicNetworkMonitoringRuleDuration = "1m"` - `const MagicNetworkMonitoringRuleDuration5m MagicNetworkMonitoringRuleDuration = "5m"` - `const MagicNetworkMonitoringRuleDuration10m MagicNetworkMonitoringRuleDuration = "10m"` - `const MagicNetworkMonitoringRuleDuration15m MagicNetworkMonitoringRuleDuration = "15m"` - `const MagicNetworkMonitoringRuleDuration20m MagicNetworkMonitoringRuleDuration = "20m"` - `const MagicNetworkMonitoringRuleDuration30m MagicNetworkMonitoringRuleDuration = "30m"` - `const MagicNetworkMonitoringRuleDuration45m MagicNetworkMonitoringRuleDuration = "45m"` - `const MagicNetworkMonitoringRuleDuration60m MagicNetworkMonitoringRuleDuration = "60m"` - `PacketThreshold float64` 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. - `PrefixMatch MagicNetworkMonitoringRulePrefixMatch` Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. - `const MagicNetworkMonitoringRulePrefixMatchExact MagicNetworkMonitoringRulePrefixMatch = "exact"` - `const MagicNetworkMonitoringRulePrefixMatchSubnet MagicNetworkMonitoringRulePrefixMatch = "subnet"` - `const MagicNetworkMonitoringRulePrefixMatchSupernet MagicNetworkMonitoringRulePrefixMatch = "supernet"` - `ZscoreSensitivity MagicNetworkMonitoringRuleZscoreSensitivity` Level of sensitivity set for zscore rules. - `const MagicNetworkMonitoringRuleZscoreSensitivityLow MagicNetworkMonitoringRuleZscoreSensitivity = "low"` - `const MagicNetworkMonitoringRuleZscoreSensitivityMedium MagicNetworkMonitoringRuleZscoreSensitivity = "medium"` - `const MagicNetworkMonitoringRuleZscoreSensitivityHigh MagicNetworkMonitoringRuleZscoreSensitivity = "high"` - `ZscoreTarget MagicNetworkMonitoringRuleZscoreTarget` Target of the zscore rule analysis. - `const MagicNetworkMonitoringRuleZscoreTargetBits MagicNetworkMonitoringRuleZscoreTarget = "bits"` - `const MagicNetworkMonitoringRuleZscoreTargetPackets MagicNetworkMonitoringRuleZscoreTarget = "packets"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_network_monitoring" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) magicNetworkMonitoringRule, err := client.MagicNetworkMonitoring.Rules.Update(context.TODO(), magic_network_monitoring.RuleUpdateParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), Duration: cloudflare.F(magic_network_monitoring.RuleUpdateParamsDuration1m), Name: cloudflare.F("my_rule_1"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", magicNetworkMonitoringRule.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 `client.MagicNetworkMonitoring.Rules.Edit(ctx, ruleID, params) (*MagicNetworkMonitoringRule, error)` **patch** `/accounts/{account_id}/mnm/rules/{rule_id}` Update a network monitoring rule for account. ### Parameters - `ruleID string` The id of the rule. Must be unique. - `params RuleEditParams` - `AccountID param.Field[string]` Path param - `AutomaticAdvertisement param.Field[bool]` Body param: 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 param.Field[float64]` Body param: 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 param.Field[RuleEditParamsDuration]` Body param: 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"]. - `const RuleEditParamsDuration1m RuleEditParamsDuration = "1m"` - `const RuleEditParamsDuration5m RuleEditParamsDuration = "5m"` - `const RuleEditParamsDuration10m RuleEditParamsDuration = "10m"` - `const RuleEditParamsDuration15m RuleEditParamsDuration = "15m"` - `const RuleEditParamsDuration20m RuleEditParamsDuration = "20m"` - `const RuleEditParamsDuration30m RuleEditParamsDuration = "30m"` - `const RuleEditParamsDuration45m RuleEditParamsDuration = "45m"` - `const RuleEditParamsDuration60m RuleEditParamsDuration = "60m"` - `Name param.Field[string]` Body param: 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. - `PacketThreshold param.Field[float64]` Body param: 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 param.Field[[]string]` Body param ### Returns - `type MagicNetworkMonitoringRule struct{…}` - `AutomaticAdvertisement 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 string` 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 []string` - `Type MagicNetworkMonitoringRuleType` MNM rule type. - `const MagicNetworkMonitoringRuleTypeThreshold MagicNetworkMonitoringRuleType = "threshold"` - `const MagicNetworkMonitoringRuleTypeZscore MagicNetworkMonitoringRuleType = "zscore"` - `const MagicNetworkMonitoringRuleTypeAdvancedDDoS MagicNetworkMonitoringRuleType = "advanced_ddos"` - `ID string` The id of the rule. Must be unique. - `BandwidthThreshold float64` 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 MagicNetworkMonitoringRuleDuration` 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"]. - `const MagicNetworkMonitoringRuleDuration1m MagicNetworkMonitoringRuleDuration = "1m"` - `const MagicNetworkMonitoringRuleDuration5m MagicNetworkMonitoringRuleDuration = "5m"` - `const MagicNetworkMonitoringRuleDuration10m MagicNetworkMonitoringRuleDuration = "10m"` - `const MagicNetworkMonitoringRuleDuration15m MagicNetworkMonitoringRuleDuration = "15m"` - `const MagicNetworkMonitoringRuleDuration20m MagicNetworkMonitoringRuleDuration = "20m"` - `const MagicNetworkMonitoringRuleDuration30m MagicNetworkMonitoringRuleDuration = "30m"` - `const MagicNetworkMonitoringRuleDuration45m MagicNetworkMonitoringRuleDuration = "45m"` - `const MagicNetworkMonitoringRuleDuration60m MagicNetworkMonitoringRuleDuration = "60m"` - `PacketThreshold float64` 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. - `PrefixMatch MagicNetworkMonitoringRulePrefixMatch` Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. - `const MagicNetworkMonitoringRulePrefixMatchExact MagicNetworkMonitoringRulePrefixMatch = "exact"` - `const MagicNetworkMonitoringRulePrefixMatchSubnet MagicNetworkMonitoringRulePrefixMatch = "subnet"` - `const MagicNetworkMonitoringRulePrefixMatchSupernet MagicNetworkMonitoringRulePrefixMatch = "supernet"` - `ZscoreSensitivity MagicNetworkMonitoringRuleZscoreSensitivity` Level of sensitivity set for zscore rules. - `const MagicNetworkMonitoringRuleZscoreSensitivityLow MagicNetworkMonitoringRuleZscoreSensitivity = "low"` - `const MagicNetworkMonitoringRuleZscoreSensitivityMedium MagicNetworkMonitoringRuleZscoreSensitivity = "medium"` - `const MagicNetworkMonitoringRuleZscoreSensitivityHigh MagicNetworkMonitoringRuleZscoreSensitivity = "high"` - `ZscoreTarget MagicNetworkMonitoringRuleZscoreTarget` Target of the zscore rule analysis. - `const MagicNetworkMonitoringRuleZscoreTargetBits MagicNetworkMonitoringRuleZscoreTarget = "bits"` - `const MagicNetworkMonitoringRuleZscoreTargetPackets MagicNetworkMonitoringRuleZscoreTarget = "packets"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_network_monitoring" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) magicNetworkMonitoringRule, err := client.MagicNetworkMonitoring.Rules.Edit( context.TODO(), "2890e6fa406311ed9b5a23f70f6fb8cf", magic_network_monitoring.RuleEditParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", magicNetworkMonitoringRule.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 `client.MagicNetworkMonitoring.Rules.Delete(ctx, ruleID, body) (*MagicNetworkMonitoringRule, error)` **delete** `/accounts/{account_id}/mnm/rules/{rule_id}` Delete a network monitoring rule for account. ### Parameters - `ruleID string` The id of the rule. Must be unique. - `body RuleDeleteParams` - `AccountID param.Field[string]` ### Returns - `type MagicNetworkMonitoringRule struct{…}` - `AutomaticAdvertisement 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 string` 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 []string` - `Type MagicNetworkMonitoringRuleType` MNM rule type. - `const MagicNetworkMonitoringRuleTypeThreshold MagicNetworkMonitoringRuleType = "threshold"` - `const MagicNetworkMonitoringRuleTypeZscore MagicNetworkMonitoringRuleType = "zscore"` - `const MagicNetworkMonitoringRuleTypeAdvancedDDoS MagicNetworkMonitoringRuleType = "advanced_ddos"` - `ID string` The id of the rule. Must be unique. - `BandwidthThreshold float64` 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 MagicNetworkMonitoringRuleDuration` 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"]. - `const MagicNetworkMonitoringRuleDuration1m MagicNetworkMonitoringRuleDuration = "1m"` - `const MagicNetworkMonitoringRuleDuration5m MagicNetworkMonitoringRuleDuration = "5m"` - `const MagicNetworkMonitoringRuleDuration10m MagicNetworkMonitoringRuleDuration = "10m"` - `const MagicNetworkMonitoringRuleDuration15m MagicNetworkMonitoringRuleDuration = "15m"` - `const MagicNetworkMonitoringRuleDuration20m MagicNetworkMonitoringRuleDuration = "20m"` - `const MagicNetworkMonitoringRuleDuration30m MagicNetworkMonitoringRuleDuration = "30m"` - `const MagicNetworkMonitoringRuleDuration45m MagicNetworkMonitoringRuleDuration = "45m"` - `const MagicNetworkMonitoringRuleDuration60m MagicNetworkMonitoringRuleDuration = "60m"` - `PacketThreshold float64` 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. - `PrefixMatch MagicNetworkMonitoringRulePrefixMatch` Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. - `const MagicNetworkMonitoringRulePrefixMatchExact MagicNetworkMonitoringRulePrefixMatch = "exact"` - `const MagicNetworkMonitoringRulePrefixMatchSubnet MagicNetworkMonitoringRulePrefixMatch = "subnet"` - `const MagicNetworkMonitoringRulePrefixMatchSupernet MagicNetworkMonitoringRulePrefixMatch = "supernet"` - `ZscoreSensitivity MagicNetworkMonitoringRuleZscoreSensitivity` Level of sensitivity set for zscore rules. - `const MagicNetworkMonitoringRuleZscoreSensitivityLow MagicNetworkMonitoringRuleZscoreSensitivity = "low"` - `const MagicNetworkMonitoringRuleZscoreSensitivityMedium MagicNetworkMonitoringRuleZscoreSensitivity = "medium"` - `const MagicNetworkMonitoringRuleZscoreSensitivityHigh MagicNetworkMonitoringRuleZscoreSensitivity = "high"` - `ZscoreTarget MagicNetworkMonitoringRuleZscoreTarget` Target of the zscore rule analysis. - `const MagicNetworkMonitoringRuleZscoreTargetBits MagicNetworkMonitoringRuleZscoreTarget = "bits"` - `const MagicNetworkMonitoringRuleZscoreTargetPackets MagicNetworkMonitoringRuleZscoreTarget = "packets"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_network_monitoring" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) magicNetworkMonitoringRule, err := client.MagicNetworkMonitoring.Rules.Delete( context.TODO(), "2890e6fa406311ed9b5a23f70f6fb8cf", magic_network_monitoring.RuleDeleteParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", magicNetworkMonitoringRule.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 - `type MagicNetworkMonitoringRule struct{…}` - `AutomaticAdvertisement 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 string` 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 []string` - `Type MagicNetworkMonitoringRuleType` MNM rule type. - `const MagicNetworkMonitoringRuleTypeThreshold MagicNetworkMonitoringRuleType = "threshold"` - `const MagicNetworkMonitoringRuleTypeZscore MagicNetworkMonitoringRuleType = "zscore"` - `const MagicNetworkMonitoringRuleTypeAdvancedDDoS MagicNetworkMonitoringRuleType = "advanced_ddos"` - `ID string` The id of the rule. Must be unique. - `BandwidthThreshold float64` 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 MagicNetworkMonitoringRuleDuration` 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"]. - `const MagicNetworkMonitoringRuleDuration1m MagicNetworkMonitoringRuleDuration = "1m"` - `const MagicNetworkMonitoringRuleDuration5m MagicNetworkMonitoringRuleDuration = "5m"` - `const MagicNetworkMonitoringRuleDuration10m MagicNetworkMonitoringRuleDuration = "10m"` - `const MagicNetworkMonitoringRuleDuration15m MagicNetworkMonitoringRuleDuration = "15m"` - `const MagicNetworkMonitoringRuleDuration20m MagicNetworkMonitoringRuleDuration = "20m"` - `const MagicNetworkMonitoringRuleDuration30m MagicNetworkMonitoringRuleDuration = "30m"` - `const MagicNetworkMonitoringRuleDuration45m MagicNetworkMonitoringRuleDuration = "45m"` - `const MagicNetworkMonitoringRuleDuration60m MagicNetworkMonitoringRuleDuration = "60m"` - `PacketThreshold float64` 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. - `PrefixMatch MagicNetworkMonitoringRulePrefixMatch` Prefix match type to be applied for a prefix auto advertisement when using an advanced_ddos rule. - `const MagicNetworkMonitoringRulePrefixMatchExact MagicNetworkMonitoringRulePrefixMatch = "exact"` - `const MagicNetworkMonitoringRulePrefixMatchSubnet MagicNetworkMonitoringRulePrefixMatch = "subnet"` - `const MagicNetworkMonitoringRulePrefixMatchSupernet MagicNetworkMonitoringRulePrefixMatch = "supernet"` - `ZscoreSensitivity MagicNetworkMonitoringRuleZscoreSensitivity` Level of sensitivity set for zscore rules. - `const MagicNetworkMonitoringRuleZscoreSensitivityLow MagicNetworkMonitoringRuleZscoreSensitivity = "low"` - `const MagicNetworkMonitoringRuleZscoreSensitivityMedium MagicNetworkMonitoringRuleZscoreSensitivity = "medium"` - `const MagicNetworkMonitoringRuleZscoreSensitivityHigh MagicNetworkMonitoringRuleZscoreSensitivity = "high"` - `ZscoreTarget MagicNetworkMonitoringRuleZscoreTarget` Target of the zscore rule analysis. - `const MagicNetworkMonitoringRuleZscoreTargetBits MagicNetworkMonitoringRuleZscoreTarget = "bits"` - `const MagicNetworkMonitoringRuleZscoreTargetPackets MagicNetworkMonitoringRuleZscoreTarget = "packets"` # Advertisements ## Update advertisement for rule `client.MagicNetworkMonitoring.Rules.Advertisements.Edit(ctx, ruleID, params) (*Advertisement, error)` **patch** `/accounts/{account_id}/mnm/rules/{rule_id}/advertisement` Update advertisement for rule. ### Parameters - `ruleID string` The id of the rule. Must be unique. - `params RuleAdvertisementEditParams` - `AccountID param.Field[string]` Path param - `Body param.Field[unknown]` Body param ### Returns - `type Advertisement struct{…}` - `AutomaticAdvertisement 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 ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_network_monitoring" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) advertisement, err := client.MagicNetworkMonitoring.Rules.Advertisements.Edit( context.TODO(), "2890e6fa406311ed9b5a23f70f6fb8cf", magic_network_monitoring.RuleAdvertisementEditParams{ AccountID: cloudflare.F("6f91088a406011ed95aed352566e8d4c"), Body: map[string]interface{}{ }, }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", advertisement.AutomaticAdvertisement) } ``` #### 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 - `type Advertisement struct{…}` - `AutomaticAdvertisement 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.