roto-api-native 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,84 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ checks:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.11"
19
+
20
+ - name: Install Rust
21
+ uses: dtolnay/rust-toolchain@stable
22
+
23
+ - name: Install tooling
24
+ run: python -m pip install --upgrade pip maturin pytest
25
+
26
+ - name: Rust check
27
+ run: cargo check
28
+
29
+ - name: Python tests
30
+ run: pytest
31
+
32
+ - name: Build wheel
33
+ run: maturin build --release --out dist
34
+
35
+ - name: Smoke test wheel
36
+ run: |
37
+ python -m pip install dist/*.whl
38
+ python -c "import roto_api; print(roto_api.__version__)"
39
+
40
+ wheels:
41
+ name: ${{ matrix.os }} / ${{ matrix.target }}
42
+ runs-on: ${{ matrix.os }}
43
+ strategy:
44
+ fail-fast: false
45
+ matrix:
46
+ include:
47
+ - os: ubuntu-latest
48
+ target: x86_64-unknown-linux-gnu
49
+ - os: windows-latest
50
+ target: x86_64-pc-windows-msvc
51
+
52
+ steps:
53
+ - uses: actions/checkout@v4
54
+
55
+ - name: Build wheel
56
+ uses: PyO3/maturin-action@v1
57
+ with:
58
+ target: ${{ matrix.target }}
59
+ args: --release --out dist
60
+ manylinux: auto
61
+ sccache: true
62
+
63
+ - name: Upload wheel
64
+ uses: actions/upload-artifact@v4
65
+ with:
66
+ name: wheels-${{ matrix.target }}
67
+ path: dist/*.whl
68
+
69
+ sdist:
70
+ runs-on: ubuntu-latest
71
+ steps:
72
+ - uses: actions/checkout@v4
73
+
74
+ - name: Build sdist
75
+ uses: PyO3/maturin-action@v1
76
+ with:
77
+ command: sdist
78
+ args: --out dist
79
+
80
+ - name: Upload sdist
81
+ uses: actions/upload-artifact@v4
82
+ with:
83
+ name: sdist
84
+ path: dist/*.tar.gz
@@ -0,0 +1,75 @@
1
+ name: Publish To PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ build:
11
+ name: ${{ matrix.os }} / ${{ matrix.target }}
12
+ runs-on: ${{ matrix.os }}
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ include:
17
+ - os: ubuntu-latest
18
+ target: x86_64-unknown-linux-gnu
19
+ - os: windows-latest
20
+ target: x86_64-pc-windows-msvc
21
+
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+
25
+ - name: Build wheel
26
+ uses: PyO3/maturin-action@v1
27
+ with:
28
+ target: ${{ matrix.target }}
29
+ args: --release --out dist
30
+ manylinux: auto
31
+ sccache: true
32
+
33
+ - name: Upload wheel
34
+ uses: actions/upload-artifact@v4
35
+ with:
36
+ name: wheels-${{ matrix.target }}
37
+ path: dist/*.whl
38
+
39
+ sdist:
40
+ runs-on: ubuntu-latest
41
+ steps:
42
+ - uses: actions/checkout@v4
43
+
44
+ - name: Build sdist
45
+ uses: PyO3/maturin-action@v1
46
+ with:
47
+ command: sdist
48
+ args: --out dist
49
+
50
+ - name: Upload sdist
51
+ uses: actions/upload-artifact@v4
52
+ with:
53
+ name: sdist
54
+ path: dist/*.tar.gz
55
+
56
+ publish:
57
+ needs:
58
+ - build
59
+ - sdist
60
+ runs-on: ubuntu-latest
61
+ permissions:
62
+ id-token: write
63
+ environment:
64
+ name: pypi
65
+ url: https://pypi.org/p/roto-api-native
66
+ steps:
67
+ - name: Download all artifacts
68
+ uses: actions/download-artifact@v4
69
+ with:
70
+ path: dist
71
+ pattern: "*"
72
+ merge-multiple: true
73
+
74
+ - name: Publish to PyPI
75
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,81 @@
1
+ ## File system
2
+ .DS_Store
3
+ desktop.ini
4
+
5
+ ## Editor
6
+ *.swp
7
+ *.swo
8
+ Session.vim
9
+ .cproject
10
+ .idea
11
+ *.iml
12
+ .vscode
13
+ .project
14
+ .favorites.json
15
+ .settings/
16
+
17
+ ## Tool
18
+ .valgrindrc
19
+ .cargo
20
+
21
+ ## Configuration
22
+ /config.toml
23
+ /Makefile
24
+ config.mk
25
+ config.stamp
26
+ no_llvm_build
27
+
28
+ ## Build
29
+ /dl/
30
+ /doc/
31
+ /inst/
32
+ /llvm/
33
+ /mingw-build/
34
+ /build/
35
+ /dist/
36
+ /unicode-downloads
37
+ /target
38
+ /src/tools/x/target
39
+ # Generated by compiletest for incremental
40
+ /tmp/
41
+ # Created by default with `src/ci/docker/run.sh`
42
+ /obj/
43
+
44
+ ## Temporary files
45
+ *~
46
+ \#*
47
+ \#*\#
48
+ .#*
49
+
50
+ ## Tags
51
+ tags
52
+ tags.*
53
+ TAGS
54
+ TAGS.*
55
+
56
+ ## Python
57
+ __pycache__/
58
+ *.py[cod]
59
+ *$py.class
60
+ .pkgtest/
61
+ .tmp/
62
+ tests/.work/
63
+ .pytest_cache/
64
+ .mypy_cache/
65
+ .ruff_cache/
66
+ .coverage
67
+ .coverage.*
68
+ htmlcov/
69
+ .venv/
70
+ venv/
71
+ *.egg-info/
72
+
73
+ ## Node
74
+ **node_modules
75
+
76
+ ## This repo
77
+ /data
78
+ /downloads
79
+ /dist
80
+ /target/wheels
81
+ /*.whl
@@ -0,0 +1,141 @@
1
+ # API Reference
2
+
3
+ ## Package
4
+
5
+ Install name:
6
+ - `roto-api-native`
7
+
8
+ Import name:
9
+ - `roto_api`
10
+
11
+ ## Public Symbols
12
+
13
+ ### `roto_api.__version__`
14
+
15
+ String package version.
16
+
17
+ ## Functions
18
+
19
+ ### `roto_api.load_lookup(data_dir)`
20
+
21
+ Loads the Rust lookup engine from an already prepared data directory.
22
+
23
+ Parameters:
24
+ - `data_dir`: directory containing generated CSV files
25
+
26
+ Returns:
27
+ - `RotoLookup`
28
+
29
+ Example:
30
+
31
+ ```python
32
+ from roto_api import load_lookup
33
+
34
+ lookup = load_lookup("./data")
35
+ ```
36
+
37
+ ### `roto_api.open_lookup(data_dir)`
38
+
39
+ Alias for `load_lookup(data_dir)`.
40
+
41
+ Parameters:
42
+ - `data_dir`: directory containing a prepared local dataset snapshot
43
+
44
+ Returns:
45
+ - `RotoLookup`
46
+
47
+ Example:
48
+
49
+ ```python
50
+ from roto_api import open_lookup
51
+
52
+ lookup = open_lookup("./data")
53
+ ```
54
+
55
+ ## Class `roto_api.RotoLookup`
56
+
57
+ ### `RotoLookup(prefixes_file, ris_files, timestamps_dir=None)`
58
+
59
+ Build a lookup object from explicit file paths.
60
+
61
+ Parameters:
62
+ - `prefixes_file`: path to `delegated_all.csv`
63
+ - `ris_files`: list of RIS Whois CSV paths, usually IPv4 and IPv6
64
+ - `timestamps_dir`: optional directory containing timestamp CSV files; defaults to the prefix file's parent
65
+
66
+ ### `RotoLookup.from_data_dir(data_dir)`
67
+
68
+ Convenience constructor that expects:
69
+
70
+ - `delegated_all.csv`
71
+ - one or both of `pfx_asn_dfz_v4.csv` and `pfx_asn_dfz_v6.csv`
72
+
73
+ Optional metadata files:
74
+
75
+ - `del_ext.timestamps.json`
76
+ - `riswhois.timestamps.json`
77
+
78
+ If those metadata files are absent, the lookup still loads and `source_status()` returns an empty list.
79
+
80
+ Returns:
81
+ - `RotoLookup`
82
+
83
+ ### `RotoLookup.lookup_ip(ip)`
84
+
85
+ Run a single-IP longest-prefix lookup.
86
+
87
+ Parameters:
88
+ - `ip`: string IPv4 or IPv6 address
89
+
90
+ Returns:
91
+ - dict with:
92
+ - `ip`: original input IP
93
+ - `prefix`: matched prefix string or `None`
94
+ - `origin_asns`: list of origin ASN strings like `["AS15169"]`
95
+ - `match_type`: match type string
96
+
97
+ Example:
98
+
99
+ ```python
100
+ result = lookup.lookup_ip("8.8.8.8")
101
+ ```
102
+
103
+ ### `RotoLookup.lookup_ips(ips)`
104
+
105
+ Run longest-prefix lookup for many IPs in one Rust call.
106
+
107
+ Parameters:
108
+ - `ips`: list of string IPv4/IPv6 addresses
109
+
110
+ Returns:
111
+ - list of result dicts with the same schema as `lookup_ip`
112
+
113
+ Example:
114
+
115
+ ```python
116
+ results = lookup.lookup_ips(["8.8.8.8", "1.1.1.1"])
117
+ ```
118
+
119
+ ### `RotoLookup.source_status()`
120
+
121
+ Return metadata about the currently loaded sources.
122
+
123
+ Returns:
124
+ - list of dicts containing:
125
+ - `type`: `rir-alloc` or `bgp`
126
+ - `id`: source identifier
127
+ - `serial`: source serial/timestamp integer
128
+ - `last_updated`: RFC3339 timestamp string
129
+
130
+ If the loaded snapshot does not include timestamp metadata files, this returns an empty list.
131
+
132
+ ## Dump Preparation
133
+
134
+ Dump download and transformation are intentionally outside the published package.
135
+
136
+ Use `scripts/bootstrap_data.py` or your own application code to prepare:
137
+
138
+ - `delegated_all.csv`
139
+ - `pfx_asn_dfz_v4.csv`
140
+ - `pfx_asn_dfz_v6.csv`
141
+ - optional timestamp metadata files