Skip to content

Commit e8040ec

Browse files
committed
Initial commit
1 parent 24eb36a commit e8040ec

18 files changed

Lines changed: 671 additions & 0 deletions

.bumpversion.cfg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[bumpversion]
2+
current_version = 0.1.0
3+
commit = True
4+
tag = True
5+
6+
[bumpversion:file:pyproject.toml]
7+
search = version = "{current_version}"
8+
replace = version = "{new_version}"

.github/workflows/main.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: cicd
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "*"
9+
pull_request:
10+
11+
jobs:
12+
code-scan:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
strategy:
17+
matrix:
18+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
28+
- name: Install dependencies
29+
run: pip install --no-cache-dir -U pip black flake8 bandit
30+
31+
- name: Lint with flake8
32+
run: flake8 pyproxy tests benchmark
33+
34+
- name: Check with black
35+
run: black --check pyproxy tests benchmark
36+
37+
- name: Check with bandit
38+
run: bandit -r pyproxy tests benchmark
39+
40+
unittest:
41+
needs: code-scan
42+
runs-on: ubuntu-latest
43+
permissions:
44+
contents: read
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- name: Set up Python
50+
uses: actions/setup-python@v5
51+
with:
52+
python-version: 3.13
53+
54+
- name: Install build dependencies
55+
run: pip install --no-cache-dir -r requirements.txt
56+
57+
- name: Run tests
58+
run: python -m unittest discover -s tests
59+
60+
build-packages:
61+
needs: unittest
62+
if: github.event_name == 'push'
63+
runs-on: ubuntu-latest
64+
permissions:
65+
contents: write
66+
id-token: write
67+
68+
steps:
69+
- uses: actions/checkout@v4
70+
71+
- name: Set up Python
72+
uses: actions/setup-python@v5
73+
with:
74+
python-version: 3.13
75+
76+
- name: Get version
77+
id: get_version
78+
run: |
79+
version=$(grep '^__version__' pyproxy_sdk/__init__.py | cut -d'"' -f2)
80+
echo "version=${version}" >> $GITHUB_OUTPUT
81+
82+
- name: Create Tag
83+
run: |
84+
git config user.name "github-actions[bot]"
85+
git config user.email "github-actions[bot]@users.noreply.github.com"
86+
git tag v${{ steps.get_version.outputs.version }}
87+
git push origin v${{ steps.get_version.outputs.version }}
88+
89+
- name: Create GitHub Release
90+
id: create_release
91+
uses: actions/create-release@v1
92+
with:
93+
tag_name: v${{ steps.get_version.outputs.version }}
94+
release_name: Release v${{ steps.get_version.outputs.version }}
95+
draft: false
96+
prerelease: false
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+
100+
- name: Install build dependencies
101+
run: pip install --no-cache-dir -U pip . build
102+
103+
- name: Build package
104+
run: python -m build --sdist --wheel
105+
- name: Upload built distributions
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: dist
109+
path: dist
110+
111+
- name: Install release dependencies
112+
run: pip install --no-cache-dir -U pip . twine packaging
113+
114+
- name: Upload to PyPI
115+
uses: pypa/gh-action-pypi-publish@release/v1

.gitignore

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# UV
98+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
#uv.lock
102+
103+
# poetry
104+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108+
#poetry.lock
109+
110+
# pdm
111+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112+
#pdm.lock
113+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114+
# in version control.
115+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116+
.pdm.toml
117+
.pdm-python
118+
.pdm-build/
119+
120+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121+
__pypackages__/
122+
123+
# Celery stuff
124+
celerybeat-schedule
125+
celerybeat.pid
126+
127+
# SageMath parsed files
128+
*.sage.py
129+
130+
# Environments
131+
.env
132+
.venv
133+
env/
134+
venv/
135+
ENV/
136+
env.bak/
137+
venv.bak/
138+
139+
# Spyder project settings
140+
.spyderproject
141+
.spyproject
142+
143+
# Rope project settings
144+
.ropeproject
145+
146+
# mkdocs documentation
147+
/site
148+
149+
# mypy
150+
.mypy_cache/
151+
.dmypy.json
152+
dmypy.json
153+
154+
# Pyre type checker
155+
.pyre/
156+
157+
# pytype static type analyzer
158+
.pytype/
159+
160+
# Cython debug symbols
161+
cython_debug/
162+
163+
# PyCharm
164+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166+
# and can be added to the global gitignore or merged into this file. For a more nuclear
167+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168+
#.idea/
169+
170+
# PyPI configuration file
171+
.pypirc

examples/add_domain.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from pyproxy_sdk.client import PyProxyClient
2+
from pyproxy_sdk.exceptions import PyProxyAlreadyExists
3+
4+
# Create client
5+
client = PyProxyClient(
6+
base_url="http://localhost:5000",
7+
username="admin",
8+
password="password",
9+
)
10+
11+
# Add domain to blocklist
12+
try:
13+
client.add_filtering("domain", "example.com")
14+
except PyProxyAlreadyExists:
15+
print("This domain is already blocked.")

examples/add_url.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from pyproxy_sdk.client import PyProxyClient
2+
from pyproxy_sdk.exceptions import PyProxyAlreadyExists
3+
4+
# Create client
5+
client = PyProxyClient(
6+
base_url="http://localhost:5000",
7+
username="admin",
8+
password="password",
9+
)
10+
11+
# Add URLs to blocklist
12+
try:
13+
client.add_filtering("url", "example.com/test")
14+
except PyProxyAlreadyExists:
15+
print("This URLs is already blocked.")

examples/create_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from pyproxy_sdk.client import PyProxyClient
2+
3+
# Create client
4+
client = PyProxyClient(
5+
base_url="http://localhost:5000",
6+
username="admin",
7+
password="password",
8+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from pyproxy_sdk.client import PyProxyClient
2+
3+
# Create client
4+
client = PyProxyClient(
5+
base_url="http://localhost:5000",
6+
username="admin",
7+
password="password",
8+
timeout=5,
9+
)

examples/delete_domain.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from pyproxy_sdk.client import PyProxyClient
2+
from pyproxy_sdk.exceptions import PyProxyNotFound
3+
4+
# Create client
5+
client = PyProxyClient(
6+
base_url="http://localhost:5000",
7+
username="admin",
8+
password="password",
9+
)
10+
11+
# Delete domain from blocklist
12+
try:
13+
client.delete_filtering("domain", "example.com")
14+
except PyProxyNotFound:
15+
print("This domain is not blocked.")

examples/delete_url.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from pyproxy_sdk.client import PyProxyClient
2+
from pyproxy_sdk.exceptions import PyProxyNotFound
3+
4+
# Create client
5+
client = PyProxyClient(
6+
base_url="http://localhost:5000",
7+
username="admin",
8+
password="password",
9+
)
10+
11+
# Delete URL from blocklist
12+
try:
13+
client.delete_filtering("url", "example.com/test")
14+
except PyProxyNotFound:
15+
print("This URL is not blocked.")

examples/get_filtering_rules.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from pyproxy_sdk.client import PyProxyClient
2+
from pyproxy_sdk.exceptions import PyProxyAlreadyExists, PyProxyNotFound
3+
4+
# Create client
5+
client = PyProxyClient(
6+
base_url="http://localhost:5000",
7+
username="admin",
8+
password="password",
9+
)
10+
11+
# Get filtering rules
12+
filters = client.get_filtering()
13+
print(filters)

0 commit comments

Comments
 (0)