From eedd2d6b29092642e75ac1b8417b4a6aa5e781b5 Mon Sep 17 00:00:00 2001 From: Denis Rozhnovskiy Date: Thu, 29 Aug 2024 01:39:45 +0500 Subject: [PATCH] docs: update README.md --- README.md | 61 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 48f30d4..9cbef8d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ # pyoutlineapi -`pyoutlineapi` is a Python package to interact with the Outline VPN Server API. The package includes Pydantic-based -data validation, ensuring robust and reliable API interactions. +`pyoutlineapi` is a Python package designed to interact with the Outline VPN Server API, providing robust data +validation through Pydantic models. This ensures reliable and secure API interactions. + +Whether you're building a Telegram bot or another application that requires accurate and secure API communication, +`pyoutlineapi` offers comprehensive validation for both incoming and outgoing data. This makes it an excellent choice +for integrating with bots and other automated systems. [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=orenlab_pyoutlineapi&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=orenlab_pyoutlineapi) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=orenlab_pyoutlineapi&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=orenlab_pyoutlineapi) @@ -33,45 +37,58 @@ poetry add pyoutlineapi Initialize the Client: +To get started, you need to initialize the PyOutlineWrapper client with your Outline VPN server URL and certificate +fingerprint: + ```python from pyoutlineapi.client import PyOutlineWrapper api_url = "https://your-outline-url.com" cert_sha256 = "your-cert-sha256-fingerprint" -# If a self-signed certificate is used to operate the outline server, -# the "verify_tls" parameter must be set to "False". +# If a self-signed certificate is used, set "verify_tls" to False. api_client = PyOutlineWrapper(api_url=api_url, cert_sha256=cert_sha256, verify_tls=False) -# Get Server Information: -server_info = api_client.get_server_info() -print(server_info) +# Retrieve Server Information +from pyoutlineapi.models import Server + +server_info: Server = api_client.get_server_info() +print("Server Information:", server_info) # Create a New Access Key: -new_access_key = api_client.create_access_key() -print(new_access_key) +from pyoutlineapi.models import AccessKey -# Get List of Access Keys: -access_key_list = api_client.get_access_keys() -print(access_key_list) +new_access_key: AccessKey = api_client.create_access_key(name="my_access_key", password="secure_password", port=8080) +print("New Access Key:", new_access_key) + +# List All Access Keys: +from pyoutlineapi.models import AccessKeyList + +access_key_list: AccessKeyList = api_client.get_access_keys() +print("Access Key List:") +for access_key in access_key_list.accessKeys: + print(f"- ID: {access_key.id}, Name: {access_key.name}, Port: {access_key.port}") # Delete Access Key: api_client.delete_access_key("your-key-id") +print("Access Key Deleted Successfully") # Update Server Port: -new_port = api_client.update_server_port(8080) -print(new_port) +update_success: bool = api_client.update_server_port(9090) +print("Server Port Updated:", update_success) # Set Data Limit for Access Key: -data_limit = api_client.set_access_key_data_limit("your-key-id", 50000000) -print(data_limit) +from pyoutlineapi.models import DataLimit + +data_limit: bool = api_client.set_access_key_data_limit("your-key-id", DataLimit(bytes=50000000)) +print("Data Limit Set:", data_limit) -# Enable or Disable Metrics: -metrics_status = api_client.set_metrics_enabled(True) -print(metrics_status) +# Retrieve Metrics: +from pyoutlineapi.models import Metrics -# Get Metrics: -metrics_data = api_client.get_metrics() -print(metrics_data) +metrics_data: Metrics = api_client.get_metrics() +print("Metrics Data:") +for user_id, bytes_transferred in metrics_data.bytesTransferredByUserId.items(): + print(f"- User ID: {user_id}, Bytes Transferred: {bytes_transferred}") ``` ## Contributing