netbird 0.1.0__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.
Files changed (83) hide show
  1. netbird-0.1.0/.github/workflows/docs.yml +70 -0
  2. netbird-0.1.0/.github/workflows/publish-pypi.yml +99 -0
  3. netbird-0.1.0/.gitignore +207 -0
  4. netbird-0.1.0/CHANGELOG.md +90 -0
  5. netbird-0.1.0/CONTRIBUTING.md +357 -0
  6. netbird-0.1.0/LICENSE +21 -0
  7. netbird-0.1.0/PKG-INFO +384 -0
  8. netbird-0.1.0/README.md +336 -0
  9. netbird-0.1.0/docs/Gemfile +25 -0
  10. netbird-0.1.0/docs/_config.yml +90 -0
  11. netbird-0.1.0/docs/_layouts/default.html +84 -0
  12. netbird-0.1.0/docs/api/index.md +258 -0
  13. netbird-0.1.0/docs/api/users.md +240 -0
  14. netbird-0.1.0/docs/assets/css/style.scss +349 -0
  15. netbird-0.1.0/docs/examples/index.md +568 -0
  16. netbird-0.1.0/docs/guides/contributing.md +407 -0
  17. netbird-0.1.0/docs/guides/installation.md +137 -0
  18. netbird-0.1.0/docs/guides/quickstart.md +221 -0
  19. netbird-0.1.0/docs/index.md +128 -0
  20. netbird-0.1.0/examples/basic_client.py +135 -0
  21. netbird-0.1.0/examples/network_automation.py +367 -0
  22. netbird-0.1.0/examples/user_management.py +183 -0
  23. netbird-0.1.0/netbird_demo.ipynb +1422 -0
  24. netbird-0.1.0/pyproject.toml +157 -0
  25. netbird-0.1.0/src/netbird/__init__.py +35 -0
  26. netbird-0.1.0/src/netbird/auth.py +41 -0
  27. netbird-0.1.0/src/netbird/client.py +330 -0
  28. netbird-0.1.0/src/netbird/exceptions.py +94 -0
  29. netbird-0.1.0/src/netbird/models/__init__.py +73 -0
  30. netbird-0.1.0/src/netbird/models/account.py +72 -0
  31. netbird-0.1.0/src/netbird/models/common.py +113 -0
  32. netbird-0.1.0/src/netbird/models/dns.py +47 -0
  33. netbird-0.1.0/src/netbird/models/event.py +80 -0
  34. netbird-0.1.0/src/netbird/models/group.py +69 -0
  35. netbird-0.1.0/src/netbird/models/network.py +105 -0
  36. netbird-0.1.0/src/netbird/models/peer.py +105 -0
  37. netbird-0.1.0/src/netbird/models/policy.py +103 -0
  38. netbird-0.1.0/src/netbird/models/route.py +121 -0
  39. netbird-0.1.0/src/netbird/models/setup_key.py +89 -0
  40. netbird-0.1.0/src/netbird/models/token.py +42 -0
  41. netbird-0.1.0/src/netbird/models/user.py +85 -0
  42. netbird-0.1.0/src/netbird/resources/__init__.py +31 -0
  43. netbird-0.1.0/src/netbird/resources/accounts.py +69 -0
  44. netbird-0.1.0/src/netbird/resources/base.py +36 -0
  45. netbird-0.1.0/src/netbird/resources/dns.py +136 -0
  46. netbird-0.1.0/src/netbird/resources/events.py +100 -0
  47. netbird-0.1.0/src/netbird/resources/groups.py +101 -0
  48. netbird-0.1.0/src/netbird/resources/networks.py +239 -0
  49. netbird-0.1.0/src/netbird/resources/peers.py +112 -0
  50. netbird-0.1.0/src/netbird/resources/policies.py +111 -0
  51. netbird-0.1.0/src/netbird/resources/routes.py +104 -0
  52. netbird-0.1.0/src/netbird/resources/setup_keys.py +100 -0
  53. netbird-0.1.0/src/netbird/resources/tokens.py +82 -0
  54. netbird-0.1.0/src/netbird/resources/users.py +120 -0
  55. netbird-0.1.0/tests/__init__.py +5 -0
  56. netbird-0.1.0/tests/conftest.py +165 -0
  57. netbird-0.1.0/tests/fixtures/README.md +180 -0
  58. netbird-0.1.0/tests/fixtures/__init__.py +110 -0
  59. netbird-0.1.0/tests/fixtures/api_responses/accounts.json +26 -0
  60. netbird-0.1.0/tests/fixtures/api_responses/groups.json +25 -0
  61. netbird-0.1.0/tests/fixtures/api_responses/peers.json +38 -0
  62. netbird-0.1.0/tests/fixtures/api_responses/policies.json +37 -0
  63. netbird-0.1.0/tests/fixtures/api_responses/setup_keys.json +19 -0
  64. netbird-0.1.0/tests/fixtures/api_responses/users.json +32 -0
  65. netbird-0.1.0/tests/fixtures/mock_configs/auth.yaml +32 -0
  66. netbird-0.1.0/tests/fixtures/mock_configs/client.yaml +39 -0
  67. netbird-0.1.0/tests/fixtures/sample_data/group.json +23 -0
  68. netbird-0.1.0/tests/fixtures/sample_data/peer.json +36 -0
  69. netbird-0.1.0/tests/fixtures/sample_data/user.json +17 -0
  70. netbird-0.1.0/tests/integration/README.md +188 -0
  71. netbird-0.1.0/tests/integration/__init__.py +3 -0
  72. netbird-0.1.0/tests/integration/test_basic_integration.py +209 -0
  73. netbird-0.1.0/tests/integration/test_crud_integration.py +310 -0
  74. netbird-0.1.0/tests/unit/__init__.py +3 -0
  75. netbird-0.1.0/tests/unit/test_auth.py +51 -0
  76. netbird-0.1.0/tests/unit/test_client.py +261 -0
  77. netbird-0.1.0/tests/unit/test_complete_coverage.py +494 -0
  78. netbird-0.1.0/tests/unit/test_exceptions.py +200 -0
  79. netbird-0.1.0/tests/unit/test_final_coverage.py +108 -0
  80. netbird-0.1.0/tests/unit/test_fixtures_demo.py +173 -0
  81. netbird-0.1.0/tests/unit/test_models.py +465 -0
  82. netbird-0.1.0/tests/unit/test_remaining_resources.py +490 -0
  83. netbird-0.1.0/tests/unit/test_resources.py +468 -0
@@ -0,0 +1,70 @@
1
+ name: Deploy Documentation
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - 'docs/**'
9
+ - 'README.md'
10
+ - '.github/workflows/docs.yml'
11
+ pull_request:
12
+ branches:
13
+ - main
14
+ paths:
15
+ - 'docs/**'
16
+ - 'README.md'
17
+
18
+ permissions:
19
+ contents: read
20
+ pages: write
21
+ id-token: write
22
+
23
+ # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
24
+ concurrency:
25
+ group: "pages"
26
+ cancel-in-progress: false
27
+
28
+ jobs:
29
+ # Build job
30
+ build:
31
+ runs-on: ubuntu-latest
32
+ steps:
33
+ - name: Checkout
34
+ uses: actions/checkout@v4
35
+
36
+ - name: Setup Ruby
37
+ uses: ruby/setup-ruby@v1
38
+ with:
39
+ ruby-version: '3.1'
40
+ bundler-cache: true
41
+ working-directory: ./docs
42
+
43
+ - name: Setup Pages
44
+ id: pages
45
+ uses: actions/configure-pages@v4
46
+
47
+ - name: Build with Jekyll
48
+ run: |
49
+ cd docs
50
+ bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
51
+ env:
52
+ JEKYLL_ENV: production
53
+
54
+ - name: Upload artifact
55
+ uses: actions/upload-pages-artifact@v3
56
+ with:
57
+ path: ./docs/_site
58
+
59
+ # Deployment job
60
+ deploy:
61
+ if: github.ref == 'refs/heads/main'
62
+ environment:
63
+ name: github-pages
64
+ url: ${{ steps.deployment.outputs.page_url }}
65
+ runs-on: ubuntu-latest
66
+ needs: build
67
+ steps:
68
+ - name: Deploy to GitHub Pages
69
+ id: deployment
70
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,99 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+ inputs:
8
+ publish_to_test:
9
+ description: 'Publish to Test PyPI instead of PyPI'
10
+ required: false
11
+ default: false
12
+ type: boolean
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ jobs:
18
+ build:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+
23
+ - name: Set up Python
24
+ uses: actions/setup-python@v5
25
+ with:
26
+ python-version: '3.11'
27
+
28
+ - name: Install build dependencies
29
+ run: |
30
+ python -m pip install --upgrade pip
31
+ python -m pip install build twine
32
+
33
+ - name: Build package
34
+ run: python -m build
35
+
36
+ - name: Check package
37
+ run: python -m twine check dist/*
38
+
39
+ - name: Upload build artifacts
40
+ uses: actions/upload-artifact@v4
41
+ with:
42
+ name: dist
43
+ path: dist/
44
+
45
+ test:
46
+ runs-on: ubuntu-latest
47
+ strategy:
48
+ matrix:
49
+ python-version: ['3.9', '3.10', '3.11', '3.12']
50
+ steps:
51
+ - uses: actions/checkout@v4
52
+
53
+ - name: Set up Python ${{ matrix.python-version }}
54
+ uses: actions/setup-python@v5
55
+ with:
56
+ python-version: ${{ matrix.python-version }}
57
+
58
+ - name: Install dependencies
59
+ run: |
60
+ python -m pip install --upgrade pip
61
+ python -m pip install -e ".[dev]"
62
+
63
+ - name: Run tests
64
+ run: |
65
+ pytest --cov=src/netbird --cov-report=term-missing
66
+
67
+ - name: Run type checking
68
+ run: mypy src/
69
+
70
+ - name: Run linting
71
+ run: |
72
+ black --check src/ tests/
73
+ isort --check-only src/ tests/
74
+ flake8 src/ tests/ --max-line-length=88
75
+
76
+ publish:
77
+ needs: [build, test]
78
+ runs-on: ubuntu-latest
79
+ environment:
80
+ name: ${{ github.event.inputs.publish_to_test == 'true' && 'test-pypi' || 'pypi' }}
81
+ url: ${{ github.event.inputs.publish_to_test == 'true' && 'https://test.pypi.org/p/netbird' || 'https://pypi.org/p/netbird' }}
82
+ permissions:
83
+ id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
84
+ steps:
85
+ - name: Download build artifacts
86
+ uses: actions/download-artifact@v4
87
+ with:
88
+ name: dist
89
+ path: dist/
90
+
91
+ - name: Publish to Test PyPI
92
+ if: github.event.inputs.publish_to_test == 'true'
93
+ uses: pypa/gh-action-pypi-publish@release/v1
94
+ with:
95
+ repository-url: https://test.pypi.org/legacy/
96
+
97
+ - name: Publish to PyPI
98
+ if: github.event.inputs.publish_to_test != 'true'
99
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,207 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
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
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
@@ -0,0 +1,90 @@
1
+ # Changelog
2
+
3
+ All notable changes to the NetBird Python Client will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - TBD
11
+
12
+ ### Added
13
+ - Initial release of NetBird Python Client
14
+ - Complete API coverage for all 11 NetBird API resources:
15
+ - Accounts - Account management and settings
16
+ - Users - User lifecycle management with roles and permissions
17
+ - Tokens - API token management for users
18
+ - Peers - Network peer management and connectivity
19
+ - Setup Keys - Peer setup key management with auto-groups
20
+ - Groups - Peer group management and organization
21
+ - Networks - Network and resource management with nested resources
22
+ - Policies - Access control policies with rules and posture checks
23
+ - Routes - Network routing configuration with masquerading
24
+ - DNS - DNS settings and nameserver group management
25
+ - Events - Audit events and network traffic monitoring
26
+ - Modern Python package structure with pyproject.toml
27
+ - Type-safe Pydantic models for all API objects
28
+ - Comprehensive error handling with specific exception types:
29
+ - `NetBirdAPIError` - Base exception for all API errors
30
+ - `NetBirdAuthenticationError` - Authentication failures (401)
31
+ - `NetBirdValidationError` - Request validation errors (400)
32
+ - `NetBirdNotFoundError` - Resource not found errors (404)
33
+ - `NetBirdRateLimitError` - Rate limiting errors (429)
34
+ - `NetBirdServerError` - Server errors (5xx)
35
+ - Flexible authentication support:
36
+ - Personal access tokens
37
+ - Service user tokens
38
+ - Bearer token authentication
39
+ - HTTP client with proper timeout and error handling
40
+ - Context manager support for resource cleanup
41
+ - Extensive documentation and examples:
42
+ - Complete README with usage examples
43
+ - API reference documentation
44
+ - Practical example scripts
45
+ - Type hints and docstrings throughout
46
+ - Development tooling:
47
+ - pytest for testing with coverage reporting
48
+ - mypy for type checking
49
+ - black for code formatting
50
+ - isort for import sorting
51
+ - flake8 for linting
52
+ - pre-commit hooks for code quality
53
+
54
+ ### Features
55
+ - **Complete Resource Coverage**: Support for all NetBird API endpoints
56
+ - **Type Safety**: Full typing support with runtime validation
57
+ - **Error Handling**: Comprehensive exception hierarchy for different error types
58
+ - **Authentication**: Multiple authentication methods supported
59
+ - **Documentation**: Extensive docs with practical examples
60
+ - **Modern Python**: Built for Python 3.8+ with modern packaging
61
+ - **Developer Experience**: Rich tooling and clear error messages
62
+
63
+ ### Examples Included
64
+ - `basic_client.py` - Basic API usage and resource listing
65
+ - `user_management.py` - User creation, tokens, and role management
66
+ - `network_automation.py` - Complete network setup automation
67
+
68
+ ### Development
69
+ - Modern pyproject.toml configuration
70
+ - Comprehensive test suite setup
71
+ - Type checking with mypy
72
+ - Code formatting with black and isort
73
+ - Linting with flake8
74
+ - Coverage reporting with pytest-cov
75
+
76
+ ---
77
+
78
+ ## Release Notes
79
+
80
+ ### Version 0.1.0
81
+ This is the initial release of the NetBird Python Client. It provides complete coverage of the NetBird API with a focus on developer experience, type safety, and comprehensive documentation.
82
+
83
+ **Key Highlights:**
84
+ - 🎯 **Complete API Coverage** - All 11 NetBird resources supported
85
+ - 🔒 **Type Safe** - Full Pydantic model validation
86
+ - 📚 **Well Documented** - Extensive docs and examples
87
+ - 🚀 **Production Ready** - Proper error handling and testing
88
+ - 🐍 **Modern Python** - Built for Python 3.8+ with best practices
89
+
90
+ The client is designed to be intuitive for NetBird users while providing the flexibility needed for automation and integration scenarios.