Configuration Classes¶
Configuration classes for creating BGP streams.
BGPStreamConfig¶
pybgpkitstream.bgpstreamconfig.BGPStreamConfig
pydantic-model
¶
Bases: BaseModel
Unified BGPStream config
Show JSON schema:
{
"$defs": {
"FilterOptions": {
"description": "A unified model for the available filter options.",
"properties": {
"origin_asn": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the origin AS number.",
"title": "Origin Asn"
},
"prefix": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by an exact prefix match.",
"title": "Prefix"
},
"prefix_super": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the exact prefix and its more general super-prefixes.",
"title": "Prefix Super"
},
"prefix_sub": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the exact prefix and its more specific sub-prefixes.",
"title": "Prefix Sub"
},
"prefix_super_sub": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the exact prefix and both its super- and sub-prefixes.",
"title": "Prefix Super Sub"
},
"peer_ip": {
"anyOf": [
{
"type": "string"
},
{
"format": "ipv4",
"type": "string"
},
{
"format": "ipv6",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the IP address of a single BGP peer.",
"title": "Peer Ip"
},
"peer_ips": {
"anyOf": [
{
"items": {
"anyOf": [
{
"type": "string"
},
{
"format": "ipv4",
"type": "string"
},
{
"format": "ipv6",
"type": "string"
}
]
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by a list of BGP peer IP addresses.",
"title": "Peer Ips"
},
"peer_asn": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the AS number of the BGP peer.",
"title": "Peer Asn"
},
"update_type": {
"anyOf": [
{
"enum": [
"withdraw",
"announce"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the BGP update message type.",
"title": "Update Type"
},
"as_path": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by a regular expression matching the AS path.",
"title": "As Path"
},
"ip_version": {
"anyOf": [
{
"enum": [
4,
6
],
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by ip version.",
"title": "Ip Version"
}
},
"title": "FilterOptions",
"type": "object"
}
},
"description": "Unified BGPStream config",
"properties": {
"start_time": {
"anyOf": [
{
"format": "date-time",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Start of the stream",
"title": "Start Time"
},
"end_time": {
"anyOf": [
{
"format": "date-time",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "End of the stream",
"title": "End Time"
},
"collectors": {
"description": "List of collectors to get data from",
"items": {
"type": "string"
},
"title": "Collectors",
"type": "array"
},
"data_types": {
"anyOf": [
{
"items": {
"enum": [
"ribs",
"updates"
],
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": [
"updates"
],
"description": "List of archives files to consider (`ribs` or `updates`)",
"title": "Data Types"
},
"filters": {
"anyOf": [
{
"$ref": "#/$defs/FilterOptions"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional filters"
}
},
"required": [
"collectors"
],
"title": "BGPStreamConfig",
"type": "object"
}
Fields:
-
start_time(datetime | None) -
end_time(datetime | None) -
collectors(list[str]) -
data_types(list[Literal['ribs', 'updates']] | None) -
filters(FilterOptions | None)
Validators:
-
normalize_to_utc→start_time,end_time -
validate
Source code in src/pybgpkitstream/bgpstreamconfig.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
start_time = None
pydantic-field
¶
Start of the stream
end_time = None
pydantic-field
¶
End of the stream
collectors
pydantic-field
¶
List of collectors to get data from
data_types = ['updates']
pydantic-field
¶
List of archives files to consider (ribs or updates)
filters = None
pydantic-field
¶
Optional filters
FilterOptions¶
pybgpkitstream.bgpstreamconfig.FilterOptions
pydantic-model
¶
Bases: BaseModel
A unified model for the available filter options.
Show JSON schema:
{
"description": "A unified model for the available filter options.",
"properties": {
"origin_asn": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the origin AS number.",
"title": "Origin Asn"
},
"prefix": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by an exact prefix match.",
"title": "Prefix"
},
"prefix_super": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the exact prefix and its more general super-prefixes.",
"title": "Prefix Super"
},
"prefix_sub": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the exact prefix and its more specific sub-prefixes.",
"title": "Prefix Sub"
},
"prefix_super_sub": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the exact prefix and both its super- and sub-prefixes.",
"title": "Prefix Super Sub"
},
"peer_ip": {
"anyOf": [
{
"type": "string"
},
{
"format": "ipv4",
"type": "string"
},
{
"format": "ipv6",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the IP address of a single BGP peer.",
"title": "Peer Ip"
},
"peer_ips": {
"anyOf": [
{
"items": {
"anyOf": [
{
"type": "string"
},
{
"format": "ipv4",
"type": "string"
},
{
"format": "ipv6",
"type": "string"
}
]
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by a list of BGP peer IP addresses.",
"title": "Peer Ips"
},
"peer_asn": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the AS number of the BGP peer.",
"title": "Peer Asn"
},
"update_type": {
"anyOf": [
{
"enum": [
"withdraw",
"announce"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the BGP update message type.",
"title": "Update Type"
},
"as_path": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by a regular expression matching the AS path.",
"title": "As Path"
},
"ip_version": {
"anyOf": [
{
"enum": [
4,
6
],
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by ip version.",
"title": "Ip Version"
}
},
"title": "FilterOptions",
"type": "object"
}
Fields:
-
origin_asn(int | None) -
prefix(str | None) -
prefix_super(str | None) -
prefix_sub(str | None) -
prefix_super_sub(str | None) -
peer_ip(str | IPv4Address | IPv6Address | None) -
peer_ips(list[str | IPv4Address | IPv6Address] | None) -
peer_asn(int | None) -
update_type(Literal['withdraw', 'announce'] | None) -
as_path(str | None) -
ip_version(Literal[4, 6] | None)
Source code in src/pybgpkitstream/bgpstreamconfig.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
origin_asn = None
pydantic-field
¶
Filter by the origin AS number.
prefix = None
pydantic-field
¶
Filter by an exact prefix match.
prefix_super = None
pydantic-field
¶
Filter by the exact prefix and its more general super-prefixes.
prefix_sub = None
pydantic-field
¶
Filter by the exact prefix and its more specific sub-prefixes.
prefix_super_sub = None
pydantic-field
¶
Filter by the exact prefix and both its super- and sub-prefixes.
peer_ip = None
pydantic-field
¶
Filter by the IP address of a single BGP peer.
peer_ips = None
pydantic-field
¶
Filter by a list of BGP peer IP addresses.
peer_asn = None
pydantic-field
¶
Filter by the AS number of the BGP peer.
update_type = None
pydantic-field
¶
Filter by the BGP update message type.
as_path = None
pydantic-field
¶
Filter by a regular expression matching the AS path.
ip_version = None
pydantic-field
¶
Filter by ip version.
LiveStreamConfig¶
pybgpkitstream.bgpstreamconfig.LiveStreamConfig
pydantic-model
¶
Bases: BaseModel
Config for live mode
Show JSON schema:
{
"$defs": {
"FilterOptions": {
"description": "A unified model for the available filter options.",
"properties": {
"origin_asn": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the origin AS number.",
"title": "Origin Asn"
},
"prefix": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by an exact prefix match.",
"title": "Prefix"
},
"prefix_super": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the exact prefix and its more general super-prefixes.",
"title": "Prefix Super"
},
"prefix_sub": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the exact prefix and its more specific sub-prefixes.",
"title": "Prefix Sub"
},
"prefix_super_sub": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the exact prefix and both its super- and sub-prefixes.",
"title": "Prefix Super Sub"
},
"peer_ip": {
"anyOf": [
{
"type": "string"
},
{
"format": "ipv4",
"type": "string"
},
{
"format": "ipv6",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the IP address of a single BGP peer.",
"title": "Peer Ip"
},
"peer_ips": {
"anyOf": [
{
"items": {
"anyOf": [
{
"type": "string"
},
{
"format": "ipv4",
"type": "string"
},
{
"format": "ipv6",
"type": "string"
}
]
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by a list of BGP peer IP addresses.",
"title": "Peer Ips"
},
"peer_asn": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the AS number of the BGP peer.",
"title": "Peer Asn"
},
"update_type": {
"anyOf": [
{
"enum": [
"withdraw",
"announce"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the BGP update message type.",
"title": "Update Type"
},
"as_path": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by a regular expression matching the AS path.",
"title": "As Path"
},
"ip_version": {
"anyOf": [
{
"enum": [
4,
6
],
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by ip version.",
"title": "Ip Version"
}
},
"title": "FilterOptions",
"type": "object"
}
},
"description": "Config for live mode",
"properties": {
"collectors": {
"description": "List of collectors to get data from (for now only RIS live collectors)",
"items": {
"type": "string"
},
"title": "Collectors",
"type": "array"
},
"filters": {
"anyOf": [
{
"$ref": "#/$defs/FilterOptions"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional filters"
},
"jitter_buffer_delay": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": 10.0,
"description": "Jitter buffer time in seconds to make sure RIS live updates are time-sorted. Introduce a slight delay. Set to None or 0 to disable",
"title": "Jitter Buffer Delay"
}
},
"required": [
"collectors"
],
"title": "LiveStreamConfig",
"type": "object"
}
Fields:
-
collectors(list[str]) -
filters(FilterOptions | None) -
jitter_buffer_delay(float | None)
Source code in src/pybgpkitstream/bgpstreamconfig.py
99 100 101 102 103 104 105 106 107 108 109 | |
collectors
pydantic-field
¶
List of collectors to get data from (for now only RIS live collectors)
filters = None
pydantic-field
¶
Optional filters
jitter_buffer_delay = 10.0
pydantic-field
¶
Jitter buffer time in seconds to make sure RIS live updates are time-sorted. Introduce a slight delay. Set to None or 0 to disable
PyBGPKITStreamConfig¶
pybgpkitstream.bgpstreamconfig.PyBGPKITStreamConfig
pydantic-model
¶
Bases: BaseModel
Unified BGPStream config and parameters related to PyBGPKIT implementation (all optional)
Show JSON schema:
{
"$defs": {
"BGPStreamConfig": {
"description": "Unified BGPStream config",
"properties": {
"start_time": {
"anyOf": [
{
"format": "date-time",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Start of the stream",
"title": "Start Time"
},
"end_time": {
"anyOf": [
{
"format": "date-time",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "End of the stream",
"title": "End Time"
},
"collectors": {
"description": "List of collectors to get data from",
"items": {
"type": "string"
},
"title": "Collectors",
"type": "array"
},
"data_types": {
"anyOf": [
{
"items": {
"enum": [
"ribs",
"updates"
],
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": [
"updates"
],
"description": "List of archives files to consider (`ribs` or `updates`)",
"title": "Data Types"
},
"filters": {
"anyOf": [
{
"$ref": "#/$defs/FilterOptions"
},
{
"type": "null"
}
],
"default": null,
"description": "Optional filters"
}
},
"required": [
"collectors"
],
"title": "BGPStreamConfig",
"type": "object"
},
"FilterOptions": {
"description": "A unified model for the available filter options.",
"properties": {
"origin_asn": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the origin AS number.",
"title": "Origin Asn"
},
"prefix": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by an exact prefix match.",
"title": "Prefix"
},
"prefix_super": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the exact prefix and its more general super-prefixes.",
"title": "Prefix Super"
},
"prefix_sub": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the exact prefix and its more specific sub-prefixes.",
"title": "Prefix Sub"
},
"prefix_super_sub": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the exact prefix and both its super- and sub-prefixes.",
"title": "Prefix Super Sub"
},
"peer_ip": {
"anyOf": [
{
"type": "string"
},
{
"format": "ipv4",
"type": "string"
},
{
"format": "ipv6",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the IP address of a single BGP peer.",
"title": "Peer Ip"
},
"peer_ips": {
"anyOf": [
{
"items": {
"anyOf": [
{
"type": "string"
},
{
"format": "ipv4",
"type": "string"
},
{
"format": "ipv6",
"type": "string"
}
]
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by a list of BGP peer IP addresses.",
"title": "Peer Ips"
},
"peer_asn": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the AS number of the BGP peer.",
"title": "Peer Asn"
},
"update_type": {
"anyOf": [
{
"enum": [
"withdraw",
"announce"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by the BGP update message type.",
"title": "Update Type"
},
"as_path": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by a regular expression matching the AS path.",
"title": "As Path"
},
"ip_version": {
"anyOf": [
{
"enum": [
4,
6
],
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "Filter by ip version.",
"title": "Ip Version"
}
},
"title": "FilterOptions",
"type": "object"
}
},
"description": "Unified BGPStream config and parameters related to PyBGPKIT implementation (all optional)",
"properties": {
"bgpstream_config": {
"anyOf": [
{
"$ref": "#/$defs/BGPStreamConfig"
},
{
"type": "null"
}
],
"default": null,
"description": "BGPStream config (optionnal, its fields can be passed directly to avoid nesting configs)"
},
"max_concurrent_downloads": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": 10,
"description": "Maximum concurrent downloads of archive files.",
"title": "Max Concurrent Downloads"
},
"cache_dir": {
"anyOf": [
{
"format": "directory-path",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Specifies the directory for caching downloaded files.",
"title": "Cache Dir"
},
"ram_fetch": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": false,
"description": "If caching is disabled, fetch temp files in shared RAM memory (/dev/shml) or normal disc temp dir (/tmp).Default (False) to reduce RAM usage.",
"title": "Ram Fetch"
},
"chunk_time": {
"anyOf": [
{
"format": "duration",
"type": "string"
},
{
"type": "null"
}
],
"default": "PT2H",
"description": "Interval for the fetch/parse cycles (benefits: avoid long prefetch time + periodic temps cleanup when caching is disabled).Lower value means less RAM/disk used at the cost of performance.",
"title": "Chunk Time"
},
"parser": {
"default": "pybgpkit",
"description": "MRT files parser. Default `pybgpkit` is installed but slow, the others are system dependencies.",
"enum": [
"pybgpkit",
"bgpkit",
"pybgpstream",
"bgpdump"
],
"title": "Parser",
"type": "string"
}
},
"title": "PyBGPKITStreamConfig",
"type": "object"
}
Fields:
-
bgpstream_config(BGPStreamConfig | None) -
max_concurrent_downloads(int | None) -
cache_dir(DirectoryPath | None) -
ram_fetch(bool | None) -
chunk_time(timedelta | None) -
parser(Literal['pybgpkit', 'bgpkit', 'pybgpstream', 'bgpdump'])
Validators:
-
check_parser_available→parser -
nest_bgpstream_params
Source code in src/pybgpkitstream/bgpstreamconfig.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
bgpstream_config = None
pydantic-field
¶
BGPStream config (optionnal, its fields can be passed directly to avoid nesting configs)
max_concurrent_downloads = 10
pydantic-field
¶
Maximum concurrent downloads of archive files.
cache_dir = None
pydantic-field
¶
Specifies the directory for caching downloaded files.
ram_fetch = False
pydantic-field
¶
If caching is disabled, fetch temp files in shared RAM memory (/dev/shml) or normal disc temp dir (/tmp).Default (False) to reduce RAM usage.
chunk_time = datetime.timedelta(hours=2)
pydantic-field
¶
Interval for the fetch/parse cycles (benefits: avoid long prefetch time + periodic temps cleanup when caching is disabled).Lower value means less RAM/disk used at the cost of performance.
parser = 'pybgpkit'
pydantic-field
¶
MRT files parser. Default pybgpkit is installed but slow, the others are system dependencies.
nest_bgpstream_params(data)
pydantic-validator
¶
Allow to define a flat config
Source code in src/pybgpkitstream/bgpstreamconfig.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |