{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/azure-networking-services/json-schema/azure-networking-services-ddos-custom-policy-schema.json",
  "title": "DdosCustomPolicy",
  "description": "A DDoS custom policy in a resource group.",
  "x-generated": "2026-11-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/azure-networking-services-ddoscustompolicies-api-openapi.yml#/components/schemas/DdosCustomPolicy",
  "type": "object",
  "properties": {
    "properties": {
      "$ref": "#/$defs/DdosCustomPolicyPropertiesFormat",
      "description": "Properties of the DDoS custom policy.",
      "x-ms-client-flatten": true
    },
    "etag": {
      "type": "string",
      "description": "A unique read-only string that changes whenever the resource is updated.",
      "readOnly": true
    }
  },
  "allOf": [
    {
      "$ref": "#/$defs/Resource"
    }
  ],
  "$defs": {
    "DdosContinent": {
      "type": "string",
      "description": "A continent used for DDoS geographic source matching.",
      "enum": [
        "Africa",
        "Antarctica",
        "Asia",
        "Europe",
        "NorthAmerica",
        "Oceania",
        "SouthAmerica"
      ],
      "x-ms-enum": {
        "name": "DdosContinent",
        "modelAsString": true,
        "values": [
          {
            "name": "Africa",
            "value": "Africa",
            "description": "Matches traffic originating from countries and territories in Africa."
          },
          {
            "name": "Antarctica",
            "value": "Antarctica",
            "description": "Matches traffic originating from Antarctica."
          },
          {
            "name": "Asia",
            "value": "Asia",
            "description": "Matches traffic originating from countries and territories in Asia."
          },
          {
            "name": "Europe",
            "value": "Europe",
            "description": "Matches traffic originating from countries and territories in Europe."
          },
          {
            "name": "NorthAmerica",
            "value": "NorthAmerica",
            "description": "Matches traffic originating from countries and territories in North America."
          },
          {
            "name": "Oceania",
            "value": "Oceania",
            "description": "Matches traffic originating from countries and territories in Oceania."
          },
          {
            "name": "SouthAmerica",
            "value": "SouthAmerica",
            "description": "Matches traffic originating from countries and territories in South America."
          }
        ]
      }
    },
    "DdosCustomPolicyPropertiesFormat": {
      "type": "object",
      "description": "DDoS custom policy properties.",
      "properties": {
        "resourceGuid": {
          "type": "string",
          "description": "The resource GUID property of the DDoS custom policy resource. It uniquely identifies the resource, even if the user changes its name or migrate the resource across subscriptions or resource groups.",
          "readOnly": true
        },
        "provisioningState": {
          "$ref": "#/$defs/ProvisioningState",
          "description": "The provisioning state of the DDoS custom policy resource.",
          "readOnly": true
        },
        "detectionRules": {
          "type": "array",
          "description": "The list of DDoS detection rules associated with the custom policy.",
          "items": {
            "$ref": "#/$defs/DdosDetectionRule"
          }
        },
        "mitigationRules": {
          "type": "array",
          "description": "The list of DDoS mitigation rules associated with the custom policy.",
          "items": {
            "$ref": "#/$defs/DdosMitigationRule"
          },
          "x-ms-identifiers": [
            "name"
          ]
        },
        "frontEndIpConfiguration": {
          "type": "array",
          "description": "The list of frontend IP configurations associated with the custom policy.",
          "items": {
            "$ref": "#/$defs/SubResource"
          }
        },
        "publicIPAddresses": {
          "type": "array",
          "description": "The list of public IP addresses associated with the custom policy. This list is read-only.",
          "items": {
            "$ref": "#/$defs/SubResource"
          },
          "readOnly": true
        }
      }
    },
    "DdosDetectionMode": {
      "type": "string",
      "description": "The detection mode for the DDoS detection rule.",
      "enum": [
        "TrafficThreshold"
      ],
      "x-ms-enum": {
        "name": "DdosDetectionMode",
        "modelAsString": true,
        "values": [
          {
            "name": "TrafficThreshold",
            "value": "TrafficThreshold",
            "description": "TrafficThreshold"
          }
        ]
      }
    },
    "DdosDetectionRule": {
      "type": "object",
      "description": "A DDoS detection rule resource.",
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the DDoS detection rule."
        },
        "id": {
          "type": "string",
          "description": "The resource ID of the DDoS detection rule.",
          "readOnly": true
        },
        "etag": {
          "type": "string",
          "description": "A unique read-only string that changes whenever the resource is updated.",
          "readOnly": true
        },
        "type": {
          "type": "string",
          "description": "The resource type.",
          "readOnly": true
        },
        "properties": {
          "$ref": "#/$defs/DdosDetectionRulePropertiesFormat",
          "description": "Properties of the DDoS detection rule.",
          "x-ms-client-flatten": true
        }
      },
      "allOf": [
        {
          "$ref": "#/$defs/SubResource"
        }
      ]
    },
    "DdosDetectionRulePropertiesFormat": {
      "type": "object",
      "description": "DDoS detection rule properties.",
      "properties": {
        "provisioningState": {
          "$ref": "#/$defs/ProvisioningState",
          "description": "The provisioning state of the DDoS detection rule.",
          "readOnly": true
        },
        "detectionMode": {
          "$ref": "#/$defs/DdosDetectionMode",
          "description": "The detection mode for the DDoS detection rule."
        },
        "trafficDetectionRule": {
          "$ref": "#/$defs/TrafficDetectionRule",
          "description": "The traffic detection rule details."
        }
      }
    },
    "DdosGeoMatch": {
      "type": "object",
      "description": "A geographic source match. The service validates that at least one of continent or countryCode is specified. If both are specified, the service validates that the country belongs to the continent according to the service-defined mapping. For example, RU, TR, and KZ map to Asia, EG maps to Africa, and CY maps to Europe.",
      "properties": {
        "continent": {
          "$ref": "#/$defs/DdosContinent",
          "description": "The continent to match. Country membership follows the service-defined mapping documented on DdosGeoMatch."
        },
        "countryCode": {
          "type": "string",
          "description": "The uppercase two-letter ISO 3166-1 alpha-2 code for the country or territory to match.",
          "pattern": "^[A-Z]{2}$"
        }
      }
    },
    "DdosMitigationRule": {
      "type": "object",
      "description": "A DDoS mitigation rule resource.",
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the DDoS mitigation rule."
        },
        "id": {
          "type": "string",
          "description": "The resource ID of the DDoS mitigation rule.",
          "readOnly": true
        },
        "etag": {
          "type": "string",
          "description": "A unique read-only string that changes whenever the resource is updated.",
          "readOnly": true
        },
        "type": {
          "type": "string",
          "description": "The resource type.",
          "readOnly": true
        },
        "properties": {
          "$ref": "#/$defs/DdosMitigationRulePropertiesFormat",
          "description": "Properties of the DDoS mitigation rule."
        }
      },
      "required": [
        "name",
        "properties"
      ],
      "allOf": [
        {
          "$ref": "#/$defs/SubResource"
        }
      ]
    },
    "DdosMitigationRulePropertiesFormat": {
      "type": "object",
      "description": "DDoS mitigation rule properties. The service validates that each rule specifies at least one applicable default mitigation or source policy override and that the default mitigations match the selected trafficScope.",
      "properties": {
        "provisioningState": {
          "$ref": "#/$defs/ProvisioningState",
          "description": "The provisioning state of the DDoS mitigation rule.",
          "readOnly": true
        },
        "trafficScope": {
          "$ref": "#/$defs/DdosMitigationTrafficScope",
          "description": "The traffic protocol to which the mitigation rule applies."
        },
        "tcpDefaultMitigations": {
          "$ref": "#/$defs/DdosTcpDefaultMitigations",
          "description": "The default TCP mitigations. This property is valid only when trafficScope is Tcp."
        },
        "udpDefaultMitigations": {
          "$ref": "#/$defs/DdosUdpDefaultMitigations",
          "description": "The default UDP mitigations. This property is valid only when trafficScope is Udp."
        },
        "sourcePolicyOverrides": {
          "type": "array",
          "description": "Source-specific actions that override the default mitigations. A rule supports at most one Deny override and one Permit override.",
          "items": {
            "$ref": "#/$defs/DdosSourcePolicyOverride"
          },
          "x-ms-identifiers": [
            "policyAction/actionType"
          ]
        }
      },
      "required": [
        "trafficScope"
      ]
    },
    "DdosMitigationTrafficScope": {
      "type": "string",
      "description": "The traffic protocol to which a DDoS mitigation rule applies.",
      "enum": [
        "Tcp",
        "Udp"
      ],
      "x-ms-enum": {
        "name": "DdosMitigationTrafficScope",
        "modelAsString": true,
        "values": [
          {
            "name": "Tcp",
            "value": "Tcp",
            "description": "TCP traffic."
          },
          {
            "name": "Udp",
            "value": "Udp",
            "description": "UDP traffic."
          }
        ]
      }
    },
    "DdosSourceMatchConditions": {
      "type": "object",
      "description": "Source conditions for a DDoS source policy override. A source matches when it matches any IP prefix or any geographic match.",
      "properties": {
        "ipPrefixes": {
          "type": "array",
          "description": "The IPv4 or IPv6 CIDR prefixes in `<address>/<prefix-length>` format. Entries are evaluated with OR semantics.",
          "items": {
            "type": "string"
          }
        },
        "geoMatches": {
          "type": "array",
          "description": "The geographic matches. Entries are evaluated with OR semantics.",
          "items": {
            "$ref": "#/$defs/DdosGeoMatch"
          },
          "x-ms-identifiers": []
        }
      }
    },
    "DdosSourcePolicyAction": {
      "type": "object",
      "description": "The action to apply to traffic matching a source policy override.",
      "properties": {
        "actionType": {
          "$ref": "#/$defs/DdosSourcePolicyActionType",
          "description": "The source policy action type."
        }
      },
      "required": [
        "actionType"
      ]
    },
    "DdosSourcePolicyActionType": {
      "type": "string",
      "description": "The action applied to traffic matching a source policy override.",
      "enum": [
        "Deny",
        "Permit"
      ],
      "x-ms-enum": {
        "name": "DdosSourcePolicyActionType",
        "modelAsString": true,
        "values": [
          {
            "name": "Deny",
            "value": "Deny",
            "description": "Deny traffic from matching sources."
          },
          {
            "name": "Permit",
            "value": "Permit",
            "description": "Permit traffic from matching sources."
          }
        ]
      }
    },
    "DdosSourcePolicyOverride": {
      "type": "object",
      "description": "A source-specific action that overrides the default mitigations.",
      "properties": {
        "policyAction": {
          "$ref": "#/$defs/DdosSourcePolicyAction",
          "description": "The action to apply to matching traffic."
        },
        "conditions": {
          "$ref": "#/$defs/DdosSourceMatchConditions",
          "description": "The source conditions that select traffic for the action."
        }
      },
      "required": [
        "policyAction",
        "conditions"
      ]
    },
    "DdosTcpDefaultMitigations": {
      "type": "object",
      "description": "Default mitigations for TCP traffic.",
      "properties": {
        "perSourceRateLimiting": {
          "$ref": "#/$defs/DdosTcpPerSourceRateLimitPolicy",
          "description": "The per-source TCP packet rate limit."
        },
        "perSourceConnectionRateLimiting": {
          "$ref": "#/$defs/DdosTcpPerSourceConnectionRateLimitPolicy",
          "description": "The per-source rate limit for new TCP connection establishments."
        }
      }
    },
    "DdosTcpPerSourceConnectionRateLimitPolicy": {
      "type": "object",
      "description": "A per-source TCP connection establishment rate limit.",
      "properties": {
        "connectionsPerSecond": {
          "type": "integer",
          "format": "int32",
          "description": "The maximum number of new TCP connections established per second from a source IP."
        }
      },
      "required": [
        "connectionsPerSecond"
      ]
    },
    "DdosTcpPerSourceRateLimitPolicy": {
      "type": "object",
      "description": "A per-source TCP packet rate limit.",
      "properties": {
        "packetsPerSecond": {
          "type": "integer",
          "format": "int32",
          "description": "The maximum number of TCP packets allowed per second from a source IP."
        }
      },
      "required": [
        "packetsPerSecond"
      ]
    },
    "DdosTrafficType": {
      "type": "string",
      "description": "The traffic type (one of Tcp, Udp, TcpSyn) that the detection rule will be applied upon.",
      "enum": [
        "Tcp",
        "Udp",
        "TcpSyn"
      ],
      "x-ms-enum": {
        "name": "DdosTrafficType",
        "modelAsString": true,
        "values": [
          {
            "name": "Tcp",
            "value": "Tcp",
            "description": "Tcp"
          },
          {
            "name": "Udp",
            "value": "Udp",
            "description": "Udp"
          },
          {
            "name": "TcpSyn",
            "value": "TcpSyn",
            "description": "TcpSyn"
          }
        ]
      }
    },
    "DdosUdpDefaultMitigations": {
      "type": "object",
      "description": "Default mitigations for UDP traffic.",
      "properties": {
        "perSourceRateLimiting": {
          "$ref": "#/$defs/DdosUdpPerSourceRateLimitPolicy",
          "description": "The per-source UDP packet rate limit."
        }
      }
    },
    "DdosUdpPerSourceRateLimitPolicy": {
      "type": "object",
      "description": "A per-source UDP packet rate limit.",
      "properties": {
        "packetsPerSecond": {
          "type": "integer",
          "format": "int32",
          "description": "The maximum number of UDP packets allowed per second from a source IP."
        }
      },
      "required": [
        "packetsPerSecond"
      ]
    },
    "ProvisioningState": {
      "type": "string",
      "description": "Provisioning states of a resource.",
      "enum": [
        "Failed",
        "Succeeded",
        "Canceled",
        "Creating",
        "Updating",
        "Deleting"
      ],
      "x-ms-enum": {
        "name": "ProvisioningState",
        "modelAsString": true,
        "values": [
          {
            "name": "Failed",
            "value": "Failed",
            "description": "Failed"
          },
          {
            "name": "Succeeded",
            "value": "Succeeded",
            "description": "Succeeded"
          },
          {
            "name": "Canceled",
            "value": "Canceled",
            "description": "Canceled"
          },
          {
            "name": "Creating",
            "value": "Creating",
            "description": "Creating"
          },
          {
            "name": "Updating",
            "value": "Updating",
            "description": "Updating"
          },
          {
            "name": "Deleting",
            "value": "Deleting",
            "description": "Deleting"
          }
        ]
      }
    },
    "Resource": {
      "type": "object",
      "description": "Common resource representation.",
      "properties": {
        "id": {
          "type": "string",
          "description": "Resource ID."
        },
        "name": {
          "type": "string",
          "description": "Resource name.",
          "readOnly": true
        },
        "type": {
          "type": "string",
          "description": "Resource type.",
          "readOnly": true
        },
        "location": {
          "type": "string",
          "description": "Resource location."
        },
        "tags": {
          "type": "object",
          "description": "Resource tags.",
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "x-ms-azure-resource": true
    },
    "SubResource": {
      "type": "object",
      "description": "Reference to another subresource.",
      "properties": {
        "id": {
          "type": "string",
          "description": "Resource ID."
        }
      }
    },
    "TrafficDetectionRule": {
      "type": "object",
      "description": "Ddos Custom Policy traffic detection rule.",
      "properties": {
        "trafficType": {
          "$ref": "#/$defs/DdosTrafficType",
          "description": "The traffic type (one of Tcp, Udp, TcpSyn) that the detection rule will be applied upon."
        },
        "packetsPerSecond": {
          "type": "integer",
          "format": "int32",
          "description": "The customized packets per second threshold."
        }
      }
    }
  }
}