netbird
Advanced tools
+51
-51
| Metadata-Version: 2.4 | ||
| Name: netbird | ||
| Version: 0.1.0 | ||
| Version: 1.0.0 | ||
| Summary: Python client for the NetBird API | ||
@@ -14,3 +14,3 @@ Project-URL: Homepage, https://github.com/drtinkerer/netbird-python-client | ||
| Keywords: api,client,mesh,netbird,networking,vpn | ||
| Classifier: Development Status :: 4 - Beta | ||
| Classifier: Development Status :: 5 - Production/Stable | ||
| Classifier: Intended Audience :: Developers | ||
@@ -98,4 +98,4 @@ Classifier: Intended Audience :: System Administrators | ||
| client = APIClient( | ||
| host=\"api.netbird.io\", | ||
| api_token=\"your-api-token-here\" | ||
| host="api.netbird.io", | ||
| api_token="your-api-token-here" | ||
| ) | ||
@@ -105,7 +105,7 @@ | ||
| peers = client.peers.list() | ||
| print(f\"Found {len(peers)} peers\") | ||
| print(f"Found {len(peers)} peers") | ||
| # Get current user | ||
| user = client.users.get_current() | ||
| print(f\"Logged in as: {user['name']}\") | ||
| print(f"Logged in as: {user['name']}") | ||
@@ -115,7 +115,7 @@ # Create a new group | ||
| group_data = GroupCreate( | ||
| name=\"Development Team\", | ||
| peers=[\"peer-1\", \"peer-2\"] | ||
| name="Development Team", | ||
| peers=["peer-1", "peer-2"] | ||
| ) | ||
| group = client.groups.create(group_data) | ||
| print(f\"Created group: {group['name']}\") | ||
| print(f"Created group: {group['name']}") | ||
| ``` | ||
@@ -130,4 +130,4 @@ | ||
| client = APIClient( | ||
| host=\"api.netbird.io\", | ||
| api_token=\"your-personal-access-token\" | ||
| host="api.netbird.io", | ||
| api_token="your-personal-access-token" | ||
| ) | ||
@@ -139,4 +139,4 @@ ``` | ||
| client = APIClient( | ||
| host=\"api.netbird.io\", | ||
| api_token=\"your-service-user-token\" | ||
| host="api.netbird.io", | ||
| api_token="your-service-user-token" | ||
| ) | ||
@@ -148,4 +148,4 @@ ``` | ||
| client = APIClient( | ||
| host=\"netbird.yourcompany.com:33073\", | ||
| api_token=\"your-token\", | ||
| host="netbird.yourcompany.com:33073", | ||
| api_token="your-token", | ||
| use_ssl=True # or False for HTTP | ||
@@ -163,9 +163,9 @@ ) | ||
| user_data = UserCreate( | ||
| email=\"john@example.com\", | ||
| name=\"John Doe\", | ||
| email="john@example.com", | ||
| name="John Doe", | ||
| role=UserRole.USER, | ||
| auto_groups=[\"group-developers\"] | ||
| auto_groups=["group-developers"] | ||
| ) | ||
| user = client.users.create(user_data) | ||
| print(f\"Created user: {user['name']} ({user['email']})\") | ||
| print(f"Created user: {user['name']} ({user['email']})") | ||
@@ -176,3 +176,3 @@ # Update user role | ||
| updated_user = client.users.update(user['id'], update_data) | ||
| print(f\"Updated user role to: {updated_user['role']}\") | ||
| print(f"Updated user role to: {updated_user['role']}") | ||
| ``` | ||
@@ -186,23 +186,23 @@ | ||
| network_data = NetworkCreate( | ||
| name=\"Production Network\", | ||
| description=\"Main production environment\" | ||
| name="Production Network", | ||
| description="Main production environment" | ||
| ) | ||
| network = client.networks.create(network_data) | ||
| print(f\"Created network: {network['name']}\") | ||
| print(f"Created network: {network['name']}") | ||
| # Create access policy | ||
| rule = PolicyRule( | ||
| name=\"Allow SSH\", | ||
| action=\"accept\", | ||
| protocol=\"tcp\", | ||
| ports=[\"22\"], | ||
| sources=[\"group-admins\"], | ||
| destinations=[\"group-servers\"] | ||
| name="Allow SSH", | ||
| action="accept", | ||
| protocol="tcp", | ||
| ports=["22"], | ||
| sources=["group-admins"], | ||
| destinations=["group-servers"] | ||
| ) | ||
| policy_data = PolicyCreate( | ||
| name=\"Admin SSH Access\", | ||
| name="Admin SSH Access", | ||
| rules=[rule] | ||
| ) | ||
| policy = client.policies.create(policy_data) | ||
| print(f\"Created policy: {policy['name']}\") | ||
| print(f"Created policy: {policy['name']}") | ||
| ``` | ||
@@ -216,11 +216,11 @@ | ||
| key_data = SetupKeyCreate( | ||
| name=\"Development Environment\", | ||
| type=\"reusable\", | ||
| name="Development Environment", | ||
| type="reusable", | ||
| expires_in=86400, # 24 hours | ||
| usage_limit=10, | ||
| auto_groups=[\"group-dev\"] | ||
| auto_groups=["group-dev"] | ||
| ) | ||
| setup_key = client.setup_keys.create(key_data) | ||
| print(f\"Setup key: {setup_key['key']}\") | ||
| print(f\"Key valid: {setup_key['valid']}\") | ||
| print(f"Setup key: {setup_key['key']}") | ||
| print(f"Key valid: {setup_key['valid']}") | ||
| ``` | ||
@@ -233,13 +233,13 @@ | ||
| for event in audit_events[-10:]: # Last 10 events | ||
| print(f\"{event['timestamp']}: {event['activity']}\") | ||
| print(f"{event['timestamp']}: {event['activity']}") | ||
| if event.get('initiator_name'): | ||
| print(f\" Initiated by: {event['initiator_name']}\") | ||
| print(f" Initiated by: {event['initiator_name']}") | ||
| # Get network traffic events (cloud-only) | ||
| traffic_events = client.events.get_network_traffic_events( | ||
| protocol=\"tcp\", | ||
| protocol="tcp", | ||
| page_size=100 | ||
| ) | ||
| for traffic in traffic_events[:5]: | ||
| print(f\"Traffic: {traffic['source_ip']} -> {traffic['destination_ip']}\") | ||
| print(f"Traffic: {traffic['source_ip']} -> {traffic['destination_ip']}") | ||
| ``` | ||
@@ -262,11 +262,11 @@ | ||
| try: | ||
| user = client.users.get(\"invalid-user-id\") | ||
| user = client.users.get("invalid-user-id") | ||
| except NetBirdNotFoundError: | ||
| print(\"User not found\") | ||
| print("User not found") | ||
| except NetBirdAuthenticationError: | ||
| print(\"Invalid API token\") | ||
| print("Invalid API token") | ||
| except NetBirdRateLimitError as e: | ||
| print(f\"Rate limited. Retry after {e.retry_after} seconds\") | ||
| print(f"Rate limited. Retry after {e.retry_after} seconds") | ||
| except NetBirdAPIError as e: | ||
| print(f\"API error: {e.message}\") | ||
| print(f"API error: {e.message}") | ||
| ``` | ||
@@ -278,7 +278,7 @@ | ||
| client = APIClient( | ||
| host=\"api.netbird.io\", | ||
| api_token=\"your-token\", | ||
| host="api.netbird.io", | ||
| api_token="your-token", | ||
| use_ssl=True, # Use HTTPS (default: True) | ||
| timeout=30.0, # Request timeout in seconds (default: 30) | ||
| base_path=\"/api\" # API base path (default: \"/api\") | ||
| base_path="/api" # API base path (default: "/api") | ||
| ) | ||
@@ -297,3 +297,3 @@ ``` | ||
| # Install development dependencies | ||
| pip install -e \".[dev]\" | ||
| pip install -e ".[dev]" | ||
@@ -389,3 +389,3 @@ # Run tests | ||
| - **GitHub Issues**: [Report bugs or request features](https://github.com/netbirdio/netbird-python-client/issues) | ||
| - **GitHub Issues**: [Report bugs or request features](https://github.com/drtinkerer/netbird-python-client/issues) | ||
| - **NetBird Community**: [Join the discussion](https://github.com/netbirdio/netbird/discussions) | ||
@@ -400,2 +400,2 @@ - **Documentation**: [API Documentation](https://docs.netbird.io/api) | ||
| Made with ❤️ by [Bhushan Rane](https://github.com/bhushanrane) | Contributed to the NetBird community | ||
| Made with ❤️ by [Bhushan Rane](https://github.com/drtinkerer) |
+1
-1
@@ -17,3 +17,3 @@ [build-system] | ||
| classifiers = [ | ||
| "Development Status :: 4 - Beta", | ||
| "Development Status :: 5 - Production/Stable", | ||
| "Intended Audience :: Developers", | ||
@@ -20,0 +20,0 @@ "Intended Audience :: System Administrators", |
+49
-49
@@ -49,4 +49,4 @@ # NetBird Python Client | ||
| client = APIClient( | ||
| host=\"api.netbird.io\", | ||
| api_token=\"your-api-token-here\" | ||
| host="api.netbird.io", | ||
| api_token="your-api-token-here" | ||
| ) | ||
@@ -56,7 +56,7 @@ | ||
| peers = client.peers.list() | ||
| print(f\"Found {len(peers)} peers\") | ||
| print(f"Found {len(peers)} peers") | ||
| # Get current user | ||
| user = client.users.get_current() | ||
| print(f\"Logged in as: {user['name']}\") | ||
| print(f"Logged in as: {user['name']}") | ||
@@ -66,7 +66,7 @@ # Create a new group | ||
| group_data = GroupCreate( | ||
| name=\"Development Team\", | ||
| peers=[\"peer-1\", \"peer-2\"] | ||
| name="Development Team", | ||
| peers=["peer-1", "peer-2"] | ||
| ) | ||
| group = client.groups.create(group_data) | ||
| print(f\"Created group: {group['name']}\") | ||
| print(f"Created group: {group['name']}") | ||
| ``` | ||
@@ -81,4 +81,4 @@ | ||
| client = APIClient( | ||
| host=\"api.netbird.io\", | ||
| api_token=\"your-personal-access-token\" | ||
| host="api.netbird.io", | ||
| api_token="your-personal-access-token" | ||
| ) | ||
@@ -90,4 +90,4 @@ ``` | ||
| client = APIClient( | ||
| host=\"api.netbird.io\", | ||
| api_token=\"your-service-user-token\" | ||
| host="api.netbird.io", | ||
| api_token="your-service-user-token" | ||
| ) | ||
@@ -99,4 +99,4 @@ ``` | ||
| client = APIClient( | ||
| host=\"netbird.yourcompany.com:33073\", | ||
| api_token=\"your-token\", | ||
| host="netbird.yourcompany.com:33073", | ||
| api_token="your-token", | ||
| use_ssl=True # or False for HTTP | ||
@@ -114,9 +114,9 @@ ) | ||
| user_data = UserCreate( | ||
| email=\"john@example.com\", | ||
| name=\"John Doe\", | ||
| email="john@example.com", | ||
| name="John Doe", | ||
| role=UserRole.USER, | ||
| auto_groups=[\"group-developers\"] | ||
| auto_groups=["group-developers"] | ||
| ) | ||
| user = client.users.create(user_data) | ||
| print(f\"Created user: {user['name']} ({user['email']})\") | ||
| print(f"Created user: {user['name']} ({user['email']})") | ||
@@ -127,3 +127,3 @@ # Update user role | ||
| updated_user = client.users.update(user['id'], update_data) | ||
| print(f\"Updated user role to: {updated_user['role']}\") | ||
| print(f"Updated user role to: {updated_user['role']}") | ||
| ``` | ||
@@ -137,23 +137,23 @@ | ||
| network_data = NetworkCreate( | ||
| name=\"Production Network\", | ||
| description=\"Main production environment\" | ||
| name="Production Network", | ||
| description="Main production environment" | ||
| ) | ||
| network = client.networks.create(network_data) | ||
| print(f\"Created network: {network['name']}\") | ||
| print(f"Created network: {network['name']}") | ||
| # Create access policy | ||
| rule = PolicyRule( | ||
| name=\"Allow SSH\", | ||
| action=\"accept\", | ||
| protocol=\"tcp\", | ||
| ports=[\"22\"], | ||
| sources=[\"group-admins\"], | ||
| destinations=[\"group-servers\"] | ||
| name="Allow SSH", | ||
| action="accept", | ||
| protocol="tcp", | ||
| ports=["22"], | ||
| sources=["group-admins"], | ||
| destinations=["group-servers"] | ||
| ) | ||
| policy_data = PolicyCreate( | ||
| name=\"Admin SSH Access\", | ||
| name="Admin SSH Access", | ||
| rules=[rule] | ||
| ) | ||
| policy = client.policies.create(policy_data) | ||
| print(f\"Created policy: {policy['name']}\") | ||
| print(f"Created policy: {policy['name']}") | ||
| ``` | ||
@@ -167,11 +167,11 @@ | ||
| key_data = SetupKeyCreate( | ||
| name=\"Development Environment\", | ||
| type=\"reusable\", | ||
| name="Development Environment", | ||
| type="reusable", | ||
| expires_in=86400, # 24 hours | ||
| usage_limit=10, | ||
| auto_groups=[\"group-dev\"] | ||
| auto_groups=["group-dev"] | ||
| ) | ||
| setup_key = client.setup_keys.create(key_data) | ||
| print(f\"Setup key: {setup_key['key']}\") | ||
| print(f\"Key valid: {setup_key['valid']}\") | ||
| print(f"Setup key: {setup_key['key']}") | ||
| print(f"Key valid: {setup_key['valid']}") | ||
| ``` | ||
@@ -184,13 +184,13 @@ | ||
| for event in audit_events[-10:]: # Last 10 events | ||
| print(f\"{event['timestamp']}: {event['activity']}\") | ||
| print(f"{event['timestamp']}: {event['activity']}") | ||
| if event.get('initiator_name'): | ||
| print(f\" Initiated by: {event['initiator_name']}\") | ||
| print(f" Initiated by: {event['initiator_name']}") | ||
| # Get network traffic events (cloud-only) | ||
| traffic_events = client.events.get_network_traffic_events( | ||
| protocol=\"tcp\", | ||
| protocol="tcp", | ||
| page_size=100 | ||
| ) | ||
| for traffic in traffic_events[:5]: | ||
| print(f\"Traffic: {traffic['source_ip']} -> {traffic['destination_ip']}\") | ||
| print(f"Traffic: {traffic['source_ip']} -> {traffic['destination_ip']}") | ||
| ``` | ||
@@ -213,11 +213,11 @@ | ||
| try: | ||
| user = client.users.get(\"invalid-user-id\") | ||
| user = client.users.get("invalid-user-id") | ||
| except NetBirdNotFoundError: | ||
| print(\"User not found\") | ||
| print("User not found") | ||
| except NetBirdAuthenticationError: | ||
| print(\"Invalid API token\") | ||
| print("Invalid API token") | ||
| except NetBirdRateLimitError as e: | ||
| print(f\"Rate limited. Retry after {e.retry_after} seconds\") | ||
| print(f"Rate limited. Retry after {e.retry_after} seconds") | ||
| except NetBirdAPIError as e: | ||
| print(f\"API error: {e.message}\") | ||
| print(f"API error: {e.message}") | ||
| ``` | ||
@@ -229,7 +229,7 @@ | ||
| client = APIClient( | ||
| host=\"api.netbird.io\", | ||
| api_token=\"your-token\", | ||
| host="api.netbird.io", | ||
| api_token="your-token", | ||
| use_ssl=True, # Use HTTPS (default: True) | ||
| timeout=30.0, # Request timeout in seconds (default: 30) | ||
| base_path=\"/api\" # API base path (default: \"/api\") | ||
| base_path="/api" # API base path (default: "/api") | ||
| ) | ||
@@ -248,3 +248,3 @@ ``` | ||
| # Install development dependencies | ||
| pip install -e \".[dev]\" | ||
| pip install -e ".[dev]" | ||
@@ -340,3 +340,3 @@ # Run tests | ||
| - **GitHub Issues**: [Report bugs or request features](https://github.com/netbirdio/netbird-python-client/issues) | ||
| - **GitHub Issues**: [Report bugs or request features](https://github.com/drtinkerer/netbird-python-client/issues) | ||
| - **NetBird Community**: [Join the discussion](https://github.com/netbirdio/netbird/discussions) | ||
@@ -351,2 +351,2 @@ - **Documentation**: [API Documentation](https://docs.netbird.io/api) | ||
| Made with ❤️ by [Bhushan Rane](https://github.com/bhushanrane) | Contributed to the NetBird community | ||
| Made with ❤️ by [Bhushan Rane](https://github.com/drtinkerer) |
@@ -15,3 +15,3 @@ """ | ||
| __version__ = "0.1.0" | ||
| __version__ = "1.0.0" | ||
@@ -18,0 +18,0 @@ from .client import APIClient |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
405543
-0.06%